documentation.d.ts 3.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424
  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. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. }
  408. }
  409. declare module BABYLON {
  410. /**
  411. * Class containing a set of static utilities functions for deep copy.
  412. */
  413. export class DeepCopier {
  414. /**
  415. * Tries to copy an object by duplicating every property
  416. * @param source defines the source object
  417. * @param destination defines the target object
  418. * @param doNotCopyList defines a list of properties to avoid
  419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  420. */
  421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  422. }
  423. }
  424. declare module BABYLON {
  425. /**
  426. * Class containing a set of static utilities functions for precision date
  427. */
  428. export class PrecisionDate {
  429. /**
  430. * Gets either window.performance.now() if supported or Date.now() else
  431. */
  432. static readonly Now: number;
  433. }
  434. }
  435. declare module BABYLON {
  436. /** @hidden */
  437. export class _DevTools {
  438. static WarnImport(name: string): string;
  439. }
  440. }
  441. declare module BABYLON {
  442. /**
  443. * Interface used to define the mechanism to get data from the network
  444. */
  445. export interface IWebRequest {
  446. /**
  447. * Returns client's response url
  448. */
  449. responseURL: string;
  450. /**
  451. * Returns client's status
  452. */
  453. status: number;
  454. /**
  455. * Returns client's status as a text
  456. */
  457. statusText: string;
  458. }
  459. }
  460. declare module BABYLON {
  461. /**
  462. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  463. */
  464. export class WebRequest implements IWebRequest {
  465. private _xhr;
  466. /**
  467. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  468. * i.e. when loading files, where the server/service expects an Authorization header
  469. */
  470. static CustomRequestHeaders: {
  471. [key: string]: string;
  472. };
  473. /**
  474. * Add callback functions in this array to update all the requests before they get sent to the network
  475. */
  476. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  477. private _injectCustomRequestHeaders;
  478. /**
  479. * Gets or sets a function to be called when loading progress changes
  480. */
  481. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. /**
  483. * Returns client's state
  484. */
  485. readonly readyState: number;
  486. /**
  487. * Returns client's status
  488. */
  489. readonly status: number;
  490. /**
  491. * Returns client's status as a text
  492. */
  493. readonly statusText: string;
  494. /**
  495. * Returns client's response
  496. */
  497. readonly response: any;
  498. /**
  499. * Returns client's response url
  500. */
  501. readonly responseURL: string;
  502. /**
  503. * Returns client's response as text
  504. */
  505. readonly responseText: string;
  506. /**
  507. * Gets or sets the expected response type
  508. */
  509. responseType: XMLHttpRequestResponseType;
  510. /** @hidden */
  511. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  512. /** @hidden */
  513. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  514. /**
  515. * Cancels any network activity
  516. */
  517. abort(): void;
  518. /**
  519. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  520. * @param body defines an optional request body
  521. */
  522. send(body?: Document | BodyInit | null): void;
  523. /**
  524. * Sets the request method, request URL
  525. * @param method defines the method to use (GET, POST, etc..)
  526. * @param url defines the url to connect with
  527. */
  528. open(method: string, url: string): void;
  529. /**
  530. * Sets the value of a request header.
  531. * @param name The name of the header whose value is to be set
  532. * @param value The value to set as the body of the header
  533. */
  534. setRequestHeader(name: string, value: string): void;
  535. /**
  536. * Get the string containing the text of a particular header's value.
  537. * @param name The name of the header
  538. * @returns The string containing the text of the given header name
  539. */
  540. getResponseHeader(name: string): Nullable<string>;
  541. }
  542. }
  543. declare module BABYLON {
  544. /**
  545. * File request interface
  546. */
  547. export interface IFileRequest {
  548. /**
  549. * Raised when the request is complete (success or error).
  550. */
  551. onCompleteObservable: Observable<IFileRequest>;
  552. /**
  553. * Aborts the request for a file.
  554. */
  555. abort: () => void;
  556. }
  557. }
  558. declare module BABYLON {
  559. /**
  560. * Define options used to create a render target texture
  561. */
  562. export class RenderTargetCreationOptions {
  563. /**
  564. * Specifies is mipmaps must be generated
  565. */
  566. generateMipMaps?: boolean;
  567. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  568. generateDepthBuffer?: boolean;
  569. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  570. generateStencilBuffer?: boolean;
  571. /** Defines texture type (int by default) */
  572. type?: number;
  573. /** Defines sampling mode (trilinear by default) */
  574. samplingMode?: number;
  575. /** Defines format (RGBA by default) */
  576. format?: number;
  577. }
  578. }
  579. declare module BABYLON {
  580. /**
  581. * @hidden
  582. **/
  583. export class _TimeToken {
  584. _startTimeQuery: Nullable<WebGLQuery>;
  585. _endTimeQuery: Nullable<WebGLQuery>;
  586. _timeElapsedQuery: Nullable<WebGLQuery>;
  587. _timeElapsedQueryEnded: boolean;
  588. }
  589. }
  590. declare module BABYLON {
  591. /** Defines the cross module used constants to avoid circular dependncies */
  592. export class Constants {
  593. /** Defines that alpha blending is disabled */
  594. static readonly ALPHA_DISABLE: number;
  595. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  596. static readonly ALPHA_ADD: number;
  597. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  598. static readonly ALPHA_COMBINE: number;
  599. /** Defines that alpha blending to DEST - SRC * DEST */
  600. static readonly ALPHA_SUBTRACT: number;
  601. /** Defines that alpha blending to SRC * DEST */
  602. static readonly ALPHA_MULTIPLY: number;
  603. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  604. static readonly ALPHA_MAXIMIZED: number;
  605. /** Defines that alpha blending to SRC + DEST */
  606. static readonly ALPHA_ONEONE: number;
  607. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  608. static readonly ALPHA_PREMULTIPLIED: number;
  609. /**
  610. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  611. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  612. */
  613. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  614. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  615. static readonly ALPHA_INTERPOLATE: number;
  616. /**
  617. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  618. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_SCREENMODE: number;
  621. /**
  622. * Defines that alpha blending to SRC + DST
  623. * Alpha will be set to SRC ALPHA + DST ALPHA
  624. */
  625. static readonly ALPHA_ONEONE_ONEONE: number;
  626. /**
  627. * Defines that alpha blending to SRC * DST ALPHA + DST
  628. * Alpha will be set to 0
  629. */
  630. static readonly ALPHA_ALPHATOCOLOR: number;
  631. /**
  632. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  633. */
  634. static readonly ALPHA_REVERSEONEMINUS: number;
  635. /**
  636. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  637. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  638. */
  639. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST
  642. * Alpha will be set to SRC ALPHA
  643. */
  644. static readonly ALPHA_ONEONE_ONEZERO: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** 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 */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** 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 */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** 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 */
  681. static readonly GEQUAL: number;
  682. /** 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 */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and mip = linear */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** Bilinear is mag = linear and min = linear and mip = nearest */
  767. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** nearest is mag = nearest and min = nearest and mip = linear */
  771. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  773. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** mag = linear and min = linear and mip = none */
  791. static readonly TEXTURE_LINEAR_LINEAR: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * 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.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module BABYLON {
  1039. /**
  1040. * This represents the required contract to create a new type of texture loader.
  1041. */
  1042. export interface IInternalTextureLoader {
  1043. /**
  1044. * Defines wether the loader supports cascade loading the different faces.
  1045. */
  1046. supportCascades: boolean;
  1047. /**
  1048. * This returns if the loader support the current file information.
  1049. * @param extension defines the file extension of the file being loaded
  1050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1051. * @param fallback defines the fallback internal texture if any
  1052. * @param isBase64 defines whether the texture is encoded as a base64
  1053. * @param isBuffer defines whether the texture data are stored as a buffer
  1054. * @returns true if the loader can load the specified file
  1055. */
  1056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1057. /**
  1058. * Transform the url before loading if required.
  1059. * @param rootUrl the url of the texture
  1060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1061. * @returns the transformed texture
  1062. */
  1063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1064. /**
  1065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the fallback texture
  1069. */
  1070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1071. /**
  1072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param createPolynomials will be true if polynomials have been requested
  1076. * @param onLoad defines the callback to trigger once the texture is ready
  1077. * @param onError defines the callback to trigger in case of error
  1078. */
  1079. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1080. /**
  1081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1082. * @param data contains the texture data
  1083. * @param texture defines the BabylonJS internal texture
  1084. * @param callback defines the method to call once ready to upload
  1085. */
  1086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * Class used to store and describe the pipeline context associated with an effect
  1092. */
  1093. export interface IPipelineContext {
  1094. /**
  1095. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1096. */
  1097. isAsync: boolean;
  1098. /**
  1099. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1100. */
  1101. isReady: boolean;
  1102. /** @hidden */
  1103. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1104. }
  1105. }
  1106. declare module BABYLON {
  1107. /**
  1108. * Class used to store gfx data (like WebGLBuffer)
  1109. */
  1110. export class DataBuffer {
  1111. /**
  1112. * Gets or sets the number of objects referencing this buffer
  1113. */
  1114. references: number;
  1115. /** Gets or sets the size of the underlying buffer */
  1116. capacity: number;
  1117. /**
  1118. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1119. */
  1120. is32Bits: boolean;
  1121. /**
  1122. * Gets the underlying buffer
  1123. */
  1124. readonly underlyingResource: any;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /** @hidden */
  1129. export interface IShaderProcessor {
  1130. attributeProcessor?: (attribute: string) => string;
  1131. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1132. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1133. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1134. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1135. lineProcessor?: (line: string, isFragment: boolean) => string;
  1136. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1137. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1138. }
  1139. }
  1140. declare module BABYLON {
  1141. /** @hidden */
  1142. export interface ProcessingOptions {
  1143. defines: string[];
  1144. indexParameters: any;
  1145. isFragment: boolean;
  1146. shouldUseHighPrecisionShader: boolean;
  1147. supportsUniformBuffers: boolean;
  1148. shadersRepository: string;
  1149. includesShadersStore: {
  1150. [key: string]: string;
  1151. };
  1152. processor?: IShaderProcessor;
  1153. version: string;
  1154. platformName: string;
  1155. lookForClosingBracketForUniformBuffer?: boolean;
  1156. }
  1157. }
  1158. declare module BABYLON {
  1159. /** @hidden */
  1160. export class ShaderCodeNode {
  1161. line: string;
  1162. children: ShaderCodeNode[];
  1163. additionalDefineKey?: string;
  1164. additionalDefineValue?: string;
  1165. isValid(preprocessors: {
  1166. [key: string]: string;
  1167. }): boolean;
  1168. process(preprocessors: {
  1169. [key: string]: string;
  1170. }, options: ProcessingOptions): string;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeCursor {
  1176. private _lines;
  1177. lineIndex: number;
  1178. readonly currentLine: string;
  1179. readonly canRead: boolean;
  1180. lines: string[];
  1181. }
  1182. }
  1183. declare module BABYLON {
  1184. /** @hidden */
  1185. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1186. process(preprocessors: {
  1187. [key: string]: string;
  1188. }, options: ProcessingOptions): string;
  1189. }
  1190. }
  1191. declare module BABYLON {
  1192. /** @hidden */
  1193. export class ShaderDefineExpression {
  1194. isTrue(preprocessors: {
  1195. [key: string]: string;
  1196. }): boolean;
  1197. }
  1198. }
  1199. declare module BABYLON {
  1200. /** @hidden */
  1201. export class ShaderCodeTestNode extends ShaderCodeNode {
  1202. testExpression: ShaderDefineExpression;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1211. define: string;
  1212. not: boolean;
  1213. constructor(define: string, not?: boolean);
  1214. isTrue(preprocessors: {
  1215. [key: string]: string;
  1216. }): boolean;
  1217. }
  1218. }
  1219. declare module BABYLON {
  1220. /** @hidden */
  1221. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1222. leftOperand: ShaderDefineExpression;
  1223. rightOperand: ShaderDefineExpression;
  1224. isTrue(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1242. define: string;
  1243. operand: string;
  1244. testValue: string;
  1245. constructor(define: string, operand: string, testValue: string);
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /**
  1253. * Class used to enable access to offline support
  1254. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1255. */
  1256. export interface IOfflineProvider {
  1257. /**
  1258. * Gets a boolean indicating if scene must be saved in the database
  1259. */
  1260. enableSceneOffline: boolean;
  1261. /**
  1262. * Gets a boolean indicating if textures must be saved in the database
  1263. */
  1264. enableTexturesOffline: boolean;
  1265. /**
  1266. * Open the offline support and make it available
  1267. * @param successCallback defines the callback to call on success
  1268. * @param errorCallback defines the callback to call on error
  1269. */
  1270. open(successCallback: () => void, errorCallback: () => void): void;
  1271. /**
  1272. * Loads an image from the offline support
  1273. * @param url defines the url to load from
  1274. * @param image defines the target DOM image
  1275. */
  1276. loadImage(url: string, image: HTMLImageElement): void;
  1277. /**
  1278. * Loads a file from offline support
  1279. * @param url defines the URL to load from
  1280. * @param sceneLoaded defines a callback to call on success
  1281. * @param progressCallBack defines a callback to call when progress changed
  1282. * @param errorCallback defines a callback to call on error
  1283. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1284. */
  1285. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1286. }
  1287. }
  1288. declare module BABYLON {
  1289. /**
  1290. * Class used to help managing file picking and drag'n'drop
  1291. * File Storage
  1292. */
  1293. export class FilesInputStore {
  1294. /**
  1295. * List of files ready to be loaded
  1296. */
  1297. static FilesToLoad: {
  1298. [key: string]: File;
  1299. };
  1300. }
  1301. }
  1302. declare module BABYLON {
  1303. /**
  1304. * Class used to define a retry strategy when error happens while loading assets
  1305. */
  1306. export class RetryStrategy {
  1307. /**
  1308. * Function used to defines an exponential back off strategy
  1309. * @param maxRetries defines the maximum number of retries (3 by default)
  1310. * @param baseInterval defines the interval between retries
  1311. * @returns the strategy function to use
  1312. */
  1313. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1314. }
  1315. }
  1316. declare module BABYLON {
  1317. /**
  1318. * @ignore
  1319. * Application error to support additional information when loading a file
  1320. */
  1321. export abstract class BaseError extends Error {
  1322. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. 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>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. 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;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module BABYLON {
  1444. /** @hidden */
  1445. export class ShaderProcessor {
  1446. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1447. private static _ProcessPrecision;
  1448. private static _ExtractOperation;
  1449. private static _BuildSubExpression;
  1450. private static _BuildExpression;
  1451. private static _MoveCursorWithinIf;
  1452. private static _MoveCursor;
  1453. private static _EvaluatePreProcessors;
  1454. private static _PreparePreProcessors;
  1455. private static _ProcessShaderConversion;
  1456. private static _ProcessIncludes;
  1457. }
  1458. }
  1459. declare module BABYLON {
  1460. /**
  1461. * @hidden
  1462. */
  1463. export interface IColor4Like {
  1464. r: float;
  1465. g: float;
  1466. b: float;
  1467. a: float;
  1468. }
  1469. /**
  1470. * @hidden
  1471. */
  1472. export interface IColor3Like {
  1473. r: float;
  1474. g: float;
  1475. b: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IVector4Like {
  1481. x: float;
  1482. y: float;
  1483. z: float;
  1484. w: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IVector3Like {
  1490. x: float;
  1491. y: float;
  1492. z: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector2Like {
  1498. x: float;
  1499. y: float;
  1500. }
  1501. /**
  1502. * @hidden
  1503. */
  1504. export interface IMatrixLike {
  1505. toArray(): DeepImmutable<Float32Array>;
  1506. updateFlag: int;
  1507. }
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IViewportLike {
  1512. x: float;
  1513. y: float;
  1514. width: float;
  1515. height: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IPlaneLike {
  1521. normal: IVector3Like;
  1522. d: float;
  1523. normalize(): void;
  1524. }
  1525. }
  1526. declare module BABYLON {
  1527. /**
  1528. * Interface used to define common properties for effect fallbacks
  1529. */
  1530. export interface IEffectFallbacks {
  1531. /**
  1532. * Removes the defines that should be removed when falling back.
  1533. * @param currentDefines defines the current define statements for the shader.
  1534. * @param effect defines the current effect we try to compile
  1535. * @returns The resulting defines with defines of the current rank removed.
  1536. */
  1537. reduce(currentDefines: string, effect: Effect): string;
  1538. /**
  1539. * Removes the fallback from the bound mesh.
  1540. */
  1541. unBindMesh(): void;
  1542. /**
  1543. * Checks to see if more fallbacks are still availible.
  1544. */
  1545. hasMoreFallbacks: boolean;
  1546. }
  1547. }
  1548. declare module BABYLON {
  1549. /**
  1550. * Class used to evalaute queries containing `and` and `or` operators
  1551. */
  1552. export class AndOrNotEvaluator {
  1553. /**
  1554. * Evaluate a query
  1555. * @param query defines the query to evaluate
  1556. * @param evaluateCallback defines the callback used to filter result
  1557. * @returns true if the query matches
  1558. */
  1559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1560. private static _HandleParenthesisContent;
  1561. private static _SimplifyNegation;
  1562. }
  1563. }
  1564. declare module BABYLON {
  1565. /**
  1566. * Class used to store custom tags
  1567. */
  1568. export class Tags {
  1569. /**
  1570. * Adds support for tags on the given object
  1571. * @param obj defines the object to use
  1572. */
  1573. static EnableFor(obj: any): void;
  1574. /**
  1575. * Removes tags support
  1576. * @param obj defines the object to use
  1577. */
  1578. static DisableFor(obj: any): void;
  1579. /**
  1580. * Gets a boolean indicating if the given object has tags
  1581. * @param obj defines the object to use
  1582. * @returns a boolean
  1583. */
  1584. static HasTags(obj: any): boolean;
  1585. /**
  1586. * Gets the tags available on a given object
  1587. * @param obj defines the object to use
  1588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1589. * @returns the tags
  1590. */
  1591. static GetTags(obj: any, asString?: boolean): any;
  1592. /**
  1593. * Adds tags to an object
  1594. * @param obj defines the object to use
  1595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1597. */
  1598. static AddTagsTo(obj: any, tagsString: string): void;
  1599. /**
  1600. * @hidden
  1601. */
  1602. static _AddTagTo(obj: any, tag: string): void;
  1603. /**
  1604. * Removes specific tags from a specific object
  1605. * @param obj defines the object to use
  1606. * @param tagsString defines the tags to remove
  1607. */
  1608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _RemoveTagFrom(obj: any, tag: string): void;
  1613. /**
  1614. * Defines if tags hosted on an object match a given query
  1615. * @param obj defines the object to use
  1616. * @param tagsQuery defines the tag query
  1617. * @returns a boolean
  1618. */
  1619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Scalar computation library
  1625. */
  1626. export class Scalar {
  1627. /**
  1628. * Two pi constants convenient for computation.
  1629. */
  1630. static TwoPi: number;
  1631. /**
  1632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1633. * @param a number
  1634. * @param b number
  1635. * @param epsilon (default = 1.401298E-45)
  1636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1637. */
  1638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1639. /**
  1640. * Returns a string : the upper case translation of the number i to hexadecimal.
  1641. * @param i number
  1642. * @returns the upper case translation of the number i to hexadecimal.
  1643. */
  1644. static ToHex(i: number): string;
  1645. /**
  1646. * Returns -1 if value is negative and +1 is value is positive.
  1647. * @param value the value
  1648. * @returns the value itself if it's equal to zero.
  1649. */
  1650. static Sign(value: number): number;
  1651. /**
  1652. * Returns the value itself if it's between min and max.
  1653. * Returns min if the value is lower than min.
  1654. * Returns max if the value is greater than max.
  1655. * @param value the value to clmap
  1656. * @param min the min value to clamp to (default: 0)
  1657. * @param max the max value to clamp to (default: 1)
  1658. * @returns the clamped value
  1659. */
  1660. static Clamp(value: number, min?: number, max?: number): number;
  1661. /**
  1662. * the log2 of value.
  1663. * @param value the value to compute log2 of
  1664. * @returns the log2 of value.
  1665. */
  1666. static Log2(value: number): number;
  1667. /**
  1668. * Loops the value, so that it is never larger than length and never smaller than 0.
  1669. *
  1670. * This is similar to the modulo operator but it works with floating point numbers.
  1671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1672. * With t = 5 and length = 2.5, the result would be 0.0.
  1673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1674. * @param value the value
  1675. * @param length the length
  1676. * @returns the looped value
  1677. */
  1678. static Repeat(value: number, length: number): number;
  1679. /**
  1680. * Normalize the value between 0.0 and 1.0 using min and max values
  1681. * @param value value to normalize
  1682. * @param min max to normalize between
  1683. * @param max min to normalize between
  1684. * @returns the normalized value
  1685. */
  1686. static Normalize(value: number, min: number, max: number): number;
  1687. /**
  1688. * Denormalize the value from 0.0 and 1.0 using min and max values
  1689. * @param normalized value to denormalize
  1690. * @param min max to denormalize between
  1691. * @param max min to denormalize between
  1692. * @returns the denormalized value
  1693. */
  1694. static Denormalize(normalized: number, min: number, max: number): number;
  1695. /**
  1696. * Calculates the shortest difference between two given angles given in degrees.
  1697. * @param current current angle in degrees
  1698. * @param target target angle in degrees
  1699. * @returns the delta
  1700. */
  1701. static DeltaAngle(current: number, target: number): number;
  1702. /**
  1703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1704. * @param tx value
  1705. * @param length length
  1706. * @returns The returned value will move back and forth between 0 and length
  1707. */
  1708. static PingPong(tx: number, length: number): number;
  1709. /**
  1710. * Interpolates between min and max with smoothing at the limits.
  1711. *
  1712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1714. * @param from from
  1715. * @param to to
  1716. * @param tx value
  1717. * @returns the smooth stepped value
  1718. */
  1719. static SmoothStep(from: number, to: number, tx: number): number;
  1720. /**
  1721. * Moves a value current towards target.
  1722. *
  1723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1724. * Negative values of maxDelta pushes the value away from target.
  1725. * @param current current value
  1726. * @param target target value
  1727. * @param maxDelta max distance to move
  1728. * @returns resulting value
  1729. */
  1730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1731. /**
  1732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1733. *
  1734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1736. * @param current current value
  1737. * @param target target value
  1738. * @param maxDelta max distance to move
  1739. * @returns resulting angle
  1740. */
  1741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1742. /**
  1743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1744. * @param start start value
  1745. * @param end target value
  1746. * @param amount amount to lerp between
  1747. * @returns the lerped value
  1748. */
  1749. static Lerp(start: number, end: number, amount: number): number;
  1750. /**
  1751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1753. * @param start start value
  1754. * @param end target value
  1755. * @param amount amount to lerp between
  1756. * @returns the lerped value
  1757. */
  1758. static LerpAngle(start: number, end: number, amount: number): number;
  1759. /**
  1760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1761. * @param a start value
  1762. * @param b target value
  1763. * @param value value between a and b
  1764. * @returns the inverseLerp value
  1765. */
  1766. static InverseLerp(a: number, b: number, value: number): number;
  1767. /**
  1768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1770. * @param value1 spline value
  1771. * @param tangent1 spline value
  1772. * @param value2 spline value
  1773. * @param tangent2 spline value
  1774. * @param amount input value
  1775. * @returns hermite result
  1776. */
  1777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1778. /**
  1779. * Returns a random float number between and min and max values
  1780. * @param min min value of random
  1781. * @param max max value of random
  1782. * @returns random value
  1783. */
  1784. static RandomRange(min: number, max: number): number;
  1785. /**
  1786. * This function returns percentage of a number in a given range.
  1787. *
  1788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1790. * @param number to convert to percentage
  1791. * @param min min range
  1792. * @param max max range
  1793. * @returns the percentage
  1794. */
  1795. static RangeToPercent(number: number, min: number, max: number): number;
  1796. /**
  1797. * This function returns number that corresponds to the percentage in a given range.
  1798. *
  1799. * PercentToRange(0.34,0,100) will return 34.
  1800. * @param percent to convert to number
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the number
  1804. */
  1805. static PercentToRange(percent: number, min: number, max: number): number;
  1806. /**
  1807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1808. * @param angle The angle to normalize in radian.
  1809. * @return The converted angle.
  1810. */
  1811. static NormalizeRadians(angle: number): number;
  1812. }
  1813. }
  1814. declare module BABYLON {
  1815. /**
  1816. * Constant used to convert a value to gamma space
  1817. * @ignorenaming
  1818. */
  1819. export const ToGammaSpace: number;
  1820. /**
  1821. * Constant used to convert a value to linear space
  1822. * @ignorenaming
  1823. */
  1824. export const ToLinearSpace = 2.2;
  1825. /**
  1826. * Constant used to define the minimal number value in Babylon.js
  1827. * @ignorenaming
  1828. */
  1829. let Epsilon: number;
  1830. }
  1831. declare module BABYLON {
  1832. /**
  1833. * Class used to represent a viewport on screen
  1834. */
  1835. export class Viewport {
  1836. /** viewport left coordinate */
  1837. x: number;
  1838. /** viewport top coordinate */
  1839. y: number;
  1840. /**viewport width */
  1841. width: number;
  1842. /** viewport height */
  1843. height: number;
  1844. /**
  1845. * Creates a Viewport object located at (x, y) and sized (width, height)
  1846. * @param x defines viewport left coordinate
  1847. * @param y defines viewport top coordinate
  1848. * @param width defines the viewport width
  1849. * @param height defines the viewport height
  1850. */
  1851. constructor(
  1852. /** viewport left coordinate */
  1853. x: number,
  1854. /** viewport top coordinate */
  1855. y: number,
  1856. /**viewport width */
  1857. width: number,
  1858. /** viewport height */
  1859. height: number);
  1860. /**
  1861. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1862. * @param renderWidth defines the rendering width
  1863. * @param renderHeight defines the rendering height
  1864. * @returns a new Viewport
  1865. */
  1866. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1867. /**
  1868. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1869. * @param renderWidth defines the rendering width
  1870. * @param renderHeight defines the rendering height
  1871. * @param ref defines the target viewport
  1872. * @returns the current viewport
  1873. */
  1874. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1875. /**
  1876. * Returns a new Viewport copied from the current one
  1877. * @returns a new Viewport
  1878. */
  1879. clone(): Viewport;
  1880. }
  1881. }
  1882. declare module BABYLON {
  1883. /**
  1884. * Class containing a set of static utilities functions for arrays.
  1885. */
  1886. export class ArrayTools {
  1887. /**
  1888. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1889. * @param size the number of element to construct and put in the array
  1890. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1891. * @returns a new array filled with new objects
  1892. */
  1893. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1894. }
  1895. }
  1896. declare module BABYLON {
  1897. /**
  1898. * Class representing a vector containing 2 coordinates
  1899. */
  1900. export class Vector2 {
  1901. /** defines the first coordinate */
  1902. x: number;
  1903. /** defines the second coordinate */
  1904. y: number;
  1905. /**
  1906. * Creates a new Vector2 from the given x and y coordinates
  1907. * @param x defines the first coordinate
  1908. * @param y defines the second coordinate
  1909. */
  1910. constructor(
  1911. /** defines the first coordinate */
  1912. x?: number,
  1913. /** defines the second coordinate */
  1914. y?: number);
  1915. /**
  1916. * Gets a string with the Vector2 coordinates
  1917. * @returns a string with the Vector2 coordinates
  1918. */
  1919. toString(): string;
  1920. /**
  1921. * Gets class name
  1922. * @returns the string "Vector2"
  1923. */
  1924. getClassName(): string;
  1925. /**
  1926. * Gets current vector hash code
  1927. * @returns the Vector2 hash code as a number
  1928. */
  1929. getHashCode(): number;
  1930. /**
  1931. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1932. * @param array defines the source array
  1933. * @param index defines the offset in source array
  1934. * @returns the current Vector2
  1935. */
  1936. toArray(array: FloatArray, index?: number): Vector2;
  1937. /**
  1938. * Copy the current vector to an array
  1939. * @returns a new array with 2 elements: the Vector2 coordinates.
  1940. */
  1941. asArray(): number[];
  1942. /**
  1943. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1944. * @param source defines the source Vector2
  1945. * @returns the current updated Vector2
  1946. */
  1947. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1948. /**
  1949. * Sets the Vector2 coordinates with the given floats
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. * @returns the current updated Vector2
  1953. */
  1954. copyFromFloats(x: number, y: number): Vector2;
  1955. /**
  1956. * Sets the Vector2 coordinates with the given floats
  1957. * @param x defines the first coordinate
  1958. * @param y defines the second coordinate
  1959. * @returns the current updated Vector2
  1960. */
  1961. set(x: number, y: number): Vector2;
  1962. /**
  1963. * Add another vector with the current one
  1964. * @param otherVector defines the other vector
  1965. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1966. */
  1967. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1968. /**
  1969. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1970. * @param otherVector defines the other vector
  1971. * @param result defines the target vector
  1972. * @returns the unmodified current Vector2
  1973. */
  1974. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1975. /**
  1976. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1977. * @param otherVector defines the other vector
  1978. * @returns the current updated Vector2
  1979. */
  1980. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1981. /**
  1982. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1983. * @param otherVector defines the other vector
  1984. * @returns a new Vector2
  1985. */
  1986. addVector3(otherVector: Vector3): Vector2;
  1987. /**
  1988. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1989. * @param otherVector defines the other vector
  1990. * @returns a new Vector2
  1991. */
  1992. subtract(otherVector: Vector2): Vector2;
  1993. /**
  1994. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1995. * @param otherVector defines the other vector
  1996. * @param result defines the target vector
  1997. * @returns the unmodified current Vector2
  1998. */
  1999. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2000. /**
  2001. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2002. * @param otherVector defines the other vector
  2003. * @returns the current updated Vector2
  2004. */
  2005. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Multiplies in place the current Vector2 coordinates by the given ones
  2008. * @param otherVector defines the other vector
  2009. * @returns the current updated Vector2
  2010. */
  2011. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2012. /**
  2013. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @returns a new Vector2
  2016. */
  2017. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2018. /**
  2019. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2020. * @param otherVector defines the other vector
  2021. * @param result defines the target vector
  2022. * @returns the unmodified current Vector2
  2023. */
  2024. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2027. * @param x defines the first coordinate
  2028. * @param y defines the second coordinate
  2029. * @returns a new Vector2
  2030. */
  2031. multiplyByFloats(x: number, y: number): Vector2;
  2032. /**
  2033. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2034. * @param otherVector defines the other vector
  2035. * @returns a new Vector2
  2036. */
  2037. divide(otherVector: Vector2): Vector2;
  2038. /**
  2039. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @param result defines the target vector
  2042. * @returns the unmodified current Vector2
  2043. */
  2044. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2045. /**
  2046. * Divides the current Vector2 coordinates by the given ones
  2047. * @param otherVector defines the other vector
  2048. * @returns the current updated Vector2
  2049. */
  2050. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2051. /**
  2052. * Gets a new Vector2 with current Vector2 negated coordinates
  2053. * @returns a new Vector2
  2054. */
  2055. negate(): Vector2;
  2056. /**
  2057. * Multiply the Vector2 coordinates by scale
  2058. * @param scale defines the scaling factor
  2059. * @returns the current updated Vector2
  2060. */
  2061. scaleInPlace(scale: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2064. * @param scale defines the scaling factor
  2065. * @returns a new Vector2
  2066. */
  2067. scale(scale: number): Vector2;
  2068. /**
  2069. * Scale the current Vector2 values by a factor to a given Vector2
  2070. * @param scale defines the scale factor
  2071. * @param result defines the Vector2 object where to store the result
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. scaleToRef(scale: number, result: Vector2): Vector2;
  2075. /**
  2076. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2077. * @param scale defines the scale factor
  2078. * @param result defines the Vector2 object where to store the result
  2079. * @returns the unmodified current Vector2
  2080. */
  2081. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2082. /**
  2083. * Gets a boolean if two vectors are equals
  2084. * @param otherVector defines the other vector
  2085. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2086. */
  2087. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2088. /**
  2089. * Gets a boolean if two vectors are equals (using an epsilon value)
  2090. * @param otherVector defines the other vector
  2091. * @param epsilon defines the minimal distance to consider equality
  2092. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2093. */
  2094. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. floor(): Vector2;
  2100. /**
  2101. * Gets a new Vector2 from current Vector2 floored values
  2102. * @returns a new Vector2
  2103. */
  2104. fract(): Vector2;
  2105. /**
  2106. * Gets the length of the vector
  2107. * @returns the vector length (float)
  2108. */
  2109. length(): number;
  2110. /**
  2111. * Gets the vector squared length
  2112. * @returns the vector squared length (float)
  2113. */
  2114. lengthSquared(): number;
  2115. /**
  2116. * Normalize the vector
  2117. * @returns the current updated Vector2
  2118. */
  2119. normalize(): Vector2;
  2120. /**
  2121. * Gets a new Vector2 copied from the Vector2
  2122. * @returns a new Vector2
  2123. */
  2124. clone(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(0, 0)
  2127. * @returns a new Vector2
  2128. */
  2129. static Zero(): Vector2;
  2130. /**
  2131. * Gets a new Vector2(1, 1)
  2132. * @returns a new Vector2
  2133. */
  2134. static One(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 set from the given index element of the given array
  2137. * @param array defines the data source
  2138. * @param offset defines the offset in the data source
  2139. * @returns a new Vector2
  2140. */
  2141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2142. /**
  2143. * Sets "result" from the given index element of the given array
  2144. * @param array defines the data source
  2145. * @param offset defines the offset in the data source
  2146. * @param result defines the target vector
  2147. */
  2148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2149. /**
  2150. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2151. * @param value1 defines 1st point of control
  2152. * @param value2 defines 2nd point of control
  2153. * @param value3 defines 3rd point of control
  2154. * @param value4 defines 4th point of control
  2155. * @param amount defines the interpolation factor
  2156. * @returns a new Vector2
  2157. */
  2158. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2159. /**
  2160. * 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".
  2161. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2162. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2163. * @param value defines the value to clamp
  2164. * @param min defines the lower limit
  2165. * @param max defines the upper limit
  2166. * @returns a new Vector2
  2167. */
  2168. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2171. * @param value1 defines the 1st control point
  2172. * @param tangent1 defines the outgoing tangent
  2173. * @param value2 defines the 2nd control point
  2174. * @param tangent2 defines the incoming tangent
  2175. * @param amount defines the interpolation factor
  2176. * @returns a new Vector2
  2177. */
  2178. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2179. /**
  2180. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2181. * @param start defines the start vector
  2182. * @param end defines the end vector
  2183. * @param amount defines the interpolation factor
  2184. * @returns a new Vector2
  2185. */
  2186. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2187. /**
  2188. * Gets the dot product of the vector "left" and the vector "right"
  2189. * @param left defines first vector
  2190. * @param right defines second vector
  2191. * @returns the dot product (float)
  2192. */
  2193. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2194. /**
  2195. * Returns a new Vector2 equal to the normalized given vector
  2196. * @param vector defines the vector to normalize
  2197. * @returns a new Vector2
  2198. */
  2199. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2202. * @param left defines 1st vector
  2203. * @param right defines 2nd vector
  2204. * @returns a new Vector2
  2205. */
  2206. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2209. * @param left defines 1st vector
  2210. * @param right defines 2nd vector
  2211. * @returns a new Vector2
  2212. */
  2213. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2216. * @param vector defines the vector to transform
  2217. * @param transformation defines the matrix to apply
  2218. * @returns a new Vector2
  2219. */
  2220. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2221. /**
  2222. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2223. * @param vector defines the vector to transform
  2224. * @param transformation defines the matrix to apply
  2225. * @param result defines the target vector
  2226. */
  2227. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2228. /**
  2229. * Determines if a given vector is included in a triangle
  2230. * @param p defines the vector to test
  2231. * @param p0 defines 1st triangle point
  2232. * @param p1 defines 2nd triangle point
  2233. * @param p2 defines 3rd triangle point
  2234. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2235. */
  2236. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2237. /**
  2238. * Gets the distance between the vectors "value1" and "value2"
  2239. * @param value1 defines first vector
  2240. * @param value2 defines second vector
  2241. * @returns the distance between vectors
  2242. */
  2243. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2244. /**
  2245. * Returns the squared distance between the vectors "value1" and "value2"
  2246. * @param value1 defines first vector
  2247. * @param value2 defines second vector
  2248. * @returns the squared distance between vectors
  2249. */
  2250. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2251. /**
  2252. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2253. * @param value1 defines first vector
  2254. * @param value2 defines second vector
  2255. * @returns a new Vector2
  2256. */
  2257. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2258. /**
  2259. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2260. * @param p defines the middle point
  2261. * @param segA defines one point of the segment
  2262. * @param segB defines the other point of the segment
  2263. * @returns the shortest distance
  2264. */
  2265. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2266. }
  2267. /**
  2268. * Classed used to store (x,y,z) vector representation
  2269. * A Vector3 is the main object used in 3D geometry
  2270. * It can represent etiher the coordinates of a point the space, either a direction
  2271. * Reminder: js uses a left handed forward facing system
  2272. */
  2273. export class Vector3 {
  2274. /**
  2275. * Defines the first coordinates (on X axis)
  2276. */
  2277. x: number;
  2278. /**
  2279. * Defines the second coordinates (on Y axis)
  2280. */
  2281. y: number;
  2282. /**
  2283. * Defines the third coordinates (on Z axis)
  2284. */
  2285. z: number;
  2286. private static _UpReadOnly;
  2287. private static _ZeroReadOnly;
  2288. /**
  2289. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2290. * @param x defines the first coordinates (on X axis)
  2291. * @param y defines the second coordinates (on Y axis)
  2292. * @param z defines the third coordinates (on Z axis)
  2293. */
  2294. constructor(
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x?: number,
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y?: number,
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z?: number);
  2307. /**
  2308. * Creates a string representation of the Vector3
  2309. * @returns a string with the Vector3 coordinates.
  2310. */
  2311. toString(): string;
  2312. /**
  2313. * Gets the class name
  2314. * @returns the string "Vector3"
  2315. */
  2316. getClassName(): string;
  2317. /**
  2318. * Creates the Vector3 hash code
  2319. * @returns a number which tends to be unique between Vector3 instances
  2320. */
  2321. getHashCode(): number;
  2322. /**
  2323. * Creates an array containing three elements : the coordinates of the Vector3
  2324. * @returns a new array of numbers
  2325. */
  2326. asArray(): number[];
  2327. /**
  2328. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2329. * @param array defines the destination array
  2330. * @param index defines the offset in the destination array
  2331. * @returns the current Vector3
  2332. */
  2333. toArray(array: FloatArray, index?: number): Vector3;
  2334. /**
  2335. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2336. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2337. */
  2338. toQuaternion(): Quaternion;
  2339. /**
  2340. * Adds the given vector to the current Vector3
  2341. * @param otherVector defines the second operand
  2342. * @returns the current updated Vector3
  2343. */
  2344. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2345. /**
  2346. * Adds the given coordinates to the current Vector3
  2347. * @param x defines the x coordinate of the operand
  2348. * @param y defines the y coordinate of the operand
  2349. * @param z defines the z coordinate of the operand
  2350. * @returns the current updated Vector3
  2351. */
  2352. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2353. /**
  2354. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2355. * @param otherVector defines the second operand
  2356. * @returns the resulting Vector3
  2357. */
  2358. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2361. * @param otherVector defines the second operand
  2362. * @param result defines the Vector3 object where to store the result
  2363. * @returns the current Vector3
  2364. */
  2365. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2366. /**
  2367. * Subtract the given vector from the current Vector3
  2368. * @param otherVector defines the second operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2372. /**
  2373. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2380. * @param otherVector defines the second operand
  2381. * @param result defines the Vector3 object where to store the result
  2382. * @returns the current Vector3
  2383. */
  2384. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2387. * @param x defines the x coordinate of the operand
  2388. * @param y defines the y coordinate of the operand
  2389. * @param z defines the z coordinate of the operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2393. /**
  2394. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2395. * @param x defines the x coordinate of the operand
  2396. * @param y defines the y coordinate of the operand
  2397. * @param z defines the z coordinate of the operand
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2402. /**
  2403. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2404. * @returns a new Vector3
  2405. */
  2406. negate(): Vector3;
  2407. /**
  2408. * Multiplies the Vector3 coordinates by the float "scale"
  2409. * @param scale defines the multiplier factor
  2410. * @returns the current updated Vector3
  2411. */
  2412. scaleInPlace(scale: number): Vector3;
  2413. /**
  2414. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2415. * @param scale defines the multiplier factor
  2416. * @returns a new Vector3
  2417. */
  2418. scale(scale: number): Vector3;
  2419. /**
  2420. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2421. * @param scale defines the multiplier factor
  2422. * @param result defines the Vector3 object where to store the result
  2423. * @returns the current Vector3
  2424. */
  2425. scaleToRef(scale: number, result: Vector3): Vector3;
  2426. /**
  2427. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2428. * @param scale defines the scale factor
  2429. * @param result defines the Vector3 object where to store the result
  2430. * @returns the unmodified current Vector3
  2431. */
  2432. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2433. /**
  2434. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2435. * @param otherVector defines the second operand
  2436. * @returns true if both vectors are equals
  2437. */
  2438. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2439. /**
  2440. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2441. * @param otherVector defines the second operand
  2442. * @param epsilon defines the minimal distance to define values as equals
  2443. * @returns true if both vectors are distant less than epsilon
  2444. */
  2445. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2446. /**
  2447. * Returns true if the current Vector3 coordinates equals the given floats
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @returns true if both vectors are equals
  2452. */
  2453. equalsToFloats(x: number, y: number, z: number): boolean;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the given ones
  2456. * @param otherVector defines the second operand
  2457. * @returns the current updated Vector3
  2458. */
  2459. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2460. /**
  2461. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2462. * @param otherVector defines the second operand
  2463. * @returns the new Vector3
  2464. */
  2465. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2466. /**
  2467. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2468. * @param otherVector defines the second operand
  2469. * @param result defines the Vector3 object where to store the result
  2470. * @returns the current Vector3
  2471. */
  2472. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns the new Vector3
  2479. */
  2480. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2481. /**
  2482. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the new Vector3
  2485. */
  2486. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2489. * @param otherVector defines the second operand
  2490. * @param result defines the Vector3 object where to store the result
  2491. * @returns the current Vector3
  2492. */
  2493. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2494. /**
  2495. * Divides the current Vector3 coordinates by the given ones.
  2496. * @param otherVector defines the second operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. divideInPlace(otherVector: Vector3): Vector3;
  2500. /**
  2501. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2502. * @param other defines the second operand
  2503. * @returns the current updated Vector3
  2504. */
  2505. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2508. * @param other defines the second operand
  2509. * @returns the current updated Vector3
  2510. */
  2511. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2512. /**
  2513. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2514. * @param x defines the x coordinate of the operand
  2515. * @param y defines the y coordinate of the operand
  2516. * @param z defines the z coordinate of the operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2520. /**
  2521. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2522. * @param x defines the x coordinate of the operand
  2523. * @param y defines the y coordinate of the operand
  2524. * @param z defines the z coordinate of the operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2528. /**
  2529. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2530. * Check if is non uniform within a certain amount of decimal places to account for this
  2531. * @param epsilon the amount the values can differ
  2532. * @returns if the the vector is non uniform to a certain number of decimal places
  2533. */
  2534. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2535. /**
  2536. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2537. */
  2538. readonly isNonUniform: boolean;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. floor(): Vector3;
  2544. /**
  2545. * Gets a new Vector3 from current Vector3 floored values
  2546. * @returns a new Vector3
  2547. */
  2548. fract(): Vector3;
  2549. /**
  2550. * Gets the length of the Vector3
  2551. * @returns the length of the Vector3
  2552. */
  2553. length(): number;
  2554. /**
  2555. * Gets the squared length of the Vector3
  2556. * @returns squared length of the Vector3
  2557. */
  2558. lengthSquared(): number;
  2559. /**
  2560. * Normalize the current Vector3.
  2561. * Please note that this is an in place operation.
  2562. * @returns the current updated Vector3
  2563. */
  2564. normalize(): Vector3;
  2565. /**
  2566. * Reorders the x y z properties of the vector in place
  2567. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2568. * @returns the current updated vector
  2569. */
  2570. reorderInPlace(order: string): this;
  2571. /**
  2572. * Rotates the vector around 0,0,0 by a quaternion
  2573. * @param quaternion the rotation quaternion
  2574. * @param result vector to store the result
  2575. * @returns the resulting vector
  2576. */
  2577. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2578. /**
  2579. * Rotates a vector around a given point
  2580. * @param quaternion the rotation quaternion
  2581. * @param point the point to rotate around
  2582. * @param result vector to store the result
  2583. * @returns the resulting vector
  2584. */
  2585. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2586. /**
  2587. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2588. * The cross product is then orthogonal to both current and "other"
  2589. * @param other defines the right operand
  2590. * @returns the cross product
  2591. */
  2592. cross(other: Vector3): Vector3;
  2593. /**
  2594. * Normalize the current Vector3 with the given input length.
  2595. * Please note that this is an in place operation.
  2596. * @param len the length of the vector
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalizeFromLength(len: number): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to a new vector
  2602. * @returns the new Vector3
  2603. */
  2604. normalizeToNew(): Vector3;
  2605. /**
  2606. * Normalize the current Vector3 to the reference
  2607. * @param reference define the Vector3 to update
  2608. * @returns the updated Vector3
  2609. */
  2610. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2611. /**
  2612. * Creates a new Vector3 copied from the current Vector3
  2613. * @returns the new Vector3
  2614. */
  2615. clone(): Vector3;
  2616. /**
  2617. * Copies the given vector coordinates to the current Vector3 ones
  2618. * @param source defines the source Vector3
  2619. * @returns the current updated Vector3
  2620. */
  2621. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Copies the given floats to the current Vector3 coordinates
  2624. * @param x defines the x coordinate of the operand
  2625. * @param y defines the y coordinate of the operand
  2626. * @param z defines the z coordinate of the operand
  2627. * @returns the current updated Vector3
  2628. */
  2629. copyFromFloats(x: number, y: number, z: number): Vector3;
  2630. /**
  2631. * Copies the given floats to the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the current updated Vector3
  2636. */
  2637. set(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Copies the given float to the current Vector3 coordinates
  2640. * @param v defines the x, y and z coordinates of the operand
  2641. * @returns the current updated Vector3
  2642. */
  2643. setAll(v: number): Vector3;
  2644. /**
  2645. * Get the clip factor between two vectors
  2646. * @param vector0 defines the first operand
  2647. * @param vector1 defines the second operand
  2648. * @param axis defines the axis to use
  2649. * @param size defines the size along the axis
  2650. * @returns the clip factor
  2651. */
  2652. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2653. /**
  2654. * Get angle between two vectors
  2655. * @param vector0 angle between vector0 and vector1
  2656. * @param vector1 angle between vector0 and vector1
  2657. * @param normal direction of the normal
  2658. * @return the angle between vector0 and vector1
  2659. */
  2660. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2661. /**
  2662. * Returns a new Vector3 set from the index "offset" of the given array
  2663. * @param array defines the source array
  2664. * @param offset defines the offset in the source array
  2665. * @returns the new Vector3
  2666. */
  2667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2670. * This function is deprecated. Use FromArray instead
  2671. * @param array defines the source array
  2672. * @param offset defines the offset in the source array
  2673. * @returns the new Vector3
  2674. */
  2675. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2676. /**
  2677. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2678. * @param array defines the source array
  2679. * @param offset defines the offset in the source array
  2680. * @param result defines the Vector3 where to store the result
  2681. */
  2682. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2683. /**
  2684. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2685. * This function is deprecated. Use FromArrayToRef instead.
  2686. * @param array defines the source array
  2687. * @param offset defines the offset in the source array
  2688. * @param result defines the Vector3 where to store the result
  2689. */
  2690. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2691. /**
  2692. * Sets the given vector "result" with the given floats.
  2693. * @param x defines the x coordinate of the source
  2694. * @param y defines the y coordinate of the source
  2695. * @param z defines the z coordinate of the source
  2696. * @param result defines the Vector3 where to store the result
  2697. */
  2698. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2699. /**
  2700. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2701. * @returns a new empty Vector3
  2702. */
  2703. static Zero(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2706. * @returns a new unit Vector3
  2707. */
  2708. static One(): Vector3;
  2709. /**
  2710. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2711. * @returns a new up Vector3
  2712. */
  2713. static Up(): Vector3;
  2714. /**
  2715. * Gets a up Vector3 that must not be updated
  2716. */
  2717. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2718. /**
  2719. * Gets a zero Vector3 that must not be updated
  2720. */
  2721. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2724. * @returns a new down Vector3
  2725. */
  2726. static Down(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Forward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2734. * @returns a new forward Vector3
  2735. */
  2736. static Backward(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2739. * @returns a new right Vector3
  2740. */
  2741. static Right(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2744. * @returns a new left Vector3
  2745. */
  2746. static Left(): Vector3;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2749. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the transformed Vector3
  2753. */
  2754. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2757. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2765. * This method computes tranformed coordinates only, not transformed direction vectors
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2775. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2776. * @param vector defines the Vector3 to transform
  2777. * @param transformation defines the transformation matrix
  2778. * @returns the new Vector3
  2779. */
  2780. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2781. /**
  2782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2783. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2784. * @param vector defines the Vector3 to transform
  2785. * @param transformation defines the transformation matrix
  2786. * @param result defines the Vector3 where to store the result
  2787. */
  2788. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2789. /**
  2790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2791. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2792. * @param x define the x coordinate of the source vector
  2793. * @param y define the y coordinate of the source vector
  2794. * @param z define the z coordinate of the source vector
  2795. * @param transformation defines the transformation matrix
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2799. /**
  2800. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2801. * @param value1 defines the first control point
  2802. * @param value2 defines the second control point
  2803. * @param value3 defines the third control point
  2804. * @param value4 defines the fourth control point
  2805. * @param amount defines the amount on the spline to use
  2806. * @returns the new Vector3
  2807. */
  2808. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2809. /**
  2810. * 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"
  2811. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2812. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2813. * @param value defines the current value
  2814. * @param min defines the lower range value
  2815. * @param max defines the upper range value
  2816. * @returns the new Vector3
  2817. */
  2818. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2819. /**
  2820. * 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"
  2821. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2822. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2823. * @param value defines the current value
  2824. * @param min defines the lower range value
  2825. * @param max defines the upper range value
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2829. /**
  2830. * Checks if a given vector is inside a specific range
  2831. * @param v defines the vector to test
  2832. * @param min defines the minimum range
  2833. * @param max defines the maximum range
  2834. */
  2835. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2838. * @param value1 defines the first control point
  2839. * @param tangent1 defines the first tangent vector
  2840. * @param value2 defines the second control point
  2841. * @param tangent2 defines the second tangent vector
  2842. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2843. * @returns the new Vector3
  2844. */
  2845. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2846. /**
  2847. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2848. * @param start defines the start value
  2849. * @param end defines the end value
  2850. * @param amount max defines amount between both (between 0 and 1)
  2851. * @returns the new Vector3
  2852. */
  2853. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2856. * @param start defines the start value
  2857. * @param end defines the end value
  2858. * @param amount max defines amount between both (between 0 and 1)
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2862. /**
  2863. * Returns the dot product (float) between the vectors "left" and "right"
  2864. * @param left defines the left operand
  2865. * @param right defines the right operand
  2866. * @returns the dot product
  2867. */
  2868. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2871. * The cross product is then orthogonal to both "left" and "right"
  2872. * @param left defines the left operand
  2873. * @param right defines the right operand
  2874. * @returns the cross product
  2875. */
  2876. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the cross product of "left" and "right"
  2879. * The cross product is then orthogonal to both "left" and "right"
  2880. * @param left defines the left operand
  2881. * @param right defines the right operand
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2885. /**
  2886. * Returns a new Vector3 as the normalization of the given vector
  2887. * @param vector defines the Vector3 to normalize
  2888. * @returns the new Vector3
  2889. */
  2890. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2891. /**
  2892. * Sets the given vector "result" with the normalization of the given first vector
  2893. * @param vector defines the Vector3 to normalize
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2897. /**
  2898. * Project a Vector3 onto screen space
  2899. * @param vector defines the Vector3 to project
  2900. * @param world defines the world matrix to use
  2901. * @param transform defines the transform (view x projection) matrix to use
  2902. * @param viewport defines the screen viewport to use
  2903. * @returns the new Vector3
  2904. */
  2905. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2906. /** @hidden */
  2907. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2908. /**
  2909. * Unproject from screen space to object space
  2910. * @param source defines the screen space Vector3 to use
  2911. * @param viewportWidth defines the current width of the viewport
  2912. * @param viewportHeight defines the current height of the viewport
  2913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2914. * @param transform defines the transform (view x projection) matrix to use
  2915. * @returns the new Vector3
  2916. */
  2917. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2918. /**
  2919. * Unproject from screen space to object space
  2920. * @param source defines the screen space Vector3 to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @returns the new Vector3
  2927. */
  2928. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Unproject from screen space to object space
  2931. * @param source defines the screen space Vector3 to use
  2932. * @param viewportWidth defines the current width of the viewport
  2933. * @param viewportHeight defines the current height of the viewport
  2934. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2935. * @param view defines the view matrix to use
  2936. * @param projection defines the projection matrix to use
  2937. * @param result defines the Vector3 where to store the result
  2938. */
  2939. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param sourceX defines the screen space x coordinate to use
  2943. * @param sourceY defines the screen space y coordinate to use
  2944. * @param sourceZ defines the screen space z coordinate to use
  2945. * @param viewportWidth defines the current width of the viewport
  2946. * @param viewportHeight defines the current height of the viewport
  2947. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2948. * @param view defines the view matrix to use
  2949. * @param projection defines the projection matrix to use
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Gets the minimal coordinate values between two Vector3
  2955. * @param left defines the first operand
  2956. * @param right defines the second operand
  2957. * @returns the new Vector3
  2958. */
  2959. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2960. /**
  2961. * Gets the maximal coordinate values between two Vector3
  2962. * @param left defines the first operand
  2963. * @param right defines the second operand
  2964. * @returns the new Vector3
  2965. */
  2966. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Returns the distance between the vectors "value1" and "value2"
  2969. * @param value1 defines the first operand
  2970. * @param value2 defines the second operand
  2971. * @returns the distance
  2972. */
  2973. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2974. /**
  2975. * Returns the squared distance between the vectors "value1" and "value2"
  2976. * @param value1 defines the first operand
  2977. * @param value2 defines the second operand
  2978. * @returns the squared distance
  2979. */
  2980. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2981. /**
  2982. * Returns a new Vector3 located at the center between "value1" and "value2"
  2983. * @param value1 defines the first operand
  2984. * @param value2 defines the second operand
  2985. * @returns the new Vector3
  2986. */
  2987. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2988. /**
  2989. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2990. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2991. * to something in order to rotate it from its local system to the given target system
  2992. * Note: axis1, axis2 and axis3 are normalized during this operation
  2993. * @param axis1 defines the first axis
  2994. * @param axis2 defines the second axis
  2995. * @param axis3 defines the third axis
  2996. * @returns a new Vector3
  2997. */
  2998. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3001. * @param axis1 defines the first axis
  3002. * @param axis2 defines the second axis
  3003. * @param axis3 defines the third axis
  3004. * @param ref defines the Vector3 where to store the result
  3005. */
  3006. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3007. }
  3008. /**
  3009. * Vector4 class created for EulerAngle class conversion to Quaternion
  3010. */
  3011. export class Vector4 {
  3012. /** x value of the vector */
  3013. x: number;
  3014. /** y value of the vector */
  3015. y: number;
  3016. /** z value of the vector */
  3017. z: number;
  3018. /** w value of the vector */
  3019. w: number;
  3020. /**
  3021. * Creates a Vector4 object from the given floats.
  3022. * @param x x value of the vector
  3023. * @param y y value of the vector
  3024. * @param z z value of the vector
  3025. * @param w w value of the vector
  3026. */
  3027. constructor(
  3028. /** x value of the vector */
  3029. x: number,
  3030. /** y value of the vector */
  3031. y: number,
  3032. /** z value of the vector */
  3033. z: number,
  3034. /** w value of the vector */
  3035. w: number);
  3036. /**
  3037. * Returns the string with the Vector4 coordinates.
  3038. * @returns a string containing all the vector values
  3039. */
  3040. toString(): string;
  3041. /**
  3042. * Returns the string "Vector4".
  3043. * @returns "Vector4"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Returns the Vector4 hash code.
  3048. * @returns a unique hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3053. * @returns the resulting array
  3054. */
  3055. asArray(): number[];
  3056. /**
  3057. * Populates the given array from the given index with the Vector4 coordinates.
  3058. * @param array array to populate
  3059. * @param index index of the array to start at (default: 0)
  3060. * @returns the Vector4.
  3061. */
  3062. toArray(array: FloatArray, index?: number): Vector4;
  3063. /**
  3064. * Adds the given vector to the current Vector4.
  3065. * @param otherVector the vector to add
  3066. * @returns the updated Vector4.
  3067. */
  3068. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3069. /**
  3070. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3071. * @param otherVector the vector to add
  3072. * @returns the resulting vector
  3073. */
  3074. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3075. /**
  3076. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3077. * @param otherVector the vector to add
  3078. * @param result the vector to store the result
  3079. * @returns the current Vector4.
  3080. */
  3081. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3082. /**
  3083. * Subtract in place the given vector from the current Vector4.
  3084. * @param otherVector the vector to subtract
  3085. * @returns the updated Vector4.
  3086. */
  3087. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3088. /**
  3089. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3090. * @param otherVector the vector to add
  3091. * @returns the new vector with the result
  3092. */
  3093. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3094. /**
  3095. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3096. * @param otherVector the vector to subtract
  3097. * @param result the vector to store the result
  3098. * @returns the current Vector4.
  3099. */
  3100. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3101. /**
  3102. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3103. */
  3104. /**
  3105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3106. * @param x value to subtract
  3107. * @param y value to subtract
  3108. * @param z value to subtract
  3109. * @param w value to subtract
  3110. * @returns new vector containing the result
  3111. */
  3112. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3113. /**
  3114. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3115. * @param x value to subtract
  3116. * @param y value to subtract
  3117. * @param z value to subtract
  3118. * @param w value to subtract
  3119. * @param result the vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3123. /**
  3124. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3125. * @returns a new vector with the negated values
  3126. */
  3127. negate(): Vector4;
  3128. /**
  3129. * Multiplies the current Vector4 coordinates by scale (float).
  3130. * @param scale the number to scale with
  3131. * @returns the updated Vector4.
  3132. */
  3133. scaleInPlace(scale: number): Vector4;
  3134. /**
  3135. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3136. * @param scale the number to scale with
  3137. * @returns a new vector with the result
  3138. */
  3139. scale(scale: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3142. * @param scale the number to scale with
  3143. * @param result a vector to store the result in
  3144. * @returns the current Vector4.
  3145. */
  3146. scaleToRef(scale: number, result: Vector4): Vector4;
  3147. /**
  3148. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3149. * @param scale defines the scale factor
  3150. * @param result defines the Vector4 object where to store the result
  3151. * @returns the unmodified current Vector4
  3152. */
  3153. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3154. /**
  3155. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3156. * @param otherVector the vector to compare against
  3157. * @returns true if they are equal
  3158. */
  3159. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3160. /**
  3161. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3162. * @param otherVector vector to compare against
  3163. * @param epsilon (Default: very small number)
  3164. * @returns true if they are equal
  3165. */
  3166. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3167. /**
  3168. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3169. * @param x x value to compare against
  3170. * @param y y value to compare against
  3171. * @param z z value to compare against
  3172. * @param w w value to compare against
  3173. * @returns true if equal
  3174. */
  3175. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3176. /**
  3177. * Multiplies in place the current Vector4 by the given one.
  3178. * @param otherVector vector to multiple with
  3179. * @returns the updated Vector4.
  3180. */
  3181. multiplyInPlace(otherVector: Vector4): Vector4;
  3182. /**
  3183. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3184. * @param otherVector vector to multiple with
  3185. * @returns resulting new vector
  3186. */
  3187. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3188. /**
  3189. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3190. * @param otherVector vector to multiple with
  3191. * @param result vector to store the result
  3192. * @returns the current Vector4.
  3193. */
  3194. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3195. /**
  3196. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3197. * @param x x value multiply with
  3198. * @param y y value multiply with
  3199. * @param z z value multiply with
  3200. * @param w w value multiply with
  3201. * @returns resulting new vector
  3202. */
  3203. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3204. /**
  3205. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3206. * @param otherVector vector to devide with
  3207. * @returns resulting new vector
  3208. */
  3209. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3210. /**
  3211. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3212. * @param otherVector vector to devide with
  3213. * @param result vector to store the result
  3214. * @returns the current Vector4.
  3215. */
  3216. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3217. /**
  3218. * Divides the current Vector3 coordinates by the given ones.
  3219. * @param otherVector vector to devide with
  3220. * @returns the updated Vector3.
  3221. */
  3222. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3225. * @param other defines the second operand
  3226. * @returns the current updated Vector4
  3227. */
  3228. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3231. * @param other defines the second operand
  3232. * @returns the current updated Vector4
  3233. */
  3234. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector4 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. floor(): Vector4;
  3240. /**
  3241. * Gets a new Vector4 from current Vector3 floored values
  3242. * @returns a new Vector4
  3243. */
  3244. fract(): Vector4;
  3245. /**
  3246. * Returns the Vector4 length (float).
  3247. * @returns the length
  3248. */
  3249. length(): number;
  3250. /**
  3251. * Returns the Vector4 squared length (float).
  3252. * @returns the length squared
  3253. */
  3254. lengthSquared(): number;
  3255. /**
  3256. * Normalizes in place the Vector4.
  3257. * @returns the updated Vector4.
  3258. */
  3259. normalize(): Vector4;
  3260. /**
  3261. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3262. * @returns this converted to a new vector3
  3263. */
  3264. toVector3(): Vector3;
  3265. /**
  3266. * Returns a new Vector4 copied from the current one.
  3267. * @returns the new cloned vector
  3268. */
  3269. clone(): Vector4;
  3270. /**
  3271. * Updates the current Vector4 with the given one coordinates.
  3272. * @param source the source vector to copy from
  3273. * @returns the updated Vector4.
  3274. */
  3275. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the current Vector4 coordinates with the given floats.
  3278. * @param x float to copy from
  3279. * @param y float to copy from
  3280. * @param z float to copy from
  3281. * @param w float to copy from
  3282. * @returns the updated Vector4.
  3283. */
  3284. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3285. /**
  3286. * Updates the current Vector4 coordinates with the given floats.
  3287. * @param x float to set from
  3288. * @param y float to set from
  3289. * @param z float to set from
  3290. * @param w float to set from
  3291. * @returns the updated Vector4.
  3292. */
  3293. set(x: number, y: number, z: number, w: number): Vector4;
  3294. /**
  3295. * Copies the given float to the current Vector3 coordinates
  3296. * @param v defines the x, y, z and w coordinates of the operand
  3297. * @returns the current updated Vector3
  3298. */
  3299. setAll(v: number): Vector4;
  3300. /**
  3301. * Returns a new Vector4 set from the starting index of the given array.
  3302. * @param array the array to pull values from
  3303. * @param offset the offset into the array to start at
  3304. * @returns the new vector
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3307. /**
  3308. * Updates the given vector "result" from the starting index of the given array.
  3309. * @param array the array to pull values from
  3310. * @param offset the offset into the array to start at
  3311. * @param result the vector to store the result in
  3312. */
  3313. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3314. /**
  3315. * Updates the given vector "result" from the starting index of the given Float32Array.
  3316. * @param array the array to pull values from
  3317. * @param offset the offset into the array to start at
  3318. * @param result the vector to store the result in
  3319. */
  3320. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3321. /**
  3322. * Updates the given vector "result" coordinates from the given floats.
  3323. * @param x float to set from
  3324. * @param y float to set from
  3325. * @param z float to set from
  3326. * @param w float to set from
  3327. * @param result the vector to the floats in
  3328. */
  3329. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3330. /**
  3331. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3332. * @returns the new vector
  3333. */
  3334. static Zero(): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3337. * @returns the new vector
  3338. */
  3339. static One(): Vector4;
  3340. /**
  3341. * Returns a new normalized Vector4 from the given one.
  3342. * @param vector the vector to normalize
  3343. * @returns the vector
  3344. */
  3345. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3346. /**
  3347. * Updates the given vector "result" from the normalization of the given one.
  3348. * @param vector the vector to normalize
  3349. * @param result the vector to store the result in
  3350. */
  3351. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3352. /**
  3353. * Returns a vector with the minimum values from the left and right vectors
  3354. * @param left left vector to minimize
  3355. * @param right right vector to minimize
  3356. * @returns a new vector with the minimum of the left and right vector values
  3357. */
  3358. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Returns a vector with the maximum values from the left and right vectors
  3361. * @param left left vector to maximize
  3362. * @param right right vector to maximize
  3363. * @returns a new vector with the maximum of the left and right vector values
  3364. */
  3365. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3366. /**
  3367. * Returns the distance (float) between the vectors "value1" and "value2".
  3368. * @param value1 value to calulate the distance between
  3369. * @param value2 value to calulate the distance between
  3370. * @return the distance between the two vectors
  3371. */
  3372. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3373. /**
  3374. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3375. * @param value1 value to calulate the distance between
  3376. * @param value2 value to calulate the distance between
  3377. * @return the distance between the two vectors squared
  3378. */
  3379. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3380. /**
  3381. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3382. * @param value1 value to calulate the center between
  3383. * @param value2 value to calulate the center between
  3384. * @return the center between the two vectors
  3385. */
  3386. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3389. * This methods computes transformed normalized direction vectors only.
  3390. * @param vector the vector to transform
  3391. * @param transformation the transformation matrix to apply
  3392. * @returns the new vector
  3393. */
  3394. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3395. /**
  3396. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3397. * This methods computes transformed normalized direction vectors only.
  3398. * @param vector the vector to transform
  3399. * @param transformation the transformation matrix to apply
  3400. * @param result the vector to store the result in
  3401. */
  3402. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3403. /**
  3404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3405. * This methods computes transformed normalized direction vectors only.
  3406. * @param x value to transform
  3407. * @param y value to transform
  3408. * @param z value to transform
  3409. * @param w value to transform
  3410. * @param transformation the transformation matrix to apply
  3411. * @param result the vector to store the results in
  3412. */
  3413. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3414. /**
  3415. * Creates a new Vector4 from a Vector3
  3416. * @param source defines the source data
  3417. * @param w defines the 4th component (default is 0)
  3418. * @returns a new Vector4
  3419. */
  3420. static FromVector3(source: Vector3, w?: number): Vector4;
  3421. }
  3422. /**
  3423. * Class used to store quaternion data
  3424. * @see https://en.wikipedia.org/wiki/Quaternion
  3425. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3426. */
  3427. export class Quaternion {
  3428. /** defines the first component (0 by default) */
  3429. x: number;
  3430. /** defines the second component (0 by default) */
  3431. y: number;
  3432. /** defines the third component (0 by default) */
  3433. z: number;
  3434. /** defines the fourth component (1.0 by default) */
  3435. w: number;
  3436. /**
  3437. * Creates a new Quaternion from the given floats
  3438. * @param x defines the first component (0 by default)
  3439. * @param y defines the second component (0 by default)
  3440. * @param z defines the third component (0 by default)
  3441. * @param w defines the fourth component (1.0 by default)
  3442. */
  3443. constructor(
  3444. /** defines the first component (0 by default) */
  3445. x?: number,
  3446. /** defines the second component (0 by default) */
  3447. y?: number,
  3448. /** defines the third component (0 by default) */
  3449. z?: number,
  3450. /** defines the fourth component (1.0 by default) */
  3451. w?: number);
  3452. /**
  3453. * Gets a string representation for the current quaternion
  3454. * @returns a string with the Quaternion coordinates
  3455. */
  3456. toString(): string;
  3457. /**
  3458. * Gets the class name of the quaternion
  3459. * @returns the string "Quaternion"
  3460. */
  3461. getClassName(): string;
  3462. /**
  3463. * Gets a hash code for this quaternion
  3464. * @returns the quaternion hash code
  3465. */
  3466. getHashCode(): number;
  3467. /**
  3468. * Copy the quaternion to an array
  3469. * @returns a new array populated with 4 elements from the quaternion coordinates
  3470. */
  3471. asArray(): number[];
  3472. /**
  3473. * Check if two quaternions are equals
  3474. * @param otherQuaternion defines the second operand
  3475. * @return true if the current quaternion and the given one coordinates are strictly equals
  3476. */
  3477. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3478. /**
  3479. * Clone the current quaternion
  3480. * @returns a new quaternion copied from the current one
  3481. */
  3482. clone(): Quaternion;
  3483. /**
  3484. * Copy a quaternion to the current one
  3485. * @param other defines the other quaternion
  3486. * @returns the updated current quaternion
  3487. */
  3488. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Updates the current quaternion with the given float coordinates
  3491. * @param x defines the x coordinate
  3492. * @param y defines the y coordinate
  3493. * @param z defines the z coordinate
  3494. * @param w defines the w coordinate
  3495. * @returns the updated current quaternion
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3498. /**
  3499. * Updates the current quaternion from the given float coordinates
  3500. * @param x defines the x coordinate
  3501. * @param y defines the y coordinate
  3502. * @param z defines the z coordinate
  3503. * @param w defines the w coordinate
  3504. * @returns the updated current quaternion
  3505. */
  3506. set(x: number, y: number, z: number, w: number): Quaternion;
  3507. /**
  3508. * Adds two quaternions
  3509. * @param other defines the second operand
  3510. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3511. */
  3512. add(other: DeepImmutable<Quaternion>): Quaternion;
  3513. /**
  3514. * Add a quaternion to the current one
  3515. * @param other defines the quaternion to add
  3516. * @returns the current quaternion
  3517. */
  3518. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Subtract two quaternions
  3521. * @param other defines the second operand
  3522. * @returns a new quaternion as the subtraction result of the given one from the current one
  3523. */
  3524. subtract(other: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies the current quaternion by a scale factor
  3527. * @param value defines the scale factor
  3528. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3529. */
  3530. scale(value: number): Quaternion;
  3531. /**
  3532. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Quaternion object where to store the result
  3535. * @returns the unmodified current quaternion
  3536. */
  3537. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3538. /**
  3539. * Multiplies in place the current quaternion by a scale factor
  3540. * @param value defines the scale factor
  3541. * @returns the current modified quaternion
  3542. */
  3543. scaleInPlace(value: number): Quaternion;
  3544. /**
  3545. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3546. * @param scale defines the scale factor
  3547. * @param result defines the Quaternion object where to store the result
  3548. * @returns the unmodified current quaternion
  3549. */
  3550. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3551. /**
  3552. * Multiplies two quaternions
  3553. * @param q1 defines the second operand
  3554. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3555. */
  3556. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3557. /**
  3558. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3559. * @param q1 defines the second operand
  3560. * @param result defines the target quaternion
  3561. * @returns the current quaternion
  3562. */
  3563. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3564. /**
  3565. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3566. * @param q1 defines the second operand
  3567. * @returns the currentupdated quaternion
  3568. */
  3569. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3572. * @param ref defines the target quaternion
  3573. * @returns the current quaternion
  3574. */
  3575. conjugateToRef(ref: Quaternion): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns the current updated quaternion
  3579. */
  3580. conjugateInPlace(): Quaternion;
  3581. /**
  3582. * Conjugates in place (1-q) the current quaternion
  3583. * @returns a new quaternion
  3584. */
  3585. conjugate(): Quaternion;
  3586. /**
  3587. * Gets length of current quaternion
  3588. * @returns the quaternion length (float)
  3589. */
  3590. length(): number;
  3591. /**
  3592. * Normalize in place the current quaternion
  3593. * @returns the current updated quaternion
  3594. */
  3595. normalize(): Quaternion;
  3596. /**
  3597. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3598. * @param order is a reserved parameter and is ignore for now
  3599. * @returns a new Vector3 containing the Euler angles
  3600. */
  3601. toEulerAngles(order?: string): Vector3;
  3602. /**
  3603. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3604. * @param result defines the vector which will be filled with the Euler angles
  3605. * @param order is a reserved parameter and is ignore for now
  3606. * @returns the current unchanged quaternion
  3607. */
  3608. toEulerAnglesToRef(result: Vector3): Quaternion;
  3609. /**
  3610. * Updates the given rotation matrix with the current quaternion values
  3611. * @param result defines the target matrix
  3612. * @returns the current unchanged quaternion
  3613. */
  3614. toRotationMatrix(result: Matrix): Quaternion;
  3615. /**
  3616. * Updates the current quaternion from the given rotation matrix values
  3617. * @param matrix defines the source matrix
  3618. * @returns the current updated quaternion
  3619. */
  3620. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3621. /**
  3622. * Creates a new quaternion from a rotation matrix
  3623. * @param matrix defines the source matrix
  3624. * @returns a new quaternion created from the given rotation matrix values
  3625. */
  3626. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3627. /**
  3628. * Updates the given quaternion with the given rotation matrix values
  3629. * @param matrix defines the source matrix
  3630. * @param result defines the target quaternion
  3631. */
  3632. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3633. /**
  3634. * Returns the dot product (float) between the quaternions "left" and "right"
  3635. * @param left defines the left operand
  3636. * @param right defines the right operand
  3637. * @returns the dot product
  3638. */
  3639. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3640. /**
  3641. * Checks if the two quaternions are close to each other
  3642. * @param quat0 defines the first quaternion to check
  3643. * @param quat1 defines the second quaternion to check
  3644. * @returns true if the two quaternions are close to each other
  3645. */
  3646. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3647. /**
  3648. * Creates an empty quaternion
  3649. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3650. */
  3651. static Zero(): Quaternion;
  3652. /**
  3653. * Inverse a given quaternion
  3654. * @param q defines the source quaternion
  3655. * @returns a new quaternion as the inverted current quaternion
  3656. */
  3657. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3658. /**
  3659. * Inverse a given quaternion
  3660. * @param q defines the source quaternion
  3661. * @param result the quaternion the result will be stored in
  3662. * @returns the result quaternion
  3663. */
  3664. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates an identity quaternion
  3667. * @returns the identity quaternion
  3668. */
  3669. static Identity(): Quaternion;
  3670. /**
  3671. * Gets a boolean indicating if the given quaternion is identity
  3672. * @param quaternion defines the quaternion to check
  3673. * @returns true if the quaternion is identity
  3674. */
  3675. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3676. /**
  3677. * Creates a quaternion from a rotation around an axis
  3678. * @param axis defines the axis to use
  3679. * @param angle defines the angle to use
  3680. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3681. */
  3682. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3683. /**
  3684. * Creates a rotation around an axis and stores it into the given quaternion
  3685. * @param axis defines the axis to use
  3686. * @param angle defines the angle to use
  3687. * @param result defines the target quaternion
  3688. * @returns the target quaternion
  3689. */
  3690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Creates a new quaternion from data stored into an array
  3693. * @param array defines the data source
  3694. * @param offset defines the offset in the source array where the data starts
  3695. * @returns a new quaternion
  3696. */
  3697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3698. /**
  3699. * Create a quaternion from Euler rotation angles
  3700. * @param x Pitch
  3701. * @param y Yaw
  3702. * @param z Roll
  3703. * @returns the new Quaternion
  3704. */
  3705. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3706. /**
  3707. * Updates a quaternion from Euler rotation angles
  3708. * @param x Pitch
  3709. * @param y Yaw
  3710. * @param z Roll
  3711. * @param result the quaternion to store the result
  3712. * @returns the updated quaternion
  3713. */
  3714. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3715. /**
  3716. * Create a quaternion from Euler rotation vector
  3717. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3718. * @returns the new Quaternion
  3719. */
  3720. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3721. /**
  3722. * Updates a quaternion from Euler rotation vector
  3723. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3724. * @param result the quaternion to store the result
  3725. * @returns the updated quaternion
  3726. */
  3727. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3730. * @param yaw defines the rotation around Y axis
  3731. * @param pitch defines the rotation around X axis
  3732. * @param roll defines the rotation around Z axis
  3733. * @returns the new quaternion
  3734. */
  3735. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3736. /**
  3737. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3738. * @param yaw defines the rotation around Y axis
  3739. * @param pitch defines the rotation around X axis
  3740. * @param roll defines the rotation around Z axis
  3741. * @param result defines the target quaternion
  3742. */
  3743. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3744. /**
  3745. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3746. * @param alpha defines the rotation around first axis
  3747. * @param beta defines the rotation around second axis
  3748. * @param gamma defines the rotation around third axis
  3749. * @returns the new quaternion
  3750. */
  3751. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3752. /**
  3753. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3754. * @param alpha defines the rotation around first axis
  3755. * @param beta defines the rotation around second axis
  3756. * @param gamma defines the rotation around third axis
  3757. * @param result defines the target quaternion
  3758. */
  3759. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3760. /**
  3761. * 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)
  3762. * @param axis1 defines the first axis
  3763. * @param axis2 defines the second axis
  3764. * @param axis3 defines the third axis
  3765. * @returns the new quaternion
  3766. */
  3767. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3768. /**
  3769. * 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
  3770. * @param axis1 defines the first axis
  3771. * @param axis2 defines the second axis
  3772. * @param axis3 defines the third axis
  3773. * @param ref defines the target quaternion
  3774. */
  3775. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3776. /**
  3777. * Interpolates between two quaternions
  3778. * @param left defines first quaternion
  3779. * @param right defines second quaternion
  3780. * @param amount defines the gradient to use
  3781. * @returns the new interpolated quaternion
  3782. */
  3783. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3784. /**
  3785. * Interpolates between two quaternions and stores it into a target quaternion
  3786. * @param left defines first quaternion
  3787. * @param right defines second quaternion
  3788. * @param amount defines the gradient to use
  3789. * @param result defines the target quaternion
  3790. */
  3791. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3792. /**
  3793. * Interpolate between two quaternions using Hermite interpolation
  3794. * @param value1 defines first quaternion
  3795. * @param tangent1 defines the incoming tangent
  3796. * @param value2 defines second quaternion
  3797. * @param tangent2 defines the outgoing tangent
  3798. * @param amount defines the target quaternion
  3799. * @returns the new interpolated quaternion
  3800. */
  3801. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3802. }
  3803. /**
  3804. * Class used to store matrix data (4x4)
  3805. */
  3806. export class Matrix {
  3807. private static _updateFlagSeed;
  3808. private static _identityReadOnly;
  3809. private _isIdentity;
  3810. private _isIdentityDirty;
  3811. private _isIdentity3x2;
  3812. private _isIdentity3x2Dirty;
  3813. /**
  3814. * Gets the update flag of the matrix which is an unique number for the matrix.
  3815. * It will be incremented every time the matrix data change.
  3816. * You can use it to speed the comparison between two versions of the same matrix.
  3817. */
  3818. updateFlag: number;
  3819. private readonly _m;
  3820. /**
  3821. * Gets the internal data of the matrix
  3822. */
  3823. readonly m: DeepImmutable<Float32Array>;
  3824. /** @hidden */
  3825. _markAsUpdated(): void;
  3826. /** @hidden */
  3827. private _updateIdentityStatus;
  3828. /**
  3829. * Creates an empty matrix (filled with zeros)
  3830. */
  3831. constructor();
  3832. /**
  3833. * Check if the current matrix is identity
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentity(): boolean;
  3837. /**
  3838. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3839. * @returns true is the matrix is the identity matrix
  3840. */
  3841. isIdentityAs3x2(): boolean;
  3842. /**
  3843. * Gets the determinant of the matrix
  3844. * @returns the matrix determinant
  3845. */
  3846. determinant(): number;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array
  3850. */
  3851. toArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Returns the matrix as a Float32Array
  3854. * @returns the matrix underlying array.
  3855. */
  3856. asArray(): DeepImmutable<Float32Array>;
  3857. /**
  3858. * Inverts the current matrix in place
  3859. * @returns the current inverted matrix
  3860. */
  3861. invert(): Matrix;
  3862. /**
  3863. * Sets all the matrix elements to zero
  3864. * @returns the current matrix
  3865. */
  3866. reset(): Matrix;
  3867. /**
  3868. * Adds the current matrix with a second one
  3869. * @param other defines the matrix to add
  3870. * @returns a new matrix as the addition of the current matrix and the given one
  3871. */
  3872. add(other: DeepImmutable<Matrix>): Matrix;
  3873. /**
  3874. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3875. * @param other defines the matrix to add
  3876. * @param result defines the target matrix
  3877. * @returns the current matrix
  3878. */
  3879. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3880. /**
  3881. * Adds in place the given matrix to the current matrix
  3882. * @param other defines the second operand
  3883. * @returns the current updated matrix
  3884. */
  3885. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3886. /**
  3887. * Sets the given matrix to the current inverted Matrix
  3888. * @param other defines the target matrix
  3889. * @returns the unmodified current matrix
  3890. */
  3891. invertToRef(other: Matrix): Matrix;
  3892. /**
  3893. * add a value at the specified position in the current Matrix
  3894. * @param index the index of the value within the matrix. between 0 and 15.
  3895. * @param value the value to be added
  3896. * @returns the current updated matrix
  3897. */
  3898. addAtIndex(index: number, value: number): Matrix;
  3899. /**
  3900. * mutiply the specified position in the current Matrix by a value
  3901. * @param index the index of the value within the matrix. between 0 and 15.
  3902. * @param value the value to be added
  3903. * @returns the current updated matrix
  3904. */
  3905. multiplyAtIndex(index: number, value: number): Matrix;
  3906. /**
  3907. * Inserts the translation vector (using 3 floats) in the current matrix
  3908. * @param x defines the 1st component of the translation
  3909. * @param y defines the 2nd component of the translation
  3910. * @param z defines the 3rd component of the translation
  3911. * @returns the current updated matrix
  3912. */
  3913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3914. /**
  3915. * Adds the translation vector (using 3 floats) in the current matrix
  3916. * @param x defines the 1st component of the translation
  3917. * @param y defines the 2nd component of the translation
  3918. * @param z defines the 3rd component of the translation
  3919. * @returns the current updated matrix
  3920. */
  3921. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3922. /**
  3923. * Inserts the translation vector in the current matrix
  3924. * @param vector3 defines the translation to insert
  3925. * @returns the current updated matrix
  3926. */
  3927. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3928. /**
  3929. * Gets the translation value of the current matrix
  3930. * @returns a new Vector3 as the extracted translation from the matrix
  3931. */
  3932. getTranslation(): Vector3;
  3933. /**
  3934. * Fill a Vector3 with the extracted translation from the matrix
  3935. * @param result defines the Vector3 where to store the translation
  3936. * @returns the current matrix
  3937. */
  3938. getTranslationToRef(result: Vector3): Matrix;
  3939. /**
  3940. * Remove rotation and scaling part from the matrix
  3941. * @returns the updated matrix
  3942. */
  3943. removeRotationAndScaling(): Matrix;
  3944. /**
  3945. * Multiply two matrices
  3946. * @param other defines the second operand
  3947. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3948. */
  3949. multiply(other: DeepImmutable<Matrix>): Matrix;
  3950. /**
  3951. * Copy the current matrix from the given one
  3952. * @param other defines the source matrix
  3953. * @returns the current updated matrix
  3954. */
  3955. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3956. /**
  3957. * Populates the given array from the starting index with the current matrix values
  3958. * @param array defines the target array
  3959. * @param offset defines the offset in the target array where to start storing values
  3960. * @returns the current matrix
  3961. */
  3962. copyToArray(array: Float32Array, offset?: number): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3965. * @param other defines the second operand
  3966. * @param result defines the matrix where to store the multiplication
  3967. * @returns the current matrix
  3968. */
  3969. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3972. * @param other defines the second operand
  3973. * @param result defines the array where to store the multiplication
  3974. * @param offset defines the offset in the target array where to start storing values
  3975. * @returns the current matrix
  3976. */
  3977. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3978. /**
  3979. * Check equality between this matrix and a second one
  3980. * @param value defines the second matrix to compare
  3981. * @returns true is the current matrix and the given one values are strictly equal
  3982. */
  3983. equals(value: DeepImmutable<Matrix>): boolean;
  3984. /**
  3985. * Clone the current matrix
  3986. * @returns a new matrix from the current matrix
  3987. */
  3988. clone(): Matrix;
  3989. /**
  3990. * Returns the name of the current matrix class
  3991. * @returns the string "Matrix"
  3992. */
  3993. getClassName(): string;
  3994. /**
  3995. * Gets the hash code of the current matrix
  3996. * @returns the hash code
  3997. */
  3998. getHashCode(): number;
  3999. /**
  4000. * Decomposes the current Matrix into a translation, rotation and scaling components
  4001. * @param scale defines the scale vector3 given as a reference to update
  4002. * @param rotation defines the rotation quaternion given as a reference to update
  4003. * @param translation defines the translation vector3 given as a reference to update
  4004. * @returns true if operation was successful
  4005. */
  4006. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4007. /**
  4008. * Gets specific row of the matrix
  4009. * @param index defines the number of the row to get
  4010. * @returns the index-th row of the current matrix as a new Vector4
  4011. */
  4012. getRow(index: number): Nullable<Vector4>;
  4013. /**
  4014. * Sets the index-th row of the current matrix to the vector4 values
  4015. * @param index defines the number of the row to set
  4016. * @param row defines the target vector4
  4017. * @returns the updated current matrix
  4018. */
  4019. setRow(index: number, row: Vector4): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix
  4022. * @returns the new transposed matrix
  4023. */
  4024. transpose(): Matrix;
  4025. /**
  4026. * Compute the transpose of the matrix and store it in a given matrix
  4027. * @param result defines the target matrix
  4028. * @returns the current matrix
  4029. */
  4030. transposeToRef(result: Matrix): Matrix;
  4031. /**
  4032. * Sets the index-th row of the current matrix with the given 4 x float values
  4033. * @param index defines the row index
  4034. * @param x defines the x component to set
  4035. * @param y defines the y component to set
  4036. * @param z defines the z component to set
  4037. * @param w defines the w component to set
  4038. * @returns the updated current matrix
  4039. */
  4040. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4041. /**
  4042. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4043. * @param scale defines the scale factor
  4044. * @returns a new matrix
  4045. */
  4046. scale(scale: number): Matrix;
  4047. /**
  4048. * Scale the current matrix values by a factor to a given result matrix
  4049. * @param scale defines the scale factor
  4050. * @param result defines the matrix to store the result
  4051. * @returns the current matrix
  4052. */
  4053. scaleToRef(scale: number, result: Matrix): Matrix;
  4054. /**
  4055. * Scale the current matrix values by a factor and add the result to a given matrix
  4056. * @param scale defines the scale factor
  4057. * @param result defines the Matrix to store the result
  4058. * @returns the current matrix
  4059. */
  4060. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4061. /**
  4062. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4063. * @param ref matrix to store the result
  4064. */
  4065. toNormalMatrix(ref: Matrix): void;
  4066. /**
  4067. * Gets only rotation part of the current matrix
  4068. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4069. */
  4070. getRotationMatrix(): Matrix;
  4071. /**
  4072. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4073. * @param result defines the target matrix to store data to
  4074. * @returns the current matrix
  4075. */
  4076. getRotationMatrixToRef(result: Matrix): Matrix;
  4077. /**
  4078. * Toggles model matrix from being right handed to left handed in place and vice versa
  4079. */
  4080. toggleModelMatrixHandInPlace(): void;
  4081. /**
  4082. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4083. */
  4084. toggleProjectionMatrixHandInPlace(): void;
  4085. /**
  4086. * Creates a matrix from an array
  4087. * @param array defines the source array
  4088. * @param offset defines an offset in the source array
  4089. * @returns a new Matrix set from the starting index of the given array
  4090. */
  4091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4092. /**
  4093. * Copy the content of an array into a given matrix
  4094. * @param array defines the source array
  4095. * @param offset defines an offset in the source array
  4096. * @param result defines the target matrix
  4097. */
  4098. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4099. /**
  4100. * Stores an array into a matrix after having multiplied each component by a given factor
  4101. * @param array defines the source array
  4102. * @param offset defines the offset in the source array
  4103. * @param scale defines the scaling factor
  4104. * @param result defines the target matrix
  4105. */
  4106. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4107. /**
  4108. * Gets an identity matrix that must not be updated
  4109. */
  4110. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4111. /**
  4112. * Stores a list of values (16) inside a given matrix
  4113. * @param initialM11 defines 1st value of 1st row
  4114. * @param initialM12 defines 2nd value of 1st row
  4115. * @param initialM13 defines 3rd value of 1st row
  4116. * @param initialM14 defines 4th value of 1st row
  4117. * @param initialM21 defines 1st value of 2nd row
  4118. * @param initialM22 defines 2nd value of 2nd row
  4119. * @param initialM23 defines 3rd value of 2nd row
  4120. * @param initialM24 defines 4th value of 2nd row
  4121. * @param initialM31 defines 1st value of 3rd row
  4122. * @param initialM32 defines 2nd value of 3rd row
  4123. * @param initialM33 defines 3rd value of 3rd row
  4124. * @param initialM34 defines 4th value of 3rd row
  4125. * @param initialM41 defines 1st value of 4th row
  4126. * @param initialM42 defines 2nd value of 4th row
  4127. * @param initialM43 defines 3rd value of 4th row
  4128. * @param initialM44 defines 4th value of 4th row
  4129. * @param result defines the target matrix
  4130. */
  4131. 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;
  4132. /**
  4133. * Creates new matrix from a list of values (16)
  4134. * @param initialM11 defines 1st value of 1st row
  4135. * @param initialM12 defines 2nd value of 1st row
  4136. * @param initialM13 defines 3rd value of 1st row
  4137. * @param initialM14 defines 4th value of 1st row
  4138. * @param initialM21 defines 1st value of 2nd row
  4139. * @param initialM22 defines 2nd value of 2nd row
  4140. * @param initialM23 defines 3rd value of 2nd row
  4141. * @param initialM24 defines 4th value of 2nd row
  4142. * @param initialM31 defines 1st value of 3rd row
  4143. * @param initialM32 defines 2nd value of 3rd row
  4144. * @param initialM33 defines 3rd value of 3rd row
  4145. * @param initialM34 defines 4th value of 3rd row
  4146. * @param initialM41 defines 1st value of 4th row
  4147. * @param initialM42 defines 2nd value of 4th row
  4148. * @param initialM43 defines 3rd value of 4th row
  4149. * @param initialM44 defines 4th value of 4th row
  4150. * @returns the new matrix
  4151. */
  4152. 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;
  4153. /**
  4154. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4155. * @param scale defines the scale vector3
  4156. * @param rotation defines the rotation quaternion
  4157. * @param translation defines the translation vector3
  4158. * @returns a new matrix
  4159. */
  4160. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4161. /**
  4162. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4163. * @param scale defines the scale vector3
  4164. * @param rotation defines the rotation quaternion
  4165. * @param translation defines the translation vector3
  4166. * @param result defines the target matrix
  4167. */
  4168. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4169. /**
  4170. * Creates a new identity matrix
  4171. * @returns a new identity matrix
  4172. */
  4173. static Identity(): Matrix;
  4174. /**
  4175. * Creates a new identity matrix and stores the result in a given matrix
  4176. * @param result defines the target matrix
  4177. */
  4178. static IdentityToRef(result: Matrix): void;
  4179. /**
  4180. * Creates a new zero matrix
  4181. * @returns a new zero matrix
  4182. */
  4183. static Zero(): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the X axis
  4186. * @param angle defines the angle (in radians) to use
  4187. * @return the new matrix
  4188. */
  4189. static RotationX(angle: number): Matrix;
  4190. /**
  4191. * Creates a new matrix as the invert of a given matrix
  4192. * @param source defines the source matrix
  4193. * @returns the new matrix
  4194. */
  4195. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationXToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the Y axis
  4204. * @param angle defines the angle (in radians) to use
  4205. * @return the new matrix
  4206. */
  4207. static RotationY(angle: number): Matrix;
  4208. /**
  4209. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationYToRef(angle: number, result: Matrix): void;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the Z axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationZ(angle: number): Matrix;
  4220. /**
  4221. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4222. * @param angle defines the angle (in radians) to use
  4223. * @param result defines the target matrix
  4224. */
  4225. static RotationZToRef(angle: number, result: Matrix): void;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the given axis
  4228. * @param axis defines the axis to use
  4229. * @param angle defines the angle (in radians) to use
  4230. * @return the new matrix
  4231. */
  4232. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4233. /**
  4234. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4235. * @param axis defines the axis to use
  4236. * @param angle defines the angle (in radians) to use
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4240. /**
  4241. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4242. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4243. * @param from defines the vector to align
  4244. * @param to defines the vector to align to
  4245. * @param result defines the target matrix
  4246. */
  4247. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4248. /**
  4249. * Creates a rotation matrix
  4250. * @param yaw defines the yaw angle in radians (Y axis)
  4251. * @param pitch defines the pitch angle in radians (X axis)
  4252. * @param roll defines the roll angle in radians (X axis)
  4253. * @returns the new rotation matrix
  4254. */
  4255. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4256. /**
  4257. * Creates a rotation matrix and stores it in a given matrix
  4258. * @param yaw defines the yaw angle in radians (Y axis)
  4259. * @param pitch defines the pitch angle in radians (X axis)
  4260. * @param roll defines the roll angle in radians (X axis)
  4261. * @param result defines the target matrix
  4262. */
  4263. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4264. /**
  4265. * Creates a scaling matrix
  4266. * @param x defines the scale factor on X axis
  4267. * @param y defines the scale factor on Y axis
  4268. * @param z defines the scale factor on Z axis
  4269. * @returns the new matrix
  4270. */
  4271. static Scaling(x: number, y: number, z: number): Matrix;
  4272. /**
  4273. * Creates a scaling matrix and stores it in a given matrix
  4274. * @param x defines the scale factor on X axis
  4275. * @param y defines the scale factor on Y axis
  4276. * @param z defines the scale factor on Z axis
  4277. * @param result defines the target matrix
  4278. */
  4279. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4280. /**
  4281. * Creates a translation matrix
  4282. * @param x defines the translation on X axis
  4283. * @param y defines the translation on Y axis
  4284. * @param z defines the translationon Z axis
  4285. * @returns the new matrix
  4286. */
  4287. static Translation(x: number, y: number, z: number): Matrix;
  4288. /**
  4289. * Creates a translation matrix and stores it in a given matrix
  4290. * @param x defines the translation on X axis
  4291. * @param y defines the translation on Y axis
  4292. * @param z defines the translationon Z axis
  4293. * @param result defines the target matrix
  4294. */
  4295. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4296. /**
  4297. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4298. * @param startValue defines the start value
  4299. * @param endValue defines the end value
  4300. * @param gradient defines the gradient factor
  4301. * @returns the new matrix
  4302. */
  4303. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4304. /**
  4305. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4306. * @param startValue defines the start value
  4307. * @param endValue defines the end value
  4308. * @param gradient defines the gradient factor
  4309. * @param result defines the Matrix object where to store data
  4310. */
  4311. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4312. /**
  4313. * Builds a new matrix whose values are computed by:
  4314. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4315. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4316. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4317. * @param startValue defines the first matrix
  4318. * @param endValue defines the second matrix
  4319. * @param gradient defines the gradient between the two matrices
  4320. * @returns the new matrix
  4321. */
  4322. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4323. /**
  4324. * Update a matrix to values which are computed by:
  4325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4328. * @param startValue defines the first matrix
  4329. * @param endValue defines the second matrix
  4330. * @param gradient defines the gradient between the two matrices
  4331. * @param result defines the target matrix
  4332. */
  4333. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4334. /**
  4335. * 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"
  4336. * This function works in left handed mode
  4337. * @param eye defines the final position of the entity
  4338. * @param target defines where the entity should look at
  4339. * @param up defines the up vector for the entity
  4340. * @returns the new matrix
  4341. */
  4342. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4343. /**
  4344. * 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".
  4345. * This function works in left handed mode
  4346. * @param eye defines the final position of the entity
  4347. * @param target defines where the entity should look at
  4348. * @param up defines the up vector for the entity
  4349. * @param result defines the target matrix
  4350. */
  4351. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4352. /**
  4353. * 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"
  4354. * This function works in right handed mode
  4355. * @param eye defines the final position of the entity
  4356. * @param target defines where the entity should look at
  4357. * @param up defines the up vector for the entity
  4358. * @returns the new matrix
  4359. */
  4360. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4361. /**
  4362. * 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".
  4363. * This function works in right handed mode
  4364. * @param eye defines the final position of the entity
  4365. * @param target defines where the entity should look at
  4366. * @param up defines the up vector for the entity
  4367. * @param result defines the target matrix
  4368. */
  4369. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4370. /**
  4371. * Create a left-handed orthographic projection matrix
  4372. * @param width defines the viewport width
  4373. * @param height defines the viewport height
  4374. * @param znear defines the near clip plane
  4375. * @param zfar defines the far clip plane
  4376. * @returns a new matrix as a left-handed orthographic projection matrix
  4377. */
  4378. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4379. /**
  4380. * Store a left-handed orthographic projection to a given matrix
  4381. * @param width defines the viewport width
  4382. * @param height defines the viewport height
  4383. * @param znear defines the near clip plane
  4384. * @param zfar defines the far clip plane
  4385. * @param result defines the target matrix
  4386. */
  4387. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4388. /**
  4389. * Create a left-handed orthographic projection matrix
  4390. * @param left defines the viewport left coordinate
  4391. * @param right defines the viewport right coordinate
  4392. * @param bottom defines the viewport bottom coordinate
  4393. * @param top defines the viewport top coordinate
  4394. * @param znear defines the near clip plane
  4395. * @param zfar defines the far clip plane
  4396. * @returns a new matrix as a left-handed orthographic projection matrix
  4397. */
  4398. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4399. /**
  4400. * Stores a left-handed orthographic projection into a given matrix
  4401. * @param left defines the viewport left coordinate
  4402. * @param right defines the viewport right coordinate
  4403. * @param bottom defines the viewport bottom coordinate
  4404. * @param top defines the viewport top coordinate
  4405. * @param znear defines the near clip plane
  4406. * @param zfar defines the far clip plane
  4407. * @param result defines the target matrix
  4408. */
  4409. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4410. /**
  4411. * Creates a right-handed orthographic projection matrix
  4412. * @param left defines the viewport left coordinate
  4413. * @param right defines the viewport right coordinate
  4414. * @param bottom defines the viewport bottom coordinate
  4415. * @param top defines the viewport top coordinate
  4416. * @param znear defines the near clip plane
  4417. * @param zfar defines the far clip plane
  4418. * @returns a new matrix as a right-handed orthographic projection matrix
  4419. */
  4420. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4421. /**
  4422. * Stores a right-handed orthographic projection into a given matrix
  4423. * @param left defines the viewport left coordinate
  4424. * @param right defines the viewport right coordinate
  4425. * @param bottom defines the viewport bottom coordinate
  4426. * @param top defines the viewport top coordinate
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @param result defines the target matrix
  4430. */
  4431. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4432. /**
  4433. * Creates a left-handed perspective projection matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @returns a new matrix as a left-handed perspective projection matrix
  4439. */
  4440. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4441. /**
  4442. * Creates a left-handed perspective projection matrix
  4443. * @param fov defines the horizontal field of view
  4444. * @param aspect defines the aspect ratio
  4445. * @param znear defines the near clip plane
  4446. * @param zfar defines the far clip plane
  4447. * @returns a new matrix as a left-handed perspective projection matrix
  4448. */
  4449. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4450. /**
  4451. * Stores a left-handed perspective projection into a given matrix
  4452. * @param fov defines the horizontal field of view
  4453. * @param aspect defines the aspect ratio
  4454. * @param znear defines the near clip plane
  4455. * @param zfar defines the far clip plane
  4456. * @param result defines the target matrix
  4457. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4458. */
  4459. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4460. /**
  4461. * Creates a right-handed perspective projection matrix
  4462. * @param fov defines the horizontal field of view
  4463. * @param aspect defines the aspect ratio
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed perspective projection matrix
  4467. */
  4468. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed perspective projection into a given matrix
  4471. * @param fov defines the horizontal field of view
  4472. * @param aspect defines the aspect ratio
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4477. */
  4478. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4479. /**
  4480. * Stores a perspective projection for WebVR info a given matrix
  4481. * @param fov defines the field of view
  4482. * @param znear defines the near clip plane
  4483. * @param zfar defines the far clip plane
  4484. * @param result defines the target matrix
  4485. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4486. */
  4487. static PerspectiveFovWebVRToRef(fov: {
  4488. upDegrees: number;
  4489. downDegrees: number;
  4490. leftDegrees: number;
  4491. rightDegrees: number;
  4492. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4493. /**
  4494. * Computes a complete transformation matrix
  4495. * @param viewport defines the viewport to use
  4496. * @param world defines the world matrix
  4497. * @param view defines the view matrix
  4498. * @param projection defines the projection matrix
  4499. * @param zmin defines the near clip plane
  4500. * @param zmax defines the far clip plane
  4501. * @returns the transformation matrix
  4502. */
  4503. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4504. /**
  4505. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4506. * @param matrix defines the matrix to use
  4507. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4508. */
  4509. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4510. /**
  4511. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4512. * @param matrix defines the matrix to use
  4513. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4514. */
  4515. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4516. /**
  4517. * Compute the transpose of a given matrix
  4518. * @param matrix defines the matrix to transpose
  4519. * @returns the new matrix
  4520. */
  4521. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4522. /**
  4523. * Compute the transpose of a matrix and store it in a target matrix
  4524. * @param matrix defines the matrix to transpose
  4525. * @param result defines the target matrix
  4526. */
  4527. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4528. /**
  4529. * Computes a reflection matrix from a plane
  4530. * @param plane defines the reflection plane
  4531. * @returns a new matrix
  4532. */
  4533. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4534. /**
  4535. * Computes a reflection matrix from a plane
  4536. * @param plane defines the reflection plane
  4537. * @param result defines the target matrix
  4538. */
  4539. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4540. /**
  4541. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4542. * @param xaxis defines the value of the 1st axis
  4543. * @param yaxis defines the value of the 2nd axis
  4544. * @param zaxis defines the value of the 3rd axis
  4545. * @param result defines the target matrix
  4546. */
  4547. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4550. * @param quat defines the quaternion to use
  4551. * @param result defines the target matrix
  4552. */
  4553. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4554. }
  4555. /**
  4556. * @hidden
  4557. */
  4558. export class TmpVectors {
  4559. static Vector2: Vector2[];
  4560. static Vector3: Vector3[];
  4561. static Vector4: Vector4[];
  4562. static Quaternion: Quaternion[];
  4563. static Matrix: Matrix[];
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /**
  4568. * Defines potential orientation for back face culling
  4569. */
  4570. export enum Orientation {
  4571. /**
  4572. * Clockwise
  4573. */
  4574. CW = 0,
  4575. /** Counter clockwise */
  4576. CCW = 1
  4577. }
  4578. /** Class used to represent a Bezier curve */
  4579. export class BezierCurve {
  4580. /**
  4581. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4582. * @param t defines the time
  4583. * @param x1 defines the left coordinate on X axis
  4584. * @param y1 defines the left coordinate on Y axis
  4585. * @param x2 defines the right coordinate on X axis
  4586. * @param y2 defines the right coordinate on Y axis
  4587. * @returns the interpolated value
  4588. */
  4589. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4590. }
  4591. /**
  4592. * Defines angle representation
  4593. */
  4594. export class Angle {
  4595. private _radians;
  4596. /**
  4597. * Creates an Angle object of "radians" radians (float).
  4598. * @param radians the angle in radians
  4599. */
  4600. constructor(radians: number);
  4601. /**
  4602. * Get value in degrees
  4603. * @returns the Angle value in degrees (float)
  4604. */
  4605. degrees(): number;
  4606. /**
  4607. * Get value in radians
  4608. * @returns the Angle value in radians (float)
  4609. */
  4610. radians(): number;
  4611. /**
  4612. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4613. * @param a defines first vector
  4614. * @param b defines second vector
  4615. * @returns a new Angle
  4616. */
  4617. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4618. /**
  4619. * Gets a new Angle object from the given float in radians
  4620. * @param radians defines the angle value in radians
  4621. * @returns a new Angle
  4622. */
  4623. static FromRadians(radians: number): Angle;
  4624. /**
  4625. * Gets a new Angle object from the given float in degrees
  4626. * @param degrees defines the angle value in degrees
  4627. * @returns a new Angle
  4628. */
  4629. static FromDegrees(degrees: number): Angle;
  4630. }
  4631. /**
  4632. * This represents an arc in a 2d space.
  4633. */
  4634. export class Arc2 {
  4635. /** Defines the start point of the arc */
  4636. startPoint: Vector2;
  4637. /** Defines the mid point of the arc */
  4638. midPoint: Vector2;
  4639. /** Defines the end point of the arc */
  4640. endPoint: Vector2;
  4641. /**
  4642. * Defines the center point of the arc.
  4643. */
  4644. centerPoint: Vector2;
  4645. /**
  4646. * Defines the radius of the arc.
  4647. */
  4648. radius: number;
  4649. /**
  4650. * Defines the angle of the arc (from mid point to end point).
  4651. */
  4652. angle: Angle;
  4653. /**
  4654. * Defines the start angle of the arc (from start point to middle point).
  4655. */
  4656. startAngle: Angle;
  4657. /**
  4658. * Defines the orientation of the arc (clock wise/counter clock wise).
  4659. */
  4660. orientation: Orientation;
  4661. /**
  4662. * Creates an Arc object from the three given points : start, middle and end.
  4663. * @param startPoint Defines the start point of the arc
  4664. * @param midPoint Defines the midlle point of the arc
  4665. * @param endPoint Defines the end point of the arc
  4666. */
  4667. constructor(
  4668. /** Defines the start point of the arc */
  4669. startPoint: Vector2,
  4670. /** Defines the mid point of the arc */
  4671. midPoint: Vector2,
  4672. /** Defines the end point of the arc */
  4673. endPoint: Vector2);
  4674. }
  4675. /**
  4676. * Represents a 2D path made up of multiple 2D points
  4677. */
  4678. export class Path2 {
  4679. private _points;
  4680. private _length;
  4681. /**
  4682. * If the path start and end point are the same
  4683. */
  4684. closed: boolean;
  4685. /**
  4686. * Creates a Path2 object from the starting 2D coordinates x and y.
  4687. * @param x the starting points x value
  4688. * @param y the starting points y value
  4689. */
  4690. constructor(x: number, y: number);
  4691. /**
  4692. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4693. * @param x the added points x value
  4694. * @param y the added points y value
  4695. * @returns the updated Path2.
  4696. */
  4697. addLineTo(x: number, y: number): Path2;
  4698. /**
  4699. * 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.
  4700. * @param midX middle point x value
  4701. * @param midY middle point y value
  4702. * @param endX end point x value
  4703. * @param endY end point y value
  4704. * @param numberOfSegments (default: 36)
  4705. * @returns the updated Path2.
  4706. */
  4707. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4708. /**
  4709. * Closes the Path2.
  4710. * @returns the Path2.
  4711. */
  4712. close(): Path2;
  4713. /**
  4714. * Gets the sum of the distance between each sequential point in the path
  4715. * @returns the Path2 total length (float).
  4716. */
  4717. length(): number;
  4718. /**
  4719. * Gets the points which construct the path
  4720. * @returns the Path2 internal array of points.
  4721. */
  4722. getPoints(): Vector2[];
  4723. /**
  4724. * Retreives the point at the distance aways from the starting point
  4725. * @param normalizedLengthPosition the length along the path to retreive the point from
  4726. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4727. */
  4728. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4729. /**
  4730. * Creates a new path starting from an x and y position
  4731. * @param x starting x value
  4732. * @param y starting y value
  4733. * @returns a new Path2 starting at the coordinates (x, y).
  4734. */
  4735. static StartingAt(x: number, y: number): Path2;
  4736. }
  4737. /**
  4738. * Represents a 3D path made up of multiple 3D points
  4739. */
  4740. export class Path3D {
  4741. /**
  4742. * an array of Vector3, the curve axis of the Path3D
  4743. */
  4744. path: Vector3[];
  4745. private _curve;
  4746. private _distances;
  4747. private _tangents;
  4748. private _normals;
  4749. private _binormals;
  4750. private _raw;
  4751. /**
  4752. * new Path3D(path, normal, raw)
  4753. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4754. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4755. * @param path an array of Vector3, the curve axis of the Path3D
  4756. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4757. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4758. */
  4759. constructor(
  4760. /**
  4761. * an array of Vector3, the curve axis of the Path3D
  4762. */
  4763. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4764. /**
  4765. * Returns the Path3D array of successive Vector3 designing its curve.
  4766. * @returns the Path3D array of successive Vector3 designing its curve.
  4767. */
  4768. getCurve(): Vector3[];
  4769. /**
  4770. * Returns an array populated with tangent vectors on each Path3D curve point.
  4771. * @returns an array populated with tangent vectors on each Path3D curve point.
  4772. */
  4773. getTangents(): Vector3[];
  4774. /**
  4775. * Returns an array populated with normal vectors on each Path3D curve point.
  4776. * @returns an array populated with normal vectors on each Path3D curve point.
  4777. */
  4778. getNormals(): Vector3[];
  4779. /**
  4780. * Returns an array populated with binormal vectors on each Path3D curve point.
  4781. * @returns an array populated with binormal vectors on each Path3D curve point.
  4782. */
  4783. getBinormals(): Vector3[];
  4784. /**
  4785. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4786. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4787. */
  4788. getDistances(): number[];
  4789. /**
  4790. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4791. * @param path path which all values are copied into the curves points
  4792. * @param firstNormal which should be projected onto the curve
  4793. * @returns the same object updated.
  4794. */
  4795. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4796. private _compute;
  4797. private _getFirstNonNullVector;
  4798. private _getLastNonNullVector;
  4799. private _normalVector;
  4800. }
  4801. /**
  4802. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4803. * A Curve3 is designed from a series of successive Vector3.
  4804. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4805. */
  4806. export class Curve3 {
  4807. private _points;
  4808. private _length;
  4809. /**
  4810. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4811. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4812. * @param v1 (Vector3) the control point
  4813. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4814. * @param nbPoints (integer) the wanted number of points in the curve
  4815. * @returns the created Curve3
  4816. */
  4817. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4818. /**
  4819. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4820. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4821. * @param v1 (Vector3) the first control point
  4822. * @param v2 (Vector3) the second control point
  4823. * @param v3 (Vector3) the end point of the Cubic Bezier
  4824. * @param nbPoints (integer) the wanted number of points in the curve
  4825. * @returns the created Curve3
  4826. */
  4827. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4828. /**
  4829. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4830. * @param p1 (Vector3) the origin point of the Hermite Spline
  4831. * @param t1 (Vector3) the tangent vector at the origin point
  4832. * @param p2 (Vector3) the end point of the Hermite Spline
  4833. * @param t2 (Vector3) the tangent vector at the end point
  4834. * @param nbPoints (integer) the wanted number of points in the curve
  4835. * @returns the created Curve3
  4836. */
  4837. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4838. /**
  4839. * Returns a Curve3 object along a CatmullRom Spline curve :
  4840. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4841. * @param nbPoints (integer) the wanted number of points between each curve control points
  4842. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4843. * @returns the created Curve3
  4844. */
  4845. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4846. /**
  4847. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4848. * A Curve3 is designed from a series of successive Vector3.
  4849. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4850. * @param points points which make up the curve
  4851. */
  4852. constructor(points: Vector3[]);
  4853. /**
  4854. * @returns the Curve3 stored array of successive Vector3
  4855. */
  4856. getPoints(): Vector3[];
  4857. /**
  4858. * @returns the computed length (float) of the curve.
  4859. */
  4860. length(): number;
  4861. /**
  4862. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4863. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4864. * curveA and curveB keep unchanged.
  4865. * @param curve the curve to continue from this curve
  4866. * @returns the newly constructed curve
  4867. */
  4868. continue(curve: DeepImmutable<Curve3>): Curve3;
  4869. private _computeLength;
  4870. }
  4871. }
  4872. declare module BABYLON {
  4873. /**
  4874. * This represents the main contract an easing function should follow.
  4875. * Easing functions are used throughout the animation system.
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. export interface IEasingFunction {
  4879. /**
  4880. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4881. * of the easing function.
  4882. * The link below provides some of the most common examples of easing functions.
  4883. * @see https://easings.net/
  4884. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4885. * @returns the corresponding value on the curve defined by the easing function
  4886. */
  4887. ease(gradient: number): number;
  4888. }
  4889. /**
  4890. * Base class used for every default easing function.
  4891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4892. */
  4893. export class EasingFunction implements IEasingFunction {
  4894. /**
  4895. * Interpolation follows the mathematical formula associated with the easing function.
  4896. */
  4897. static readonly EASINGMODE_EASEIN: number;
  4898. /**
  4899. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4900. */
  4901. static readonly EASINGMODE_EASEOUT: number;
  4902. /**
  4903. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4904. */
  4905. static readonly EASINGMODE_EASEINOUT: number;
  4906. private _easingMode;
  4907. /**
  4908. * Sets the easing mode of the current function.
  4909. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4910. */
  4911. setEasingMode(easingMode: number): void;
  4912. /**
  4913. * Gets the current easing mode.
  4914. * @returns the easing mode
  4915. */
  4916. getEasingMode(): number;
  4917. /**
  4918. * @hidden
  4919. */
  4920. easeInCore(gradient: number): number;
  4921. /**
  4922. * Given an input gradient between 0 and 1, this returns the corresponding value
  4923. * of the easing function.
  4924. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4925. * @returns the corresponding value on the curve defined by the easing function
  4926. */
  4927. ease(gradient: number): number;
  4928. }
  4929. /**
  4930. * Easing function with a circle shape (see link below).
  4931. * @see https://easings.net/#easeInCirc
  4932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4933. */
  4934. export class CircleEase extends EasingFunction implements IEasingFunction {
  4935. /** @hidden */
  4936. easeInCore(gradient: number): number;
  4937. }
  4938. /**
  4939. * Easing function with a ease back shape (see link below).
  4940. * @see https://easings.net/#easeInBack
  4941. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4942. */
  4943. export class BackEase extends EasingFunction implements IEasingFunction {
  4944. /** Defines the amplitude of the function */
  4945. amplitude: number;
  4946. /**
  4947. * Instantiates a back ease easing
  4948. * @see https://easings.net/#easeInBack
  4949. * @param amplitude Defines the amplitude of the function
  4950. */
  4951. constructor(
  4952. /** Defines the amplitude of the function */
  4953. amplitude?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a bouncing shape (see link below).
  4959. * @see https://easings.net/#easeInBounce
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class BounceEase extends EasingFunction implements IEasingFunction {
  4963. /** Defines the number of bounces */
  4964. bounces: number;
  4965. /** Defines the amplitude of the bounce */
  4966. bounciness: number;
  4967. /**
  4968. * Instantiates a bounce easing
  4969. * @see https://easings.net/#easeInBounce
  4970. * @param bounces Defines the number of bounces
  4971. * @param bounciness Defines the amplitude of the bounce
  4972. */
  4973. constructor(
  4974. /** Defines the number of bounces */
  4975. bounces?: number,
  4976. /** Defines the amplitude of the bounce */
  4977. bounciness?: number);
  4978. /** @hidden */
  4979. easeInCore(gradient: number): number;
  4980. }
  4981. /**
  4982. * Easing function with a power of 3 shape (see link below).
  4983. * @see https://easings.net/#easeInCubic
  4984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4985. */
  4986. export class CubicEase extends EasingFunction implements IEasingFunction {
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an elastic shape (see link below).
  4992. * @see https://easings.net/#easeInElastic
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the number of oscillations*/
  4997. oscillations: number;
  4998. /** Defines the amplitude of the oscillations*/
  4999. springiness: number;
  5000. /**
  5001. * Instantiates an elastic easing function
  5002. * @see https://easings.net/#easeInElastic
  5003. * @param oscillations Defines the number of oscillations
  5004. * @param springiness Defines the amplitude of the oscillations
  5005. */
  5006. constructor(
  5007. /** Defines the number of oscillations*/
  5008. oscillations?: number,
  5009. /** Defines the amplitude of the oscillations*/
  5010. springiness?: number);
  5011. /** @hidden */
  5012. easeInCore(gradient: number): number;
  5013. }
  5014. /**
  5015. * Easing function with an exponential shape (see link below).
  5016. * @see https://easings.net/#easeInExpo
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5020. /** Defines the exponent of the function */
  5021. exponent: number;
  5022. /**
  5023. * Instantiates an exponential easing function
  5024. * @see https://easings.net/#easeInExpo
  5025. * @param exponent Defines the exponent of the function
  5026. */
  5027. constructor(
  5028. /** Defines the exponent of the function */
  5029. exponent?: number);
  5030. /** @hidden */
  5031. easeInCore(gradient: number): number;
  5032. }
  5033. /**
  5034. * Easing function with a power shape (see link below).
  5035. * @see https://easings.net/#easeInQuad
  5036. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5037. */
  5038. export class PowerEase extends EasingFunction implements IEasingFunction {
  5039. /** Defines the power of the function */
  5040. power: number;
  5041. /**
  5042. * Instantiates an power base easing function
  5043. * @see https://easings.net/#easeInQuad
  5044. * @param power Defines the power of the function
  5045. */
  5046. constructor(
  5047. /** Defines the power of the function */
  5048. power?: number);
  5049. /** @hidden */
  5050. easeInCore(gradient: number): number;
  5051. }
  5052. /**
  5053. * Easing function with a power of 2 shape (see link below).
  5054. * @see https://easings.net/#easeInQuad
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5058. /** @hidden */
  5059. easeInCore(gradient: number): number;
  5060. }
  5061. /**
  5062. * Easing function with a power of 4 shape (see link below).
  5063. * @see https://easings.net/#easeInQuart
  5064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5065. */
  5066. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5067. /** @hidden */
  5068. easeInCore(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a power of 5 shape (see link below).
  5072. * @see https://easings.net/#easeInQuint
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a sin shape (see link below).
  5081. * @see https://easings.net/#easeInSine
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class SineEase extends EasingFunction implements IEasingFunction {
  5085. /** @hidden */
  5086. easeInCore(gradient: number): number;
  5087. }
  5088. /**
  5089. * Easing function with a bezier shape (see link below).
  5090. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5092. */
  5093. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5094. /** Defines the x component of the start tangent in the bezier curve */
  5095. x1: number;
  5096. /** Defines the y component of the start tangent in the bezier curve */
  5097. y1: number;
  5098. /** Defines the x component of the end tangent in the bezier curve */
  5099. x2: number;
  5100. /** Defines the y component of the end tangent in the bezier curve */
  5101. y2: number;
  5102. /**
  5103. * Instantiates a bezier function
  5104. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5105. * @param x1 Defines the x component of the start tangent in the bezier curve
  5106. * @param y1 Defines the y component of the start tangent in the bezier curve
  5107. * @param x2 Defines the x component of the end tangent in the bezier curve
  5108. * @param y2 Defines the y component of the end tangent in the bezier curve
  5109. */
  5110. constructor(
  5111. /** Defines the x component of the start tangent in the bezier curve */
  5112. x1?: number,
  5113. /** Defines the y component of the start tangent in the bezier curve */
  5114. y1?: number,
  5115. /** Defines the x component of the end tangent in the bezier curve */
  5116. x2?: number,
  5117. /** Defines the y component of the end tangent in the bezier curve */
  5118. y2?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. }
  5123. declare module BABYLON {
  5124. /**
  5125. * Class used to hold a RBG color
  5126. */
  5127. export class Color3 {
  5128. /**
  5129. * Defines the red component (between 0 and 1, default is 0)
  5130. */
  5131. r: number;
  5132. /**
  5133. * Defines the green component (between 0 and 1, default is 0)
  5134. */
  5135. g: number;
  5136. /**
  5137. * Defines the blue component (between 0 and 1, default is 0)
  5138. */
  5139. b: number;
  5140. /**
  5141. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5142. * @param r defines the red component (between 0 and 1, default is 0)
  5143. * @param g defines the green component (between 0 and 1, default is 0)
  5144. * @param b defines the blue component (between 0 and 1, default is 0)
  5145. */
  5146. constructor(
  5147. /**
  5148. * Defines the red component (between 0 and 1, default is 0)
  5149. */
  5150. r?: number,
  5151. /**
  5152. * Defines the green component (between 0 and 1, default is 0)
  5153. */
  5154. g?: number,
  5155. /**
  5156. * Defines the blue component (between 0 and 1, default is 0)
  5157. */
  5158. b?: number);
  5159. /**
  5160. * Creates a string with the Color3 current values
  5161. * @returns the string representation of the Color3 object
  5162. */
  5163. toString(): string;
  5164. /**
  5165. * Returns the string "Color3"
  5166. * @returns "Color3"
  5167. */
  5168. getClassName(): string;
  5169. /**
  5170. * Compute the Color3 hash code
  5171. * @returns an unique number that can be used to hash Color3 objects
  5172. */
  5173. getHashCode(): number;
  5174. /**
  5175. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5176. * @param array defines the array where to store the r,g,b components
  5177. * @param index defines an optional index in the target array to define where to start storing values
  5178. * @returns the current Color3 object
  5179. */
  5180. toArray(array: FloatArray, index?: number): Color3;
  5181. /**
  5182. * Returns a new Color4 object from the current Color3 and the given alpha
  5183. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5184. * @returns a new Color4 object
  5185. */
  5186. toColor4(alpha?: number): Color4;
  5187. /**
  5188. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5189. * @returns the new array
  5190. */
  5191. asArray(): number[];
  5192. /**
  5193. * Returns the luminance value
  5194. * @returns a float value
  5195. */
  5196. toLuminance(): number;
  5197. /**
  5198. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5199. * @param otherColor defines the second operand
  5200. * @returns the new Color3 object
  5201. */
  5202. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5203. /**
  5204. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5205. * @param otherColor defines the second operand
  5206. * @param result defines the Color3 object where to store the result
  5207. * @returns the current Color3
  5208. */
  5209. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5210. /**
  5211. * Determines equality between Color3 objects
  5212. * @param otherColor defines the second operand
  5213. * @returns true if the rgb values are equal to the given ones
  5214. */
  5215. equals(otherColor: DeepImmutable<Color3>): boolean;
  5216. /**
  5217. * Determines equality between the current Color3 object and a set of r,b,g values
  5218. * @param r defines the red component to check
  5219. * @param g defines the green component to check
  5220. * @param b defines the blue component to check
  5221. * @returns true if the rgb values are equal to the given ones
  5222. */
  5223. equalsFloats(r: number, g: number, b: number): boolean;
  5224. /**
  5225. * Multiplies in place each rgb value by scale
  5226. * @param scale defines the scaling factor
  5227. * @returns the updated Color3
  5228. */
  5229. scale(scale: number): Color3;
  5230. /**
  5231. * Multiplies the rgb values by scale and stores the result into "result"
  5232. * @param scale defines the scaling factor
  5233. * @param result defines the Color3 object where to store the result
  5234. * @returns the unmodified current Color3
  5235. */
  5236. scaleToRef(scale: number, result: Color3): Color3;
  5237. /**
  5238. * Scale the current Color3 values by a factor and add the result to a given Color3
  5239. * @param scale defines the scale factor
  5240. * @param result defines color to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5244. /**
  5245. * Clamps the rgb values by the min and max values and stores the result into "result"
  5246. * @param min defines minimum clamping value (default is 0)
  5247. * @param max defines maximum clamping value (default is 1)
  5248. * @param result defines color to store the result into
  5249. * @returns the original Color3
  5250. */
  5251. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5252. /**
  5253. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5254. * @param otherColor defines the second operand
  5255. * @returns the new Color3
  5256. */
  5257. add(otherColor: DeepImmutable<Color3>): Color3;
  5258. /**
  5259. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5260. * @param otherColor defines the second operand
  5261. * @param result defines Color3 object to store the result into
  5262. * @returns the unmodified current Color3
  5263. */
  5264. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5265. /**
  5266. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5267. * @param otherColor defines the second operand
  5268. * @returns the new Color3
  5269. */
  5270. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5271. /**
  5272. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5273. * @param otherColor defines the second operand
  5274. * @param result defines Color3 object to store the result into
  5275. * @returns the unmodified current Color3
  5276. */
  5277. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5278. /**
  5279. * Copy the current object
  5280. * @returns a new Color3 copied the current one
  5281. */
  5282. clone(): Color3;
  5283. /**
  5284. * Copies the rgb values from the source in the current Color3
  5285. * @param source defines the source Color3 object
  5286. * @returns the updated Color3 object
  5287. */
  5288. copyFrom(source: DeepImmutable<Color3>): Color3;
  5289. /**
  5290. * Updates the Color3 rgb values from the given floats
  5291. * @param r defines the red component to read from
  5292. * @param g defines the green component to read from
  5293. * @param b defines the blue component to read from
  5294. * @returns the current Color3 object
  5295. */
  5296. copyFromFloats(r: number, g: number, b: number): Color3;
  5297. /**
  5298. * Updates the Color3 rgb values from the given floats
  5299. * @param r defines the red component to read from
  5300. * @param g defines the green component to read from
  5301. * @param b defines the blue component to read from
  5302. * @returns the current Color3 object
  5303. */
  5304. set(r: number, g: number, b: number): Color3;
  5305. /**
  5306. * Compute the Color3 hexadecimal code as a string
  5307. * @returns a string containing the hexadecimal representation of the Color3 object
  5308. */
  5309. toHexString(): string;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to linear space
  5312. * @returns a new Color3 object
  5313. */
  5314. toLinearSpace(): Color3;
  5315. /**
  5316. * Converts current color in rgb space to HSV values
  5317. * @returns a new color3 representing the HSV values
  5318. */
  5319. toHSV(): Color3;
  5320. /**
  5321. * Converts current color in rgb space to HSV values
  5322. * @param result defines the Color3 where to store the HSV values
  5323. */
  5324. toHSVToRef(result: Color3): void;
  5325. /**
  5326. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5327. * @param convertedColor defines the Color3 object where to store the linear space version
  5328. * @returns the unmodified Color3
  5329. */
  5330. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5331. /**
  5332. * Computes a new Color3 converted from the current one to gamma space
  5333. * @returns a new Color3 object
  5334. */
  5335. toGammaSpace(): Color3;
  5336. /**
  5337. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5338. * @param convertedColor defines the Color3 object where to store the gamma space version
  5339. * @returns the unmodified Color3
  5340. */
  5341. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5342. private static _BlackReadOnly;
  5343. /**
  5344. * Convert Hue, saturation and value to a Color3 (RGB)
  5345. * @param hue defines the hue
  5346. * @param saturation defines the saturation
  5347. * @param value defines the value
  5348. * @param result defines the Color3 where to store the RGB values
  5349. */
  5350. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5351. /**
  5352. * Creates a new Color3 from the string containing valid hexadecimal values
  5353. * @param hex defines a string containing valid hexadecimal values
  5354. * @returns a new Color3 object
  5355. */
  5356. static FromHexString(hex: string): Color3;
  5357. /**
  5358. * Creates a new Color3 from the starting index of the given array
  5359. * @param array defines the source array
  5360. * @param offset defines an offset in the source array
  5361. * @returns a new Color3 object
  5362. */
  5363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5364. /**
  5365. * Creates a new Color3 from integer values (< 256)
  5366. * @param r defines the red component to read from (value between 0 and 255)
  5367. * @param g defines the green component to read from (value between 0 and 255)
  5368. * @param b defines the blue component to read from (value between 0 and 255)
  5369. * @returns a new Color3 object
  5370. */
  5371. static FromInts(r: number, g: number, b: number): Color3;
  5372. /**
  5373. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5374. * @param start defines the start Color3 value
  5375. * @param end defines the end Color3 value
  5376. * @param amount defines the gradient value between start and end
  5377. * @returns a new Color3 object
  5378. */
  5379. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5380. /**
  5381. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5382. * @param left defines the start value
  5383. * @param right defines the end value
  5384. * @param amount defines the gradient factor
  5385. * @param result defines the Color3 object where to store the result
  5386. */
  5387. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5388. /**
  5389. * Returns a Color3 value containing a red color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Red(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a green color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Green(): Color3;
  5398. /**
  5399. * Returns a Color3 value containing a blue color
  5400. * @returns a new Color3 object
  5401. */
  5402. static Blue(): Color3;
  5403. /**
  5404. * Returns a Color3 value containing a black color
  5405. * @returns a new Color3 object
  5406. */
  5407. static Black(): Color3;
  5408. /**
  5409. * Gets a Color3 value containing a black color that must not be updated
  5410. */
  5411. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5412. /**
  5413. * Returns a Color3 value containing a white color
  5414. * @returns a new Color3 object
  5415. */
  5416. static White(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a purple color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Purple(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a magenta color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Magenta(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a yellow color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Yellow(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a gray color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Gray(): Color3;
  5437. /**
  5438. * Returns a Color3 value containing a teal color
  5439. * @returns a new Color3 object
  5440. */
  5441. static Teal(): Color3;
  5442. /**
  5443. * Returns a Color3 value containing a random color
  5444. * @returns a new Color3 object
  5445. */
  5446. static Random(): Color3;
  5447. }
  5448. /**
  5449. * Class used to hold a RBGA color
  5450. */
  5451. export class Color4 {
  5452. /**
  5453. * Defines the red component (between 0 and 1, default is 0)
  5454. */
  5455. r: number;
  5456. /**
  5457. * Defines the green component (between 0 and 1, default is 0)
  5458. */
  5459. g: number;
  5460. /**
  5461. * Defines the blue component (between 0 and 1, default is 0)
  5462. */
  5463. b: number;
  5464. /**
  5465. * Defines the alpha component (between 0 and 1, default is 1)
  5466. */
  5467. a: number;
  5468. /**
  5469. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5470. * @param r defines the red component (between 0 and 1, default is 0)
  5471. * @param g defines the green component (between 0 and 1, default is 0)
  5472. * @param b defines the blue component (between 0 and 1, default is 0)
  5473. * @param a defines the alpha component (between 0 and 1, default is 1)
  5474. */
  5475. constructor(
  5476. /**
  5477. * Defines the red component (between 0 and 1, default is 0)
  5478. */
  5479. r?: number,
  5480. /**
  5481. * Defines the green component (between 0 and 1, default is 0)
  5482. */
  5483. g?: number,
  5484. /**
  5485. * Defines the blue component (between 0 and 1, default is 0)
  5486. */
  5487. b?: number,
  5488. /**
  5489. * Defines the alpha component (between 0 and 1, default is 1)
  5490. */
  5491. a?: number);
  5492. /**
  5493. * Adds in place the given Color4 values to the current Color4 object
  5494. * @param right defines the second operand
  5495. * @returns the current updated Color4 object
  5496. */
  5497. addInPlace(right: DeepImmutable<Color4>): Color4;
  5498. /**
  5499. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5500. * @returns the new array
  5501. */
  5502. asArray(): number[];
  5503. /**
  5504. * Stores from the starting index in the given array the Color4 successive values
  5505. * @param array defines the array where to store the r,g,b components
  5506. * @param index defines an optional index in the target array to define where to start storing values
  5507. * @returns the current Color4 object
  5508. */
  5509. toArray(array: number[], index?: number): Color4;
  5510. /**
  5511. * Determines equality between Color4 objects
  5512. * @param otherColor defines the second operand
  5513. * @returns true if the rgba values are equal to the given ones
  5514. */
  5515. equals(otherColor: DeepImmutable<Color4>): boolean;
  5516. /**
  5517. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5518. * @param right defines the second operand
  5519. * @returns a new Color4 object
  5520. */
  5521. add(right: DeepImmutable<Color4>): Color4;
  5522. /**
  5523. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5524. * @param right defines the second operand
  5525. * @returns a new Color4 object
  5526. */
  5527. subtract(right: DeepImmutable<Color4>): Color4;
  5528. /**
  5529. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5530. * @param right defines the second operand
  5531. * @param result defines the Color4 object where to store the result
  5532. * @returns the current Color4 object
  5533. */
  5534. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5535. /**
  5536. * Creates a new Color4 with the current Color4 values multiplied by scale
  5537. * @param scale defines the scaling factor to apply
  5538. * @returns a new Color4 object
  5539. */
  5540. scale(scale: number): Color4;
  5541. /**
  5542. * Multiplies the current Color4 values by scale and stores the result in "result"
  5543. * @param scale defines the scaling factor to apply
  5544. * @param result defines the Color4 object where to store the result
  5545. * @returns the current unmodified Color4
  5546. */
  5547. scaleToRef(scale: number, result: Color4): Color4;
  5548. /**
  5549. * Scale the current Color4 values by a factor and add the result to a given Color4
  5550. * @param scale defines the scale factor
  5551. * @param result defines the Color4 object where to store the result
  5552. * @returns the unmodified current Color4
  5553. */
  5554. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5555. /**
  5556. * Clamps the rgb values by the min and max values and stores the result into "result"
  5557. * @param min defines minimum clamping value (default is 0)
  5558. * @param max defines maximum clamping value (default is 1)
  5559. * @param result defines color to store the result into.
  5560. * @returns the cuurent Color4
  5561. */
  5562. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5563. /**
  5564. * Multipy an Color4 value by another and return a new Color4 object
  5565. * @param color defines the Color4 value to multiply by
  5566. * @returns a new Color4 object
  5567. */
  5568. multiply(color: Color4): Color4;
  5569. /**
  5570. * Multipy a Color4 value by another and push the result in a reference value
  5571. * @param color defines the Color4 value to multiply by
  5572. * @param result defines the Color4 to fill the result in
  5573. * @returns the result Color4
  5574. */
  5575. multiplyToRef(color: Color4, result: Color4): Color4;
  5576. /**
  5577. * Creates a string with the Color4 current values
  5578. * @returns the string representation of the Color4 object
  5579. */
  5580. toString(): string;
  5581. /**
  5582. * Returns the string "Color4"
  5583. * @returns "Color4"
  5584. */
  5585. getClassName(): string;
  5586. /**
  5587. * Compute the Color4 hash code
  5588. * @returns an unique number that can be used to hash Color4 objects
  5589. */
  5590. getHashCode(): number;
  5591. /**
  5592. * Creates a new Color4 copied from the current one
  5593. * @returns a new Color4 object
  5594. */
  5595. clone(): Color4;
  5596. /**
  5597. * Copies the given Color4 values into the current one
  5598. * @param source defines the source Color4 object
  5599. * @returns the current updated Color4 object
  5600. */
  5601. copyFrom(source: Color4): Color4;
  5602. /**
  5603. * Copies the given float values into the current one
  5604. * @param r defines the red component to read from
  5605. * @param g defines the green component to read from
  5606. * @param b defines the blue component to read from
  5607. * @param a defines the alpha component to read from
  5608. * @returns the current updated Color4 object
  5609. */
  5610. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5611. /**
  5612. * Copies the given float values into the current one
  5613. * @param r defines the red component to read from
  5614. * @param g defines the green component to read from
  5615. * @param b defines the blue component to read from
  5616. * @param a defines the alpha component to read from
  5617. * @returns the current updated Color4 object
  5618. */
  5619. set(r: number, g: number, b: number, a: number): Color4;
  5620. /**
  5621. * Compute the Color4 hexadecimal code as a string
  5622. * @returns a string containing the hexadecimal representation of the Color4 object
  5623. */
  5624. toHexString(): string;
  5625. /**
  5626. * Computes a new Color4 converted from the current one to linear space
  5627. * @returns a new Color4 object
  5628. */
  5629. toLinearSpace(): Color4;
  5630. /**
  5631. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5632. * @param convertedColor defines the Color4 object where to store the linear space version
  5633. * @returns the unmodified Color4
  5634. */
  5635. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5636. /**
  5637. * Computes a new Color4 converted from the current one to gamma space
  5638. * @returns a new Color4 object
  5639. */
  5640. toGammaSpace(): Color4;
  5641. /**
  5642. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5643. * @param convertedColor defines the Color4 object where to store the gamma space version
  5644. * @returns the unmodified Color4
  5645. */
  5646. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5647. /**
  5648. * Creates a new Color4 from the string containing valid hexadecimal values
  5649. * @param hex defines a string containing valid hexadecimal values
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromHexString(hex: string): Color4;
  5653. /**
  5654. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5655. * @param left defines the start value
  5656. * @param right defines the end value
  5657. * @param amount defines the gradient factor
  5658. * @returns a new Color4 object
  5659. */
  5660. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5661. /**
  5662. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5663. * @param left defines the start value
  5664. * @param right defines the end value
  5665. * @param amount defines the gradient factor
  5666. * @param result defines the Color4 object where to store data
  5667. */
  5668. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5669. /**
  5670. * Creates a new Color4 from a Color3 and an alpha value
  5671. * @param color3 defines the source Color3 to read from
  5672. * @param alpha defines the alpha component (1.0 by default)
  5673. * @returns a new Color4 object
  5674. */
  5675. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5676. /**
  5677. * Creates a new Color4 from the starting index element of the given array
  5678. * @param array defines the source array to read from
  5679. * @param offset defines the offset in the source array
  5680. * @returns a new Color4 object
  5681. */
  5682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5683. /**
  5684. * Creates a new Color3 from integer values (< 256)
  5685. * @param r defines the red component to read from (value between 0 and 255)
  5686. * @param g defines the green component to read from (value between 0 and 255)
  5687. * @param b defines the blue component to read from (value between 0 and 255)
  5688. * @param a defines the alpha component to read from (value between 0 and 255)
  5689. * @returns a new Color3 object
  5690. */
  5691. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5692. /**
  5693. * Check the content of a given array and convert it to an array containing RGBA data
  5694. * If the original array was already containing count * 4 values then it is returned directly
  5695. * @param colors defines the array to check
  5696. * @param count defines the number of RGBA data to expect
  5697. * @returns an array containing count * 4 values (RGBA)
  5698. */
  5699. static CheckColors4(colors: number[], count: number): number[];
  5700. }
  5701. /**
  5702. * @hidden
  5703. */
  5704. export class TmpColors {
  5705. static Color3: Color3[];
  5706. static Color4: Color4[];
  5707. }
  5708. }
  5709. declare module BABYLON {
  5710. /**
  5711. * Defines an interface which represents an animation key frame
  5712. */
  5713. export interface IAnimationKey {
  5714. /**
  5715. * Frame of the key frame
  5716. */
  5717. frame: number;
  5718. /**
  5719. * Value at the specifies key frame
  5720. */
  5721. value: any;
  5722. /**
  5723. * The input tangent for the cubic hermite spline
  5724. */
  5725. inTangent?: any;
  5726. /**
  5727. * The output tangent for the cubic hermite spline
  5728. */
  5729. outTangent?: any;
  5730. /**
  5731. * The animation interpolation type
  5732. */
  5733. interpolation?: AnimationKeyInterpolation;
  5734. }
  5735. /**
  5736. * Enum for the animation key frame interpolation type
  5737. */
  5738. export enum AnimationKeyInterpolation {
  5739. /**
  5740. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5741. */
  5742. STEP = 1
  5743. }
  5744. }
  5745. declare module BABYLON {
  5746. /**
  5747. * Represents the range of an animation
  5748. */
  5749. export class AnimationRange {
  5750. /**The name of the animation range**/
  5751. name: string;
  5752. /**The starting frame of the animation */
  5753. from: number;
  5754. /**The ending frame of the animation*/
  5755. to: number;
  5756. /**
  5757. * Initializes the range of an animation
  5758. * @param name The name of the animation range
  5759. * @param from The starting frame of the animation
  5760. * @param to The ending frame of the animation
  5761. */
  5762. constructor(
  5763. /**The name of the animation range**/
  5764. name: string,
  5765. /**The starting frame of the animation */
  5766. from: number,
  5767. /**The ending frame of the animation*/
  5768. to: number);
  5769. /**
  5770. * Makes a copy of the animation range
  5771. * @returns A copy of the animation range
  5772. */
  5773. clone(): AnimationRange;
  5774. }
  5775. }
  5776. declare module BABYLON {
  5777. /**
  5778. * Composed of a frame, and an action function
  5779. */
  5780. export class AnimationEvent {
  5781. /** The frame for which the event is triggered **/
  5782. frame: number;
  5783. /** The event to perform when triggered **/
  5784. action: (currentFrame: number) => void;
  5785. /** Specifies if the event should be triggered only once**/
  5786. onlyOnce?: boolean | undefined;
  5787. /**
  5788. * Specifies if the animation event is done
  5789. */
  5790. isDone: boolean;
  5791. /**
  5792. * Initializes the animation event
  5793. * @param frame The frame for which the event is triggered
  5794. * @param action The event to perform when triggered
  5795. * @param onlyOnce Specifies if the event should be triggered only once
  5796. */
  5797. constructor(
  5798. /** The frame for which the event is triggered **/
  5799. frame: number,
  5800. /** The event to perform when triggered **/
  5801. action: (currentFrame: number) => void,
  5802. /** Specifies if the event should be triggered only once**/
  5803. onlyOnce?: boolean | undefined);
  5804. /** @hidden */
  5805. _clone(): AnimationEvent;
  5806. }
  5807. }
  5808. declare module BABYLON {
  5809. /**
  5810. * Interface used to define a behavior
  5811. */
  5812. export interface Behavior<T> {
  5813. /** gets or sets behavior's name */
  5814. name: string;
  5815. /**
  5816. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5817. */
  5818. init(): void;
  5819. /**
  5820. * Called when the behavior is attached to a target
  5821. * @param target defines the target where the behavior is attached to
  5822. */
  5823. attach(target: T): void;
  5824. /**
  5825. * Called when the behavior is detached from its target
  5826. */
  5827. detach(): void;
  5828. }
  5829. /**
  5830. * Interface implemented by classes supporting behaviors
  5831. */
  5832. export interface IBehaviorAware<T> {
  5833. /**
  5834. * Attach a behavior
  5835. * @param behavior defines the behavior to attach
  5836. * @returns the current host
  5837. */
  5838. addBehavior(behavior: Behavior<T>): T;
  5839. /**
  5840. * Remove a behavior from the current object
  5841. * @param behavior defines the behavior to detach
  5842. * @returns the current host
  5843. */
  5844. removeBehavior(behavior: Behavior<T>): T;
  5845. /**
  5846. * Gets a behavior using its name to search
  5847. * @param name defines the name to search
  5848. * @returns the behavior or null if not found
  5849. */
  5850. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. /**
  5855. * Defines an array and its length.
  5856. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5857. */
  5858. export interface ISmartArrayLike<T> {
  5859. /**
  5860. * The data of the array.
  5861. */
  5862. data: Array<T>;
  5863. /**
  5864. * The active length of the array.
  5865. */
  5866. length: number;
  5867. }
  5868. /**
  5869. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5870. */
  5871. export class SmartArray<T> implements ISmartArrayLike<T> {
  5872. /**
  5873. * The full set of data from the array.
  5874. */
  5875. data: Array<T>;
  5876. /**
  5877. * The active length of the array.
  5878. */
  5879. length: number;
  5880. protected _id: number;
  5881. /**
  5882. * Instantiates a Smart Array.
  5883. * @param capacity defines the default capacity of the array.
  5884. */
  5885. constructor(capacity: number);
  5886. /**
  5887. * Pushes a value at the end of the active data.
  5888. * @param value defines the object to push in the array.
  5889. */
  5890. push(value: T): void;
  5891. /**
  5892. * Iterates over the active data and apply the lambda to them.
  5893. * @param func defines the action to apply on each value.
  5894. */
  5895. forEach(func: (content: T) => void): void;
  5896. /**
  5897. * Sorts the full sets of data.
  5898. * @param compareFn defines the comparison function to apply.
  5899. */
  5900. sort(compareFn: (a: T, b: T) => number): void;
  5901. /**
  5902. * Resets the active data to an empty array.
  5903. */
  5904. reset(): void;
  5905. /**
  5906. * Releases all the data from the array as well as the array.
  5907. */
  5908. dispose(): void;
  5909. /**
  5910. * Concats the active data with a given array.
  5911. * @param array defines the data to concatenate with.
  5912. */
  5913. concat(array: any): void;
  5914. /**
  5915. * Returns the position of a value in the active data.
  5916. * @param value defines the value to find the index for
  5917. * @returns the index if found in the active data otherwise -1
  5918. */
  5919. indexOf(value: T): number;
  5920. /**
  5921. * Returns whether an element is part of the active data.
  5922. * @param value defines the value to look for
  5923. * @returns true if found in the active data otherwise false
  5924. */
  5925. contains(value: T): boolean;
  5926. private static _GlobalId;
  5927. }
  5928. /**
  5929. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5930. * The data in this array can only be present once
  5931. */
  5932. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5933. private _duplicateId;
  5934. /**
  5935. * Pushes a value at the end of the active data.
  5936. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5937. * @param value defines the object to push in the array.
  5938. */
  5939. push(value: T): void;
  5940. /**
  5941. * Pushes a value at the end of the active data.
  5942. * If the data is already present, it won t be added again
  5943. * @param value defines the object to push in the array.
  5944. * @returns true if added false if it was already present
  5945. */
  5946. pushNoDuplicate(value: T): boolean;
  5947. /**
  5948. * Resets the active data to an empty array.
  5949. */
  5950. reset(): void;
  5951. /**
  5952. * Concats the active data with a given array.
  5953. * This ensures no dupplicate will be present in the result.
  5954. * @param array defines the data to concatenate with.
  5955. */
  5956. concatWithNoDuplicate(array: any): void;
  5957. }
  5958. }
  5959. declare module BABYLON {
  5960. /**
  5961. * @ignore
  5962. * This is a list of all the different input types that are available in the application.
  5963. * Fo instance: ArcRotateCameraGamepadInput...
  5964. */
  5965. export var CameraInputTypes: {};
  5966. /**
  5967. * This is the contract to implement in order to create a new input class.
  5968. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5969. */
  5970. export interface ICameraInput<TCamera extends Camera> {
  5971. /**
  5972. * Defines the camera the input is attached to.
  5973. */
  5974. camera: Nullable<TCamera>;
  5975. /**
  5976. * Gets the class name of the current intput.
  5977. * @returns the class name
  5978. */
  5979. getClassName(): string;
  5980. /**
  5981. * Get the friendly name associated with the input class.
  5982. * @returns the input friendly name
  5983. */
  5984. getSimpleName(): string;
  5985. /**
  5986. * Attach the input controls to a specific dom element to get the input from.
  5987. * @param element Defines the element the controls should be listened from
  5988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5989. */
  5990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5991. /**
  5992. * Detach the current controls from the specified dom element.
  5993. * @param element Defines the element to stop listening the inputs from
  5994. */
  5995. detachControl(element: Nullable<HTMLElement>): void;
  5996. /**
  5997. * Update the current camera state depending on the inputs that have been used this frame.
  5998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5999. */
  6000. checkInputs?: () => void;
  6001. }
  6002. /**
  6003. * Represents a map of input types to input instance or input index to input instance.
  6004. */
  6005. export interface CameraInputsMap<TCamera extends Camera> {
  6006. /**
  6007. * Accessor to the input by input type.
  6008. */
  6009. [name: string]: ICameraInput<TCamera>;
  6010. /**
  6011. * Accessor to the input by input index.
  6012. */
  6013. [idx: number]: ICameraInput<TCamera>;
  6014. }
  6015. /**
  6016. * This represents the input manager used within a camera.
  6017. * It helps dealing with all the different kind of input attached to a camera.
  6018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6019. */
  6020. export class CameraInputsManager<TCamera extends Camera> {
  6021. /**
  6022. * Defines the list of inputs attahed to the camera.
  6023. */
  6024. attached: CameraInputsMap<TCamera>;
  6025. /**
  6026. * Defines the dom element the camera is collecting inputs from.
  6027. * This is null if the controls have not been attached.
  6028. */
  6029. attachedElement: Nullable<HTMLElement>;
  6030. /**
  6031. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6032. */
  6033. noPreventDefault: boolean;
  6034. /**
  6035. * Defined the camera the input manager belongs to.
  6036. */
  6037. camera: TCamera;
  6038. /**
  6039. * Update the current camera state depending on the inputs that have been used this frame.
  6040. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6041. */
  6042. checkInputs: () => void;
  6043. /**
  6044. * Instantiate a new Camera Input Manager.
  6045. * @param camera Defines the camera the input manager blongs to
  6046. */
  6047. constructor(camera: TCamera);
  6048. /**
  6049. * Add an input method to a camera
  6050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6051. * @param input camera input method
  6052. */
  6053. add(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Remove a specific input method from a camera
  6056. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6057. * @param inputToRemove camera input method
  6058. */
  6059. remove(inputToRemove: ICameraInput<TCamera>): void;
  6060. /**
  6061. * Remove a specific input type from a camera
  6062. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6063. * @param inputType the type of the input to remove
  6064. */
  6065. removeByType(inputType: string): void;
  6066. private _addCheckInputs;
  6067. /**
  6068. * Attach the input controls to the currently attached dom element to listen the events from.
  6069. * @param input Defines the input to attach
  6070. */
  6071. attachInput(input: ICameraInput<TCamera>): void;
  6072. /**
  6073. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6074. * @param element Defines the dom element to collect the events from
  6075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6076. */
  6077. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6078. /**
  6079. * Detach the current manager inputs controls from a specific dom element.
  6080. * @param element Defines the dom element to collect the events from
  6081. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6082. */
  6083. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6084. /**
  6085. * Rebuild the dynamic inputCheck function from the current list of
  6086. * defined inputs in the manager.
  6087. */
  6088. rebuildInputCheck(): void;
  6089. /**
  6090. * Remove all attached input methods from a camera
  6091. */
  6092. clear(): void;
  6093. /**
  6094. * Serialize the current input manager attached to a camera.
  6095. * This ensures than once parsed,
  6096. * the input associated to the camera will be identical to the current ones
  6097. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6098. */
  6099. serialize(serializedCamera: any): void;
  6100. /**
  6101. * Parses an input manager serialized JSON to restore the previous list of inputs
  6102. * and states associated to a camera.
  6103. * @param parsedCamera Defines the JSON to parse
  6104. */
  6105. parse(parsedCamera: any): void;
  6106. }
  6107. }
  6108. declare module BABYLON {
  6109. /**
  6110. * Class used to store data that will be store in GPU memory
  6111. */
  6112. export class Buffer {
  6113. private _engine;
  6114. private _buffer;
  6115. /** @hidden */
  6116. _data: Nullable<DataArray>;
  6117. private _updatable;
  6118. private _instanced;
  6119. private _divisor;
  6120. /**
  6121. * Gets the byte stride.
  6122. */
  6123. readonly byteStride: number;
  6124. /**
  6125. * Constructor
  6126. * @param engine the engine
  6127. * @param data the data to use for this buffer
  6128. * @param updatable whether the data is updatable
  6129. * @param stride the stride (optional)
  6130. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6131. * @param instanced whether the buffer is instanced (optional)
  6132. * @param useBytes set to true if the stride in in bytes (optional)
  6133. * @param divisor sets an optional divisor for instances (1 by default)
  6134. */
  6135. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6136. /**
  6137. * Create a new VertexBuffer based on the current buffer
  6138. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6139. * @param offset defines offset in the buffer (0 by default)
  6140. * @param size defines the size in floats of attributes (position is 3 for instance)
  6141. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6142. * @param instanced defines if the vertex buffer contains indexed data
  6143. * @param useBytes defines if the offset and stride are in bytes *
  6144. * @param divisor sets an optional divisor for instances (1 by default)
  6145. * @returns the new vertex buffer
  6146. */
  6147. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6148. /**
  6149. * Gets a boolean indicating if the Buffer is updatable?
  6150. * @returns true if the buffer is updatable
  6151. */
  6152. isUpdatable(): boolean;
  6153. /**
  6154. * Gets current buffer's data
  6155. * @returns a DataArray or null
  6156. */
  6157. getData(): Nullable<DataArray>;
  6158. /**
  6159. * Gets underlying native buffer
  6160. * @returns underlying native buffer
  6161. */
  6162. getBuffer(): Nullable<DataBuffer>;
  6163. /**
  6164. * Gets the stride in float32 units (i.e. byte stride / 4).
  6165. * May not be an integer if the byte stride is not divisible by 4.
  6166. * DEPRECATED. Use byteStride instead.
  6167. * @returns the stride in float32 units
  6168. */
  6169. getStrideSize(): number;
  6170. /**
  6171. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6172. * @param data defines the data to store
  6173. */
  6174. create(data?: Nullable<DataArray>): void;
  6175. /** @hidden */
  6176. _rebuild(): void;
  6177. /**
  6178. * Update current buffer data
  6179. * @param data defines the data to store
  6180. */
  6181. update(data: DataArray): void;
  6182. /**
  6183. * Updates the data directly.
  6184. * @param data the new data
  6185. * @param offset the new offset
  6186. * @param vertexCount the vertex count (optional)
  6187. * @param useBytes set to true if the offset is in bytes
  6188. */
  6189. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6190. /**
  6191. * Release all resources
  6192. */
  6193. dispose(): void;
  6194. }
  6195. /**
  6196. * Specialized buffer used to store vertex data
  6197. */
  6198. export class VertexBuffer {
  6199. /** @hidden */
  6200. _buffer: Buffer;
  6201. private _kind;
  6202. private _size;
  6203. private _ownsBuffer;
  6204. private _instanced;
  6205. private _instanceDivisor;
  6206. /**
  6207. * The byte type.
  6208. */
  6209. static readonly BYTE: number;
  6210. /**
  6211. * The unsigned byte type.
  6212. */
  6213. static readonly UNSIGNED_BYTE: number;
  6214. /**
  6215. * The short type.
  6216. */
  6217. static readonly SHORT: number;
  6218. /**
  6219. * The unsigned short type.
  6220. */
  6221. static readonly UNSIGNED_SHORT: number;
  6222. /**
  6223. * The integer type.
  6224. */
  6225. static readonly INT: number;
  6226. /**
  6227. * The unsigned integer type.
  6228. */
  6229. static readonly UNSIGNED_INT: number;
  6230. /**
  6231. * The float type.
  6232. */
  6233. static readonly FLOAT: number;
  6234. /**
  6235. * Gets or sets the instance divisor when in instanced mode
  6236. */
  6237. instanceDivisor: number;
  6238. /**
  6239. * Gets the byte stride.
  6240. */
  6241. readonly byteStride: number;
  6242. /**
  6243. * Gets the byte offset.
  6244. */
  6245. readonly byteOffset: number;
  6246. /**
  6247. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6248. */
  6249. readonly normalized: boolean;
  6250. /**
  6251. * Gets the data type of each component in the array.
  6252. */
  6253. readonly type: number;
  6254. /**
  6255. * Constructor
  6256. * @param engine the engine
  6257. * @param data the data to use for this vertex buffer
  6258. * @param kind the vertex buffer kind
  6259. * @param updatable whether the data is updatable
  6260. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6261. * @param stride the stride (optional)
  6262. * @param instanced whether the buffer is instanced (optional)
  6263. * @param offset the offset of the data (optional)
  6264. * @param size the number of components (optional)
  6265. * @param type the type of the component (optional)
  6266. * @param normalized whether the data contains normalized data (optional)
  6267. * @param useBytes set to true if stride and offset are in bytes (optional)
  6268. * @param divisor defines the instance divisor to use (1 by default)
  6269. */
  6270. 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);
  6271. /** @hidden */
  6272. _rebuild(): void;
  6273. /**
  6274. * Returns the kind of the VertexBuffer (string)
  6275. * @returns a string
  6276. */
  6277. getKind(): string;
  6278. /**
  6279. * Gets a boolean indicating if the VertexBuffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Returns the offset as a multiple of the type byte length.
  6302. * DEPRECATED. Use byteOffset instead.
  6303. * @returns the offset in bytes
  6304. */
  6305. getOffset(): number;
  6306. /**
  6307. * Returns the number of components per vertex attribute (integer)
  6308. * @returns the size in float
  6309. */
  6310. getSize(): number;
  6311. /**
  6312. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6313. * @returns true if this buffer is instanced
  6314. */
  6315. getIsInstanced(): boolean;
  6316. /**
  6317. * Returns the instancing divisor, zero for non-instanced (integer).
  6318. * @returns a number
  6319. */
  6320. getInstanceDivisor(): number;
  6321. /**
  6322. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6323. * @param data defines the data to store
  6324. */
  6325. create(data?: DataArray): void;
  6326. /**
  6327. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6328. * This function will create a new buffer if the current one is not updatable
  6329. * @param data defines the data to store
  6330. */
  6331. update(data: DataArray): void;
  6332. /**
  6333. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6334. * Returns the directly updated WebGLBuffer.
  6335. * @param data the new data
  6336. * @param offset the new offset
  6337. * @param useBytes set to true if the offset is in bytes
  6338. */
  6339. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6340. /**
  6341. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6342. */
  6343. dispose(): void;
  6344. /**
  6345. * Enumerates each value of this vertex buffer as numbers.
  6346. * @param count the number of values to enumerate
  6347. * @param callback the callback function called for each value
  6348. */
  6349. forEach(count: number, callback: (value: number, index: number) => void): void;
  6350. /**
  6351. * Positions
  6352. */
  6353. static readonly PositionKind: string;
  6354. /**
  6355. * Normals
  6356. */
  6357. static readonly NormalKind: string;
  6358. /**
  6359. * Tangents
  6360. */
  6361. static readonly TangentKind: string;
  6362. /**
  6363. * Texture coordinates
  6364. */
  6365. static readonly UVKind: string;
  6366. /**
  6367. * Texture coordinates 2
  6368. */
  6369. static readonly UV2Kind: string;
  6370. /**
  6371. * Texture coordinates 3
  6372. */
  6373. static readonly UV3Kind: string;
  6374. /**
  6375. * Texture coordinates 4
  6376. */
  6377. static readonly UV4Kind: string;
  6378. /**
  6379. * Texture coordinates 5
  6380. */
  6381. static readonly UV5Kind: string;
  6382. /**
  6383. * Texture coordinates 6
  6384. */
  6385. static readonly UV6Kind: string;
  6386. /**
  6387. * Colors
  6388. */
  6389. static readonly ColorKind: string;
  6390. /**
  6391. * Matrix indices (for bones)
  6392. */
  6393. static readonly MatricesIndicesKind: string;
  6394. /**
  6395. * Matrix weights (for bones)
  6396. */
  6397. static readonly MatricesWeightsKind: string;
  6398. /**
  6399. * Additional matrix indices (for bones)
  6400. */
  6401. static readonly MatricesIndicesExtraKind: string;
  6402. /**
  6403. * Additional matrix weights (for bones)
  6404. */
  6405. static readonly MatricesWeightsExtraKind: string;
  6406. /**
  6407. * Deduces the stride given a kind.
  6408. * @param kind The kind string to deduce
  6409. * @returns The deduced stride
  6410. */
  6411. static DeduceStride(kind: string): number;
  6412. /**
  6413. * Gets the byte length of the given type.
  6414. * @param type the type
  6415. * @returns the number of bytes
  6416. */
  6417. static GetTypeByteLength(type: number): number;
  6418. /**
  6419. * Enumerates each value of the given parameters as numbers.
  6420. * @param data the data to enumerate
  6421. * @param byteOffset the byte offset of the data
  6422. * @param byteStride the byte stride of the data
  6423. * @param componentCount the number of components per element
  6424. * @param componentType the type of the component
  6425. * @param count the number of values to enumerate
  6426. * @param normalized whether the data is normalized
  6427. * @param callback the callback function called for each value
  6428. */
  6429. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6430. private static _GetFloatValue;
  6431. }
  6432. }
  6433. declare module BABYLON {
  6434. /**
  6435. * @hidden
  6436. */
  6437. export class IntersectionInfo {
  6438. bu: Nullable<number>;
  6439. bv: Nullable<number>;
  6440. distance: number;
  6441. faceId: number;
  6442. subMeshId: number;
  6443. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6444. }
  6445. }
  6446. declare module BABYLON {
  6447. /**
  6448. * Represens a plane by the equation ax + by + cz + d = 0
  6449. */
  6450. export class Plane {
  6451. private static _TmpMatrix;
  6452. /**
  6453. * Normal of the plane (a,b,c)
  6454. */
  6455. normal: Vector3;
  6456. /**
  6457. * d component of the plane
  6458. */
  6459. d: number;
  6460. /**
  6461. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6462. * @param a a component of the plane
  6463. * @param b b component of the plane
  6464. * @param c c component of the plane
  6465. * @param d d component of the plane
  6466. */
  6467. constructor(a: number, b: number, c: number, d: number);
  6468. /**
  6469. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6470. */
  6471. asArray(): number[];
  6472. /**
  6473. * @returns a new plane copied from the current Plane.
  6474. */
  6475. clone(): Plane;
  6476. /**
  6477. * @returns the string "Plane".
  6478. */
  6479. getClassName(): string;
  6480. /**
  6481. * @returns the Plane hash code.
  6482. */
  6483. getHashCode(): number;
  6484. /**
  6485. * Normalize the current Plane in place.
  6486. * @returns the updated Plane.
  6487. */
  6488. normalize(): Plane;
  6489. /**
  6490. * Applies a transformation the plane and returns the result
  6491. * @param transformation the transformation matrix to be applied to the plane
  6492. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6493. */
  6494. transform(transformation: DeepImmutable<Matrix>): Plane;
  6495. /**
  6496. * Calcualtte the dot product between the point and the plane normal
  6497. * @param point point to calculate the dot product with
  6498. * @returns the dot product (float) of the point coordinates and the plane normal.
  6499. */
  6500. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6501. /**
  6502. * Updates the current Plane from the plane defined by the three given points.
  6503. * @param point1 one of the points used to contruct the plane
  6504. * @param point2 one of the points used to contruct the plane
  6505. * @param point3 one of the points used to contruct the plane
  6506. * @returns the updated Plane.
  6507. */
  6508. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6509. /**
  6510. * Checks if the plane is facing a given direction
  6511. * @param direction the direction to check if the plane is facing
  6512. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6513. * @returns True is the vector "direction" is the same side than the plane normal.
  6514. */
  6515. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6516. /**
  6517. * Calculates the distance to a point
  6518. * @param point point to calculate distance to
  6519. * @returns the signed distance (float) from the given point to the Plane.
  6520. */
  6521. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6522. /**
  6523. * Creates a plane from an array
  6524. * @param array the array to create a plane from
  6525. * @returns a new Plane from the given array.
  6526. */
  6527. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6528. /**
  6529. * Creates a plane from three points
  6530. * @param point1 point used to create the plane
  6531. * @param point2 point used to create the plane
  6532. * @param point3 point used to create the plane
  6533. * @returns a new Plane defined by the three given points.
  6534. */
  6535. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6536. /**
  6537. * Creates a plane from an origin point and a normal
  6538. * @param origin origin of the plane to be constructed
  6539. * @param normal normal of the plane to be constructed
  6540. * @returns a new Plane the normal vector to this plane at the given origin point.
  6541. * Note : the vector "normal" is updated because normalized.
  6542. */
  6543. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6544. /**
  6545. * Calculates the distance from a plane and a point
  6546. * @param origin origin of the plane to be constructed
  6547. * @param normal normal of the plane to be constructed
  6548. * @param point point to calculate distance to
  6549. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6550. */
  6551. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6552. }
  6553. }
  6554. declare module BABYLON {
  6555. /**
  6556. * Class used to store bounding sphere information
  6557. */
  6558. export class BoundingSphere {
  6559. /**
  6560. * Gets the center of the bounding sphere in local space
  6561. */
  6562. readonly center: Vector3;
  6563. /**
  6564. * Radius of the bounding sphere in local space
  6565. */
  6566. radius: number;
  6567. /**
  6568. * Gets the center of the bounding sphere in world space
  6569. */
  6570. readonly centerWorld: Vector3;
  6571. /**
  6572. * Radius of the bounding sphere in world space
  6573. */
  6574. radiusWorld: number;
  6575. /**
  6576. * Gets the minimum vector in local space
  6577. */
  6578. readonly minimum: Vector3;
  6579. /**
  6580. * Gets the maximum vector in local space
  6581. */
  6582. readonly maximum: Vector3;
  6583. private _worldMatrix;
  6584. private static readonly TmpVector3;
  6585. /**
  6586. * Creates a new bounding sphere
  6587. * @param min defines the minimum vector (in local space)
  6588. * @param max defines the maximum vector (in local space)
  6589. * @param worldMatrix defines the new world matrix
  6590. */
  6591. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6592. /**
  6593. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6594. * @param min defines the new minimum vector (in local space)
  6595. * @param max defines the new maximum vector (in local space)
  6596. * @param worldMatrix defines the new world matrix
  6597. */
  6598. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6599. /**
  6600. * Scale the current bounding sphere by applying a scale factor
  6601. * @param factor defines the scale factor to apply
  6602. * @returns the current bounding box
  6603. */
  6604. scale(factor: number): BoundingSphere;
  6605. /**
  6606. * Gets the world matrix of the bounding box
  6607. * @returns a matrix
  6608. */
  6609. getWorldMatrix(): DeepImmutable<Matrix>;
  6610. /** @hidden */
  6611. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6612. /**
  6613. * Tests if the bounding sphere is intersecting the frustum planes
  6614. * @param frustumPlanes defines the frustum planes to test
  6615. * @returns true if there is an intersection
  6616. */
  6617. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6618. /**
  6619. * Tests if the bounding sphere center is in between the frustum planes.
  6620. * Used for optimistic fast inclusion.
  6621. * @param frustumPlanes defines the frustum planes to test
  6622. * @returns true if the sphere center is in between the frustum planes
  6623. */
  6624. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6625. /**
  6626. * Tests if a point is inside the bounding sphere
  6627. * @param point defines the point to test
  6628. * @returns true if the point is inside the bounding sphere
  6629. */
  6630. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6631. /**
  6632. * Checks if two sphere intersct
  6633. * @param sphere0 sphere 0
  6634. * @param sphere1 sphere 1
  6635. * @returns true if the speres intersect
  6636. */
  6637. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6638. }
  6639. }
  6640. declare module BABYLON {
  6641. /**
  6642. * Class used to store bounding box information
  6643. */
  6644. export class BoundingBox implements ICullable {
  6645. /**
  6646. * Gets the 8 vectors representing the bounding box in local space
  6647. */
  6648. readonly vectors: Vector3[];
  6649. /**
  6650. * Gets the center of the bounding box in local space
  6651. */
  6652. readonly center: Vector3;
  6653. /**
  6654. * Gets the center of the bounding box in world space
  6655. */
  6656. readonly centerWorld: Vector3;
  6657. /**
  6658. * Gets the extend size in local space
  6659. */
  6660. readonly extendSize: Vector3;
  6661. /**
  6662. * Gets the extend size in world space
  6663. */
  6664. readonly extendSizeWorld: Vector3;
  6665. /**
  6666. * Gets the OBB (object bounding box) directions
  6667. */
  6668. readonly directions: Vector3[];
  6669. /**
  6670. * Gets the 8 vectors representing the bounding box in world space
  6671. */
  6672. readonly vectorsWorld: Vector3[];
  6673. /**
  6674. * Gets the minimum vector in world space
  6675. */
  6676. readonly minimumWorld: Vector3;
  6677. /**
  6678. * Gets the maximum vector in world space
  6679. */
  6680. readonly maximumWorld: Vector3;
  6681. /**
  6682. * Gets the minimum vector in local space
  6683. */
  6684. readonly minimum: Vector3;
  6685. /**
  6686. * Gets the maximum vector in local space
  6687. */
  6688. readonly maximum: Vector3;
  6689. private _worldMatrix;
  6690. private static readonly TmpVector3;
  6691. /**
  6692. * @hidden
  6693. */
  6694. _tag: number;
  6695. /**
  6696. * Creates a new bounding box
  6697. * @param min defines the minimum vector (in local space)
  6698. * @param max defines the maximum vector (in local space)
  6699. * @param worldMatrix defines the new world matrix
  6700. */
  6701. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6702. /**
  6703. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6704. * @param min defines the new minimum vector (in local space)
  6705. * @param max defines the new maximum vector (in local space)
  6706. * @param worldMatrix defines the new world matrix
  6707. */
  6708. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6709. /**
  6710. * Scale the current bounding box by applying a scale factor
  6711. * @param factor defines the scale factor to apply
  6712. * @returns the current bounding box
  6713. */
  6714. scale(factor: number): BoundingBox;
  6715. /**
  6716. * Gets the world matrix of the bounding box
  6717. * @returns a matrix
  6718. */
  6719. getWorldMatrix(): DeepImmutable<Matrix>;
  6720. /** @hidden */
  6721. _update(world: DeepImmutable<Matrix>): void;
  6722. /**
  6723. * Tests if the bounding box is intersecting the frustum planes
  6724. * @param frustumPlanes defines the frustum planes to test
  6725. * @returns true if there is an intersection
  6726. */
  6727. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6728. /**
  6729. * Tests if the bounding box is entirely inside the frustum planes
  6730. * @param frustumPlanes defines the frustum planes to test
  6731. * @returns true if there is an inclusion
  6732. */
  6733. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6734. /**
  6735. * Tests if a point is inside the bounding box
  6736. * @param point defines the point to test
  6737. * @returns true if the point is inside the bounding box
  6738. */
  6739. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6740. /**
  6741. * Tests if the bounding box intersects with a bounding sphere
  6742. * @param sphere defines the sphere to test
  6743. * @returns true if there is an intersection
  6744. */
  6745. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6746. /**
  6747. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6748. * @param min defines the min vector to use
  6749. * @param max defines the max vector to use
  6750. * @returns true if there is an intersection
  6751. */
  6752. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6753. /**
  6754. * Tests if two bounding boxes are intersections
  6755. * @param box0 defines the first box to test
  6756. * @param box1 defines the second box to test
  6757. * @returns true if there is an intersection
  6758. */
  6759. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6760. /**
  6761. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6762. * @param minPoint defines the minimum vector of the bounding box
  6763. * @param maxPoint defines the maximum vector of the bounding box
  6764. * @param sphereCenter defines the sphere center
  6765. * @param sphereRadius defines the sphere radius
  6766. * @returns true if there is an intersection
  6767. */
  6768. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6769. /**
  6770. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6771. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @return true if there is an inclusion
  6774. */
  6775. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6778. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @return true if there is an intersection
  6781. */
  6782. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /** @hidden */
  6787. export class Collider {
  6788. /** Define if a collision was found */
  6789. collisionFound: boolean;
  6790. /**
  6791. * Define last intersection point in local space
  6792. */
  6793. intersectionPoint: Vector3;
  6794. /**
  6795. * Define last collided mesh
  6796. */
  6797. collidedMesh: Nullable<AbstractMesh>;
  6798. private _collisionPoint;
  6799. private _planeIntersectionPoint;
  6800. private _tempVector;
  6801. private _tempVector2;
  6802. private _tempVector3;
  6803. private _tempVector4;
  6804. private _edge;
  6805. private _baseToVertex;
  6806. private _destinationPoint;
  6807. private _slidePlaneNormal;
  6808. private _displacementVector;
  6809. /** @hidden */
  6810. _radius: Vector3;
  6811. /** @hidden */
  6812. _retry: number;
  6813. private _velocity;
  6814. private _basePoint;
  6815. private _epsilon;
  6816. /** @hidden */
  6817. _velocityWorldLength: number;
  6818. /** @hidden */
  6819. _basePointWorld: Vector3;
  6820. private _velocityWorld;
  6821. private _normalizedVelocity;
  6822. /** @hidden */
  6823. _initialVelocity: Vector3;
  6824. /** @hidden */
  6825. _initialPosition: Vector3;
  6826. private _nearestDistance;
  6827. private _collisionMask;
  6828. collisionMask: number;
  6829. /**
  6830. * Gets the plane normal used to compute the sliding response (in local space)
  6831. */
  6832. readonly slidePlaneNormal: Vector3;
  6833. /** @hidden */
  6834. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6835. /** @hidden */
  6836. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6837. /** @hidden */
  6838. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6839. /** @hidden */
  6840. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6841. /** @hidden */
  6842. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6843. /** @hidden */
  6844. _getResponse(pos: Vector3, vel: Vector3): void;
  6845. }
  6846. }
  6847. declare module BABYLON {
  6848. /**
  6849. * Interface for cullable objects
  6850. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6851. */
  6852. export interface ICullable {
  6853. /**
  6854. * Checks if the object or part of the object is in the frustum
  6855. * @param frustumPlanes Camera near/planes
  6856. * @returns true if the object is in frustum otherwise false
  6857. */
  6858. isInFrustum(frustumPlanes: Plane[]): boolean;
  6859. /**
  6860. * Checks if a cullable object (mesh...) is in the camera frustum
  6861. * Unlike isInFrustum this cheks the full bounding box
  6862. * @param frustumPlanes Camera near/planes
  6863. * @returns true if the object is in frustum otherwise false
  6864. */
  6865. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6866. }
  6867. /**
  6868. * Info for a bounding data of a mesh
  6869. */
  6870. export class BoundingInfo implements ICullable {
  6871. /**
  6872. * Bounding box for the mesh
  6873. */
  6874. readonly boundingBox: BoundingBox;
  6875. /**
  6876. * Bounding sphere for the mesh
  6877. */
  6878. readonly boundingSphere: BoundingSphere;
  6879. private _isLocked;
  6880. private static readonly TmpVector3;
  6881. /**
  6882. * Constructs bounding info
  6883. * @param minimum min vector of the bounding box/sphere
  6884. * @param maximum max vector of the bounding box/sphere
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6888. /**
  6889. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6890. * @param min defines the new minimum vector (in local space)
  6891. * @param max defines the new maximum vector (in local space)
  6892. * @param worldMatrix defines the new world matrix
  6893. */
  6894. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6895. /**
  6896. * min vector of the bounding box/sphere
  6897. */
  6898. readonly minimum: Vector3;
  6899. /**
  6900. * max vector of the bounding box/sphere
  6901. */
  6902. readonly maximum: Vector3;
  6903. /**
  6904. * If the info is locked and won't be updated to avoid perf overhead
  6905. */
  6906. isLocked: boolean;
  6907. /**
  6908. * Updates the bounding sphere and box
  6909. * @param world world matrix to be used to update
  6910. */
  6911. update(world: DeepImmutable<Matrix>): void;
  6912. /**
  6913. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6914. * @param center New center of the bounding info
  6915. * @param extend New extend of the bounding info
  6916. * @returns the current bounding info
  6917. */
  6918. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6919. /**
  6920. * Scale the current bounding info by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding info
  6923. */
  6924. scale(factor: number): BoundingInfo;
  6925. /**
  6926. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6927. * @param frustumPlanes defines the frustum to test
  6928. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6929. * @returns true if the bounding info is in the frustum planes
  6930. */
  6931. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6932. /**
  6933. * Gets the world distance between the min and max points of the bounding box
  6934. */
  6935. readonly diagonalLength: number;
  6936. /**
  6937. * Checks if a cullable object (mesh...) is in the camera frustum
  6938. * Unlike isInFrustum this cheks the full bounding box
  6939. * @param frustumPlanes Camera near/planes
  6940. * @returns true if the object is in frustum otherwise false
  6941. */
  6942. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /** @hidden */
  6944. _checkCollision(collider: Collider): boolean;
  6945. /**
  6946. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6947. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6948. * @param point the point to check intersection with
  6949. * @returns if the point intersects
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6954. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6955. * @param boundingInfo the bounding info to check intersection with
  6956. * @param precise if the intersection should be done using OBB
  6957. * @returns if the bounding info intersects
  6958. */
  6959. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6960. }
  6961. }
  6962. declare module BABYLON {
  6963. /**
  6964. * Extracts minimum and maximum values from a list of indexed positions
  6965. * @param positions defines the positions to use
  6966. * @param indices defines the indices to the positions
  6967. * @param indexStart defines the start index
  6968. * @param indexCount defines the end index
  6969. * @param bias defines bias value to add to the result
  6970. * @return minimum and maximum values
  6971. */
  6972. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6973. minimum: Vector3;
  6974. maximum: Vector3;
  6975. };
  6976. /**
  6977. * Extracts minimum and maximum values from a list of positions
  6978. * @param positions defines the positions to use
  6979. * @param start defines the start index in the positions array
  6980. * @param count defines the number of positions to handle
  6981. * @param bias defines bias value to add to the result
  6982. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6983. * @return minimum and maximum values
  6984. */
  6985. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6986. minimum: Vector3;
  6987. maximum: Vector3;
  6988. };
  6989. }
  6990. declare module BABYLON {
  6991. /** @hidden */
  6992. export class WebGLDataBuffer extends DataBuffer {
  6993. private _buffer;
  6994. constructor(resource: WebGLBuffer);
  6995. readonly underlyingResource: any;
  6996. }
  6997. }
  6998. declare module BABYLON {
  6999. /** @hidden */
  7000. export class WebGLPipelineContext implements IPipelineContext {
  7001. engine: ThinEngine;
  7002. program: Nullable<WebGLProgram>;
  7003. context?: WebGLRenderingContext;
  7004. vertexShader?: WebGLShader;
  7005. fragmentShader?: WebGLShader;
  7006. isParallelCompiled: boolean;
  7007. onCompiled?: () => void;
  7008. transformFeedback?: WebGLTransformFeedback | null;
  7009. readonly isAsync: boolean;
  7010. readonly isReady: boolean;
  7011. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7012. }
  7013. }
  7014. declare module BABYLON {
  7015. interface ThinEngine {
  7016. /**
  7017. * Create an uniform buffer
  7018. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7019. * @param elements defines the content of the uniform buffer
  7020. * @returns the webGL uniform buffer
  7021. */
  7022. createUniformBuffer(elements: FloatArray): DataBuffer;
  7023. /**
  7024. * Create a dynamic uniform buffer
  7025. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7026. * @param elements defines the content of the uniform buffer
  7027. * @returns the webGL uniform buffer
  7028. */
  7029. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7030. /**
  7031. * Update an existing uniform buffer
  7032. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7033. * @param uniformBuffer defines the target uniform buffer
  7034. * @param elements defines the content to update
  7035. * @param offset defines the offset in the uniform buffer where update should start
  7036. * @param count defines the size of the data to update
  7037. */
  7038. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7039. /**
  7040. * Bind an uniform buffer to the current webGL context
  7041. * @param buffer defines the buffer to bind
  7042. */
  7043. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7044. /**
  7045. * Bind a buffer to the current webGL context at a given location
  7046. * @param buffer defines the buffer to bind
  7047. * @param location defines the index where to bind the buffer
  7048. */
  7049. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7050. /**
  7051. * Bind a specific block at a given index in a specific shader program
  7052. * @param pipelineContext defines the pipeline context to use
  7053. * @param blockName defines the block name
  7054. * @param index defines the index where to bind the block
  7055. */
  7056. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Uniform buffer objects.
  7062. *
  7063. * Handles blocks of uniform on the GPU.
  7064. *
  7065. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7066. *
  7067. * For more information, please refer to :
  7068. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7069. */
  7070. export class UniformBuffer {
  7071. private _engine;
  7072. private _buffer;
  7073. private _data;
  7074. private _bufferData;
  7075. private _dynamic?;
  7076. private _uniformLocations;
  7077. private _uniformSizes;
  7078. private _uniformLocationPointer;
  7079. private _needSync;
  7080. private _noUBO;
  7081. private _currentEffect;
  7082. /** @hidden */
  7083. _alreadyBound: boolean;
  7084. private static _MAX_UNIFORM_SIZE;
  7085. private static _tempBuffer;
  7086. /**
  7087. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7088. * This is dynamic to allow compat with webgl 1 and 2.
  7089. * You will need to pass the name of the uniform as well as the value.
  7090. */
  7091. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7092. /**
  7093. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7094. * This is dynamic to allow compat with webgl 1 and 2.
  7095. * You will need to pass the name of the uniform as well as the value.
  7096. */
  7097. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7098. /**
  7099. * Lambda to Update a single float in a uniform buffer.
  7100. * This is dynamic to allow compat with webgl 1 and 2.
  7101. * You will need to pass the name of the uniform as well as the value.
  7102. */
  7103. updateFloat: (name: string, x: number) => void;
  7104. /**
  7105. * Lambda to Update a vec2 of float in a uniform buffer.
  7106. * This is dynamic to allow compat with webgl 1 and 2.
  7107. * You will need to pass the name of the uniform as well as the value.
  7108. */
  7109. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7110. /**
  7111. * Lambda to Update a vec3 of float in a uniform buffer.
  7112. * This is dynamic to allow compat with webgl 1 and 2.
  7113. * You will need to pass the name of the uniform as well as the value.
  7114. */
  7115. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7116. /**
  7117. * Lambda to Update a vec4 of float in a uniform buffer.
  7118. * This is dynamic to allow compat with webgl 1 and 2.
  7119. * You will need to pass the name of the uniform as well as the value.
  7120. */
  7121. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7122. /**
  7123. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7124. * This is dynamic to allow compat with webgl 1 and 2.
  7125. * You will need to pass the name of the uniform as well as the value.
  7126. */
  7127. updateMatrix: (name: string, mat: Matrix) => void;
  7128. /**
  7129. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7130. * This is dynamic to allow compat with webgl 1 and 2.
  7131. * You will need to pass the name of the uniform as well as the value.
  7132. */
  7133. updateVector3: (name: string, vector: Vector3) => void;
  7134. /**
  7135. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7136. * This is dynamic to allow compat with webgl 1 and 2.
  7137. * You will need to pass the name of the uniform as well as the value.
  7138. */
  7139. updateVector4: (name: string, vector: Vector4) => void;
  7140. /**
  7141. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7142. * This is dynamic to allow compat with webgl 1 and 2.
  7143. * You will need to pass the name of the uniform as well as the value.
  7144. */
  7145. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7146. /**
  7147. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7148. * This is dynamic to allow compat with webgl 1 and 2.
  7149. * You will need to pass the name of the uniform as well as the value.
  7150. */
  7151. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7152. /**
  7153. * Instantiates a new Uniform buffer objects.
  7154. *
  7155. * Handles blocks of uniform on the GPU.
  7156. *
  7157. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7158. *
  7159. * For more information, please refer to :
  7160. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7161. * @param engine Define the engine the buffer is associated with
  7162. * @param data Define the data contained in the buffer
  7163. * @param dynamic Define if the buffer is updatable
  7164. */
  7165. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7166. /**
  7167. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7168. * or just falling back on setUniformXXX calls.
  7169. */
  7170. readonly useUbo: boolean;
  7171. /**
  7172. * Indicates if the WebGL underlying uniform buffer is in sync
  7173. * with the javascript cache data.
  7174. */
  7175. readonly isSync: boolean;
  7176. /**
  7177. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7178. * Also, a dynamic UniformBuffer will disable cache verification and always
  7179. * update the underlying WebGL uniform buffer to the GPU.
  7180. * @returns if Dynamic, otherwise false
  7181. */
  7182. isDynamic(): boolean;
  7183. /**
  7184. * The data cache on JS side.
  7185. * @returns the underlying data as a float array
  7186. */
  7187. getData(): Float32Array;
  7188. /**
  7189. * The underlying WebGL Uniform buffer.
  7190. * @returns the webgl buffer
  7191. */
  7192. getBuffer(): Nullable<DataBuffer>;
  7193. /**
  7194. * std140 layout specifies how to align data within an UBO structure.
  7195. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7196. * for specs.
  7197. */
  7198. private _fillAlignment;
  7199. /**
  7200. * Adds an uniform in the buffer.
  7201. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7202. * for the layout to be correct !
  7203. * @param name Name of the uniform, as used in the uniform block in the shader.
  7204. * @param size Data size, or data directly.
  7205. */
  7206. addUniform(name: string, size: number | number[]): void;
  7207. /**
  7208. * Adds a Matrix 4x4 to the uniform buffer.
  7209. * @param name Name of the uniform, as used in the uniform block in the shader.
  7210. * @param mat A 4x4 matrix.
  7211. */
  7212. addMatrix(name: string, mat: Matrix): void;
  7213. /**
  7214. * Adds a vec2 to the uniform buffer.
  7215. * @param name Name of the uniform, as used in the uniform block in the shader.
  7216. * @param x Define the x component value of the vec2
  7217. * @param y Define the y component value of the vec2
  7218. */
  7219. addFloat2(name: string, x: number, y: number): void;
  7220. /**
  7221. * Adds a vec3 to the uniform buffer.
  7222. * @param name Name of the uniform, as used in the uniform block in the shader.
  7223. * @param x Define the x component value of the vec3
  7224. * @param y Define the y component value of the vec3
  7225. * @param z Define the z component value of the vec3
  7226. */
  7227. addFloat3(name: string, x: number, y: number, z: number): void;
  7228. /**
  7229. * Adds a vec3 to the uniform buffer.
  7230. * @param name Name of the uniform, as used in the uniform block in the shader.
  7231. * @param color Define the vec3 from a Color
  7232. */
  7233. addColor3(name: string, color: Color3): void;
  7234. /**
  7235. * Adds a vec4 to the uniform buffer.
  7236. * @param name Name of the uniform, as used in the uniform block in the shader.
  7237. * @param color Define the rgb components from a Color
  7238. * @param alpha Define the a component of the vec4
  7239. */
  7240. addColor4(name: string, color: Color3, alpha: number): void;
  7241. /**
  7242. * Adds a vec3 to the uniform buffer.
  7243. * @param name Name of the uniform, as used in the uniform block in the shader.
  7244. * @param vector Define the vec3 components from a Vector
  7245. */
  7246. addVector3(name: string, vector: Vector3): void;
  7247. /**
  7248. * Adds a Matrix 3x3 to the uniform buffer.
  7249. * @param name Name of the uniform, as used in the uniform block in the shader.
  7250. */
  7251. addMatrix3x3(name: string): void;
  7252. /**
  7253. * Adds a Matrix 2x2 to the uniform buffer.
  7254. * @param name Name of the uniform, as used in the uniform block in the shader.
  7255. */
  7256. addMatrix2x2(name: string): void;
  7257. /**
  7258. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7259. */
  7260. create(): void;
  7261. /** @hidden */
  7262. _rebuild(): void;
  7263. /**
  7264. * Updates the WebGL Uniform Buffer on the GPU.
  7265. * If the `dynamic` flag is set to true, no cache comparison is done.
  7266. * Otherwise, the buffer will be updated only if the cache differs.
  7267. */
  7268. update(): void;
  7269. /**
  7270. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7271. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7272. * @param data Define the flattened data
  7273. * @param size Define the size of the data.
  7274. */
  7275. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7276. private _valueCache;
  7277. private _cacheMatrix;
  7278. private _updateMatrix3x3ForUniform;
  7279. private _updateMatrix3x3ForEffect;
  7280. private _updateMatrix2x2ForEffect;
  7281. private _updateMatrix2x2ForUniform;
  7282. private _updateFloatForEffect;
  7283. private _updateFloatForUniform;
  7284. private _updateFloat2ForEffect;
  7285. private _updateFloat2ForUniform;
  7286. private _updateFloat3ForEffect;
  7287. private _updateFloat3ForUniform;
  7288. private _updateFloat4ForEffect;
  7289. private _updateFloat4ForUniform;
  7290. private _updateMatrixForEffect;
  7291. private _updateMatrixForUniform;
  7292. private _updateVector3ForEffect;
  7293. private _updateVector3ForUniform;
  7294. private _updateVector4ForEffect;
  7295. private _updateVector4ForUniform;
  7296. private _updateColor3ForEffect;
  7297. private _updateColor3ForUniform;
  7298. private _updateColor4ForEffect;
  7299. private _updateColor4ForUniform;
  7300. /**
  7301. * Sets a sampler uniform on the effect.
  7302. * @param name Define the name of the sampler.
  7303. * @param texture Define the texture to set in the sampler
  7304. */
  7305. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7306. /**
  7307. * Directly updates the value of the uniform in the cache AND on the GPU.
  7308. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7309. * @param data Define the flattened data
  7310. */
  7311. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7312. /**
  7313. * Binds this uniform buffer to an effect.
  7314. * @param effect Define the effect to bind the buffer to
  7315. * @param name Name of the uniform block in the shader.
  7316. */
  7317. bindToEffect(effect: Effect, name: string): void;
  7318. /**
  7319. * Disposes the uniform buffer.
  7320. */
  7321. dispose(): void;
  7322. }
  7323. }
  7324. declare module BABYLON {
  7325. /**
  7326. * Enum that determines the text-wrapping mode to use.
  7327. */
  7328. export enum InspectableType {
  7329. /**
  7330. * Checkbox for booleans
  7331. */
  7332. Checkbox = 0,
  7333. /**
  7334. * Sliders for numbers
  7335. */
  7336. Slider = 1,
  7337. /**
  7338. * Vector3
  7339. */
  7340. Vector3 = 2,
  7341. /**
  7342. * Quaternions
  7343. */
  7344. Quaternion = 3,
  7345. /**
  7346. * Color3
  7347. */
  7348. Color3 = 4,
  7349. /**
  7350. * String
  7351. */
  7352. String = 5
  7353. }
  7354. /**
  7355. * Interface used to define custom inspectable properties.
  7356. * This interface is used by the inspector to display custom property grids
  7357. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7358. */
  7359. export interface IInspectable {
  7360. /**
  7361. * Gets the label to display
  7362. */
  7363. label: string;
  7364. /**
  7365. * Gets the name of the property to edit
  7366. */
  7367. propertyName: string;
  7368. /**
  7369. * Gets the type of the editor to use
  7370. */
  7371. type: InspectableType;
  7372. /**
  7373. * Gets the minimum value of the property when using in "slider" mode
  7374. */
  7375. min?: number;
  7376. /**
  7377. * Gets the maximum value of the property when using in "slider" mode
  7378. */
  7379. max?: number;
  7380. /**
  7381. * Gets the setp to use when using in "slider" mode
  7382. */
  7383. step?: number;
  7384. }
  7385. }
  7386. declare module BABYLON {
  7387. /**
  7388. * Class used to provide helper for timing
  7389. */
  7390. export class TimingTools {
  7391. /**
  7392. * Polyfill for setImmediate
  7393. * @param action defines the action to execute after the current execution block
  7394. */
  7395. static SetImmediate(action: () => void): void;
  7396. }
  7397. }
  7398. declare module BABYLON {
  7399. /**
  7400. * Class used to enable instatition of objects by class name
  7401. */
  7402. export class InstantiationTools {
  7403. /**
  7404. * Use this object to register external classes like custom textures or material
  7405. * to allow the laoders to instantiate them
  7406. */
  7407. static RegisteredExternalClasses: {
  7408. [key: string]: Object;
  7409. };
  7410. /**
  7411. * Tries to instantiate a new object from a given class name
  7412. * @param className defines the class name to instantiate
  7413. * @returns the new object or null if the system was not able to do the instantiation
  7414. */
  7415. static Instantiate(className: string): any;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * Define options used to create a depth texture
  7421. */
  7422. export class DepthTextureCreationOptions {
  7423. /** Specifies whether or not a stencil should be allocated in the texture */
  7424. generateStencil?: boolean;
  7425. /** Specifies whether or not bilinear filtering is enable on the texture */
  7426. bilinearFiltering?: boolean;
  7427. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7428. comparisonFunction?: number;
  7429. /** Specifies if the created texture is a cube texture */
  7430. isCube?: boolean;
  7431. }
  7432. }
  7433. declare module BABYLON {
  7434. interface ThinEngine {
  7435. /**
  7436. * Creates a depth stencil cube texture.
  7437. * This is only available in WebGL 2.
  7438. * @param size The size of face edge in the cube texture.
  7439. * @param options The options defining the cube texture.
  7440. * @returns The cube texture
  7441. */
  7442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7443. /**
  7444. * Creates a cube texture
  7445. * @param rootUrl defines the url where the files to load is located
  7446. * @param scene defines the current scene
  7447. * @param files defines the list of files to load (1 per face)
  7448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7449. * @param onLoad defines an optional callback raised when the texture is loaded
  7450. * @param onError defines an optional callback raised if there is an issue to load the texture
  7451. * @param format defines the format of the data
  7452. * @param forcedExtension defines the extension to use to pick the right loader
  7453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7458. * @returns the cube texture as an InternalTexture
  7459. */
  7460. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7461. /**
  7462. * Creates a cube texture
  7463. * @param rootUrl defines the url where the files to load is located
  7464. * @param scene defines the current scene
  7465. * @param files defines the list of files to load (1 per face)
  7466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7467. * @param onLoad defines an optional callback raised when the texture is loaded
  7468. * @param onError defines an optional callback raised if there is an issue to load the texture
  7469. * @param format defines the format of the data
  7470. * @param forcedExtension defines the extension to use to pick the right loader
  7471. * @returns the cube texture as an InternalTexture
  7472. */
  7473. 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;
  7474. /**
  7475. * Creates a cube texture
  7476. * @param rootUrl defines the url where the files to load is located
  7477. * @param scene defines the current scene
  7478. * @param files defines the list of files to load (1 per face)
  7479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7480. * @param onLoad defines an optional callback raised when the texture is loaded
  7481. * @param onError defines an optional callback raised if there is an issue to load the texture
  7482. * @param format defines the format of the data
  7483. * @param forcedExtension defines the extension to use to pick the right loader
  7484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7487. * @returns the cube texture as an InternalTexture
  7488. */
  7489. 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;
  7490. /** @hidden */
  7491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7492. /** @hidden */
  7493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7494. /** @hidden */
  7495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7496. /** @hidden */
  7497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7498. /**
  7499. * @hidden
  7500. */
  7501. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7502. }
  7503. }
  7504. declare module BABYLON {
  7505. /**
  7506. * Class for creating a cube texture
  7507. */
  7508. export class CubeTexture extends BaseTexture {
  7509. private _delayedOnLoad;
  7510. /**
  7511. * The url of the texture
  7512. */
  7513. url: string;
  7514. /**
  7515. * Gets or sets the center of the bounding box associated with the cube texture.
  7516. * It must define where the camera used to render the texture was set
  7517. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7518. */
  7519. boundingBoxPosition: Vector3;
  7520. private _boundingBoxSize;
  7521. /**
  7522. * Gets or sets the size of the bounding box associated with the cube texture
  7523. * When defined, the cubemap will switch to local mode
  7524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7525. * @example https://www.babylonjs-playground.com/#RNASML
  7526. */
  7527. /**
  7528. * Returns the bounding box size
  7529. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7530. */
  7531. boundingBoxSize: Vector3;
  7532. protected _rotationY: number;
  7533. /**
  7534. * Sets texture matrix rotation angle around Y axis in radians.
  7535. */
  7536. /**
  7537. * Gets texture matrix rotation angle around Y axis radians.
  7538. */
  7539. rotationY: number;
  7540. /**
  7541. * Are mip maps generated for this texture or not.
  7542. */
  7543. readonly noMipmap: boolean;
  7544. private _noMipmap;
  7545. private _files;
  7546. protected _forcedExtension: Nullable<string>;
  7547. private _extensions;
  7548. private _textureMatrix;
  7549. private _format;
  7550. private _createPolynomials;
  7551. /** @hidden */
  7552. _prefiltered: boolean;
  7553. /**
  7554. * Creates a cube texture from an array of image urls
  7555. * @param files defines an array of image urls
  7556. * @param scene defines the hosting scene
  7557. * @param noMipmap specifies if mip maps are not used
  7558. * @returns a cube texture
  7559. */
  7560. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7561. /**
  7562. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7563. * @param url defines the url of the prefiltered texture
  7564. * @param scene defines the scene the texture is attached to
  7565. * @param forcedExtension defines the extension of the file if different from the url
  7566. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7567. * @return the prefiltered texture
  7568. */
  7569. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7570. /**
  7571. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7572. * as prefiltered data.
  7573. * @param rootUrl defines the url of the texture or the root name of the six images
  7574. * @param scene defines the scene the texture is attached to
  7575. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7576. * @param noMipmap defines if mipmaps should be created or not
  7577. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7578. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7579. * @param onError defines a callback triggered in case of error during load
  7580. * @param format defines the internal format to use for the texture once loaded
  7581. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7582. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7583. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7584. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7585. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7586. * @return the cube texture
  7587. */
  7588. 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);
  7589. /**
  7590. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7591. */
  7592. readonly isPrefiltered: boolean;
  7593. /**
  7594. * Get the current class name of the texture useful for serialization or dynamic coding.
  7595. * @returns "CubeTexture"
  7596. */
  7597. getClassName(): string;
  7598. /**
  7599. * Update the url (and optional buffer) of this texture if url was null during construction.
  7600. * @param url the url of the texture
  7601. * @param forcedExtension defines the extension to use
  7602. * @param onLoad callback called when the texture is loaded (defaults to null)
  7603. */
  7604. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7605. /**
  7606. * Delays loading of the cube texture
  7607. * @param forcedExtension defines the extension to use
  7608. */
  7609. delayLoad(forcedExtension?: string): void;
  7610. /**
  7611. * Returns the reflection texture matrix
  7612. * @returns the reflection texture matrix
  7613. */
  7614. getReflectionTextureMatrix(): Matrix;
  7615. /**
  7616. * Sets the reflection texture matrix
  7617. * @param value Reflection texture matrix
  7618. */
  7619. setReflectionTextureMatrix(value: Matrix): void;
  7620. /**
  7621. * Parses text to create a cube texture
  7622. * @param parsedTexture define the serialized text to read from
  7623. * @param scene defines the hosting scene
  7624. * @param rootUrl defines the root url of the cube texture
  7625. * @returns a cube texture
  7626. */
  7627. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7628. /**
  7629. * Makes a clone, or deep copy, of the cube texture
  7630. * @returns a new cube texture
  7631. */
  7632. clone(): CubeTexture;
  7633. }
  7634. }
  7635. declare module BABYLON {
  7636. /**
  7637. * Manages the defines for the Material
  7638. */
  7639. export class MaterialDefines {
  7640. /** @hidden */
  7641. protected _keys: string[];
  7642. private _isDirty;
  7643. /** @hidden */
  7644. _renderId: number;
  7645. /** @hidden */
  7646. _areLightsDirty: boolean;
  7647. /** @hidden */
  7648. _areLightsDisposed: boolean;
  7649. /** @hidden */
  7650. _areAttributesDirty: boolean;
  7651. /** @hidden */
  7652. _areTexturesDirty: boolean;
  7653. /** @hidden */
  7654. _areFresnelDirty: boolean;
  7655. /** @hidden */
  7656. _areMiscDirty: boolean;
  7657. /** @hidden */
  7658. _areImageProcessingDirty: boolean;
  7659. /** @hidden */
  7660. _normals: boolean;
  7661. /** @hidden */
  7662. _uvs: boolean;
  7663. /** @hidden */
  7664. _needNormals: boolean;
  7665. /** @hidden */
  7666. _needUVs: boolean;
  7667. [id: string]: any;
  7668. /**
  7669. * Specifies if the material needs to be re-calculated
  7670. */
  7671. readonly isDirty: boolean;
  7672. /**
  7673. * Marks the material to indicate that it has been re-calculated
  7674. */
  7675. markAsProcessed(): void;
  7676. /**
  7677. * Marks the material to indicate that it needs to be re-calculated
  7678. */
  7679. markAsUnprocessed(): void;
  7680. /**
  7681. * Marks the material to indicate all of its defines need to be re-calculated
  7682. */
  7683. markAllAsDirty(): void;
  7684. /**
  7685. * Marks the material to indicate that image processing needs to be re-calculated
  7686. */
  7687. markAsImageProcessingDirty(): void;
  7688. /**
  7689. * Marks the material to indicate the lights need to be re-calculated
  7690. * @param disposed Defines whether the light is dirty due to dispose or not
  7691. */
  7692. markAsLightDirty(disposed?: boolean): void;
  7693. /**
  7694. * Marks the attribute state as changed
  7695. */
  7696. markAsAttributesDirty(): void;
  7697. /**
  7698. * Marks the texture state as changed
  7699. */
  7700. markAsTexturesDirty(): void;
  7701. /**
  7702. * Marks the fresnel state as changed
  7703. */
  7704. markAsFresnelDirty(): void;
  7705. /**
  7706. * Marks the misc state as changed
  7707. */
  7708. markAsMiscDirty(): void;
  7709. /**
  7710. * Rebuilds the material defines
  7711. */
  7712. rebuild(): void;
  7713. /**
  7714. * Specifies if two material defines are equal
  7715. * @param other - A material define instance to compare to
  7716. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7717. */
  7718. isEqual(other: MaterialDefines): boolean;
  7719. /**
  7720. * Clones this instance's defines to another instance
  7721. * @param other - material defines to clone values to
  7722. */
  7723. cloneTo(other: MaterialDefines): void;
  7724. /**
  7725. * Resets the material define values
  7726. */
  7727. reset(): void;
  7728. /**
  7729. * Converts the material define values to a string
  7730. * @returns - String of material define information
  7731. */
  7732. toString(): string;
  7733. }
  7734. }
  7735. declare module BABYLON {
  7736. /**
  7737. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7738. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7739. * 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;
  7740. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7741. */
  7742. export class ColorCurves {
  7743. private _dirty;
  7744. private _tempColor;
  7745. private _globalCurve;
  7746. private _highlightsCurve;
  7747. private _midtonesCurve;
  7748. private _shadowsCurve;
  7749. private _positiveCurve;
  7750. private _negativeCurve;
  7751. private _globalHue;
  7752. private _globalDensity;
  7753. private _globalSaturation;
  7754. private _globalExposure;
  7755. /**
  7756. * Gets the global Hue value.
  7757. * 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).
  7758. */
  7759. /**
  7760. * Sets the global Hue value.
  7761. * 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).
  7762. */
  7763. globalHue: number;
  7764. /**
  7765. * Gets the global Density value.
  7766. * 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.
  7767. * Values less than zero provide a filter of opposite hue.
  7768. */
  7769. /**
  7770. * Sets the global Density value.
  7771. * 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.
  7772. * Values less than zero provide a filter of opposite hue.
  7773. */
  7774. globalDensity: number;
  7775. /**
  7776. * Gets the global Saturation value.
  7777. * 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.
  7778. */
  7779. /**
  7780. * Sets the global Saturation value.
  7781. * 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.
  7782. */
  7783. globalSaturation: number;
  7784. /**
  7785. * Gets the global Exposure value.
  7786. * 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.
  7787. */
  7788. /**
  7789. * Sets the global Exposure value.
  7790. * 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.
  7791. */
  7792. globalExposure: number;
  7793. private _highlightsHue;
  7794. private _highlightsDensity;
  7795. private _highlightsSaturation;
  7796. private _highlightsExposure;
  7797. /**
  7798. * Gets the highlights Hue value.
  7799. * 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).
  7800. */
  7801. /**
  7802. * Sets the highlights Hue value.
  7803. * 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).
  7804. */
  7805. highlightsHue: number;
  7806. /**
  7807. * Gets the highlights Density value.
  7808. * 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.
  7809. * Values less than zero provide a filter of opposite hue.
  7810. */
  7811. /**
  7812. * Sets the highlights Density value.
  7813. * 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.
  7814. * Values less than zero provide a filter of opposite hue.
  7815. */
  7816. highlightsDensity: number;
  7817. /**
  7818. * Gets the highlights Saturation value.
  7819. * 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.
  7820. */
  7821. /**
  7822. * Sets the highlights Saturation value.
  7823. * 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.
  7824. */
  7825. highlightsSaturation: number;
  7826. /**
  7827. * Gets the highlights Exposure value.
  7828. * 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.
  7829. */
  7830. /**
  7831. * Sets the highlights Exposure value.
  7832. * 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.
  7833. */
  7834. highlightsExposure: number;
  7835. private _midtonesHue;
  7836. private _midtonesDensity;
  7837. private _midtonesSaturation;
  7838. private _midtonesExposure;
  7839. /**
  7840. * Gets the midtones Hue value.
  7841. * 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).
  7842. */
  7843. /**
  7844. * Sets the midtones Hue value.
  7845. * 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).
  7846. */
  7847. midtonesHue: number;
  7848. /**
  7849. * Gets the midtones Density value.
  7850. * 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.
  7851. * Values less than zero provide a filter of opposite hue.
  7852. */
  7853. /**
  7854. * Sets the midtones Density value.
  7855. * 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.
  7856. * Values less than zero provide a filter of opposite hue.
  7857. */
  7858. midtonesDensity: number;
  7859. /**
  7860. * Gets the midtones Saturation value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the midtones Saturation value.
  7865. * 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.
  7866. */
  7867. midtonesSaturation: number;
  7868. /**
  7869. * Gets the midtones Exposure value.
  7870. * 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.
  7871. */
  7872. /**
  7873. * Sets the midtones Exposure value.
  7874. * 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.
  7875. */
  7876. midtonesExposure: number;
  7877. private _shadowsHue;
  7878. private _shadowsDensity;
  7879. private _shadowsSaturation;
  7880. private _shadowsExposure;
  7881. /**
  7882. * Gets the shadows Hue value.
  7883. * 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).
  7884. */
  7885. /**
  7886. * Sets the shadows Hue value.
  7887. * 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).
  7888. */
  7889. shadowsHue: number;
  7890. /**
  7891. * Gets the shadows Density value.
  7892. * 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.
  7893. * Values less than zero provide a filter of opposite hue.
  7894. */
  7895. /**
  7896. * Sets the shadows Density value.
  7897. * 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.
  7898. * Values less than zero provide a filter of opposite hue.
  7899. */
  7900. shadowsDensity: number;
  7901. /**
  7902. * Gets the shadows Saturation value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the shadows Saturation value.
  7907. * 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.
  7908. */
  7909. shadowsSaturation: number;
  7910. /**
  7911. * Gets the shadows Exposure value.
  7912. * 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.
  7913. */
  7914. /**
  7915. * Sets the shadows Exposure value.
  7916. * 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.
  7917. */
  7918. shadowsExposure: number;
  7919. /**
  7920. * Returns the class name
  7921. * @returns The class name
  7922. */
  7923. getClassName(): string;
  7924. /**
  7925. * Binds the color curves to the shader.
  7926. * @param colorCurves The color curve to bind
  7927. * @param effect The effect to bind to
  7928. * @param positiveUniform The positive uniform shader parameter
  7929. * @param neutralUniform The neutral uniform shader parameter
  7930. * @param negativeUniform The negative uniform shader parameter
  7931. */
  7932. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7933. /**
  7934. * Prepare the list of uniforms associated with the ColorCurves effects.
  7935. * @param uniformsList The list of uniforms used in the effect
  7936. */
  7937. static PrepareUniforms(uniformsList: string[]): void;
  7938. /**
  7939. * Returns color grading data based on a hue, density, saturation and exposure value.
  7940. * @param filterHue The hue of the color filter.
  7941. * @param filterDensity The density of the color filter.
  7942. * @param saturation The saturation.
  7943. * @param exposure The exposure.
  7944. * @param result The result data container.
  7945. */
  7946. private getColorGradingDataToRef;
  7947. /**
  7948. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7949. * @param value The input slider value in range [-100,100].
  7950. * @returns Adjusted value.
  7951. */
  7952. private static applyColorGradingSliderNonlinear;
  7953. /**
  7954. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7955. * @param hue The hue (H) input.
  7956. * @param saturation The saturation (S) input.
  7957. * @param brightness The brightness (B) input.
  7958. * @result An RGBA color represented as Vector4.
  7959. */
  7960. private static fromHSBToRef;
  7961. /**
  7962. * Returns a value clamped between min and max
  7963. * @param value The value to clamp
  7964. * @param min The minimum of value
  7965. * @param max The maximum of value
  7966. * @returns The clamped value.
  7967. */
  7968. private static clamp;
  7969. /**
  7970. * Clones the current color curve instance.
  7971. * @return The cloned curves
  7972. */
  7973. clone(): ColorCurves;
  7974. /**
  7975. * Serializes the current color curve instance to a json representation.
  7976. * @return a JSON representation
  7977. */
  7978. serialize(): any;
  7979. /**
  7980. * Parses the color curve from a json representation.
  7981. * @param source the JSON source to parse
  7982. * @return The parsed curves
  7983. */
  7984. static Parse(source: any): ColorCurves;
  7985. }
  7986. }
  7987. declare module BABYLON {
  7988. /**
  7989. * Interface to follow in your material defines to integrate easily the
  7990. * Image proccessing functions.
  7991. * @hidden
  7992. */
  7993. export interface IImageProcessingConfigurationDefines {
  7994. IMAGEPROCESSING: boolean;
  7995. VIGNETTE: boolean;
  7996. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7997. VIGNETTEBLENDMODEOPAQUE: boolean;
  7998. TONEMAPPING: boolean;
  7999. TONEMAPPING_ACES: boolean;
  8000. CONTRAST: boolean;
  8001. EXPOSURE: boolean;
  8002. COLORCURVES: boolean;
  8003. COLORGRADING: boolean;
  8004. COLORGRADING3D: boolean;
  8005. SAMPLER3DGREENDEPTH: boolean;
  8006. SAMPLER3DBGRMAP: boolean;
  8007. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8008. }
  8009. /**
  8010. * @hidden
  8011. */
  8012. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8013. IMAGEPROCESSING: boolean;
  8014. VIGNETTE: boolean;
  8015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8016. VIGNETTEBLENDMODEOPAQUE: boolean;
  8017. TONEMAPPING: boolean;
  8018. TONEMAPPING_ACES: boolean;
  8019. CONTRAST: boolean;
  8020. COLORCURVES: boolean;
  8021. COLORGRADING: boolean;
  8022. COLORGRADING3D: boolean;
  8023. SAMPLER3DGREENDEPTH: boolean;
  8024. SAMPLER3DBGRMAP: boolean;
  8025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8026. EXPOSURE: boolean;
  8027. constructor();
  8028. }
  8029. /**
  8030. * This groups together the common properties used for image processing either in direct forward pass
  8031. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8032. * or not.
  8033. */
  8034. export class ImageProcessingConfiguration {
  8035. /**
  8036. * Default tone mapping applied in BabylonJS.
  8037. */
  8038. static readonly TONEMAPPING_STANDARD: number;
  8039. /**
  8040. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8041. * to other engines rendering to increase portability.
  8042. */
  8043. static readonly TONEMAPPING_ACES: number;
  8044. /**
  8045. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8046. */
  8047. colorCurves: Nullable<ColorCurves>;
  8048. private _colorCurvesEnabled;
  8049. /**
  8050. * Gets wether the color curves effect is enabled.
  8051. */
  8052. /**
  8053. * Sets wether the color curves effect is enabled.
  8054. */
  8055. colorCurvesEnabled: boolean;
  8056. private _colorGradingTexture;
  8057. /**
  8058. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8059. */
  8060. /**
  8061. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8062. */
  8063. colorGradingTexture: Nullable<BaseTexture>;
  8064. private _colorGradingEnabled;
  8065. /**
  8066. * Gets wether the color grading effect is enabled.
  8067. */
  8068. /**
  8069. * Sets wether the color grading effect is enabled.
  8070. */
  8071. colorGradingEnabled: boolean;
  8072. private _colorGradingWithGreenDepth;
  8073. /**
  8074. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8075. */
  8076. /**
  8077. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8078. */
  8079. colorGradingWithGreenDepth: boolean;
  8080. private _colorGradingBGR;
  8081. /**
  8082. * Gets wether the color grading texture contains BGR values.
  8083. */
  8084. /**
  8085. * Sets wether the color grading texture contains BGR values.
  8086. */
  8087. colorGradingBGR: boolean;
  8088. /** @hidden */
  8089. _exposure: number;
  8090. /**
  8091. * Gets the Exposure used in the effect.
  8092. */
  8093. /**
  8094. * Sets the Exposure used in the effect.
  8095. */
  8096. exposure: number;
  8097. private _toneMappingEnabled;
  8098. /**
  8099. * Gets wether the tone mapping effect is enabled.
  8100. */
  8101. /**
  8102. * Sets wether the tone mapping effect is enabled.
  8103. */
  8104. toneMappingEnabled: boolean;
  8105. private _toneMappingType;
  8106. /**
  8107. * Gets the type of tone mapping effect.
  8108. */
  8109. /**
  8110. * Sets the type of tone mapping effect used in BabylonJS.
  8111. */
  8112. toneMappingType: number;
  8113. protected _contrast: number;
  8114. /**
  8115. * Gets the contrast used in the effect.
  8116. */
  8117. /**
  8118. * Sets the contrast used in the effect.
  8119. */
  8120. contrast: number;
  8121. /**
  8122. * Vignette stretch size.
  8123. */
  8124. vignetteStretch: number;
  8125. /**
  8126. * Vignette centre X Offset.
  8127. */
  8128. vignetteCentreX: number;
  8129. /**
  8130. * Vignette centre Y Offset.
  8131. */
  8132. vignetteCentreY: number;
  8133. /**
  8134. * Vignette weight or intensity of the vignette effect.
  8135. */
  8136. vignetteWeight: number;
  8137. /**
  8138. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8139. * if vignetteEnabled is set to true.
  8140. */
  8141. vignetteColor: Color4;
  8142. /**
  8143. * Camera field of view used by the Vignette effect.
  8144. */
  8145. vignetteCameraFov: number;
  8146. private _vignetteBlendMode;
  8147. /**
  8148. * Gets the vignette blend mode allowing different kind of effect.
  8149. */
  8150. /**
  8151. * Sets the vignette blend mode allowing different kind of effect.
  8152. */
  8153. vignetteBlendMode: number;
  8154. private _vignetteEnabled;
  8155. /**
  8156. * Gets wether the vignette effect is enabled.
  8157. */
  8158. /**
  8159. * Sets wether the vignette effect is enabled.
  8160. */
  8161. vignetteEnabled: boolean;
  8162. private _applyByPostProcess;
  8163. /**
  8164. * Gets wether the image processing is applied through a post process or not.
  8165. */
  8166. /**
  8167. * Sets wether the image processing is applied through a post process or not.
  8168. */
  8169. applyByPostProcess: boolean;
  8170. private _isEnabled;
  8171. /**
  8172. * Gets wether the image processing is enabled or not.
  8173. */
  8174. /**
  8175. * Sets wether the image processing is enabled or not.
  8176. */
  8177. isEnabled: boolean;
  8178. /**
  8179. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8180. */
  8181. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8182. /**
  8183. * Method called each time the image processing information changes requires to recompile the effect.
  8184. */
  8185. protected _updateParameters(): void;
  8186. /**
  8187. * Gets the current class name.
  8188. * @return "ImageProcessingConfiguration"
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * Prepare the list of uniforms associated with the Image Processing effects.
  8193. * @param uniforms The list of uniforms used in the effect
  8194. * @param defines the list of defines currently in use
  8195. */
  8196. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8197. /**
  8198. * Prepare the list of samplers associated with the Image Processing effects.
  8199. * @param samplersList The list of uniforms used in the effect
  8200. * @param defines the list of defines currently in use
  8201. */
  8202. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8203. /**
  8204. * Prepare the list of defines associated to the shader.
  8205. * @param defines the list of defines to complete
  8206. * @param forPostProcess Define if we are currently in post process mode or not
  8207. */
  8208. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8209. /**
  8210. * Returns true if all the image processing information are ready.
  8211. * @returns True if ready, otherwise, false
  8212. */
  8213. isReady(): boolean;
  8214. /**
  8215. * Binds the image processing to the shader.
  8216. * @param effect The effect to bind to
  8217. * @param overrideAspectRatio Override the aspect ratio of the effect
  8218. */
  8219. bind(effect: Effect, overrideAspectRatio?: number): void;
  8220. /**
  8221. * Clones the current image processing instance.
  8222. * @return The cloned image processing
  8223. */
  8224. clone(): ImageProcessingConfiguration;
  8225. /**
  8226. * Serializes the current image processing instance to a json representation.
  8227. * @return a JSON representation
  8228. */
  8229. serialize(): any;
  8230. /**
  8231. * Parses the image processing from a json representation.
  8232. * @param source the JSON source to parse
  8233. * @return The parsed image processing
  8234. */
  8235. static Parse(source: any): ImageProcessingConfiguration;
  8236. private static _VIGNETTEMODE_MULTIPLY;
  8237. private static _VIGNETTEMODE_OPAQUE;
  8238. /**
  8239. * Used to apply the vignette as a mix with the pixel color.
  8240. */
  8241. static readonly VIGNETTEMODE_MULTIPLY: number;
  8242. /**
  8243. * Used to apply the vignette as a replacement of the pixel color.
  8244. */
  8245. static readonly VIGNETTEMODE_OPAQUE: number;
  8246. }
  8247. }
  8248. declare module BABYLON {
  8249. /** @hidden */
  8250. export var postprocessVertexShader: {
  8251. name: string;
  8252. shader: string;
  8253. };
  8254. }
  8255. declare module BABYLON {
  8256. interface ThinEngine {
  8257. /**
  8258. * Creates a new render target texture
  8259. * @param size defines the size of the texture
  8260. * @param options defines the options used to create the texture
  8261. * @returns a new render target texture stored in an InternalTexture
  8262. */
  8263. createRenderTargetTexture(size: number | {
  8264. width: number;
  8265. height: number;
  8266. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8267. /**
  8268. * Creates a depth stencil texture.
  8269. * This is only available in WebGL 2 or with the depth texture extension available.
  8270. * @param size The size of face edge in the texture.
  8271. * @param options The options defining the texture.
  8272. * @returns The texture
  8273. */
  8274. createDepthStencilTexture(size: number | {
  8275. width: number;
  8276. height: number;
  8277. }, options: DepthTextureCreationOptions): InternalTexture;
  8278. /** @hidden */
  8279. _createDepthStencilTexture(size: number | {
  8280. width: number;
  8281. height: number;
  8282. }, options: DepthTextureCreationOptions): InternalTexture;
  8283. }
  8284. }
  8285. declare module BABYLON {
  8286. /** Defines supported spaces */
  8287. export enum Space {
  8288. /** Local (object) space */
  8289. LOCAL = 0,
  8290. /** World space */
  8291. WORLD = 1,
  8292. /** Bone space */
  8293. BONE = 2
  8294. }
  8295. /** Defines the 3 main axes */
  8296. export class Axis {
  8297. /** X axis */
  8298. static X: Vector3;
  8299. /** Y axis */
  8300. static Y: Vector3;
  8301. /** Z axis */
  8302. static Z: Vector3;
  8303. }
  8304. }
  8305. declare module BABYLON {
  8306. /**
  8307. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8308. * This is the base of the follow, arc rotate cameras and Free camera
  8309. * @see http://doc.babylonjs.com/features/cameras
  8310. */
  8311. export class TargetCamera extends Camera {
  8312. private static _RigCamTransformMatrix;
  8313. private static _TargetTransformMatrix;
  8314. private static _TargetFocalPoint;
  8315. /**
  8316. * Define the current direction the camera is moving to
  8317. */
  8318. cameraDirection: Vector3;
  8319. /**
  8320. * Define the current rotation the camera is rotating to
  8321. */
  8322. cameraRotation: Vector2;
  8323. /**
  8324. * When set, the up vector of the camera will be updated by the rotation of the camera
  8325. */
  8326. updateUpVectorFromRotation: boolean;
  8327. private _tmpQuaternion;
  8328. /**
  8329. * Define the current rotation of the camera
  8330. */
  8331. rotation: Vector3;
  8332. /**
  8333. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8334. */
  8335. rotationQuaternion: Quaternion;
  8336. /**
  8337. * Define the current speed of the camera
  8338. */
  8339. speed: number;
  8340. /**
  8341. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8342. * around all axis.
  8343. */
  8344. noRotationConstraint: boolean;
  8345. /**
  8346. * Define the current target of the camera as an object or a position.
  8347. */
  8348. lockedTarget: any;
  8349. /** @hidden */
  8350. _currentTarget: Vector3;
  8351. /** @hidden */
  8352. _initialFocalDistance: number;
  8353. /** @hidden */
  8354. _viewMatrix: Matrix;
  8355. /** @hidden */
  8356. _camMatrix: Matrix;
  8357. /** @hidden */
  8358. _cameraTransformMatrix: Matrix;
  8359. /** @hidden */
  8360. _cameraRotationMatrix: Matrix;
  8361. /** @hidden */
  8362. _referencePoint: Vector3;
  8363. /** @hidden */
  8364. _transformedReferencePoint: Vector3;
  8365. protected _globalCurrentTarget: Vector3;
  8366. protected _globalCurrentUpVector: Vector3;
  8367. /** @hidden */
  8368. _reset: () => void;
  8369. private _defaultUp;
  8370. /**
  8371. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8372. * This is the base of the follow, arc rotate cameras and Free camera
  8373. * @see http://doc.babylonjs.com/features/cameras
  8374. * @param name Defines the name of the camera in the scene
  8375. * @param position Defines the start position of the camera in the scene
  8376. * @param scene Defines the scene the camera belongs to
  8377. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8378. */
  8379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8380. /**
  8381. * Gets the position in front of the camera at a given distance.
  8382. * @param distance The distance from the camera we want the position to be
  8383. * @returns the position
  8384. */
  8385. getFrontPosition(distance: number): Vector3;
  8386. /** @hidden */
  8387. _getLockedTargetPosition(): Nullable<Vector3>;
  8388. private _storedPosition;
  8389. private _storedRotation;
  8390. private _storedRotationQuaternion;
  8391. /**
  8392. * Store current camera state of the camera (fov, position, rotation, etc..)
  8393. * @returns the camera
  8394. */
  8395. storeState(): Camera;
  8396. /**
  8397. * Restored camera state. You must call storeState() first
  8398. * @returns whether it was successful or not
  8399. * @hidden
  8400. */
  8401. _restoreStateValues(): boolean;
  8402. /** @hidden */
  8403. _initCache(): void;
  8404. /** @hidden */
  8405. _updateCache(ignoreParentClass?: boolean): void;
  8406. /** @hidden */
  8407. _isSynchronizedViewMatrix(): boolean;
  8408. /** @hidden */
  8409. _computeLocalCameraSpeed(): number;
  8410. /**
  8411. * Defines the target the camera should look at.
  8412. * @param target Defines the new target as a Vector or a mesh
  8413. */
  8414. setTarget(target: Vector3): void;
  8415. /**
  8416. * Return the current target position of the camera. This value is expressed in local space.
  8417. * @returns the target position
  8418. */
  8419. getTarget(): Vector3;
  8420. /** @hidden */
  8421. _decideIfNeedsToMove(): boolean;
  8422. /** @hidden */
  8423. _updatePosition(): void;
  8424. /** @hidden */
  8425. _checkInputs(): void;
  8426. protected _updateCameraRotationMatrix(): void;
  8427. /**
  8428. * 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)
  8429. * @returns the current camera
  8430. */
  8431. private _rotateUpVectorWithCameraRotationMatrix;
  8432. private _cachedRotationZ;
  8433. private _cachedQuaternionRotationZ;
  8434. /** @hidden */
  8435. _getViewMatrix(): Matrix;
  8436. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8437. /**
  8438. * @hidden
  8439. */
  8440. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8441. /**
  8442. * @hidden
  8443. */
  8444. _updateRigCameras(): void;
  8445. private _getRigCamPositionAndTarget;
  8446. /**
  8447. * Gets the current object class name.
  8448. * @return the class name
  8449. */
  8450. getClassName(): string;
  8451. }
  8452. }
  8453. declare module BABYLON {
  8454. /**
  8455. * Gather the list of keyboard event types as constants.
  8456. */
  8457. export class KeyboardEventTypes {
  8458. /**
  8459. * The keydown event is fired when a key becomes active (pressed).
  8460. */
  8461. static readonly KEYDOWN: number;
  8462. /**
  8463. * The keyup event is fired when a key has been released.
  8464. */
  8465. static readonly KEYUP: number;
  8466. }
  8467. /**
  8468. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8469. */
  8470. export class KeyboardInfo {
  8471. /**
  8472. * Defines the type of event (KeyboardEventTypes)
  8473. */
  8474. type: number;
  8475. /**
  8476. * Defines the related dom event
  8477. */
  8478. event: KeyboardEvent;
  8479. /**
  8480. * Instantiates a new keyboard info.
  8481. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8482. * @param type Defines the type of event (KeyboardEventTypes)
  8483. * @param event Defines the related dom event
  8484. */
  8485. constructor(
  8486. /**
  8487. * Defines the type of event (KeyboardEventTypes)
  8488. */
  8489. type: number,
  8490. /**
  8491. * Defines the related dom event
  8492. */
  8493. event: KeyboardEvent);
  8494. }
  8495. /**
  8496. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8497. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8498. */
  8499. export class KeyboardInfoPre extends KeyboardInfo {
  8500. /**
  8501. * Defines the type of event (KeyboardEventTypes)
  8502. */
  8503. type: number;
  8504. /**
  8505. * Defines the related dom event
  8506. */
  8507. event: KeyboardEvent;
  8508. /**
  8509. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8510. */
  8511. skipOnPointerObservable: boolean;
  8512. /**
  8513. * Instantiates a new keyboard pre info.
  8514. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8515. * @param type Defines the type of event (KeyboardEventTypes)
  8516. * @param event Defines the related dom event
  8517. */
  8518. constructor(
  8519. /**
  8520. * Defines the type of event (KeyboardEventTypes)
  8521. */
  8522. type: number,
  8523. /**
  8524. * Defines the related dom event
  8525. */
  8526. event: KeyboardEvent);
  8527. }
  8528. }
  8529. declare module BABYLON {
  8530. /**
  8531. * Manage the keyboard inputs to control the movement of a free camera.
  8532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8533. */
  8534. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8535. /**
  8536. * Defines the camera the input is attached to.
  8537. */
  8538. camera: FreeCamera;
  8539. /**
  8540. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8541. */
  8542. keysUp: number[];
  8543. /**
  8544. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8545. */
  8546. keysDown: number[];
  8547. /**
  8548. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8549. */
  8550. keysLeft: number[];
  8551. /**
  8552. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8553. */
  8554. keysRight: number[];
  8555. private _keys;
  8556. private _onCanvasBlurObserver;
  8557. private _onKeyboardObserver;
  8558. private _engine;
  8559. private _scene;
  8560. /**
  8561. * Attach the input controls to a specific dom element to get the input from.
  8562. * @param element Defines the element the controls should be listened from
  8563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8564. */
  8565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8566. /**
  8567. * Detach the current controls from the specified dom element.
  8568. * @param element Defines the element to stop listening the inputs from
  8569. */
  8570. detachControl(element: Nullable<HTMLElement>): void;
  8571. /**
  8572. * Update the current camera state depending on the inputs that have been used this frame.
  8573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8574. */
  8575. checkInputs(): void;
  8576. /**
  8577. * Gets the class name of the current intput.
  8578. * @returns the class name
  8579. */
  8580. getClassName(): string;
  8581. /** @hidden */
  8582. _onLostFocus(): void;
  8583. /**
  8584. * Get the friendly name associated with the input class.
  8585. * @returns the input friendly name
  8586. */
  8587. getSimpleName(): string;
  8588. }
  8589. }
  8590. declare module BABYLON {
  8591. /**
  8592. * Interface describing all the common properties and methods a shadow light needs to implement.
  8593. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8594. * as well as binding the different shadow properties to the effects.
  8595. */
  8596. export interface IShadowLight extends Light {
  8597. /**
  8598. * The light id in the scene (used in scene.findLighById for instance)
  8599. */
  8600. id: string;
  8601. /**
  8602. * The position the shdow will be casted from.
  8603. */
  8604. position: Vector3;
  8605. /**
  8606. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8607. */
  8608. direction: Vector3;
  8609. /**
  8610. * The transformed position. Position of the light in world space taking parenting in account.
  8611. */
  8612. transformedPosition: Vector3;
  8613. /**
  8614. * The transformed direction. Direction of the light in world space taking parenting in account.
  8615. */
  8616. transformedDirection: Vector3;
  8617. /**
  8618. * The friendly name of the light in the scene.
  8619. */
  8620. name: string;
  8621. /**
  8622. * Defines the shadow projection clipping minimum z value.
  8623. */
  8624. shadowMinZ: number;
  8625. /**
  8626. * Defines the shadow projection clipping maximum z value.
  8627. */
  8628. shadowMaxZ: number;
  8629. /**
  8630. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8631. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8632. */
  8633. computeTransformedInformation(): boolean;
  8634. /**
  8635. * Gets the scene the light belongs to.
  8636. * @returns The scene
  8637. */
  8638. getScene(): Scene;
  8639. /**
  8640. * Callback defining a custom Projection Matrix Builder.
  8641. * This can be used to override the default projection matrix computation.
  8642. */
  8643. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8644. /**
  8645. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8646. * @param matrix The materix to updated with the projection information
  8647. * @param viewMatrix The transform matrix of the light
  8648. * @param renderList The list of mesh to render in the map
  8649. * @returns The current light
  8650. */
  8651. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8652. /**
  8653. * Gets the current depth scale used in ESM.
  8654. * @returns The scale
  8655. */
  8656. getDepthScale(): number;
  8657. /**
  8658. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8659. * @returns true if a cube texture needs to be use
  8660. */
  8661. needCube(): boolean;
  8662. /**
  8663. * Detects if the projection matrix requires to be recomputed this frame.
  8664. * @returns true if it requires to be recomputed otherwise, false.
  8665. */
  8666. needProjectionMatrixCompute(): boolean;
  8667. /**
  8668. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8669. */
  8670. forceProjectionMatrixCompute(): void;
  8671. /**
  8672. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8673. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8674. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8675. */
  8676. getShadowDirection(faceIndex?: number): Vector3;
  8677. /**
  8678. * Gets the minZ used for shadow according to both the scene and the light.
  8679. * @param activeCamera The camera we are returning the min for
  8680. * @returns the depth min z
  8681. */
  8682. getDepthMinZ(activeCamera: Camera): number;
  8683. /**
  8684. * Gets the maxZ used for shadow according to both the scene and the light.
  8685. * @param activeCamera The camera we are returning the max for
  8686. * @returns the depth max z
  8687. */
  8688. getDepthMaxZ(activeCamera: Camera): number;
  8689. }
  8690. /**
  8691. * Base implementation IShadowLight
  8692. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8693. */
  8694. export abstract class ShadowLight extends Light implements IShadowLight {
  8695. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8696. protected _position: Vector3;
  8697. protected _setPosition(value: Vector3): void;
  8698. /**
  8699. * Sets the position the shadow will be casted from. Also use as the light position for both
  8700. * point and spot lights.
  8701. */
  8702. /**
  8703. * Sets the position the shadow will be casted from. Also use as the light position for both
  8704. * point and spot lights.
  8705. */
  8706. position: Vector3;
  8707. protected _direction: Vector3;
  8708. protected _setDirection(value: Vector3): void;
  8709. /**
  8710. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8711. * Also use as the light direction on spot and directional lights.
  8712. */
  8713. /**
  8714. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8715. * Also use as the light direction on spot and directional lights.
  8716. */
  8717. direction: Vector3;
  8718. private _shadowMinZ;
  8719. /**
  8720. * Gets the shadow projection clipping minimum z value.
  8721. */
  8722. /**
  8723. * Sets the shadow projection clipping minimum z value.
  8724. */
  8725. shadowMinZ: number;
  8726. private _shadowMaxZ;
  8727. /**
  8728. * Sets the shadow projection clipping maximum z value.
  8729. */
  8730. /**
  8731. * Gets the shadow projection clipping maximum z value.
  8732. */
  8733. shadowMaxZ: number;
  8734. /**
  8735. * Callback defining a custom Projection Matrix Builder.
  8736. * This can be used to override the default projection matrix computation.
  8737. */
  8738. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8739. /**
  8740. * The transformed position. Position of the light in world space taking parenting in account.
  8741. */
  8742. transformedPosition: Vector3;
  8743. /**
  8744. * The transformed direction. Direction of the light in world space taking parenting in account.
  8745. */
  8746. transformedDirection: Vector3;
  8747. private _needProjectionMatrixCompute;
  8748. /**
  8749. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8750. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8751. */
  8752. computeTransformedInformation(): boolean;
  8753. /**
  8754. * Return the depth scale used for the shadow map.
  8755. * @returns the depth scale.
  8756. */
  8757. getDepthScale(): number;
  8758. /**
  8759. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8760. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8761. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8762. */
  8763. getShadowDirection(faceIndex?: number): Vector3;
  8764. /**
  8765. * Returns the ShadowLight absolute position in the World.
  8766. * @returns the position vector in world space
  8767. */
  8768. getAbsolutePosition(): Vector3;
  8769. /**
  8770. * Sets the ShadowLight direction toward the passed target.
  8771. * @param target The point to target in local space
  8772. * @returns the updated ShadowLight direction
  8773. */
  8774. setDirectionToTarget(target: Vector3): Vector3;
  8775. /**
  8776. * Returns the light rotation in euler definition.
  8777. * @returns the x y z rotation in local space.
  8778. */
  8779. getRotation(): Vector3;
  8780. /**
  8781. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8782. * @returns true if a cube texture needs to be use
  8783. */
  8784. needCube(): boolean;
  8785. /**
  8786. * Detects if the projection matrix requires to be recomputed this frame.
  8787. * @returns true if it requires to be recomputed otherwise, false.
  8788. */
  8789. needProjectionMatrixCompute(): boolean;
  8790. /**
  8791. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8792. */
  8793. forceProjectionMatrixCompute(): void;
  8794. /** @hidden */
  8795. _initCache(): void;
  8796. /** @hidden */
  8797. _isSynchronized(): boolean;
  8798. /**
  8799. * Computes the world matrix of the node
  8800. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8801. * @returns the world matrix
  8802. */
  8803. computeWorldMatrix(force?: boolean): Matrix;
  8804. /**
  8805. * Gets the minZ used for shadow according to both the scene and the light.
  8806. * @param activeCamera The camera we are returning the min for
  8807. * @returns the depth min z
  8808. */
  8809. getDepthMinZ(activeCamera: Camera): number;
  8810. /**
  8811. * Gets the maxZ used for shadow according to both the scene and the light.
  8812. * @param activeCamera The camera we are returning the max for
  8813. * @returns the depth max z
  8814. */
  8815. getDepthMaxZ(activeCamera: Camera): number;
  8816. /**
  8817. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8818. * @param matrix The materix to updated with the projection information
  8819. * @param viewMatrix The transform matrix of the light
  8820. * @param renderList The list of mesh to render in the map
  8821. * @returns The current light
  8822. */
  8823. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8824. }
  8825. }
  8826. declare module BABYLON {
  8827. /**
  8828. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8829. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8830. */
  8831. export class EffectFallbacks implements IEffectFallbacks {
  8832. private _defines;
  8833. private _currentRank;
  8834. private _maxRank;
  8835. private _mesh;
  8836. /**
  8837. * Removes the fallback from the bound mesh.
  8838. */
  8839. unBindMesh(): void;
  8840. /**
  8841. * Adds a fallback on the specified property.
  8842. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8843. * @param define The name of the define in the shader
  8844. */
  8845. addFallback(rank: number, define: string): void;
  8846. /**
  8847. * Sets the mesh to use CPU skinning when needing to fallback.
  8848. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8849. * @param mesh The mesh to use the fallbacks.
  8850. */
  8851. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8852. /**
  8853. * Checks to see if more fallbacks are still availible.
  8854. */
  8855. readonly hasMoreFallbacks: boolean;
  8856. /**
  8857. * Removes the defines that should be removed when falling back.
  8858. * @param currentDefines defines the current define statements for the shader.
  8859. * @param effect defines the current effect we try to compile
  8860. * @returns The resulting defines with defines of the current rank removed.
  8861. */
  8862. reduce(currentDefines: string, effect: Effect): string;
  8863. }
  8864. }
  8865. declare module BABYLON {
  8866. /**
  8867. * "Static Class" containing the most commonly used helper while dealing with material for
  8868. * rendering purpose.
  8869. *
  8870. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8871. *
  8872. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8873. */
  8874. export class MaterialHelper {
  8875. /**
  8876. * Bind the current view position to an effect.
  8877. * @param effect The effect to be bound
  8878. * @param scene The scene the eyes position is used from
  8879. */
  8880. static BindEyePosition(effect: Effect, scene: Scene): void;
  8881. /**
  8882. * Helps preparing the defines values about the UVs in used in the effect.
  8883. * UVs are shared as much as we can accross channels in the shaders.
  8884. * @param texture The texture we are preparing the UVs for
  8885. * @param defines The defines to update
  8886. * @param key The channel key "diffuse", "specular"... used in the shader
  8887. */
  8888. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8889. /**
  8890. * Binds a texture matrix value to its corrsponding uniform
  8891. * @param texture The texture to bind the matrix for
  8892. * @param uniformBuffer The uniform buffer receivin the data
  8893. * @param key The channel key "diffuse", "specular"... used in the shader
  8894. */
  8895. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8896. /**
  8897. * Gets the current status of the fog (should it be enabled?)
  8898. * @param mesh defines the mesh to evaluate for fog support
  8899. * @param scene defines the hosting scene
  8900. * @returns true if fog must be enabled
  8901. */
  8902. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8903. /**
  8904. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8905. * @param mesh defines the current mesh
  8906. * @param scene defines the current scene
  8907. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8908. * @param pointsCloud defines if point cloud rendering has to be turned on
  8909. * @param fogEnabled defines if fog has to be turned on
  8910. * @param alphaTest defines if alpha testing has to be turned on
  8911. * @param defines defines the current list of defines
  8912. */
  8913. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8914. /**
  8915. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8916. * @param scene defines the current scene
  8917. * @param engine defines the current engine
  8918. * @param defines specifies the list of active defines
  8919. * @param useInstances defines if instances have to be turned on
  8920. * @param useClipPlane defines if clip plane have to be turned on
  8921. */
  8922. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8923. /**
  8924. * Prepares the defines for bones
  8925. * @param mesh The mesh containing the geometry data we will draw
  8926. * @param defines The defines to update
  8927. */
  8928. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8929. /**
  8930. * Prepares the defines for morph targets
  8931. * @param mesh The mesh containing the geometry data we will draw
  8932. * @param defines The defines to update
  8933. */
  8934. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8935. /**
  8936. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8937. * @param mesh The mesh containing the geometry data we will draw
  8938. * @param defines The defines to update
  8939. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8940. * @param useBones Precise whether bones should be used or not (override mesh info)
  8941. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8942. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8943. * @returns false if defines are considered not dirty and have not been checked
  8944. */
  8945. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8946. /**
  8947. * Prepares the defines related to multiview
  8948. * @param scene The scene we are intending to draw
  8949. * @param defines The defines to update
  8950. */
  8951. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8952. /**
  8953. * Prepares the defines related to the light information passed in parameter
  8954. * @param scene The scene we are intending to draw
  8955. * @param mesh The mesh the effect is compiling for
  8956. * @param light The light the effect is compiling for
  8957. * @param lightIndex The index of the light
  8958. * @param defines The defines to update
  8959. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8960. * @param state Defines the current state regarding what is needed (normals, etc...)
  8961. */
  8962. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8963. needNormals: boolean;
  8964. needRebuild: boolean;
  8965. shadowEnabled: boolean;
  8966. specularEnabled: boolean;
  8967. lightmapMode: boolean;
  8968. }): void;
  8969. /**
  8970. * Prepares the defines related to the light information passed in parameter
  8971. * @param scene The scene we are intending to draw
  8972. * @param mesh The mesh the effect is compiling for
  8973. * @param defines The defines to update
  8974. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8975. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8976. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8977. * @returns true if normals will be required for the rest of the effect
  8978. */
  8979. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8980. /**
  8981. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8982. * @param lightIndex defines the light index
  8983. * @param uniformsList The uniform list
  8984. * @param samplersList The sampler list
  8985. * @param projectedLightTexture defines if projected texture must be used
  8986. * @param uniformBuffersList defines an optional list of uniform buffers
  8987. */
  8988. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect
  8991. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8992. * @param samplersList The sampler list
  8993. * @param defines The defines helping in the list generation
  8994. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8995. */
  8996. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8997. /**
  8998. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8999. * @param defines The defines to update while falling back
  9000. * @param fallbacks The authorized effect fallbacks
  9001. * @param maxSimultaneousLights The maximum number of lights allowed
  9002. * @param rank the current rank of the Effect
  9003. * @returns The newly affected rank
  9004. */
  9005. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9006. private static _TmpMorphInfluencers;
  9007. /**
  9008. * Prepares the list of attributes required for morph targets according to the effect defines.
  9009. * @param attribs The current list of supported attribs
  9010. * @param mesh The mesh to prepare the morph targets attributes for
  9011. * @param influencers The number of influencers
  9012. */
  9013. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9014. /**
  9015. * Prepares the list of attributes required for morph targets according to the effect defines.
  9016. * @param attribs The current list of supported attribs
  9017. * @param mesh The mesh to prepare the morph targets attributes for
  9018. * @param defines The current Defines of the effect
  9019. */
  9020. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9021. /**
  9022. * Prepares the list of attributes required for bones according to the effect defines.
  9023. * @param attribs The current list of supported attribs
  9024. * @param mesh The mesh to prepare the bones attributes for
  9025. * @param defines The current Defines of the effect
  9026. * @param fallbacks The current efffect fallback strategy
  9027. */
  9028. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9029. /**
  9030. * Check and prepare the list of attributes required for instances according to the effect defines.
  9031. * @param attribs The current list of supported attribs
  9032. * @param defines The current MaterialDefines of the effect
  9033. */
  9034. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9035. /**
  9036. * Add the list of attributes required for instances to the attribs array.
  9037. * @param attribs The current list of supported attribs
  9038. */
  9039. static PushAttributesForInstances(attribs: string[]): void;
  9040. /**
  9041. * Binds the light information to the effect.
  9042. * @param light The light containing the generator
  9043. * @param effect The effect we are binding the data to
  9044. * @param lightIndex The light index in the effect used to render
  9045. */
  9046. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9047. /**
  9048. * Binds the lights information from the scene to the effect for the given mesh.
  9049. * @param light Light to bind
  9050. * @param lightIndex Light index
  9051. * @param scene The scene where the light belongs to
  9052. * @param effect The effect we are binding the data to
  9053. * @param useSpecular Defines if specular is supported
  9054. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9055. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9056. */
  9057. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9058. /**
  9059. * Binds the lights information from the scene to the effect for the given mesh.
  9060. * @param scene The scene the lights belongs to
  9061. * @param mesh The mesh we are binding the information to render
  9062. * @param effect The effect we are binding the data to
  9063. * @param defines The generated defines for the effect
  9064. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9067. */
  9068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9069. private static _tempFogColor;
  9070. /**
  9071. * Binds the fog information from the scene to the effect for the given mesh.
  9072. * @param scene The scene the lights belongs to
  9073. * @param mesh The mesh we are binding the information to render
  9074. * @param effect The effect we are binding the data to
  9075. * @param linearSpace Defines if the fog effect is applied in linear space
  9076. */
  9077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9078. /**
  9079. * Binds the bones information from the mesh to the effect.
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. */
  9083. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9084. /**
  9085. * Binds the morph targets information from the mesh to the effect.
  9086. * @param abstractMesh The mesh we are binding the information to render
  9087. * @param effect The effect we are binding the data to
  9088. */
  9089. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9090. /**
  9091. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9092. * @param defines The generated defines used in the effect
  9093. * @param effect The effect we are binding the data to
  9094. * @param scene The scene we are willing to render with logarithmic scale for
  9095. */
  9096. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9097. /**
  9098. * Binds the clip plane information from the scene to the effect.
  9099. * @param scene The scene the clip plane information are extracted from
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindClipPlane(effect: Effect, scene: Scene): void;
  9103. }
  9104. }
  9105. declare module BABYLON {
  9106. /** @hidden */
  9107. export var packingFunctions: {
  9108. name: string;
  9109. shader: string;
  9110. };
  9111. }
  9112. declare module BABYLON {
  9113. /** @hidden */
  9114. export var shadowMapPixelShader: {
  9115. name: string;
  9116. shader: string;
  9117. };
  9118. }
  9119. declare module BABYLON {
  9120. /** @hidden */
  9121. export var bonesDeclaration: {
  9122. name: string;
  9123. shader: string;
  9124. };
  9125. }
  9126. declare module BABYLON {
  9127. /** @hidden */
  9128. export var morphTargetsVertexGlobalDeclaration: {
  9129. name: string;
  9130. shader: string;
  9131. };
  9132. }
  9133. declare module BABYLON {
  9134. /** @hidden */
  9135. export var morphTargetsVertexDeclaration: {
  9136. name: string;
  9137. shader: string;
  9138. };
  9139. }
  9140. declare module BABYLON {
  9141. /** @hidden */
  9142. export var instancesDeclaration: {
  9143. name: string;
  9144. shader: string;
  9145. };
  9146. }
  9147. declare module BABYLON {
  9148. /** @hidden */
  9149. export var helperFunctions: {
  9150. name: string;
  9151. shader: string;
  9152. };
  9153. }
  9154. declare module BABYLON {
  9155. /** @hidden */
  9156. export var morphTargetsVertex: {
  9157. name: string;
  9158. shader: string;
  9159. };
  9160. }
  9161. declare module BABYLON {
  9162. /** @hidden */
  9163. export var instancesVertex: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module BABYLON {
  9169. /** @hidden */
  9170. export var bonesVertex: {
  9171. name: string;
  9172. shader: string;
  9173. };
  9174. }
  9175. declare module BABYLON {
  9176. /** @hidden */
  9177. export var shadowMapVertexShader: {
  9178. name: string;
  9179. shader: string;
  9180. };
  9181. }
  9182. declare module BABYLON {
  9183. /** @hidden */
  9184. export var depthBoxBlurPixelShader: {
  9185. name: string;
  9186. shader: string;
  9187. };
  9188. }
  9189. declare module BABYLON {
  9190. /**
  9191. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9192. */
  9193. export interface ICustomShaderOptions {
  9194. /**
  9195. * Gets or sets the custom shader name to use
  9196. */
  9197. shaderName: string;
  9198. /**
  9199. * The list of attribute names used in the shader
  9200. */
  9201. attributes?: string[];
  9202. /**
  9203. * The list of unifrom names used in the shader
  9204. */
  9205. uniforms?: string[];
  9206. /**
  9207. * The list of sampler names used in the shader
  9208. */
  9209. samplers?: string[];
  9210. /**
  9211. * The list of defines used in the shader
  9212. */
  9213. defines?: string[];
  9214. }
  9215. /**
  9216. * Interface to implement to create a shadow generator compatible with BJS.
  9217. */
  9218. export interface IShadowGenerator {
  9219. /**
  9220. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9221. * @returns The render target texture if present otherwise, null
  9222. */
  9223. getShadowMap(): Nullable<RenderTargetTexture>;
  9224. /**
  9225. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9226. * @returns The render target texture if the shadow map is present otherwise, null
  9227. */
  9228. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9229. /**
  9230. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9231. * @param subMesh The submesh we want to render in the shadow map
  9232. * @param useInstances Defines wether will draw in the map using instances
  9233. * @returns true if ready otherwise, false
  9234. */
  9235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9236. /**
  9237. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9238. * @param defines Defines of the material we want to update
  9239. * @param lightIndex Index of the light in the enabled light list of the material
  9240. */
  9241. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9242. /**
  9243. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9244. * defined in the generator but impacting the effect).
  9245. * It implies the unifroms available on the materials are the standard BJS ones.
  9246. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9247. * @param effect The effect we are binfing the information for
  9248. */
  9249. bindShadowLight(lightIndex: string, effect: Effect): void;
  9250. /**
  9251. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9252. * (eq to shadow prjection matrix * light transform matrix)
  9253. * @returns The transform matrix used to create the shadow map
  9254. */
  9255. getTransformMatrix(): Matrix;
  9256. /**
  9257. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9258. * Cube and 2D textures for instance.
  9259. */
  9260. recreateShadowMap(): void;
  9261. /**
  9262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9263. * @param onCompiled Callback triggered at the and of the effects compilation
  9264. * @param options Sets of optional options forcing the compilation with different modes
  9265. */
  9266. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9267. useInstances: boolean;
  9268. }>): void;
  9269. /**
  9270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9271. * @param options Sets of optional options forcing the compilation with different modes
  9272. * @returns A promise that resolves when the compilation completes
  9273. */
  9274. forceCompilationAsync(options?: Partial<{
  9275. useInstances: boolean;
  9276. }>): Promise<void>;
  9277. /**
  9278. * Serializes the shadow generator setup to a json object.
  9279. * @returns The serialized JSON object
  9280. */
  9281. serialize(): any;
  9282. /**
  9283. * Disposes the Shadow map and related Textures and effects.
  9284. */
  9285. dispose(): void;
  9286. }
  9287. /**
  9288. * Default implementation IShadowGenerator.
  9289. * This is the main object responsible of generating shadows in the framework.
  9290. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9291. */
  9292. export class ShadowGenerator implements IShadowGenerator {
  9293. /**
  9294. * Shadow generator mode None: no filtering applied.
  9295. */
  9296. static readonly FILTER_NONE: number;
  9297. /**
  9298. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9299. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9300. */
  9301. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9302. /**
  9303. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9304. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9305. */
  9306. static readonly FILTER_POISSONSAMPLING: number;
  9307. /**
  9308. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9309. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9310. */
  9311. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9312. /**
  9313. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9314. * edge artifacts on steep falloff.
  9315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9316. */
  9317. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9318. /**
  9319. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9320. * edge artifacts on steep falloff.
  9321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9322. */
  9323. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9324. /**
  9325. * Shadow generator mode PCF: Percentage Closer Filtering
  9326. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9327. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9328. */
  9329. static readonly FILTER_PCF: number;
  9330. /**
  9331. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9333. * Contact Hardening
  9334. */
  9335. static readonly FILTER_PCSS: number;
  9336. /**
  9337. * Reserved for PCF and PCSS
  9338. * Highest Quality.
  9339. *
  9340. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9341. *
  9342. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9343. */
  9344. static readonly QUALITY_HIGH: number;
  9345. /**
  9346. * Reserved for PCF and PCSS
  9347. * Good tradeoff for quality/perf cross devices
  9348. *
  9349. * Execute PCF on a 3*3 kernel.
  9350. *
  9351. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9352. */
  9353. static readonly QUALITY_MEDIUM: number;
  9354. /**
  9355. * Reserved for PCF and PCSS
  9356. * The lowest quality but the fastest.
  9357. *
  9358. * Execute PCF on a 1*1 kernel.
  9359. *
  9360. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9361. */
  9362. static readonly QUALITY_LOW: number;
  9363. /** Gets or sets the custom shader name to use */
  9364. customShaderOptions: ICustomShaderOptions;
  9365. /**
  9366. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9367. */
  9368. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9369. /**
  9370. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9371. */
  9372. onAfterShadowMapRenderObservable: Observable<Effect>;
  9373. /**
  9374. * Observable triggered before a mesh is rendered in the shadow map.
  9375. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9376. */
  9377. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9378. /**
  9379. * Observable triggered after a mesh is rendered in the shadow map.
  9380. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9381. */
  9382. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9383. private _bias;
  9384. /**
  9385. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9386. */
  9387. /**
  9388. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9389. */
  9390. bias: number;
  9391. private _normalBias;
  9392. /**
  9393. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9394. */
  9395. /**
  9396. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9397. */
  9398. normalBias: number;
  9399. private _blurBoxOffset;
  9400. /**
  9401. * Gets the blur box offset: offset applied during the blur pass.
  9402. * Only useful if useKernelBlur = false
  9403. */
  9404. /**
  9405. * Sets the blur box offset: offset applied during the blur pass.
  9406. * Only useful if useKernelBlur = false
  9407. */
  9408. blurBoxOffset: number;
  9409. private _blurScale;
  9410. /**
  9411. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9412. * 2 means half of the size.
  9413. */
  9414. /**
  9415. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9416. * 2 means half of the size.
  9417. */
  9418. blurScale: number;
  9419. private _blurKernel;
  9420. /**
  9421. * Gets the blur kernel: kernel size of the blur pass.
  9422. * Only useful if useKernelBlur = true
  9423. */
  9424. /**
  9425. * Sets the blur kernel: kernel size of the blur pass.
  9426. * Only useful if useKernelBlur = true
  9427. */
  9428. blurKernel: number;
  9429. private _useKernelBlur;
  9430. /**
  9431. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9432. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9433. */
  9434. /**
  9435. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9436. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9437. */
  9438. useKernelBlur: boolean;
  9439. private _depthScale;
  9440. /**
  9441. * Gets the depth scale used in ESM mode.
  9442. */
  9443. /**
  9444. * Sets the depth scale used in ESM mode.
  9445. * This can override the scale stored on the light.
  9446. */
  9447. depthScale: number;
  9448. private _filter;
  9449. /**
  9450. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9451. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9452. */
  9453. /**
  9454. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9455. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9456. */
  9457. filter: number;
  9458. /**
  9459. * Gets if the current filter is set to Poisson Sampling.
  9460. */
  9461. /**
  9462. * Sets the current filter to Poisson Sampling.
  9463. */
  9464. usePoissonSampling: boolean;
  9465. /**
  9466. * Gets if the current filter is set to ESM.
  9467. */
  9468. /**
  9469. * Sets the current filter is to ESM.
  9470. */
  9471. useExponentialShadowMap: boolean;
  9472. /**
  9473. * Gets if the current filter is set to filtered ESM.
  9474. */
  9475. /**
  9476. * Gets if the current filter is set to filtered ESM.
  9477. */
  9478. useBlurExponentialShadowMap: boolean;
  9479. /**
  9480. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9481. * exponential to prevent steep falloff artifacts).
  9482. */
  9483. /**
  9484. * Sets the current filter to "close ESM" (using the inverse of the
  9485. * exponential to prevent steep falloff artifacts).
  9486. */
  9487. useCloseExponentialShadowMap: boolean;
  9488. /**
  9489. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9490. * exponential to prevent steep falloff artifacts).
  9491. */
  9492. /**
  9493. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9494. * exponential to prevent steep falloff artifacts).
  9495. */
  9496. useBlurCloseExponentialShadowMap: boolean;
  9497. /**
  9498. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9499. */
  9500. /**
  9501. * Sets the current filter to "PCF" (percentage closer filtering).
  9502. */
  9503. usePercentageCloserFiltering: boolean;
  9504. private _filteringQuality;
  9505. /**
  9506. * Gets the PCF or PCSS Quality.
  9507. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9508. */
  9509. /**
  9510. * Sets the PCF or PCSS Quality.
  9511. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9512. */
  9513. filteringQuality: number;
  9514. /**
  9515. * Gets if the current filter is set to "PCSS" (contact hardening).
  9516. */
  9517. /**
  9518. * Sets the current filter to "PCSS" (contact hardening).
  9519. */
  9520. useContactHardeningShadow: boolean;
  9521. private _contactHardeningLightSizeUVRatio;
  9522. /**
  9523. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9524. * Using a ratio helps keeping shape stability independently of the map size.
  9525. *
  9526. * It does not account for the light projection as it was having too much
  9527. * instability during the light setup or during light position changes.
  9528. *
  9529. * Only valid if useContactHardeningShadow is true.
  9530. */
  9531. /**
  9532. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9533. * Using a ratio helps keeping shape stability independently of the map size.
  9534. *
  9535. * It does not account for the light projection as it was having too much
  9536. * instability during the light setup or during light position changes.
  9537. *
  9538. * Only valid if useContactHardeningShadow is true.
  9539. */
  9540. contactHardeningLightSizeUVRatio: number;
  9541. private _darkness;
  9542. /** Gets or sets the actual darkness of a shadow */
  9543. darkness: number;
  9544. /**
  9545. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9546. * 0 means strongest and 1 would means no shadow.
  9547. * @returns the darkness.
  9548. */
  9549. getDarkness(): number;
  9550. /**
  9551. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9552. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9553. * @returns the shadow generator allowing fluent coding.
  9554. */
  9555. setDarkness(darkness: number): ShadowGenerator;
  9556. private _transparencyShadow;
  9557. /** Gets or sets the ability to have transparent shadow */
  9558. transparencyShadow: boolean;
  9559. /**
  9560. * Sets the ability to have transparent shadow (boolean).
  9561. * @param transparent True if transparent else False
  9562. * @returns the shadow generator allowing fluent coding
  9563. */
  9564. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9565. private _shadowMap;
  9566. private _shadowMap2;
  9567. /**
  9568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9569. * @returns The render target texture if present otherwise, null
  9570. */
  9571. getShadowMap(): Nullable<RenderTargetTexture>;
  9572. /**
  9573. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9574. * @returns The render target texture if the shadow map is present otherwise, null
  9575. */
  9576. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9577. /**
  9578. * Gets the class name of that object
  9579. * @returns "ShadowGenerator"
  9580. */
  9581. getClassName(): string;
  9582. /**
  9583. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9584. * @param mesh Mesh to add
  9585. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9586. * @returns the Shadow Generator itself
  9587. */
  9588. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9589. /**
  9590. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9591. * @param mesh Mesh to remove
  9592. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9593. * @returns the Shadow Generator itself
  9594. */
  9595. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9596. /**
  9597. * Controls the extent to which the shadows fade out at the edge of the frustum
  9598. * Used only by directionals and spots
  9599. */
  9600. frustumEdgeFalloff: number;
  9601. private _light;
  9602. /**
  9603. * Returns the associated light object.
  9604. * @returns the light generating the shadow
  9605. */
  9606. getLight(): IShadowLight;
  9607. /**
  9608. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9609. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9610. * It might on the other hand introduce peter panning.
  9611. */
  9612. forceBackFacesOnly: boolean;
  9613. private _scene;
  9614. private _lightDirection;
  9615. private _effect;
  9616. private _viewMatrix;
  9617. private _projectionMatrix;
  9618. private _transformMatrix;
  9619. private _cachedPosition;
  9620. private _cachedDirection;
  9621. private _cachedDefines;
  9622. private _currentRenderID;
  9623. private _boxBlurPostprocess;
  9624. private _kernelBlurXPostprocess;
  9625. private _kernelBlurYPostprocess;
  9626. private _blurPostProcesses;
  9627. private _mapSize;
  9628. private _currentFaceIndex;
  9629. private _currentFaceIndexCache;
  9630. private _textureType;
  9631. private _defaultTextureMatrix;
  9632. private _storedUniqueId;
  9633. /** @hidden */
  9634. static _SceneComponentInitialization: (scene: Scene) => void;
  9635. /**
  9636. * Creates a ShadowGenerator object.
  9637. * A ShadowGenerator is the required tool to use the shadows.
  9638. * Each light casting shadows needs to use its own ShadowGenerator.
  9639. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9640. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9641. * @param light The light object generating the shadows.
  9642. * @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.
  9643. */
  9644. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9645. private _initializeGenerator;
  9646. private _initializeShadowMap;
  9647. private _initializeBlurRTTAndPostProcesses;
  9648. private _renderForShadowMap;
  9649. private _renderSubMeshForShadowMap;
  9650. private _applyFilterValues;
  9651. /**
  9652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9653. * @param onCompiled Callback triggered at the and of the effects compilation
  9654. * @param options Sets of optional options forcing the compilation with different modes
  9655. */
  9656. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9657. useInstances: boolean;
  9658. }>): void;
  9659. /**
  9660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9661. * @param options Sets of optional options forcing the compilation with different modes
  9662. * @returns A promise that resolves when the compilation completes
  9663. */
  9664. forceCompilationAsync(options?: Partial<{
  9665. useInstances: boolean;
  9666. }>): Promise<void>;
  9667. /**
  9668. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9669. * @param subMesh The submesh we want to render in the shadow map
  9670. * @param useInstances Defines wether will draw in the map using instances
  9671. * @returns true if ready otherwise, false
  9672. */
  9673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9674. /**
  9675. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9676. * @param defines Defines of the material we want to update
  9677. * @param lightIndex Index of the light in the enabled light list of the material
  9678. */
  9679. prepareDefines(defines: any, lightIndex: number): void;
  9680. /**
  9681. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9682. * defined in the generator but impacting the effect).
  9683. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9684. * @param effect The effect we are binfing the information for
  9685. */
  9686. bindShadowLight(lightIndex: string, effect: Effect): void;
  9687. /**
  9688. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9689. * (eq to shadow prjection matrix * light transform matrix)
  9690. * @returns The transform matrix used to create the shadow map
  9691. */
  9692. getTransformMatrix(): Matrix;
  9693. /**
  9694. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9695. * Cube and 2D textures for instance.
  9696. */
  9697. recreateShadowMap(): void;
  9698. private _disposeBlurPostProcesses;
  9699. private _disposeRTTandPostProcesses;
  9700. /**
  9701. * Disposes the ShadowGenerator.
  9702. * Returns nothing.
  9703. */
  9704. dispose(): void;
  9705. /**
  9706. * Serializes the shadow generator setup to a json object.
  9707. * @returns The serialized JSON object
  9708. */
  9709. serialize(): any;
  9710. /**
  9711. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9712. * @param parsedShadowGenerator The JSON object to parse
  9713. * @param scene The scene to create the shadow map for
  9714. * @returns The parsed shadow generator
  9715. */
  9716. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9717. }
  9718. }
  9719. declare module BABYLON {
  9720. /**
  9721. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9722. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9723. * 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.
  9724. */
  9725. export abstract class Light extends Node {
  9726. /**
  9727. * Falloff Default: light is falling off following the material specification:
  9728. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9729. */
  9730. static readonly FALLOFF_DEFAULT: number;
  9731. /**
  9732. * Falloff Physical: light is falling off following the inverse squared distance law.
  9733. */
  9734. static readonly FALLOFF_PHYSICAL: number;
  9735. /**
  9736. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9737. * to enhance interoperability with other engines.
  9738. */
  9739. static readonly FALLOFF_GLTF: number;
  9740. /**
  9741. * Falloff Standard: light is falling off like in the standard material
  9742. * to enhance interoperability with other materials.
  9743. */
  9744. static readonly FALLOFF_STANDARD: number;
  9745. /**
  9746. * If every light affecting the material is in this lightmapMode,
  9747. * material.lightmapTexture adds or multiplies
  9748. * (depends on material.useLightmapAsShadowmap)
  9749. * after every other light calculations.
  9750. */
  9751. static readonly LIGHTMAP_DEFAULT: number;
  9752. /**
  9753. * material.lightmapTexture as only diffuse lighting from this light
  9754. * adds only specular lighting from this light
  9755. * adds dynamic shadows
  9756. */
  9757. static readonly LIGHTMAP_SPECULAR: number;
  9758. /**
  9759. * material.lightmapTexture as only lighting
  9760. * no light calculation from this light
  9761. * only adds dynamic shadows from this light
  9762. */
  9763. static readonly LIGHTMAP_SHADOWSONLY: number;
  9764. /**
  9765. * Each light type uses the default quantity according to its type:
  9766. * point/spot lights use luminous intensity
  9767. * directional lights use illuminance
  9768. */
  9769. static readonly INTENSITYMODE_AUTOMATIC: number;
  9770. /**
  9771. * lumen (lm)
  9772. */
  9773. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9774. /**
  9775. * candela (lm/sr)
  9776. */
  9777. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9778. /**
  9779. * lux (lm/m^2)
  9780. */
  9781. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9782. /**
  9783. * nit (cd/m^2)
  9784. */
  9785. static readonly INTENSITYMODE_LUMINANCE: number;
  9786. /**
  9787. * Light type const id of the point light.
  9788. */
  9789. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9790. /**
  9791. * Light type const id of the directional light.
  9792. */
  9793. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9794. /**
  9795. * Light type const id of the spot light.
  9796. */
  9797. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9798. /**
  9799. * Light type const id of the hemispheric light.
  9800. */
  9801. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9802. /**
  9803. * Diffuse gives the basic color to an object.
  9804. */
  9805. diffuse: Color3;
  9806. /**
  9807. * Specular produces a highlight color on an object.
  9808. * Note: This is note affecting PBR materials.
  9809. */
  9810. specular: Color3;
  9811. /**
  9812. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9813. * falling off base on range or angle.
  9814. * This can be set to any values in Light.FALLOFF_x.
  9815. *
  9816. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9817. * other types of materials.
  9818. */
  9819. falloffType: number;
  9820. /**
  9821. * Strength of the light.
  9822. * Note: By default it is define in the framework own unit.
  9823. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9824. */
  9825. intensity: number;
  9826. private _range;
  9827. protected _inverseSquaredRange: number;
  9828. /**
  9829. * Defines how far from the source the light is impacting in scene units.
  9830. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9831. */
  9832. /**
  9833. * Defines how far from the source the light is impacting in scene units.
  9834. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9835. */
  9836. range: number;
  9837. /**
  9838. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9839. * of light.
  9840. */
  9841. private _photometricScale;
  9842. private _intensityMode;
  9843. /**
  9844. * Gets the photometric scale used to interpret the intensity.
  9845. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9846. */
  9847. /**
  9848. * Sets the photometric scale used to interpret the intensity.
  9849. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9850. */
  9851. intensityMode: number;
  9852. private _radius;
  9853. /**
  9854. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9855. */
  9856. /**
  9857. * sets the light radius used by PBR Materials to simulate soft area lights.
  9858. */
  9859. radius: number;
  9860. private _renderPriority;
  9861. /**
  9862. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9863. * exceeding the number allowed of the materials.
  9864. */
  9865. renderPriority: number;
  9866. private _shadowEnabled;
  9867. /**
  9868. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9869. * the current shadow generator.
  9870. */
  9871. /**
  9872. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9873. * the current shadow generator.
  9874. */
  9875. shadowEnabled: boolean;
  9876. private _includedOnlyMeshes;
  9877. /**
  9878. * Gets the only meshes impacted by this light.
  9879. */
  9880. /**
  9881. * Sets the only meshes impacted by this light.
  9882. */
  9883. includedOnlyMeshes: AbstractMesh[];
  9884. private _excludedMeshes;
  9885. /**
  9886. * Gets the meshes not impacted by this light.
  9887. */
  9888. /**
  9889. * Sets the meshes not impacted by this light.
  9890. */
  9891. excludedMeshes: AbstractMesh[];
  9892. private _excludeWithLayerMask;
  9893. /**
  9894. * Gets the layer id use to find what meshes are not impacted by the light.
  9895. * Inactive if 0
  9896. */
  9897. /**
  9898. * Sets the layer id use to find what meshes are not impacted by the light.
  9899. * Inactive if 0
  9900. */
  9901. excludeWithLayerMask: number;
  9902. private _includeOnlyWithLayerMask;
  9903. /**
  9904. * Gets the layer id use to find what meshes are impacted by the light.
  9905. * Inactive if 0
  9906. */
  9907. /**
  9908. * Sets the layer id use to find what meshes are impacted by the light.
  9909. * Inactive if 0
  9910. */
  9911. includeOnlyWithLayerMask: number;
  9912. private _lightmapMode;
  9913. /**
  9914. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9915. */
  9916. /**
  9917. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9918. */
  9919. lightmapMode: number;
  9920. /**
  9921. * Shadow generator associted to the light.
  9922. * @hidden Internal use only.
  9923. */
  9924. _shadowGenerator: Nullable<IShadowGenerator>;
  9925. /**
  9926. * @hidden Internal use only.
  9927. */
  9928. _excludedMeshesIds: string[];
  9929. /**
  9930. * @hidden Internal use only.
  9931. */
  9932. _includedOnlyMeshesIds: string[];
  9933. /**
  9934. * The current light unifom buffer.
  9935. * @hidden Internal use only.
  9936. */
  9937. _uniformBuffer: UniformBuffer;
  9938. /** @hidden */
  9939. _renderId: number;
  9940. /**
  9941. * Creates a Light object in the scene.
  9942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9943. * @param name The firendly name of the light
  9944. * @param scene The scene the light belongs too
  9945. */
  9946. constructor(name: string, scene: Scene);
  9947. protected abstract _buildUniformLayout(): void;
  9948. /**
  9949. * Sets the passed Effect "effect" with the Light information.
  9950. * @param effect The effect to update
  9951. * @param lightIndex The index of the light in the effect to update
  9952. * @returns The light
  9953. */
  9954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9955. /**
  9956. * Sets the passed Effect "effect" with the Light information.
  9957. * @param effect The effect to update
  9958. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9959. * @returns The light
  9960. */
  9961. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9962. /**
  9963. * Returns the string "Light".
  9964. * @returns the class name
  9965. */
  9966. getClassName(): string;
  9967. /** @hidden */
  9968. readonly _isLight: boolean;
  9969. /**
  9970. * Converts the light information to a readable string for debug purpose.
  9971. * @param fullDetails Supports for multiple levels of logging within scene loading
  9972. * @returns the human readable light info
  9973. */
  9974. toString(fullDetails?: boolean): string;
  9975. /** @hidden */
  9976. protected _syncParentEnabledState(): void;
  9977. /**
  9978. * Set the enabled state of this node.
  9979. * @param value - the new enabled state
  9980. */
  9981. setEnabled(value: boolean): void;
  9982. /**
  9983. * Returns the Light associated shadow generator if any.
  9984. * @return the associated shadow generator.
  9985. */
  9986. getShadowGenerator(): Nullable<IShadowGenerator>;
  9987. /**
  9988. * Returns a Vector3, the absolute light position in the World.
  9989. * @returns the world space position of the light
  9990. */
  9991. getAbsolutePosition(): Vector3;
  9992. /**
  9993. * Specifies if the light will affect the passed mesh.
  9994. * @param mesh The mesh to test against the light
  9995. * @return true the mesh is affected otherwise, false.
  9996. */
  9997. canAffectMesh(mesh: AbstractMesh): boolean;
  9998. /**
  9999. * Sort function to order lights for rendering.
  10000. * @param a First Light object to compare to second.
  10001. * @param b Second Light object to compare first.
  10002. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10003. */
  10004. static CompareLightsPriority(a: Light, b: Light): number;
  10005. /**
  10006. * Releases resources associated with this node.
  10007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10009. */
  10010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10011. /**
  10012. * Returns the light type ID (integer).
  10013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10014. */
  10015. getTypeID(): number;
  10016. /**
  10017. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10018. * @returns the scaled intensity in intensity mode unit
  10019. */
  10020. getScaledIntensity(): number;
  10021. /**
  10022. * Returns a new Light object, named "name", from the current one.
  10023. * @param name The name of the cloned light
  10024. * @returns the new created light
  10025. */
  10026. clone(name: string): Nullable<Light>;
  10027. /**
  10028. * Serializes the current light into a Serialization object.
  10029. * @returns the serialized object.
  10030. */
  10031. serialize(): any;
  10032. /**
  10033. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10034. * This new light is named "name" and added to the passed scene.
  10035. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10036. * @param name The friendly name of the light
  10037. * @param scene The scene the new light will belong to
  10038. * @returns the constructor function
  10039. */
  10040. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10041. /**
  10042. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10043. * @param parsedLight The JSON representation of the light
  10044. * @param scene The scene to create the parsed light in
  10045. * @returns the created light after parsing
  10046. */
  10047. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10048. private _hookArrayForExcluded;
  10049. private _hookArrayForIncludedOnly;
  10050. private _resyncMeshes;
  10051. /**
  10052. * Forces the meshes to update their light related information in their rendering used effects
  10053. * @hidden Internal Use Only
  10054. */
  10055. _markMeshesAsLightDirty(): void;
  10056. /**
  10057. * Recomputes the cached photometric scale if needed.
  10058. */
  10059. private _computePhotometricScale;
  10060. /**
  10061. * Returns the Photometric Scale according to the light type and intensity mode.
  10062. */
  10063. private _getPhotometricScale;
  10064. /**
  10065. * Reorder the light in the scene according to their defined priority.
  10066. * @hidden Internal Use Only
  10067. */
  10068. _reorderLightsInScene(): void;
  10069. /**
  10070. * Prepares the list of defines specific to the light type.
  10071. * @param defines the list of defines
  10072. * @param lightIndex defines the index of the light for the effect
  10073. */
  10074. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10075. }
  10076. }
  10077. declare module BABYLON {
  10078. /**
  10079. * Interface used to define Action
  10080. */
  10081. export interface IAction {
  10082. /**
  10083. * Trigger for the action
  10084. */
  10085. trigger: number;
  10086. /** Options of the trigger */
  10087. triggerOptions: any;
  10088. /**
  10089. * Gets the trigger parameters
  10090. * @returns the trigger parameters
  10091. */
  10092. getTriggerParameter(): any;
  10093. /**
  10094. * Internal only - executes current action event
  10095. * @hidden
  10096. */
  10097. _executeCurrent(evt?: ActionEvent): void;
  10098. /**
  10099. * Serialize placeholder for child classes
  10100. * @param parent of child
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. /**
  10105. * Internal only
  10106. * @hidden
  10107. */
  10108. _prepare(): void;
  10109. /**
  10110. * Internal only - manager for action
  10111. * @hidden
  10112. */
  10113. _actionManager: AbstractActionManager;
  10114. /**
  10115. * Adds action to chain of actions, may be a DoNothingAction
  10116. * @param action defines the next action to execute
  10117. * @returns The action passed in
  10118. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10119. */
  10120. then(action: IAction): IAction;
  10121. }
  10122. /**
  10123. * The action to be carried out following a trigger
  10124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10125. */
  10126. export class Action implements IAction {
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any;
  10129. /**
  10130. * Trigger for the action
  10131. */
  10132. trigger: number;
  10133. /**
  10134. * Internal only - manager for action
  10135. * @hidden
  10136. */
  10137. _actionManager: ActionManager;
  10138. private _nextActiveAction;
  10139. private _child;
  10140. private _condition?;
  10141. private _triggerParameter;
  10142. /**
  10143. * An event triggered prior to action being executed.
  10144. */
  10145. onBeforeExecuteObservable: Observable<Action>;
  10146. /**
  10147. * Creates a new Action
  10148. * @param triggerOptions the trigger, with or without parameters, for the action
  10149. * @param condition an optional determinant of action
  10150. */
  10151. constructor(
  10152. /** the trigger, with or without parameters, for the action */
  10153. triggerOptions: any, condition?: Condition);
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. _prepare(): void;
  10159. /**
  10160. * Gets the trigger parameters
  10161. * @returns the trigger parameters
  10162. */
  10163. getTriggerParameter(): any;
  10164. /**
  10165. * Internal only - executes current action event
  10166. * @hidden
  10167. */
  10168. _executeCurrent(evt?: ActionEvent): void;
  10169. /**
  10170. * Execute placeholder for child classes
  10171. * @param evt optional action event
  10172. */
  10173. execute(evt?: ActionEvent): void;
  10174. /**
  10175. * Skips to next active action
  10176. */
  10177. skipToNextActiveAction(): void;
  10178. /**
  10179. * Adds action to chain of actions, may be a DoNothingAction
  10180. * @param action defines the next action to execute
  10181. * @returns The action passed in
  10182. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10183. */
  10184. then(action: Action): Action;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. _getProperty(propertyPath: string): string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _getEffectiveTarget(target: any, propertyPath: string): any;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @param parent of child
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. /**
  10202. * Internal only called by serialize
  10203. * @hidden
  10204. */
  10205. protected _serialize(serializedAction: any, parent?: any): any;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. static _SerializeValueAsString: (value: any) => string;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. static _GetTargetProperty: (target: Node | Scene) => {
  10216. name: string;
  10217. targetType: string;
  10218. value: string;
  10219. };
  10220. }
  10221. }
  10222. declare module BABYLON {
  10223. /**
  10224. * A Condition applied to an Action
  10225. */
  10226. export class Condition {
  10227. /**
  10228. * Internal only - manager for action
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. _evaluationId: number;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. _currentResult: boolean;
  10242. /**
  10243. * Creates a new Condition
  10244. * @param actionManager the manager of the action the condition is applied to
  10245. */
  10246. constructor(actionManager: ActionManager);
  10247. /**
  10248. * Check if the current condition is valid
  10249. * @returns a boolean
  10250. */
  10251. isValid(): boolean;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. _getProperty(propertyPath: string): string;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _getEffectiveTarget(target: any, propertyPath: string): any;
  10262. /**
  10263. * Serialize placeholder for child classes
  10264. * @returns the serialized object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. protected _serialize(serializedCondition: any): any;
  10272. }
  10273. /**
  10274. * Defines specific conditional operators as extensions of Condition
  10275. */
  10276. export class ValueCondition extends Condition {
  10277. /** path to specify the property of the target the conditional operator uses */
  10278. propertyPath: string;
  10279. /** the value compared by the conditional operator against the current value of the property */
  10280. value: any;
  10281. /** the conditional operator, default ValueCondition.IsEqual */
  10282. operator: number;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private static _IsEqual;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. private static _IsDifferent;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. private static _IsGreater;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. private static _IsLesser;
  10303. /**
  10304. * returns the number for IsEqual
  10305. */
  10306. static readonly IsEqual: number;
  10307. /**
  10308. * Returns the number for IsDifferent
  10309. */
  10310. static readonly IsDifferent: number;
  10311. /**
  10312. * Returns the number for IsGreater
  10313. */
  10314. static readonly IsGreater: number;
  10315. /**
  10316. * Returns the number for IsLesser
  10317. */
  10318. static readonly IsLesser: number;
  10319. /**
  10320. * Internal only The action manager for the condition
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. private _target;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _effectiveTarget;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private _property;
  10339. /**
  10340. * Creates a new ValueCondition
  10341. * @param actionManager manager for the action the condition applies to
  10342. * @param target for the action
  10343. * @param propertyPath path to specify the property of the target the conditional operator uses
  10344. * @param value the value compared by the conditional operator against the current value of the property
  10345. * @param operator the conditional operator, default ValueCondition.IsEqual
  10346. */
  10347. constructor(actionManager: ActionManager, target: any,
  10348. /** path to specify the property of the target the conditional operator uses */
  10349. propertyPath: string,
  10350. /** the value compared by the conditional operator against the current value of the property */
  10351. value: any,
  10352. /** the conditional operator, default ValueCondition.IsEqual */
  10353. operator?: number);
  10354. /**
  10355. * Compares the given value with the property value for the specified conditional operator
  10356. * @returns the result of the comparison
  10357. */
  10358. isValid(): boolean;
  10359. /**
  10360. * Serialize the ValueCondition into a JSON compatible object
  10361. * @returns serialization object
  10362. */
  10363. serialize(): any;
  10364. /**
  10365. * Gets the name of the conditional operator for the ValueCondition
  10366. * @param operator the conditional operator
  10367. * @returns the name
  10368. */
  10369. static GetOperatorName(operator: number): string;
  10370. }
  10371. /**
  10372. * Defines a predicate condition as an extension of Condition
  10373. */
  10374. export class PredicateCondition extends Condition {
  10375. /** defines the predicate function used to validate the condition */
  10376. predicate: () => boolean;
  10377. /**
  10378. * Internal only - manager for action
  10379. * @hidden
  10380. */
  10381. _actionManager: ActionManager;
  10382. /**
  10383. * Creates a new PredicateCondition
  10384. * @param actionManager manager for the action the condition applies to
  10385. * @param predicate defines the predicate function used to validate the condition
  10386. */
  10387. constructor(actionManager: ActionManager,
  10388. /** defines the predicate function used to validate the condition */
  10389. predicate: () => boolean);
  10390. /**
  10391. * @returns the validity of the predicate condition
  10392. */
  10393. isValid(): boolean;
  10394. }
  10395. /**
  10396. * Defines a state condition as an extension of Condition
  10397. */
  10398. export class StateCondition extends Condition {
  10399. /** Value to compare with target state */
  10400. value: string;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: ActionManager;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private _target;
  10411. /**
  10412. * Creates a new StateCondition
  10413. * @param actionManager manager for the action the condition applies to
  10414. * @param target of the condition
  10415. * @param value to compare with target state
  10416. */
  10417. constructor(actionManager: ActionManager, target: any,
  10418. /** Value to compare with target state */
  10419. value: string);
  10420. /**
  10421. * Gets a boolean indicating if the current condition is met
  10422. * @returns the validity of the state
  10423. */
  10424. isValid(): boolean;
  10425. /**
  10426. * Serialize the StateCondition into a JSON compatible object
  10427. * @returns serialization object
  10428. */
  10429. serialize(): any;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * This defines an action responsible to toggle a boolean once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SwitchBooleanAction extends Action {
  10438. /**
  10439. * The path to the boolean property in the target object
  10440. */
  10441. propertyPath: string;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the boolean
  10449. * @param propertyPath defines the path to the boolean property in the target object
  10450. * @param condition defines the trigger related conditions
  10451. */
  10452. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10453. /** @hidden */
  10454. _prepare(): void;
  10455. /**
  10456. * Execute the action toggle the boolean value.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to set a the state field of the target
  10468. * to a desired value once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class SetStateAction extends Action {
  10472. /**
  10473. * The value to store in the state field.
  10474. */
  10475. value: string;
  10476. private _target;
  10477. /**
  10478. * Instantiate the action
  10479. * @param triggerOptions defines the trigger options
  10480. * @param target defines the object containing the state property
  10481. * @param value defines the value to store in the state field
  10482. * @param condition defines the trigger related conditions
  10483. */
  10484. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10485. /**
  10486. * Execute the action and store the value on the target state property.
  10487. */
  10488. execute(): void;
  10489. /**
  10490. * Serializes the actions and its related information.
  10491. * @param parent defines the object to serialize in
  10492. * @returns the serialized object
  10493. */
  10494. serialize(parent: any): any;
  10495. }
  10496. /**
  10497. * This defines an action responsible to set a property of the target
  10498. * to a desired value once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SetValueAction extends Action {
  10502. /**
  10503. * The path of the property to set in the target.
  10504. */
  10505. propertyPath: string;
  10506. /**
  10507. * The value to set in the property
  10508. */
  10509. value: any;
  10510. private _target;
  10511. private _effectiveTarget;
  10512. private _property;
  10513. /**
  10514. * Instantiate the action
  10515. * @param triggerOptions defines the trigger options
  10516. * @param target defines the object containing the property
  10517. * @param propertyPath defines the path of the property to set in the target
  10518. * @param value defines the value to set in the property
  10519. * @param condition defines the trigger related conditions
  10520. */
  10521. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10522. /** @hidden */
  10523. _prepare(): void;
  10524. /**
  10525. * Execute the action and set the targetted property to the desired value.
  10526. */
  10527. execute(): void;
  10528. /**
  10529. * Serializes the actions and its related information.
  10530. * @param parent defines the object to serialize in
  10531. * @returns the serialized object
  10532. */
  10533. serialize(parent: any): any;
  10534. }
  10535. /**
  10536. * This defines an action responsible to increment the target value
  10537. * to a desired value once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class IncrementValueAction extends Action {
  10541. /**
  10542. * The path of the property to increment in the target.
  10543. */
  10544. propertyPath: string;
  10545. /**
  10546. * The value we should increment the property by.
  10547. */
  10548. value: any;
  10549. private _target;
  10550. private _effectiveTarget;
  10551. private _property;
  10552. /**
  10553. * Instantiate the action
  10554. * @param triggerOptions defines the trigger options
  10555. * @param target defines the object containing the property
  10556. * @param propertyPath defines the path of the property to increment in the target
  10557. * @param value defines the value value we should increment the property by
  10558. * @param condition defines the trigger related conditions
  10559. */
  10560. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10561. /** @hidden */
  10562. _prepare(): void;
  10563. /**
  10564. * Execute the action and increment the target of the value amount.
  10565. */
  10566. execute(): void;
  10567. /**
  10568. * Serializes the actions and its related information.
  10569. * @param parent defines the object to serialize in
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. }
  10574. /**
  10575. * This defines an action responsible to start an animation once triggered.
  10576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10577. */
  10578. export class PlayAnimationAction extends Action {
  10579. /**
  10580. * Where the animation should start (animation frame)
  10581. */
  10582. from: number;
  10583. /**
  10584. * Where the animation should stop (animation frame)
  10585. */
  10586. to: number;
  10587. /**
  10588. * Define if the animation should loop or stop after the first play.
  10589. */
  10590. loop?: boolean;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the target animation or animation name
  10596. * @param from defines from where the animation should start (animation frame)
  10597. * @param end defines where the animation should stop (animation frame)
  10598. * @param loop defines if the animation should loop or stop after the first play
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and play the animation.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to stop an animation once triggered.
  10617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class StopAnimationAction extends Action {
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target animation or animation name
  10625. * @param condition defines the trigger related conditions
  10626. */
  10627. constructor(triggerOptions: any, target: any, condition?: Condition);
  10628. /** @hidden */
  10629. _prepare(): void;
  10630. /**
  10631. * Execute the action and stop the animation.
  10632. */
  10633. execute(): void;
  10634. /**
  10635. * Serializes the actions and its related information.
  10636. * @param parent defines the object to serialize in
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. }
  10641. /**
  10642. * This defines an action responsible that does nothing once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class DoNothingAction extends Action {
  10646. /**
  10647. * Instantiate the action
  10648. * @param triggerOptions defines the trigger options
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions?: any, condition?: Condition);
  10652. /**
  10653. * Execute the action and do nothing.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to trigger several actions once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class CombineAction extends Action {
  10668. /**
  10669. * The list of aggregated animations to run.
  10670. */
  10671. children: Action[];
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param children defines the list of aggregated animations to run
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action and executes all the aggregated actions.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to run code (external event) once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class ExecuteCodeAction extends Action {
  10697. /**
  10698. * The callback function to run.
  10699. */
  10700. func: (evt: ActionEvent) => void;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param func defines the callback function to run
  10705. * @param condition defines the trigger related conditions
  10706. */
  10707. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10708. /**
  10709. * Execute the action and run the attached code.
  10710. */
  10711. execute(evt: ActionEvent): void;
  10712. }
  10713. /**
  10714. * This defines an action responsible to set the parent property of the target once triggered.
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10716. */
  10717. export class SetParentAction extends Action {
  10718. private _parent;
  10719. private _target;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the target containing the parent property
  10724. * @param parent defines from where the animation should start (animation frame)
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and set the parent property.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. }
  10742. declare module BABYLON {
  10743. /**
  10744. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10745. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class ActionManager extends AbstractActionManager {
  10749. /**
  10750. * Nothing
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly NothingTrigger: number;
  10754. /**
  10755. * On pick
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnPickTrigger: number;
  10759. /**
  10760. * On left pick
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnLeftPickTrigger: number;
  10764. /**
  10765. * On right pick
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10767. */
  10768. static readonly OnRightPickTrigger: number;
  10769. /**
  10770. * On center pick
  10771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnCenterPickTrigger: number;
  10774. /**
  10775. * On pick down
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnPickDownTrigger: number;
  10779. /**
  10780. * On double pick
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnDoublePickTrigger: number;
  10784. /**
  10785. * On pick up
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPickUpTrigger: number;
  10789. /**
  10790. * On pick out.
  10791. * This trigger will only be raised if you also declared a OnPickDown
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10793. */
  10794. static readonly OnPickOutTrigger: number;
  10795. /**
  10796. * On long press
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly OnLongPressTrigger: number;
  10800. /**
  10801. * On pointer over
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPointerOverTrigger: number;
  10805. /**
  10806. * On pointer out
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPointerOutTrigger: number;
  10810. /**
  10811. * On every frame
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnEveryFrameTrigger: number;
  10815. /**
  10816. * On intersection enter
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnIntersectionEnterTrigger: number;
  10820. /**
  10821. * On intersection exit
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnIntersectionExitTrigger: number;
  10825. /**
  10826. * On key down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnKeyDownTrigger: number;
  10830. /**
  10831. * On key up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnKeyUpTrigger: number;
  10835. private _scene;
  10836. /**
  10837. * Creates a new action manager
  10838. * @param scene defines the hosting scene
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Releases all associated resources
  10843. */
  10844. dispose(): void;
  10845. /**
  10846. * Gets hosting scene
  10847. * @returns the hosting scene
  10848. */
  10849. getScene(): Scene;
  10850. /**
  10851. * Does this action manager handles actions of any of the given triggers
  10852. * @param triggers defines the triggers to be tested
  10853. * @return a boolean indicating whether one (or more) of the triggers is handled
  10854. */
  10855. hasSpecificTriggers(triggers: number[]): boolean;
  10856. /**
  10857. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10858. * speed.
  10859. * @param triggerA defines the trigger to be tested
  10860. * @param triggerB defines the trigger to be tested
  10861. * @return a boolean indicating whether one (or more) of the triggers is handled
  10862. */
  10863. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10864. /**
  10865. * Does this action manager handles actions of a given trigger
  10866. * @param trigger defines the trigger to be tested
  10867. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10868. * @return whether the trigger is handled
  10869. */
  10870. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10871. /**
  10872. * Does this action manager has pointer triggers
  10873. */
  10874. readonly hasPointerTriggers: boolean;
  10875. /**
  10876. * Does this action manager has pick triggers
  10877. */
  10878. readonly hasPickTriggers: boolean;
  10879. /**
  10880. * Registers an action to this action manager
  10881. * @param action defines the action to be registered
  10882. * @return the action amended (prepared) after registration
  10883. */
  10884. registerAction(action: IAction): Nullable<IAction>;
  10885. /**
  10886. * Unregisters an action to this action manager
  10887. * @param action defines the action to be unregistered
  10888. * @return a boolean indicating whether the action has been unregistered
  10889. */
  10890. unregisterAction(action: IAction): Boolean;
  10891. /**
  10892. * Process a specific trigger
  10893. * @param trigger defines the trigger to process
  10894. * @param evt defines the event details to be processed
  10895. */
  10896. processTrigger(trigger: number, evt?: IActionEvent): void;
  10897. /** @hidden */
  10898. _getEffectiveTarget(target: any, propertyPath: string): any;
  10899. /** @hidden */
  10900. _getProperty(propertyPath: string): string;
  10901. /**
  10902. * Serialize this manager to a JSON object
  10903. * @param name defines the property name to store this manager
  10904. * @returns a JSON representation of this manager
  10905. */
  10906. serialize(name: string): any;
  10907. /**
  10908. * Creates a new ActionManager from a JSON data
  10909. * @param parsedActions defines the JSON data to read from
  10910. * @param object defines the hosting mesh
  10911. * @param scene defines the hosting scene
  10912. */
  10913. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10914. /**
  10915. * Get a trigger name by index
  10916. * @param trigger defines the trigger index
  10917. * @returns a trigger name
  10918. */
  10919. static GetTriggerName(trigger: number): string;
  10920. }
  10921. }
  10922. declare module BABYLON {
  10923. /**
  10924. * Class representing a ray with position and direction
  10925. */
  10926. export class Ray {
  10927. /** origin point */
  10928. origin: Vector3;
  10929. /** direction */
  10930. direction: Vector3;
  10931. /** length of the ray */
  10932. length: number;
  10933. private static readonly TmpVector3;
  10934. private _tmpRay;
  10935. /**
  10936. * Creates a new ray
  10937. * @param origin origin point
  10938. * @param direction direction
  10939. * @param length length of the ray
  10940. */
  10941. constructor(
  10942. /** origin point */
  10943. origin: Vector3,
  10944. /** direction */
  10945. direction: Vector3,
  10946. /** length of the ray */
  10947. length?: number);
  10948. /**
  10949. * Checks if the ray intersects a box
  10950. * @param minimum bound of the box
  10951. * @param maximum bound of the box
  10952. * @param intersectionTreshold extra extend to be added to the box in all direction
  10953. * @returns if the box was hit
  10954. */
  10955. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10956. /**
  10957. * Checks if the ray intersects a box
  10958. * @param box the bounding box to check
  10959. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10960. * @returns if the box was hit
  10961. */
  10962. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10963. /**
  10964. * If the ray hits a sphere
  10965. * @param sphere the bounding sphere to check
  10966. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10967. * @returns true if it hits the sphere
  10968. */
  10969. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10970. /**
  10971. * If the ray hits a triange
  10972. * @param vertex0 triangle vertex
  10973. * @param vertex1 triangle vertex
  10974. * @param vertex2 triangle vertex
  10975. * @returns intersection information if hit
  10976. */
  10977. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10978. /**
  10979. * Checks if ray intersects a plane
  10980. * @param plane the plane to check
  10981. * @returns the distance away it was hit
  10982. */
  10983. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10984. /**
  10985. * Calculate the intercept of a ray on a given axis
  10986. * @param axis to check 'x' | 'y' | 'z'
  10987. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10988. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10989. */
  10990. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10991. /**
  10992. * Checks if ray intersects a mesh
  10993. * @param mesh the mesh to check
  10994. * @param fastCheck if only the bounding box should checked
  10995. * @returns picking info of the intersecton
  10996. */
  10997. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10998. /**
  10999. * Checks if ray intersects a mesh
  11000. * @param meshes the meshes to check
  11001. * @param fastCheck if only the bounding box should checked
  11002. * @param results array to store result in
  11003. * @returns Array of picking infos
  11004. */
  11005. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11006. private _comparePickingInfo;
  11007. private static smallnum;
  11008. private static rayl;
  11009. /**
  11010. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11011. * @param sega the first point of the segment to test the intersection against
  11012. * @param segb the second point of the segment to test the intersection against
  11013. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11014. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11015. */
  11016. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11017. /**
  11018. * Update the ray from viewport position
  11019. * @param x position
  11020. * @param y y position
  11021. * @param viewportWidth viewport width
  11022. * @param viewportHeight viewport height
  11023. * @param world world matrix
  11024. * @param view view matrix
  11025. * @param projection projection matrix
  11026. * @returns this ray updated
  11027. */
  11028. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11029. /**
  11030. * Creates a ray with origin and direction of 0,0,0
  11031. * @returns the new ray
  11032. */
  11033. static Zero(): Ray;
  11034. /**
  11035. * Creates a new ray from screen space and viewport
  11036. * @param x position
  11037. * @param y y position
  11038. * @param viewportWidth viewport width
  11039. * @param viewportHeight viewport height
  11040. * @param world world matrix
  11041. * @param view view matrix
  11042. * @param projection projection matrix
  11043. * @returns new ray
  11044. */
  11045. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11046. /**
  11047. * 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
  11048. * transformed to the given world matrix.
  11049. * @param origin The origin point
  11050. * @param end The end point
  11051. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11052. * @returns the new ray
  11053. */
  11054. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11055. /**
  11056. * Transforms a ray by a matrix
  11057. * @param ray ray to transform
  11058. * @param matrix matrix to apply
  11059. * @returns the resulting new ray
  11060. */
  11061. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11062. /**
  11063. * Transforms a ray by a matrix
  11064. * @param ray ray to transform
  11065. * @param matrix matrix to apply
  11066. * @param result ray to store result in
  11067. */
  11068. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11069. /**
  11070. * Unproject a ray from screen space to object space
  11071. * @param sourceX defines the screen space x coordinate to use
  11072. * @param sourceY defines the screen space y coordinate to use
  11073. * @param viewportWidth defines the current width of the viewport
  11074. * @param viewportHeight defines the current height of the viewport
  11075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11076. * @param view defines the view matrix to use
  11077. * @param projection defines the projection matrix to use
  11078. */
  11079. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11080. }
  11081. /**
  11082. * Type used to define predicate used to select faces when a mesh intersection is detected
  11083. */
  11084. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11085. interface Scene {
  11086. /** @hidden */
  11087. _tempPickingRay: Nullable<Ray>;
  11088. /** @hidden */
  11089. _cachedRayForTransform: Ray;
  11090. /** @hidden */
  11091. _pickWithRayInverseMatrix: Matrix;
  11092. /** @hidden */
  11093. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11094. /** @hidden */
  11095. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11096. }
  11097. }
  11098. declare module BABYLON {
  11099. /**
  11100. * Groups all the scene component constants in one place to ease maintenance.
  11101. * @hidden
  11102. */
  11103. export class SceneComponentConstants {
  11104. static readonly NAME_EFFECTLAYER: string;
  11105. static readonly NAME_LAYER: string;
  11106. static readonly NAME_LENSFLARESYSTEM: string;
  11107. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11108. static readonly NAME_PARTICLESYSTEM: string;
  11109. static readonly NAME_GAMEPAD: string;
  11110. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11111. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11112. static readonly NAME_DEPTHRENDERER: string;
  11113. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11114. static readonly NAME_SPRITE: string;
  11115. static readonly NAME_OUTLINERENDERER: string;
  11116. static readonly NAME_PROCEDURALTEXTURE: string;
  11117. static readonly NAME_SHADOWGENERATOR: string;
  11118. static readonly NAME_OCTREE: string;
  11119. static readonly NAME_PHYSICSENGINE: string;
  11120. static readonly NAME_AUDIO: string;
  11121. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11122. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11123. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11125. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11126. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11127. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11128. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11129. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11130. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11131. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11132. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11133. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11134. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11135. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11136. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11137. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11138. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11139. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11140. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11141. static readonly STEP_AFTERRENDER_AUDIO: number;
  11142. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11143. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11144. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11145. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11146. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11147. static readonly STEP_POINTERMOVE_SPRITE: number;
  11148. static readonly STEP_POINTERDOWN_SPRITE: number;
  11149. static readonly STEP_POINTERUP_SPRITE: number;
  11150. }
  11151. /**
  11152. * This represents a scene component.
  11153. *
  11154. * This is used to decouple the dependency the scene is having on the different workloads like
  11155. * layers, post processes...
  11156. */
  11157. export interface ISceneComponent {
  11158. /**
  11159. * The name of the component. Each component must have a unique name.
  11160. */
  11161. name: string;
  11162. /**
  11163. * The scene the component belongs to.
  11164. */
  11165. scene: Scene;
  11166. /**
  11167. * Register the component to one instance of a scene.
  11168. */
  11169. register(): void;
  11170. /**
  11171. * Rebuilds the elements related to this component in case of
  11172. * context lost for instance.
  11173. */
  11174. rebuild(): void;
  11175. /**
  11176. * Disposes the component and the associated ressources.
  11177. */
  11178. dispose(): void;
  11179. }
  11180. /**
  11181. * This represents a SERIALIZABLE scene component.
  11182. *
  11183. * This extends Scene Component to add Serialization methods on top.
  11184. */
  11185. export interface ISceneSerializableComponent extends ISceneComponent {
  11186. /**
  11187. * Adds all the elements from the container to the scene
  11188. * @param container the container holding the elements
  11189. */
  11190. addFromContainer(container: AbstractScene): void;
  11191. /**
  11192. * Removes all the elements in the container from the scene
  11193. * @param container contains the elements to remove
  11194. * @param dispose if the removed element should be disposed (default: false)
  11195. */
  11196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11197. /**
  11198. * Serializes the component data to the specified json object
  11199. * @param serializationObject The object to serialize to
  11200. */
  11201. serialize(serializationObject: any): void;
  11202. }
  11203. /**
  11204. * Strong typing of a Mesh related stage step action
  11205. */
  11206. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11207. /**
  11208. * Strong typing of a Evaluate Sub Mesh related stage step action
  11209. */
  11210. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11211. /**
  11212. * Strong typing of a Active Mesh related stage step action
  11213. */
  11214. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11215. /**
  11216. * Strong typing of a Camera related stage step action
  11217. */
  11218. export type CameraStageAction = (camera: Camera) => void;
  11219. /**
  11220. * Strong typing of a Camera Frame buffer related stage step action
  11221. */
  11222. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11223. /**
  11224. * Strong typing of a Render Target related stage step action
  11225. */
  11226. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11227. /**
  11228. * Strong typing of a RenderingGroup related stage step action
  11229. */
  11230. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11231. /**
  11232. * Strong typing of a Mesh Render related stage step action
  11233. */
  11234. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11235. /**
  11236. * Strong typing of a simple stage step action
  11237. */
  11238. export type SimpleStageAction = () => void;
  11239. /**
  11240. * Strong typing of a render target action.
  11241. */
  11242. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11243. /**
  11244. * Strong typing of a pointer move action.
  11245. */
  11246. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11247. /**
  11248. * Strong typing of a pointer up/down action.
  11249. */
  11250. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11251. /**
  11252. * Representation of a stage in the scene (Basically a list of ordered steps)
  11253. * @hidden
  11254. */
  11255. export class Stage<T extends Function> extends Array<{
  11256. index: number;
  11257. component: ISceneComponent;
  11258. action: T;
  11259. }> {
  11260. /**
  11261. * Hide ctor from the rest of the world.
  11262. * @param items The items to add.
  11263. */
  11264. private constructor();
  11265. /**
  11266. * Creates a new Stage.
  11267. * @returns A new instance of a Stage
  11268. */
  11269. static Create<T extends Function>(): Stage<T>;
  11270. /**
  11271. * Registers a step in an ordered way in the targeted stage.
  11272. * @param index Defines the position to register the step in
  11273. * @param component Defines the component attached to the step
  11274. * @param action Defines the action to launch during the step
  11275. */
  11276. registerStep(index: number, component: ISceneComponent, action: T): void;
  11277. /**
  11278. * Clears all the steps from the stage.
  11279. */
  11280. clear(): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface Scene {
  11285. /** @hidden */
  11286. _pointerOverSprite: Nullable<Sprite>;
  11287. /** @hidden */
  11288. _pickedDownSprite: Nullable<Sprite>;
  11289. /** @hidden */
  11290. _tempSpritePickingRay: Nullable<Ray>;
  11291. /**
  11292. * All of the sprite managers added to this scene
  11293. * @see http://doc.babylonjs.com/babylon101/sprites
  11294. */
  11295. spriteManagers: Array<ISpriteManager>;
  11296. /**
  11297. * An event triggered when sprites rendering is about to start
  11298. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11299. */
  11300. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11301. /**
  11302. * An event triggered when sprites rendering is done
  11303. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11304. */
  11305. onAfterSpritesRenderingObservable: Observable<Scene>;
  11306. /** @hidden */
  11307. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11308. /** Launch a ray to try to pick a sprite in the scene
  11309. * @param x position on screen
  11310. * @param y position on screen
  11311. * @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
  11312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11314. * @returns a PickingInfo
  11315. */
  11316. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11317. /** Use the given ray to pick a sprite in the scene
  11318. * @param ray The ray (in world space) to use to pick meshes
  11319. * @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
  11320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11322. * @returns a PickingInfo
  11323. */
  11324. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11325. /** @hidden */
  11326. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11327. /** Launch a ray to try to pick sprites in the scene
  11328. * @param x position on screen
  11329. * @param y position on screen
  11330. * @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
  11331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /** Use the given ray to pick sprites in the scene
  11336. * @param ray The ray (in world space) to use to pick meshes
  11337. * @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
  11338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11339. * @returns a PickingInfo array
  11340. */
  11341. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11342. /**
  11343. * Force the sprite under the pointer
  11344. * @param sprite defines the sprite to use
  11345. */
  11346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11347. /**
  11348. * Gets the sprite under the pointer
  11349. * @returns a Sprite or null if no sprite is under the pointer
  11350. */
  11351. getPointerOverSprite(): Nullable<Sprite>;
  11352. }
  11353. /**
  11354. * Defines the sprite scene component responsible to manage sprites
  11355. * in a given scene.
  11356. */
  11357. export class SpriteSceneComponent implements ISceneComponent {
  11358. /**
  11359. * The component name helpfull to identify the component in the list of scene components.
  11360. */
  11361. readonly name: string;
  11362. /**
  11363. * The scene the component belongs to.
  11364. */
  11365. scene: Scene;
  11366. /** @hidden */
  11367. private _spritePredicate;
  11368. /**
  11369. * Creates a new instance of the component for the given scene
  11370. * @param scene Defines the scene to register the component in
  11371. */
  11372. constructor(scene: Scene);
  11373. /**
  11374. * Registers the component in a given scene
  11375. */
  11376. register(): void;
  11377. /**
  11378. * Rebuilds the elements related to this component in case of
  11379. * context lost for instance.
  11380. */
  11381. rebuild(): void;
  11382. /**
  11383. * Disposes the component and the associated ressources.
  11384. */
  11385. dispose(): void;
  11386. private _pickSpriteButKeepRay;
  11387. private _pointerMove;
  11388. private _pointerDown;
  11389. private _pointerUp;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /** @hidden */
  11394. export var fogFragmentDeclaration: {
  11395. name: string;
  11396. shader: string;
  11397. };
  11398. }
  11399. declare module BABYLON {
  11400. /** @hidden */
  11401. export var fogFragment: {
  11402. name: string;
  11403. shader: string;
  11404. };
  11405. }
  11406. declare module BABYLON {
  11407. /** @hidden */
  11408. export var spritesPixelShader: {
  11409. name: string;
  11410. shader: string;
  11411. };
  11412. }
  11413. declare module BABYLON {
  11414. /** @hidden */
  11415. export var fogVertexDeclaration: {
  11416. name: string;
  11417. shader: string;
  11418. };
  11419. }
  11420. declare module BABYLON {
  11421. /** @hidden */
  11422. export var spritesVertexShader: {
  11423. name: string;
  11424. shader: string;
  11425. };
  11426. }
  11427. declare module BABYLON {
  11428. /**
  11429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11430. */
  11431. export interface ISpriteManager extends IDisposable {
  11432. /**
  11433. * Restricts the camera to viewing objects with the same layerMask.
  11434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11435. */
  11436. layerMask: number;
  11437. /**
  11438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11439. */
  11440. isPickable: boolean;
  11441. /**
  11442. * Specifies the rendering group id for this mesh (0 by default)
  11443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11444. */
  11445. renderingGroupId: number;
  11446. /**
  11447. * Defines the list of sprites managed by the manager.
  11448. */
  11449. sprites: Array<Sprite>;
  11450. /**
  11451. * Tests the intersection of a sprite with a specific ray.
  11452. * @param ray The ray we are sending to test the collision
  11453. * @param camera The camera space we are sending rays in
  11454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11456. * @returns picking info or null.
  11457. */
  11458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11459. /**
  11460. * Intersects the sprites with a ray
  11461. * @param ray defines the ray to intersect with
  11462. * @param camera defines the current active camera
  11463. * @param predicate defines a predicate used to select candidate sprites
  11464. * @returns null if no hit or a PickingInfo array
  11465. */
  11466. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11467. /**
  11468. * Renders the list of sprites on screen.
  11469. */
  11470. render(): void;
  11471. }
  11472. /**
  11473. * Class used to manage multiple sprites on the same spritesheet
  11474. * @see http://doc.babylonjs.com/babylon101/sprites
  11475. */
  11476. export class SpriteManager implements ISpriteManager {
  11477. /** defines the manager's name */
  11478. name: string;
  11479. /** Gets the list of sprites */
  11480. sprites: Sprite[];
  11481. /** Gets or sets the rendering group id (0 by default) */
  11482. renderingGroupId: number;
  11483. /** Gets or sets camera layer mask */
  11484. layerMask: number;
  11485. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11486. fogEnabled: boolean;
  11487. /** Gets or sets a boolean indicating if the sprites are pickable */
  11488. isPickable: boolean;
  11489. /** Defines the default width of a cell in the spritesheet */
  11490. cellWidth: number;
  11491. /** Defines the default height of a cell in the spritesheet */
  11492. cellHeight: number;
  11493. /** Associative array from JSON sprite data file */
  11494. private _cellData;
  11495. /** Array of sprite names from JSON sprite data file */
  11496. private _spriteMap;
  11497. /** True when packed cell data from JSON file is ready*/
  11498. private _packedAndReady;
  11499. /**
  11500. * An event triggered when the manager is disposed.
  11501. */
  11502. onDisposeObservable: Observable<SpriteManager>;
  11503. private _onDisposeObserver;
  11504. /**
  11505. * Callback called when the manager is disposed
  11506. */
  11507. onDispose: () => void;
  11508. private _capacity;
  11509. private _fromPacked;
  11510. private _spriteTexture;
  11511. private _epsilon;
  11512. private _scene;
  11513. private _vertexData;
  11514. private _buffer;
  11515. private _vertexBuffers;
  11516. private _indexBuffer;
  11517. private _effectBase;
  11518. private _effectFog;
  11519. /**
  11520. * Gets or sets the spritesheet texture
  11521. */
  11522. texture: Texture;
  11523. /**
  11524. * Creates a new sprite manager
  11525. * @param name defines the manager's name
  11526. * @param imgUrl defines the sprite sheet url
  11527. * @param capacity defines the maximum allowed number of sprites
  11528. * @param cellSize defines the size of a sprite cell
  11529. * @param scene defines the hosting scene
  11530. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11531. * @param samplingMode defines the smapling mode to use with spritesheet
  11532. * @param fromPacked set to false; do not alter
  11533. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11534. */
  11535. constructor(
  11536. /** defines the manager's name */
  11537. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11538. private _makePacked;
  11539. private _appendSpriteVertex;
  11540. /**
  11541. * Intersects the sprites with a ray
  11542. * @param ray defines the ray to intersect with
  11543. * @param camera defines the current active camera
  11544. * @param predicate defines a predicate used to select candidate sprites
  11545. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11546. * @returns null if no hit or a PickingInfo
  11547. */
  11548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11549. /**
  11550. * Intersects the sprites with a ray
  11551. * @param ray defines the ray to intersect with
  11552. * @param camera defines the current active camera
  11553. * @param predicate defines a predicate used to select candidate sprites
  11554. * @returns null if no hit or a PickingInfo array
  11555. */
  11556. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Render all child sprites
  11559. */
  11560. render(): void;
  11561. /**
  11562. * Release associated resources
  11563. */
  11564. dispose(): void;
  11565. }
  11566. }
  11567. declare module BABYLON {
  11568. /**
  11569. * Class used to represent a sprite
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. export class Sprite {
  11573. /** defines the name */
  11574. name: string;
  11575. /** Gets or sets the current world position */
  11576. position: Vector3;
  11577. /** Gets or sets the main color */
  11578. color: Color4;
  11579. /** Gets or sets the width */
  11580. width: number;
  11581. /** Gets or sets the height */
  11582. height: number;
  11583. /** Gets or sets rotation angle */
  11584. angle: number;
  11585. /** Gets or sets the cell index in the sprite sheet */
  11586. cellIndex: number;
  11587. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11588. cellRef: string;
  11589. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11590. invertU: number;
  11591. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11592. invertV: number;
  11593. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11594. disposeWhenFinishedAnimating: boolean;
  11595. /** Gets the list of attached animations */
  11596. animations: Animation[];
  11597. /** Gets or sets a boolean indicating if the sprite can be picked */
  11598. isPickable: boolean;
  11599. /**
  11600. * Gets or sets the associated action manager
  11601. */
  11602. actionManager: Nullable<ActionManager>;
  11603. private _animationStarted;
  11604. private _loopAnimation;
  11605. private _fromIndex;
  11606. private _toIndex;
  11607. private _delay;
  11608. private _direction;
  11609. private _manager;
  11610. private _time;
  11611. private _onAnimationEnd;
  11612. /**
  11613. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11614. */
  11615. isVisible: boolean;
  11616. /**
  11617. * Gets or sets the sprite size
  11618. */
  11619. size: number;
  11620. /**
  11621. * Creates a new Sprite
  11622. * @param name defines the name
  11623. * @param manager defines the manager
  11624. */
  11625. constructor(
  11626. /** defines the name */
  11627. name: string, manager: ISpriteManager);
  11628. /**
  11629. * Starts an animation
  11630. * @param from defines the initial key
  11631. * @param to defines the end key
  11632. * @param loop defines if the animation must loop
  11633. * @param delay defines the start delay (in ms)
  11634. * @param onAnimationEnd defines a callback to call when animation ends
  11635. */
  11636. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11637. /** Stops current animation (if any) */
  11638. stopAnimation(): void;
  11639. /** @hidden */
  11640. _animate(deltaTime: number): void;
  11641. /** Release associated resources */
  11642. dispose(): void;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /**
  11647. * Information about the result of picking within a scene
  11648. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11649. */
  11650. export class PickingInfo {
  11651. /** @hidden */
  11652. _pickingUnavailable: boolean;
  11653. /**
  11654. * If the pick collided with an object
  11655. */
  11656. hit: boolean;
  11657. /**
  11658. * Distance away where the pick collided
  11659. */
  11660. distance: number;
  11661. /**
  11662. * The location of pick collision
  11663. */
  11664. pickedPoint: Nullable<Vector3>;
  11665. /**
  11666. * The mesh corresponding the the pick collision
  11667. */
  11668. pickedMesh: Nullable<AbstractMesh>;
  11669. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11670. bu: number;
  11671. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11672. bv: number;
  11673. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11674. faceId: number;
  11675. /** Id of the the submesh that was picked */
  11676. subMeshId: number;
  11677. /** If a sprite was picked, this will be the sprite the pick collided with */
  11678. pickedSprite: Nullable<Sprite>;
  11679. /**
  11680. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11681. */
  11682. originMesh: Nullable<AbstractMesh>;
  11683. /**
  11684. * The ray that was used to perform the picking.
  11685. */
  11686. ray: Nullable<Ray>;
  11687. /**
  11688. * Gets the normal correspodning to the face the pick collided with
  11689. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11690. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11691. * @returns The normal correspodning to the face the pick collided with
  11692. */
  11693. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11694. /**
  11695. * Gets the texture coordinates of where the pick occured
  11696. * @returns the vector containing the coordnates of the texture
  11697. */
  11698. getTextureCoordinates(): Nullable<Vector2>;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. /**
  11703. * Gather the list of pointer event types as constants.
  11704. */
  11705. export class PointerEventTypes {
  11706. /**
  11707. * 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.
  11708. */
  11709. static readonly POINTERDOWN: number;
  11710. /**
  11711. * The pointerup event is fired when a pointer is no longer active.
  11712. */
  11713. static readonly POINTERUP: number;
  11714. /**
  11715. * The pointermove event is fired when a pointer changes coordinates.
  11716. */
  11717. static readonly POINTERMOVE: number;
  11718. /**
  11719. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11720. */
  11721. static readonly POINTERWHEEL: number;
  11722. /**
  11723. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11724. */
  11725. static readonly POINTERPICK: number;
  11726. /**
  11727. * The pointertap event is fired when a the object has been touched and released without drag.
  11728. */
  11729. static readonly POINTERTAP: number;
  11730. /**
  11731. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11732. */
  11733. static readonly POINTERDOUBLETAP: number;
  11734. }
  11735. /**
  11736. * Base class of pointer info types.
  11737. */
  11738. export class PointerInfoBase {
  11739. /**
  11740. * Defines the type of event (PointerEventTypes)
  11741. */
  11742. type: number;
  11743. /**
  11744. * Defines the related dom event
  11745. */
  11746. event: PointerEvent | MouseWheelEvent;
  11747. /**
  11748. * Instantiates the base class of pointers info.
  11749. * @param type Defines the type of event (PointerEventTypes)
  11750. * @param event Defines the related dom event
  11751. */
  11752. constructor(
  11753. /**
  11754. * Defines the type of event (PointerEventTypes)
  11755. */
  11756. type: number,
  11757. /**
  11758. * Defines the related dom event
  11759. */
  11760. event: PointerEvent | MouseWheelEvent);
  11761. }
  11762. /**
  11763. * This class is used to store pointer related info for the onPrePointerObservable event.
  11764. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11765. */
  11766. export class PointerInfoPre extends PointerInfoBase {
  11767. /**
  11768. * Ray from a pointer if availible (eg. 6dof controller)
  11769. */
  11770. ray: Nullable<Ray>;
  11771. /**
  11772. * Defines the local position of the pointer on the canvas.
  11773. */
  11774. localPosition: Vector2;
  11775. /**
  11776. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11777. */
  11778. skipOnPointerObservable: boolean;
  11779. /**
  11780. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11781. * @param type Defines the type of event (PointerEventTypes)
  11782. * @param event Defines the related dom event
  11783. * @param localX Defines the local x coordinates of the pointer when the event occured
  11784. * @param localY Defines the local y coordinates of the pointer when the event occured
  11785. */
  11786. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11787. }
  11788. /**
  11789. * This type contains all the data related to a pointer event in Babylon.js.
  11790. * 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.
  11791. */
  11792. export class PointerInfo extends PointerInfoBase {
  11793. /**
  11794. * Defines the picking info associated to the info (if any)\
  11795. */
  11796. pickInfo: Nullable<PickingInfo>;
  11797. /**
  11798. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11799. * @param type Defines the type of event (PointerEventTypes)
  11800. * @param event Defines the related dom event
  11801. * @param pickInfo Defines the picking info associated to the info (if any)\
  11802. */
  11803. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11804. /**
  11805. * Defines the picking info associated to the info (if any)\
  11806. */
  11807. pickInfo: Nullable<PickingInfo>);
  11808. }
  11809. /**
  11810. * Data relating to a touch event on the screen.
  11811. */
  11812. export interface PointerTouch {
  11813. /**
  11814. * X coordinate of touch.
  11815. */
  11816. x: number;
  11817. /**
  11818. * Y coordinate of touch.
  11819. */
  11820. y: number;
  11821. /**
  11822. * Id of touch. Unique for each finger.
  11823. */
  11824. pointerId: number;
  11825. /**
  11826. * Event type passed from DOM.
  11827. */
  11828. type: any;
  11829. }
  11830. }
  11831. declare module BABYLON {
  11832. /**
  11833. * Manage the mouse inputs to control the movement of a free camera.
  11834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11835. */
  11836. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11837. /**
  11838. * Define if touch is enabled in the mouse input
  11839. */
  11840. touchEnabled: boolean;
  11841. /**
  11842. * Defines the camera the input is attached to.
  11843. */
  11844. camera: FreeCamera;
  11845. /**
  11846. * Defines the buttons associated with the input to handle camera move.
  11847. */
  11848. buttons: number[];
  11849. /**
  11850. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11851. */
  11852. angularSensibility: number;
  11853. private _pointerInput;
  11854. private _onMouseMove;
  11855. private _observer;
  11856. private previousPosition;
  11857. /**
  11858. * Observable for when a pointer move event occurs containing the move offset
  11859. */
  11860. onPointerMovedObservable: Observable<{
  11861. offsetX: number;
  11862. offsetY: number;
  11863. }>;
  11864. /**
  11865. * @hidden
  11866. * If the camera should be rotated automatically based on pointer movement
  11867. */
  11868. _allowCameraRotation: boolean;
  11869. /**
  11870. * Manage the mouse inputs to control the movement of a free camera.
  11871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11872. * @param touchEnabled Defines if touch is enabled or not
  11873. */
  11874. constructor(
  11875. /**
  11876. * Define if touch is enabled in the mouse input
  11877. */
  11878. touchEnabled?: boolean);
  11879. /**
  11880. * Attach the input controls to a specific dom element to get the input from.
  11881. * @param element Defines the element the controls should be listened from
  11882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11883. */
  11884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11885. /**
  11886. * Called on JS contextmenu event.
  11887. * Override this method to provide functionality.
  11888. */
  11889. protected onContextMenu(evt: PointerEvent): void;
  11890. /**
  11891. * Detach the current controls from the specified dom element.
  11892. * @param element Defines the element to stop listening the inputs from
  11893. */
  11894. detachControl(element: Nullable<HTMLElement>): void;
  11895. /**
  11896. * Gets the class name of the current intput.
  11897. * @returns the class name
  11898. */
  11899. getClassName(): string;
  11900. /**
  11901. * Get the friendly name associated with the input class.
  11902. * @returns the input friendly name
  11903. */
  11904. getSimpleName(): string;
  11905. }
  11906. }
  11907. declare module BABYLON {
  11908. /**
  11909. * Manage the touch inputs to control the movement of a free camera.
  11910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11911. */
  11912. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11913. /**
  11914. * Defines the camera the input is attached to.
  11915. */
  11916. camera: FreeCamera;
  11917. /**
  11918. * Defines the touch sensibility for rotation.
  11919. * The higher the faster.
  11920. */
  11921. touchAngularSensibility: number;
  11922. /**
  11923. * Defines the touch sensibility for move.
  11924. * The higher the faster.
  11925. */
  11926. touchMoveSensibility: number;
  11927. private _offsetX;
  11928. private _offsetY;
  11929. private _pointerPressed;
  11930. private _pointerInput;
  11931. private _observer;
  11932. private _onLostFocus;
  11933. /**
  11934. * Attach the input controls to a specific dom element to get the input from.
  11935. * @param element Defines the element the controls should be listened from
  11936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11937. */
  11938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11939. /**
  11940. * Detach the current controls from the specified dom element.
  11941. * @param element Defines the element to stop listening the inputs from
  11942. */
  11943. detachControl(element: Nullable<HTMLElement>): void;
  11944. /**
  11945. * Update the current camera state depending on the inputs that have been used this frame.
  11946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11947. */
  11948. checkInputs(): void;
  11949. /**
  11950. * Gets the class name of the current intput.
  11951. * @returns the class name
  11952. */
  11953. getClassName(): string;
  11954. /**
  11955. * Get the friendly name associated with the input class.
  11956. * @returns the input friendly name
  11957. */
  11958. getSimpleName(): string;
  11959. }
  11960. }
  11961. declare module BABYLON {
  11962. /**
  11963. * Default Inputs manager for the FreeCamera.
  11964. * It groups all the default supported inputs for ease of use.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11968. /**
  11969. * @hidden
  11970. */
  11971. _mouseInput: Nullable<FreeCameraMouseInput>;
  11972. /**
  11973. * Instantiates a new FreeCameraInputsManager.
  11974. * @param camera Defines the camera the inputs belong to
  11975. */
  11976. constructor(camera: FreeCamera);
  11977. /**
  11978. * Add keyboard input support to the input manager.
  11979. * @returns the current input manager
  11980. */
  11981. addKeyboard(): FreeCameraInputsManager;
  11982. /**
  11983. * Add mouse input support to the input manager.
  11984. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11985. * @returns the current input manager
  11986. */
  11987. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11988. /**
  11989. * Removes the mouse input support from the manager
  11990. * @returns the current input manager
  11991. */
  11992. removeMouse(): FreeCameraInputsManager;
  11993. /**
  11994. * Add touch input support to the input manager.
  11995. * @returns the current input manager
  11996. */
  11997. addTouch(): FreeCameraInputsManager;
  11998. /**
  11999. * Remove all attached input methods from a camera
  12000. */
  12001. clear(): void;
  12002. }
  12003. }
  12004. declare module BABYLON {
  12005. /**
  12006. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12007. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12009. */
  12010. export class FreeCamera extends TargetCamera {
  12011. /**
  12012. * Define the collision ellipsoid of the camera.
  12013. * This is helpful to simulate a camera body like the player body around the camera
  12014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12015. */
  12016. ellipsoid: Vector3;
  12017. /**
  12018. * Define an offset for the position of the ellipsoid around the camera.
  12019. * This can be helpful to determine the center of the body near the gravity center of the body
  12020. * instead of its head.
  12021. */
  12022. ellipsoidOffset: Vector3;
  12023. /**
  12024. * Enable or disable collisions of the camera with the rest of the scene objects.
  12025. */
  12026. checkCollisions: boolean;
  12027. /**
  12028. * Enable or disable gravity on the camera.
  12029. */
  12030. applyGravity: boolean;
  12031. /**
  12032. * Define the input manager associated to the camera.
  12033. */
  12034. inputs: FreeCameraInputsManager;
  12035. /**
  12036. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12037. * Higher values reduce sensitivity.
  12038. */
  12039. /**
  12040. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12041. * Higher values reduce sensitivity.
  12042. */
  12043. angularSensibility: number;
  12044. /**
  12045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12046. */
  12047. keysUp: number[];
  12048. /**
  12049. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12050. */
  12051. keysDown: number[];
  12052. /**
  12053. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12054. */
  12055. keysLeft: number[];
  12056. /**
  12057. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12058. */
  12059. keysRight: number[];
  12060. /**
  12061. * Event raised when the camera collide with a mesh in the scene.
  12062. */
  12063. onCollide: (collidedMesh: AbstractMesh) => void;
  12064. private _collider;
  12065. private _needMoveForGravity;
  12066. private _oldPosition;
  12067. private _diffPosition;
  12068. private _newPosition;
  12069. /** @hidden */
  12070. _localDirection: Vector3;
  12071. /** @hidden */
  12072. _transformedDirection: Vector3;
  12073. /**
  12074. * Instantiates a Free Camera.
  12075. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12076. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12078. * @param name Define the name of the camera in the scene
  12079. * @param position Define the start position of the camera in the scene
  12080. * @param scene Define the scene the camera belongs to
  12081. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12082. */
  12083. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12084. /**
  12085. * Attached controls to the current camera.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Detach the current controls from the camera.
  12092. * The camera will stop reacting to inputs.
  12093. * @param element Defines the element to stop listening the inputs from
  12094. */
  12095. detachControl(element: HTMLElement): void;
  12096. private _collisionMask;
  12097. /**
  12098. * Define a collision mask to limit the list of object the camera can collide with
  12099. */
  12100. collisionMask: number;
  12101. /** @hidden */
  12102. _collideWithWorld(displacement: Vector3): void;
  12103. private _onCollisionPositionChange;
  12104. /** @hidden */
  12105. _checkInputs(): void;
  12106. /** @hidden */
  12107. _decideIfNeedsToMove(): boolean;
  12108. /** @hidden */
  12109. _updatePosition(): void;
  12110. /**
  12111. * Destroy the camera and release the current resources hold by it.
  12112. */
  12113. dispose(): void;
  12114. /**
  12115. * Gets the current object class name.
  12116. * @return the class name
  12117. */
  12118. getClassName(): string;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Represents a gamepad control stick position
  12124. */
  12125. export class StickValues {
  12126. /**
  12127. * The x component of the control stick
  12128. */
  12129. x: number;
  12130. /**
  12131. * The y component of the control stick
  12132. */
  12133. y: number;
  12134. /**
  12135. * Initializes the gamepad x and y control stick values
  12136. * @param x The x component of the gamepad control stick value
  12137. * @param y The y component of the gamepad control stick value
  12138. */
  12139. constructor(
  12140. /**
  12141. * The x component of the control stick
  12142. */
  12143. x: number,
  12144. /**
  12145. * The y component of the control stick
  12146. */
  12147. y: number);
  12148. }
  12149. /**
  12150. * An interface which manages callbacks for gamepad button changes
  12151. */
  12152. export interface GamepadButtonChanges {
  12153. /**
  12154. * Called when a gamepad has been changed
  12155. */
  12156. changed: boolean;
  12157. /**
  12158. * Called when a gamepad press event has been triggered
  12159. */
  12160. pressChanged: boolean;
  12161. /**
  12162. * Called when a touch event has been triggered
  12163. */
  12164. touchChanged: boolean;
  12165. /**
  12166. * Called when a value has changed
  12167. */
  12168. valueChanged: boolean;
  12169. }
  12170. /**
  12171. * Represents a gamepad
  12172. */
  12173. export class Gamepad {
  12174. /**
  12175. * The id of the gamepad
  12176. */
  12177. id: string;
  12178. /**
  12179. * The index of the gamepad
  12180. */
  12181. index: number;
  12182. /**
  12183. * The browser gamepad
  12184. */
  12185. browserGamepad: any;
  12186. /**
  12187. * Specifies what type of gamepad this represents
  12188. */
  12189. type: number;
  12190. private _leftStick;
  12191. private _rightStick;
  12192. /** @hidden */
  12193. _isConnected: boolean;
  12194. private _leftStickAxisX;
  12195. private _leftStickAxisY;
  12196. private _rightStickAxisX;
  12197. private _rightStickAxisY;
  12198. /**
  12199. * Triggered when the left control stick has been changed
  12200. */
  12201. private _onleftstickchanged;
  12202. /**
  12203. * Triggered when the right control stick has been changed
  12204. */
  12205. private _onrightstickchanged;
  12206. /**
  12207. * Represents a gamepad controller
  12208. */
  12209. static GAMEPAD: number;
  12210. /**
  12211. * Represents a generic controller
  12212. */
  12213. static GENERIC: number;
  12214. /**
  12215. * Represents an XBox controller
  12216. */
  12217. static XBOX: number;
  12218. /**
  12219. * Represents a pose-enabled controller
  12220. */
  12221. static POSE_ENABLED: number;
  12222. /**
  12223. * Represents an Dual Shock controller
  12224. */
  12225. static DUALSHOCK: number;
  12226. /**
  12227. * Specifies whether the left control stick should be Y-inverted
  12228. */
  12229. protected _invertLeftStickY: boolean;
  12230. /**
  12231. * Specifies if the gamepad has been connected
  12232. */
  12233. readonly isConnected: boolean;
  12234. /**
  12235. * Initializes the gamepad
  12236. * @param id The id of the gamepad
  12237. * @param index The index of the gamepad
  12238. * @param browserGamepad The browser gamepad
  12239. * @param leftStickX The x component of the left joystick
  12240. * @param leftStickY The y component of the left joystick
  12241. * @param rightStickX The x component of the right joystick
  12242. * @param rightStickY The y component of the right joystick
  12243. */
  12244. constructor(
  12245. /**
  12246. * The id of the gamepad
  12247. */
  12248. id: string,
  12249. /**
  12250. * The index of the gamepad
  12251. */
  12252. index: number,
  12253. /**
  12254. * The browser gamepad
  12255. */
  12256. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12257. /**
  12258. * Callback triggered when the left joystick has changed
  12259. * @param callback
  12260. */
  12261. onleftstickchanged(callback: (values: StickValues) => void): void;
  12262. /**
  12263. * Callback triggered when the right joystick has changed
  12264. * @param callback
  12265. */
  12266. onrightstickchanged(callback: (values: StickValues) => void): void;
  12267. /**
  12268. * Gets the left joystick
  12269. */
  12270. /**
  12271. * Sets the left joystick values
  12272. */
  12273. leftStick: StickValues;
  12274. /**
  12275. * Gets the right joystick
  12276. */
  12277. /**
  12278. * Sets the right joystick value
  12279. */
  12280. rightStick: StickValues;
  12281. /**
  12282. * Updates the gamepad joystick positions
  12283. */
  12284. update(): void;
  12285. /**
  12286. * Disposes the gamepad
  12287. */
  12288. dispose(): void;
  12289. }
  12290. /**
  12291. * Represents a generic gamepad
  12292. */
  12293. export class GenericPad extends Gamepad {
  12294. private _buttons;
  12295. private _onbuttondown;
  12296. private _onbuttonup;
  12297. /**
  12298. * Observable triggered when a button has been pressed
  12299. */
  12300. onButtonDownObservable: Observable<number>;
  12301. /**
  12302. * Observable triggered when a button has been released
  12303. */
  12304. onButtonUpObservable: Observable<number>;
  12305. /**
  12306. * Callback triggered when a button has been pressed
  12307. * @param callback Called when a button has been pressed
  12308. */
  12309. onbuttondown(callback: (buttonPressed: number) => void): void;
  12310. /**
  12311. * Callback triggered when a button has been released
  12312. * @param callback Called when a button has been released
  12313. */
  12314. onbuttonup(callback: (buttonReleased: number) => void): void;
  12315. /**
  12316. * Initializes the generic gamepad
  12317. * @param id The id of the generic gamepad
  12318. * @param index The index of the generic gamepad
  12319. * @param browserGamepad The browser gamepad
  12320. */
  12321. constructor(id: string, index: number, browserGamepad: any);
  12322. private _setButtonValue;
  12323. /**
  12324. * Updates the generic gamepad
  12325. */
  12326. update(): void;
  12327. /**
  12328. * Disposes the generic gamepad
  12329. */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module BABYLON {
  12334. interface Engine {
  12335. /**
  12336. * Creates a raw texture
  12337. * @param data defines the data to store in the texture
  12338. * @param width defines the width of the texture
  12339. * @param height defines the height of the texture
  12340. * @param format defines the format of the data
  12341. * @param generateMipMaps defines if the engine should generate the mip levels
  12342. * @param invertY defines if data must be stored with Y axis inverted
  12343. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12344. * @param compression defines the compression used (null by default)
  12345. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12346. * @returns the raw texture inside an InternalTexture
  12347. */
  12348. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12349. /**
  12350. * Update a raw texture
  12351. * @param texture defines the texture to update
  12352. * @param data defines the data to store in the texture
  12353. * @param format defines the format of the data
  12354. * @param invertY defines if data must be stored with Y axis inverted
  12355. */
  12356. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12357. /**
  12358. * Update a raw texture
  12359. * @param texture defines the texture to update
  12360. * @param data defines the data to store in the texture
  12361. * @param format defines the format of the data
  12362. * @param invertY defines if data must be stored with Y axis inverted
  12363. * @param compression defines the compression used (null by default)
  12364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12365. */
  12366. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12367. /**
  12368. * Creates a new raw cube texture
  12369. * @param data defines the array of data to use to create each face
  12370. * @param size defines the size of the textures
  12371. * @param format defines the format of the data
  12372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12373. * @param generateMipMaps defines if the engine should generate the mip levels
  12374. * @param invertY defines if data must be stored with Y axis inverted
  12375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12376. * @param compression defines the compression used (null by default)
  12377. * @returns the cube texture as an InternalTexture
  12378. */
  12379. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12380. /**
  12381. * Update a raw cube texture
  12382. * @param texture defines the texture to udpdate
  12383. * @param data defines the data to store
  12384. * @param format defines the data format
  12385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12386. * @param invertY defines if data must be stored with Y axis inverted
  12387. */
  12388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12389. /**
  12390. * Update a raw cube texture
  12391. * @param texture defines the texture to udpdate
  12392. * @param data defines the data to store
  12393. * @param format defines the data format
  12394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12395. * @param invertY defines if data must be stored with Y axis inverted
  12396. * @param compression defines the compression used (null by default)
  12397. */
  12398. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12399. /**
  12400. * Update a raw cube texture
  12401. * @param texture defines the texture to udpdate
  12402. * @param data defines the data to store
  12403. * @param format defines the data format
  12404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12405. * @param invertY defines if data must be stored with Y axis inverted
  12406. * @param compression defines the compression used (null by default)
  12407. * @param level defines which level of the texture to update
  12408. */
  12409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12410. /**
  12411. * Creates a new raw cube texture from a specified url
  12412. * @param url defines the url where the data is located
  12413. * @param scene defines the current scene
  12414. * @param size defines the size of the textures
  12415. * @param format defines the format of the data
  12416. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12417. * @param noMipmap defines if the engine should avoid generating the mip levels
  12418. * @param callback defines a callback used to extract texture data from loaded data
  12419. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12420. * @param onLoad defines a callback called when texture is loaded
  12421. * @param onError defines a callback called if there is an error
  12422. * @returns the cube texture as an InternalTexture
  12423. */
  12424. 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;
  12425. /**
  12426. * Creates a new raw cube texture from a specified url
  12427. * @param url defines the url where the data is located
  12428. * @param scene defines the current scene
  12429. * @param size defines the size of the textures
  12430. * @param format defines the format of the data
  12431. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12432. * @param noMipmap defines if the engine should avoid generating the mip levels
  12433. * @param callback defines a callback used to extract texture data from loaded data
  12434. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12435. * @param onLoad defines a callback called when texture is loaded
  12436. * @param onError defines a callback called if there is an error
  12437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @returns the cube texture as an InternalTexture
  12440. */
  12441. 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;
  12442. /**
  12443. * Creates a new raw 3D texture
  12444. * @param data defines the data used to create the texture
  12445. * @param width defines the width of the texture
  12446. * @param height defines the height of the texture
  12447. * @param depth defines the depth of the texture
  12448. * @param format defines the format of the texture
  12449. * @param generateMipMaps defines if the engine must generate mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compressed used (can be null)
  12453. * @param textureType defines the compressed used (can be null)
  12454. * @returns a new raw 3D texture (stored in an InternalTexture)
  12455. */
  12456. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12457. /**
  12458. * Update a raw 3D texture
  12459. * @param texture defines the texture to update
  12460. * @param data defines the data to store
  12461. * @param format defines the data format
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw 3D texture
  12467. * @param texture defines the texture to update
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param invertY defines if data must be stored with Y axis inverted
  12471. * @param compression defines the used compression (can be null)
  12472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12473. */
  12474. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12475. /**
  12476. * Creates a new raw 2D array texture
  12477. * @param data defines the data used to create the texture
  12478. * @param width defines the width of the texture
  12479. * @param height defines the height of the texture
  12480. * @param depth defines the number of layers of the texture
  12481. * @param format defines the format of the texture
  12482. * @param generateMipMaps defines if the engine must generate mip levels
  12483. * @param invertY defines if data must be stored with Y axis inverted
  12484. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12485. * @param compression defines the compressed used (can be null)
  12486. * @param textureType defines the compressed used (can be null)
  12487. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12488. */
  12489. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12490. /**
  12491. * Update a raw 2D array texture
  12492. * @param texture defines the texture to update
  12493. * @param data defines the data to store
  12494. * @param format defines the data format
  12495. * @param invertY defines if data must be stored with Y axis inverted
  12496. */
  12497. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12498. /**
  12499. * Update a raw 2D array texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store
  12502. * @param format defines the data format
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. * @param compression defines the used compression (can be null)
  12505. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12506. */
  12507. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12508. }
  12509. }
  12510. declare module BABYLON {
  12511. /**
  12512. * Raw texture can help creating a texture directly from an array of data.
  12513. * This can be super useful if you either get the data from an uncompressed source or
  12514. * if you wish to create your texture pixel by pixel.
  12515. */
  12516. export class RawTexture extends Texture {
  12517. /**
  12518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12519. */
  12520. format: number;
  12521. private _engine;
  12522. /**
  12523. * Instantiates a new RawTexture.
  12524. * Raw texture can help creating a texture directly from an array of data.
  12525. * This can be super useful if you either get the data from an uncompressed source or
  12526. * if you wish to create your texture pixel by pixel.
  12527. * @param data define the array of data to use to create the texture
  12528. * @param width define the width of the texture
  12529. * @param height define the height of the texture
  12530. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12531. * @param scene define the scene the texture belongs to
  12532. * @param generateMipMaps define whether mip maps should be generated or not
  12533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12535. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12536. */
  12537. constructor(data: ArrayBufferView, width: number, height: number,
  12538. /**
  12539. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12540. */
  12541. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12542. /**
  12543. * Updates the texture underlying data.
  12544. * @param data Define the new data of the texture
  12545. */
  12546. update(data: ArrayBufferView): void;
  12547. /**
  12548. * Creates a luminance texture from some data.
  12549. * @param data Define the texture data
  12550. * @param width Define the width of the texture
  12551. * @param height Define the height of the texture
  12552. * @param scene Define the scene the texture belongs to
  12553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12556. * @returns the luminance texture
  12557. */
  12558. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12559. /**
  12560. * Creates a luminance alpha texture from some data.
  12561. * @param data Define the texture data
  12562. * @param width Define the width of the texture
  12563. * @param height Define the height of the texture
  12564. * @param scene Define the scene the texture belongs to
  12565. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12566. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12567. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12568. * @returns the luminance alpha texture
  12569. */
  12570. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12571. /**
  12572. * Creates an alpha texture from some data.
  12573. * @param data Define the texture data
  12574. * @param width Define the width of the texture
  12575. * @param height Define the height of the texture
  12576. * @param scene Define the scene the texture belongs to
  12577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12580. * @returns the alpha texture
  12581. */
  12582. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12583. /**
  12584. * Creates a RGB texture from some data.
  12585. * @param data Define the texture data
  12586. * @param width Define the width of the texture
  12587. * @param height Define the height of the texture
  12588. * @param scene Define the scene the texture belongs to
  12589. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12590. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12591. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12592. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12593. * @returns the RGB alpha texture
  12594. */
  12595. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12596. /**
  12597. * Creates a RGBA texture from some data.
  12598. * @param data Define the texture data
  12599. * @param width Define the width of the texture
  12600. * @param height Define the height of the texture
  12601. * @param scene Define the scene the texture belongs to
  12602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12605. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12606. * @returns the RGBA texture
  12607. */
  12608. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12609. /**
  12610. * Creates a R texture from some data.
  12611. * @param data Define the texture data
  12612. * @param width Define the width of the texture
  12613. * @param height Define the height of the texture
  12614. * @param scene Define the scene the texture belongs to
  12615. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12616. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12617. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12618. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12619. * @returns the R texture
  12620. */
  12621. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12622. }
  12623. }
  12624. declare module BABYLON {
  12625. /**
  12626. * Interface for the size containing width and height
  12627. */
  12628. export interface ISize {
  12629. /**
  12630. * Width
  12631. */
  12632. width: number;
  12633. /**
  12634. * Heighht
  12635. */
  12636. height: number;
  12637. }
  12638. /**
  12639. * Size containing widht and height
  12640. */
  12641. export class Size implements ISize {
  12642. /**
  12643. * Width
  12644. */
  12645. width: number;
  12646. /**
  12647. * Height
  12648. */
  12649. height: number;
  12650. /**
  12651. * Creates a Size object from the given width and height (floats).
  12652. * @param width width of the new size
  12653. * @param height height of the new size
  12654. */
  12655. constructor(width: number, height: number);
  12656. /**
  12657. * Returns a string with the Size width and height
  12658. * @returns a string with the Size width and height
  12659. */
  12660. toString(): string;
  12661. /**
  12662. * "Size"
  12663. * @returns the string "Size"
  12664. */
  12665. getClassName(): string;
  12666. /**
  12667. * Returns the Size hash code.
  12668. * @returns a hash code for a unique width and height
  12669. */
  12670. getHashCode(): number;
  12671. /**
  12672. * Updates the current size from the given one.
  12673. * @param src the given size
  12674. */
  12675. copyFrom(src: Size): void;
  12676. /**
  12677. * Updates in place the current Size from the given floats.
  12678. * @param width width of the new size
  12679. * @param height height of the new size
  12680. * @returns the updated Size.
  12681. */
  12682. copyFromFloats(width: number, height: number): Size;
  12683. /**
  12684. * Updates in place the current Size from the given floats.
  12685. * @param width width to set
  12686. * @param height height to set
  12687. * @returns the updated Size.
  12688. */
  12689. set(width: number, height: number): Size;
  12690. /**
  12691. * Multiplies the width and height by numbers
  12692. * @param w factor to multiple the width by
  12693. * @param h factor to multiple the height by
  12694. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12695. */
  12696. multiplyByFloats(w: number, h: number): Size;
  12697. /**
  12698. * Clones the size
  12699. * @returns a new Size copied from the given one.
  12700. */
  12701. clone(): Size;
  12702. /**
  12703. * True if the current Size and the given one width and height are strictly equal.
  12704. * @param other the other size to compare against
  12705. * @returns True if the current Size and the given one width and height are strictly equal.
  12706. */
  12707. equals(other: Size): boolean;
  12708. /**
  12709. * The surface of the Size : width * height (float).
  12710. */
  12711. readonly surface: number;
  12712. /**
  12713. * Create a new size of zero
  12714. * @returns a new Size set to (0.0, 0.0)
  12715. */
  12716. static Zero(): Size;
  12717. /**
  12718. * Sums the width and height of two sizes
  12719. * @param otherSize size to add to this size
  12720. * @returns a new Size set as the addition result of the current Size and the given one.
  12721. */
  12722. add(otherSize: Size): Size;
  12723. /**
  12724. * Subtracts the width and height of two
  12725. * @param otherSize size to subtract to this size
  12726. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12727. */
  12728. subtract(otherSize: Size): Size;
  12729. /**
  12730. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12731. * @param start starting size to lerp between
  12732. * @param end end size to lerp between
  12733. * @param amount amount to lerp between the start and end values
  12734. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12735. */
  12736. static Lerp(start: Size, end: Size, amount: number): Size;
  12737. }
  12738. }
  12739. declare module BABYLON {
  12740. /**
  12741. * Defines a runtime animation
  12742. */
  12743. export class RuntimeAnimation {
  12744. private _events;
  12745. /**
  12746. * The current frame of the runtime animation
  12747. */
  12748. private _currentFrame;
  12749. /**
  12750. * The animation used by the runtime animation
  12751. */
  12752. private _animation;
  12753. /**
  12754. * The target of the runtime animation
  12755. */
  12756. private _target;
  12757. /**
  12758. * The initiating animatable
  12759. */
  12760. private _host;
  12761. /**
  12762. * The original value of the runtime animation
  12763. */
  12764. private _originalValue;
  12765. /**
  12766. * The original blend value of the runtime animation
  12767. */
  12768. private _originalBlendValue;
  12769. /**
  12770. * The offsets cache of the runtime animation
  12771. */
  12772. private _offsetsCache;
  12773. /**
  12774. * The high limits cache of the runtime animation
  12775. */
  12776. private _highLimitsCache;
  12777. /**
  12778. * Specifies if the runtime animation has been stopped
  12779. */
  12780. private _stopped;
  12781. /**
  12782. * The blending factor of the runtime animation
  12783. */
  12784. private _blendingFactor;
  12785. /**
  12786. * The BabylonJS scene
  12787. */
  12788. private _scene;
  12789. /**
  12790. * The current value of the runtime animation
  12791. */
  12792. private _currentValue;
  12793. /** @hidden */
  12794. _animationState: _IAnimationState;
  12795. /**
  12796. * The active target of the runtime animation
  12797. */
  12798. private _activeTargets;
  12799. private _currentActiveTarget;
  12800. private _directTarget;
  12801. /**
  12802. * The target path of the runtime animation
  12803. */
  12804. private _targetPath;
  12805. /**
  12806. * The weight of the runtime animation
  12807. */
  12808. private _weight;
  12809. /**
  12810. * The ratio offset of the runtime animation
  12811. */
  12812. private _ratioOffset;
  12813. /**
  12814. * The previous delay of the runtime animation
  12815. */
  12816. private _previousDelay;
  12817. /**
  12818. * The previous ratio of the runtime animation
  12819. */
  12820. private _previousRatio;
  12821. private _enableBlending;
  12822. private _keys;
  12823. private _minFrame;
  12824. private _maxFrame;
  12825. private _minValue;
  12826. private _maxValue;
  12827. private _targetIsArray;
  12828. /**
  12829. * Gets the current frame of the runtime animation
  12830. */
  12831. readonly currentFrame: number;
  12832. /**
  12833. * Gets the weight of the runtime animation
  12834. */
  12835. readonly weight: number;
  12836. /**
  12837. * Gets the current value of the runtime animation
  12838. */
  12839. readonly currentValue: any;
  12840. /**
  12841. * Gets the target path of the runtime animation
  12842. */
  12843. readonly targetPath: string;
  12844. /**
  12845. * Gets the actual target of the runtime animation
  12846. */
  12847. readonly target: any;
  12848. /** @hidden */
  12849. _onLoop: () => void;
  12850. /**
  12851. * Create a new RuntimeAnimation object
  12852. * @param target defines the target of the animation
  12853. * @param animation defines the source animation object
  12854. * @param scene defines the hosting scene
  12855. * @param host defines the initiating Animatable
  12856. */
  12857. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12858. private _preparePath;
  12859. /**
  12860. * Gets the animation from the runtime animation
  12861. */
  12862. readonly animation: Animation;
  12863. /**
  12864. * Resets the runtime animation to the beginning
  12865. * @param restoreOriginal defines whether to restore the target property to the original value
  12866. */
  12867. reset(restoreOriginal?: boolean): void;
  12868. /**
  12869. * Specifies if the runtime animation is stopped
  12870. * @returns Boolean specifying if the runtime animation is stopped
  12871. */
  12872. isStopped(): boolean;
  12873. /**
  12874. * Disposes of the runtime animation
  12875. */
  12876. dispose(): void;
  12877. /**
  12878. * Apply the interpolated value to the target
  12879. * @param currentValue defines the value computed by the animation
  12880. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12881. */
  12882. setValue(currentValue: any, weight: number): void;
  12883. private _getOriginalValues;
  12884. private _setValue;
  12885. /**
  12886. * Gets the loop pmode of the runtime animation
  12887. * @returns Loop Mode
  12888. */
  12889. private _getCorrectLoopMode;
  12890. /**
  12891. * Move the current animation to a given frame
  12892. * @param frame defines the frame to move to
  12893. */
  12894. goToFrame(frame: number): void;
  12895. /**
  12896. * @hidden Internal use only
  12897. */
  12898. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12899. /**
  12900. * Execute the current animation
  12901. * @param delay defines the delay to add to the current frame
  12902. * @param from defines the lower bound of the animation range
  12903. * @param to defines the upper bound of the animation range
  12904. * @param loop defines if the current animation must loop
  12905. * @param speedRatio defines the current speed ratio
  12906. * @param weight defines the weight of the animation (default is -1 so no weight)
  12907. * @param onLoop optional callback called when animation loops
  12908. * @returns a boolean indicating if the animation is running
  12909. */
  12910. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * Class used to store an actual running animation
  12916. */
  12917. export class Animatable {
  12918. /** defines the target object */
  12919. target: any;
  12920. /** defines the starting frame number (default is 0) */
  12921. fromFrame: number;
  12922. /** defines the ending frame number (default is 100) */
  12923. toFrame: number;
  12924. /** defines if the animation must loop (default is false) */
  12925. loopAnimation: boolean;
  12926. /** defines a callback to call when animation ends if it is not looping */
  12927. onAnimationEnd?: (() => void) | null | undefined;
  12928. /** defines a callback to call when animation loops */
  12929. onAnimationLoop?: (() => void) | null | undefined;
  12930. private _localDelayOffset;
  12931. private _pausedDelay;
  12932. private _runtimeAnimations;
  12933. private _paused;
  12934. private _scene;
  12935. private _speedRatio;
  12936. private _weight;
  12937. private _syncRoot;
  12938. /**
  12939. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12940. * This will only apply for non looping animation (default is true)
  12941. */
  12942. disposeOnEnd: boolean;
  12943. /**
  12944. * Gets a boolean indicating if the animation has started
  12945. */
  12946. animationStarted: boolean;
  12947. /**
  12948. * Observer raised when the animation ends
  12949. */
  12950. onAnimationEndObservable: Observable<Animatable>;
  12951. /**
  12952. * Observer raised when the animation loops
  12953. */
  12954. onAnimationLoopObservable: Observable<Animatable>;
  12955. /**
  12956. * Gets the root Animatable used to synchronize and normalize animations
  12957. */
  12958. readonly syncRoot: Nullable<Animatable>;
  12959. /**
  12960. * Gets the current frame of the first RuntimeAnimation
  12961. * Used to synchronize Animatables
  12962. */
  12963. readonly masterFrame: number;
  12964. /**
  12965. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12966. */
  12967. weight: number;
  12968. /**
  12969. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12970. */
  12971. speedRatio: number;
  12972. /**
  12973. * Creates a new Animatable
  12974. * @param scene defines the hosting scene
  12975. * @param target defines the target object
  12976. * @param fromFrame defines the starting frame number (default is 0)
  12977. * @param toFrame defines the ending frame number (default is 100)
  12978. * @param loopAnimation defines if the animation must loop (default is false)
  12979. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12980. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12981. * @param animations defines a group of animation to add to the new Animatable
  12982. * @param onAnimationLoop defines a callback to call when animation loops
  12983. */
  12984. constructor(scene: Scene,
  12985. /** defines the target object */
  12986. target: any,
  12987. /** defines the starting frame number (default is 0) */
  12988. fromFrame?: number,
  12989. /** defines the ending frame number (default is 100) */
  12990. toFrame?: number,
  12991. /** defines if the animation must loop (default is false) */
  12992. loopAnimation?: boolean, speedRatio?: number,
  12993. /** defines a callback to call when animation ends if it is not looping */
  12994. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12995. /** defines a callback to call when animation loops */
  12996. onAnimationLoop?: (() => void) | null | undefined);
  12997. /**
  12998. * Synchronize and normalize current Animatable with a source Animatable
  12999. * This is useful when using animation weights and when animations are not of the same length
  13000. * @param root defines the root Animatable to synchronize with
  13001. * @returns the current Animatable
  13002. */
  13003. syncWith(root: Animatable): Animatable;
  13004. /**
  13005. * Gets the list of runtime animations
  13006. * @returns an array of RuntimeAnimation
  13007. */
  13008. getAnimations(): RuntimeAnimation[];
  13009. /**
  13010. * Adds more animations to the current animatable
  13011. * @param target defines the target of the animations
  13012. * @param animations defines the new animations to add
  13013. */
  13014. appendAnimations(target: any, animations: Animation[]): void;
  13015. /**
  13016. * Gets the source animation for a specific property
  13017. * @param property defines the propertyu to look for
  13018. * @returns null or the source animation for the given property
  13019. */
  13020. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13021. /**
  13022. * Gets the runtime animation for a specific property
  13023. * @param property defines the propertyu to look for
  13024. * @returns null or the runtime animation for the given property
  13025. */
  13026. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13027. /**
  13028. * Resets the animatable to its original state
  13029. */
  13030. reset(): void;
  13031. /**
  13032. * Allows the animatable to blend with current running animations
  13033. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13034. * @param blendingSpeed defines the blending speed to use
  13035. */
  13036. enableBlending(blendingSpeed: number): void;
  13037. /**
  13038. * Disable animation blending
  13039. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13040. */
  13041. disableBlending(): void;
  13042. /**
  13043. * Jump directly to a given frame
  13044. * @param frame defines the frame to jump to
  13045. */
  13046. goToFrame(frame: number): void;
  13047. /**
  13048. * Pause the animation
  13049. */
  13050. pause(): void;
  13051. /**
  13052. * Restart the animation
  13053. */
  13054. restart(): void;
  13055. private _raiseOnAnimationEnd;
  13056. /**
  13057. * Stop and delete the current animation
  13058. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13059. * @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)
  13060. */
  13061. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13062. /**
  13063. * Wait asynchronously for the animation to end
  13064. * @returns a promise which will be fullfilled when the animation ends
  13065. */
  13066. waitAsync(): Promise<Animatable>;
  13067. /** @hidden */
  13068. _animate(delay: number): boolean;
  13069. }
  13070. interface Scene {
  13071. /** @hidden */
  13072. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13073. /** @hidden */
  13074. _processLateAnimationBindingsForMatrices(holder: {
  13075. totalWeight: number;
  13076. animations: RuntimeAnimation[];
  13077. originalValue: Matrix;
  13078. }): any;
  13079. /** @hidden */
  13080. _processLateAnimationBindingsForQuaternions(holder: {
  13081. totalWeight: number;
  13082. animations: RuntimeAnimation[];
  13083. originalValue: Quaternion;
  13084. }, refQuaternion: Quaternion): Quaternion;
  13085. /** @hidden */
  13086. _processLateAnimationBindings(): void;
  13087. /**
  13088. * Will start the animation sequence of a given target
  13089. * @param target defines the target
  13090. * @param from defines from which frame should animation start
  13091. * @param to defines until which frame should animation run.
  13092. * @param weight defines the weight to apply to the animation (1.0 by default)
  13093. * @param loop defines if the animation loops
  13094. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13095. * @param onAnimationEnd defines the function to be executed when the animation ends
  13096. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13097. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13098. * @param onAnimationLoop defines the callback to call when an animation loops
  13099. * @returns the animatable object created for this animation
  13100. */
  13101. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13102. /**
  13103. * Will start the animation sequence of a given target
  13104. * @param target defines the target
  13105. * @param from defines from which frame should animation start
  13106. * @param to defines until which frame should animation run.
  13107. * @param loop defines if the animation loops
  13108. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13109. * @param onAnimationEnd defines the function to be executed when the animation ends
  13110. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13111. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13112. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13113. * @param onAnimationLoop defines the callback to call when an animation loops
  13114. * @returns the animatable object created for this animation
  13115. */
  13116. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13117. /**
  13118. * Will start the animation sequence of a given target and its hierarchy
  13119. * @param target defines the target
  13120. * @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.
  13121. * @param from defines from which frame should animation start
  13122. * @param to defines until which frame should animation run.
  13123. * @param loop defines if the animation loops
  13124. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13125. * @param onAnimationEnd defines the function to be executed when the animation ends
  13126. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13127. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13128. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13129. * @param onAnimationLoop defines the callback to call when an animation loops
  13130. * @returns the list of created animatables
  13131. */
  13132. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13133. /**
  13134. * Begin a new animation on a given node
  13135. * @param target defines the target where the animation will take place
  13136. * @param animations defines the list of animations to start
  13137. * @param from defines the initial value
  13138. * @param to defines the final value
  13139. * @param loop defines if you want animation to loop (off by default)
  13140. * @param speedRatio defines the speed ratio to apply to all animations
  13141. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13142. * @param onAnimationLoop defines the callback to call when an animation loops
  13143. * @returns the list of created animatables
  13144. */
  13145. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13146. /**
  13147. * Begin a new animation on a given node and its hierarchy
  13148. * @param target defines the root node where the animation will take place
  13149. * @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.
  13150. * @param animations defines the list of animations to start
  13151. * @param from defines the initial value
  13152. * @param to defines the final value
  13153. * @param loop defines if you want animation to loop (off by default)
  13154. * @param speedRatio defines the speed ratio to apply to all animations
  13155. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the list of animatables created for all nodes
  13158. */
  13159. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13160. /**
  13161. * Gets the animatable associated with a specific target
  13162. * @param target defines the target of the animatable
  13163. * @returns the required animatable if found
  13164. */
  13165. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13166. /**
  13167. * Gets all animatables associated with a given target
  13168. * @param target defines the target to look animatables for
  13169. * @returns an array of Animatables
  13170. */
  13171. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13172. /**
  13173. * Stops and removes all animations that have been applied to the scene
  13174. */
  13175. stopAllAnimations(): void;
  13176. /**
  13177. * Gets the current delta time used by animation engine
  13178. */
  13179. deltaTime: number;
  13180. }
  13181. interface Bone {
  13182. /**
  13183. * Copy an animation range from another bone
  13184. * @param source defines the source bone
  13185. * @param rangeName defines the range name to copy
  13186. * @param frameOffset defines the frame offset
  13187. * @param rescaleAsRequired defines if rescaling must be applied if required
  13188. * @param skelDimensionsRatio defines the scaling ratio
  13189. * @returns true if operation was successful
  13190. */
  13191. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13192. }
  13193. }
  13194. declare module BABYLON {
  13195. /**
  13196. * Class used to override all child animations of a given target
  13197. */
  13198. export class AnimationPropertiesOverride {
  13199. /**
  13200. * Gets or sets a value indicating if animation blending must be used
  13201. */
  13202. enableBlending: boolean;
  13203. /**
  13204. * Gets or sets the blending speed to use when enableBlending is true
  13205. */
  13206. blendingSpeed: number;
  13207. /**
  13208. * Gets or sets the default loop mode to use
  13209. */
  13210. loopMode: number;
  13211. }
  13212. }
  13213. declare module BABYLON {
  13214. /**
  13215. * Class used to handle skinning animations
  13216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13217. */
  13218. export class Skeleton implements IAnimatable {
  13219. /** defines the skeleton name */
  13220. name: string;
  13221. /** defines the skeleton Id */
  13222. id: string;
  13223. /**
  13224. * Defines the list of child bones
  13225. */
  13226. bones: Bone[];
  13227. /**
  13228. * Defines an estimate of the dimension of the skeleton at rest
  13229. */
  13230. dimensionsAtRest: Vector3;
  13231. /**
  13232. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13233. */
  13234. needInitialSkinMatrix: boolean;
  13235. /**
  13236. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13237. */
  13238. overrideMesh: Nullable<AbstractMesh>;
  13239. /**
  13240. * Gets the list of animations attached to this skeleton
  13241. */
  13242. animations: Array<Animation>;
  13243. private _scene;
  13244. private _isDirty;
  13245. private _transformMatrices;
  13246. private _transformMatrixTexture;
  13247. private _meshesWithPoseMatrix;
  13248. private _animatables;
  13249. private _identity;
  13250. private _synchronizedWithMesh;
  13251. private _ranges;
  13252. private _lastAbsoluteTransformsUpdateId;
  13253. private _canUseTextureForBones;
  13254. private _uniqueId;
  13255. /** @hidden */
  13256. _numBonesWithLinkedTransformNode: number;
  13257. /** @hidden */
  13258. _hasWaitingData: Nullable<boolean>;
  13259. /**
  13260. * Specifies if the skeleton should be serialized
  13261. */
  13262. doNotSerialize: boolean;
  13263. private _useTextureToStoreBoneMatrices;
  13264. /**
  13265. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13266. * Please note that this option is not available if the hardware does not support it
  13267. */
  13268. useTextureToStoreBoneMatrices: boolean;
  13269. private _animationPropertiesOverride;
  13270. /**
  13271. * Gets or sets the animation properties override
  13272. */
  13273. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13274. /**
  13275. * List of inspectable custom properties (used by the Inspector)
  13276. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13277. */
  13278. inspectableCustomProperties: IInspectable[];
  13279. /**
  13280. * An observable triggered before computing the skeleton's matrices
  13281. */
  13282. onBeforeComputeObservable: Observable<Skeleton>;
  13283. /**
  13284. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13285. */
  13286. readonly isUsingTextureForMatrices: boolean;
  13287. /**
  13288. * Gets the unique ID of this skeleton
  13289. */
  13290. readonly uniqueId: number;
  13291. /**
  13292. * Creates a new skeleton
  13293. * @param name defines the skeleton name
  13294. * @param id defines the skeleton Id
  13295. * @param scene defines the hosting scene
  13296. */
  13297. constructor(
  13298. /** defines the skeleton name */
  13299. name: string,
  13300. /** defines the skeleton Id */
  13301. id: string, scene: Scene);
  13302. /**
  13303. * Gets the current object class name.
  13304. * @return the class name
  13305. */
  13306. getClassName(): string;
  13307. /**
  13308. * Returns an array containing the root bones
  13309. * @returns an array containing the root bones
  13310. */
  13311. getChildren(): Array<Bone>;
  13312. /**
  13313. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13314. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13315. * @returns a Float32Array containing matrices data
  13316. */
  13317. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13318. /**
  13319. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13320. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13321. * @returns a raw texture containing the data
  13322. */
  13323. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13324. /**
  13325. * Gets the current hosting scene
  13326. * @returns a scene object
  13327. */
  13328. getScene(): Scene;
  13329. /**
  13330. * Gets a string representing the current skeleton data
  13331. * @param fullDetails defines a boolean indicating if we want a verbose version
  13332. * @returns a string representing the current skeleton data
  13333. */
  13334. toString(fullDetails?: boolean): string;
  13335. /**
  13336. * Get bone's index searching by name
  13337. * @param name defines bone's name to search for
  13338. * @return the indice of the bone. Returns -1 if not found
  13339. */
  13340. getBoneIndexByName(name: string): number;
  13341. /**
  13342. * Creater a new animation range
  13343. * @param name defines the name of the range
  13344. * @param from defines the start key
  13345. * @param to defines the end key
  13346. */
  13347. createAnimationRange(name: string, from: number, to: number): void;
  13348. /**
  13349. * Delete a specific animation range
  13350. * @param name defines the name of the range
  13351. * @param deleteFrames defines if frames must be removed as well
  13352. */
  13353. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13354. /**
  13355. * Gets a specific animation range
  13356. * @param name defines the name of the range to look for
  13357. * @returns the requested animation range or null if not found
  13358. */
  13359. getAnimationRange(name: string): Nullable<AnimationRange>;
  13360. /**
  13361. * Gets the list of all animation ranges defined on this skeleton
  13362. * @returns an array
  13363. */
  13364. getAnimationRanges(): Nullable<AnimationRange>[];
  13365. /**
  13366. * Copy animation range from a source skeleton.
  13367. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13368. * @param source defines the source skeleton
  13369. * @param name defines the name of the range to copy
  13370. * @param rescaleAsRequired defines if rescaling must be applied if required
  13371. * @returns true if operation was successful
  13372. */
  13373. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13374. /**
  13375. * Forces the skeleton to go to rest pose
  13376. */
  13377. returnToRest(): void;
  13378. private _getHighestAnimationFrame;
  13379. /**
  13380. * Begin a specific animation range
  13381. * @param name defines the name of the range to start
  13382. * @param loop defines if looping must be turned on (false by default)
  13383. * @param speedRatio defines the speed ratio to apply (1 by default)
  13384. * @param onAnimationEnd defines a callback which will be called when animation will end
  13385. * @returns a new animatable
  13386. */
  13387. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13388. /** @hidden */
  13389. _markAsDirty(): void;
  13390. /** @hidden */
  13391. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13392. /** @hidden */
  13393. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13394. private _computeTransformMatrices;
  13395. /**
  13396. * Build all resources required to render a skeleton
  13397. */
  13398. prepare(): void;
  13399. /**
  13400. * Gets the list of animatables currently running for this skeleton
  13401. * @returns an array of animatables
  13402. */
  13403. getAnimatables(): IAnimatable[];
  13404. /**
  13405. * Clone the current skeleton
  13406. * @param name defines the name of the new skeleton
  13407. * @param id defines the id of the new skeleton
  13408. * @returns the new skeleton
  13409. */
  13410. clone(name: string, id?: string): Skeleton;
  13411. /**
  13412. * Enable animation blending for this skeleton
  13413. * @param blendingSpeed defines the blending speed to apply
  13414. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13415. */
  13416. enableBlending(blendingSpeed?: number): void;
  13417. /**
  13418. * Releases all resources associated with the current skeleton
  13419. */
  13420. dispose(): void;
  13421. /**
  13422. * Serialize the skeleton in a JSON object
  13423. * @returns a JSON object
  13424. */
  13425. serialize(): any;
  13426. /**
  13427. * Creates a new skeleton from serialized data
  13428. * @param parsedSkeleton defines the serialized data
  13429. * @param scene defines the hosting scene
  13430. * @returns a new skeleton
  13431. */
  13432. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13433. /**
  13434. * Compute all node absolute transforms
  13435. * @param forceUpdate defines if computation must be done even if cache is up to date
  13436. */
  13437. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13438. /**
  13439. * Gets the root pose matrix
  13440. * @returns a matrix
  13441. */
  13442. getPoseMatrix(): Nullable<Matrix>;
  13443. /**
  13444. * Sorts bones per internal index
  13445. */
  13446. sortBones(): void;
  13447. private _sortBones;
  13448. }
  13449. }
  13450. declare module BABYLON {
  13451. /**
  13452. * Class used to store bone information
  13453. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13454. */
  13455. export class Bone extends Node {
  13456. /**
  13457. * defines the bone name
  13458. */
  13459. name: string;
  13460. private static _tmpVecs;
  13461. private static _tmpQuat;
  13462. private static _tmpMats;
  13463. /**
  13464. * Gets the list of child bones
  13465. */
  13466. children: Bone[];
  13467. /** Gets the animations associated with this bone */
  13468. animations: Animation[];
  13469. /**
  13470. * Gets or sets bone length
  13471. */
  13472. length: number;
  13473. /**
  13474. * @hidden Internal only
  13475. * Set this value to map this bone to a different index in the transform matrices
  13476. * Set this value to -1 to exclude the bone from the transform matrices
  13477. */
  13478. _index: Nullable<number>;
  13479. private _skeleton;
  13480. private _localMatrix;
  13481. private _restPose;
  13482. private _baseMatrix;
  13483. private _absoluteTransform;
  13484. private _invertedAbsoluteTransform;
  13485. private _parent;
  13486. private _scalingDeterminant;
  13487. private _worldTransform;
  13488. private _localScaling;
  13489. private _localRotation;
  13490. private _localPosition;
  13491. private _needToDecompose;
  13492. private _needToCompose;
  13493. /** @hidden */
  13494. _linkedTransformNode: Nullable<TransformNode>;
  13495. /** @hidden */
  13496. _waitingTransformNodeId: Nullable<string>;
  13497. /** @hidden */
  13498. /** @hidden */
  13499. _matrix: Matrix;
  13500. /**
  13501. * Create a new bone
  13502. * @param name defines the bone name
  13503. * @param skeleton defines the parent skeleton
  13504. * @param parentBone defines the parent (can be null if the bone is the root)
  13505. * @param localMatrix defines the local matrix
  13506. * @param restPose defines the rest pose matrix
  13507. * @param baseMatrix defines the base matrix
  13508. * @param index defines index of the bone in the hiearchy
  13509. */
  13510. constructor(
  13511. /**
  13512. * defines the bone name
  13513. */
  13514. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13515. /**
  13516. * Gets the current object class name.
  13517. * @return the class name
  13518. */
  13519. getClassName(): string;
  13520. /**
  13521. * Gets the parent skeleton
  13522. * @returns a skeleton
  13523. */
  13524. getSkeleton(): Skeleton;
  13525. /**
  13526. * Gets parent bone
  13527. * @returns a bone or null if the bone is the root of the bone hierarchy
  13528. */
  13529. getParent(): Nullable<Bone>;
  13530. /**
  13531. * Returns an array containing the root bones
  13532. * @returns an array containing the root bones
  13533. */
  13534. getChildren(): Array<Bone>;
  13535. /**
  13536. * Gets the node index in matrix array generated for rendering
  13537. * @returns the node index
  13538. */
  13539. getIndex(): number;
  13540. /**
  13541. * Sets the parent bone
  13542. * @param parent defines the parent (can be null if the bone is the root)
  13543. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13544. */
  13545. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13546. /**
  13547. * Gets the local matrix
  13548. * @returns a matrix
  13549. */
  13550. getLocalMatrix(): Matrix;
  13551. /**
  13552. * Gets the base matrix (initial matrix which remains unchanged)
  13553. * @returns a matrix
  13554. */
  13555. getBaseMatrix(): Matrix;
  13556. /**
  13557. * Gets the rest pose matrix
  13558. * @returns a matrix
  13559. */
  13560. getRestPose(): Matrix;
  13561. /**
  13562. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13563. */
  13564. getWorldMatrix(): Matrix;
  13565. /**
  13566. * Sets the local matrix to rest pose matrix
  13567. */
  13568. returnToRest(): void;
  13569. /**
  13570. * Gets the inverse of the absolute transform matrix.
  13571. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13572. * @returns a matrix
  13573. */
  13574. getInvertedAbsoluteTransform(): Matrix;
  13575. /**
  13576. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13577. * @returns a matrix
  13578. */
  13579. getAbsoluteTransform(): Matrix;
  13580. /**
  13581. * Links with the given transform node.
  13582. * The local matrix of this bone is copied from the transform node every frame.
  13583. * @param transformNode defines the transform node to link to
  13584. */
  13585. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13586. /**
  13587. * Gets the node used to drive the bone's transformation
  13588. * @returns a transform node or null
  13589. */
  13590. getTransformNode(): Nullable<TransformNode>;
  13591. /** Gets or sets current position (in local space) */
  13592. position: Vector3;
  13593. /** Gets or sets current rotation (in local space) */
  13594. rotation: Vector3;
  13595. /** Gets or sets current rotation quaternion (in local space) */
  13596. rotationQuaternion: Quaternion;
  13597. /** Gets or sets current scaling (in local space) */
  13598. scaling: Vector3;
  13599. /**
  13600. * Gets the animation properties override
  13601. */
  13602. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13603. private _decompose;
  13604. private _compose;
  13605. /**
  13606. * Update the base and local matrices
  13607. * @param matrix defines the new base or local matrix
  13608. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13609. * @param updateLocalMatrix defines if the local matrix should be updated
  13610. */
  13611. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13612. /** @hidden */
  13613. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13614. /**
  13615. * Flag the bone as dirty (Forcing it to update everything)
  13616. */
  13617. markAsDirty(): void;
  13618. /** @hidden */
  13619. _markAsDirtyAndCompose(): void;
  13620. private _markAsDirtyAndDecompose;
  13621. /**
  13622. * Translate the bone in local or world space
  13623. * @param vec The amount to translate the bone
  13624. * @param space The space that the translation is in
  13625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13626. */
  13627. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13628. /**
  13629. * Set the postion of the bone in local or world space
  13630. * @param position The position to set the bone
  13631. * @param space The space that the position is in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. */
  13634. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13635. /**
  13636. * Set the absolute position of the bone (world space)
  13637. * @param position The position to set the bone
  13638. * @param mesh The mesh that this bone is attached to
  13639. */
  13640. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13641. /**
  13642. * Scale the bone on the x, y and z axes (in local space)
  13643. * @param x The amount to scale the bone on the x axis
  13644. * @param y The amount to scale the bone on the y axis
  13645. * @param z The amount to scale the bone on the z axis
  13646. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13647. */
  13648. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13649. /**
  13650. * Set the bone scaling in local space
  13651. * @param scale defines the scaling vector
  13652. */
  13653. setScale(scale: Vector3): void;
  13654. /**
  13655. * Gets the current scaling in local space
  13656. * @returns the current scaling vector
  13657. */
  13658. getScale(): Vector3;
  13659. /**
  13660. * Gets the current scaling in local space and stores it in a target vector
  13661. * @param result defines the target vector
  13662. */
  13663. getScaleToRef(result: Vector3): void;
  13664. /**
  13665. * Set the yaw, pitch, and roll of the bone in local or world space
  13666. * @param yaw The rotation of the bone on the y axis
  13667. * @param pitch The rotation of the bone on the x axis
  13668. * @param roll The rotation of the bone on the z axis
  13669. * @param space The space that the axes of rotation are in
  13670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13671. */
  13672. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13673. /**
  13674. * Add a rotation to the bone on an axis in local or world space
  13675. * @param axis The axis to rotate the bone on
  13676. * @param amount The amount to rotate the bone
  13677. * @param space The space that the axis is in
  13678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13679. */
  13680. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13681. /**
  13682. * Set the rotation of the bone to a particular axis angle in local or world space
  13683. * @param axis The axis to rotate the bone on
  13684. * @param angle The angle that the bone should be rotated to
  13685. * @param space The space that the axis is in
  13686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13687. */
  13688. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13689. /**
  13690. * Set the euler rotation of the bone in local of world space
  13691. * @param rotation The euler rotation that the bone should be set to
  13692. * @param space The space that the rotation is in
  13693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13694. */
  13695. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13696. /**
  13697. * Set the quaternion rotation of the bone in local of world space
  13698. * @param quat The quaternion rotation that the bone should be set to
  13699. * @param space The space that the rotation is in
  13700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13701. */
  13702. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13703. /**
  13704. * Set the rotation matrix of the bone in local of world space
  13705. * @param rotMat The rotation matrix that the bone should be set to
  13706. * @param space The space that the rotation is in
  13707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13708. */
  13709. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13710. private _rotateWithMatrix;
  13711. private _getNegativeRotationToRef;
  13712. /**
  13713. * Get the position of the bone in local or world space
  13714. * @param space The space that the returned position is in
  13715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13716. * @returns The position of the bone
  13717. */
  13718. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13719. /**
  13720. * Copy the position of the bone to a vector3 in local or world space
  13721. * @param space The space that the returned position is in
  13722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13723. * @param result The vector3 to copy the position to
  13724. */
  13725. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13726. /**
  13727. * Get the absolute position of the bone (world space)
  13728. * @param mesh The mesh that this bone is attached to
  13729. * @returns The absolute position of the bone
  13730. */
  13731. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13732. /**
  13733. * Copy the absolute position of the bone (world space) to the result param
  13734. * @param mesh The mesh that this bone is attached to
  13735. * @param result The vector3 to copy the absolute position to
  13736. */
  13737. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13738. /**
  13739. * Compute the absolute transforms of this bone and its children
  13740. */
  13741. computeAbsoluteTransforms(): void;
  13742. /**
  13743. * Get the world direction from an axis that is in the local space of the bone
  13744. * @param localAxis The local direction that is used to compute the world direction
  13745. * @param mesh The mesh that this bone is attached to
  13746. * @returns The world direction
  13747. */
  13748. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13749. /**
  13750. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13751. * @param localAxis The local direction that is used to compute the world direction
  13752. * @param mesh The mesh that this bone is attached to
  13753. * @param result The vector3 that the world direction will be copied to
  13754. */
  13755. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13756. /**
  13757. * Get the euler rotation of the bone in local or world space
  13758. * @param space The space that the rotation should be in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. * @returns The euler rotation
  13761. */
  13762. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13763. /**
  13764. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13765. * @param space The space that the rotation should be in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. * @param result The vector3 that the rotation should be copied to
  13768. */
  13769. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13770. /**
  13771. * Get the quaternion rotation of the bone in either local or world space
  13772. * @param space The space that the rotation should be in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. * @returns The quaternion rotation
  13775. */
  13776. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13777. /**
  13778. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13779. * @param space The space that the rotation should be in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. * @param result The quaternion that the rotation should be copied to
  13782. */
  13783. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13784. /**
  13785. * Get the rotation matrix of the bone in local or world space
  13786. * @param space The space that the rotation should be in
  13787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13788. * @returns The rotation matrix
  13789. */
  13790. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13791. /**
  13792. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13793. * @param space The space that the rotation should be in
  13794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13795. * @param result The quaternion that the rotation should be copied to
  13796. */
  13797. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13798. /**
  13799. * Get the world position of a point that is in the local space of the bone
  13800. * @param position The local position
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The world position
  13803. */
  13804. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13807. * @param position The local position
  13808. * @param mesh The mesh that this bone is attached to
  13809. * @param result The vector3 that the world position should be copied to
  13810. */
  13811. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13812. /**
  13813. * Get the local position of a point that is in world space
  13814. * @param position The world position
  13815. * @param mesh The mesh that this bone is attached to
  13816. * @returns The local position
  13817. */
  13818. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13819. /**
  13820. * Get the local position of a point that is in world space and copy it to the result param
  13821. * @param position The world position
  13822. * @param mesh The mesh that this bone is attached to
  13823. * @param result The vector3 that the local position should be copied to
  13824. */
  13825. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13826. }
  13827. }
  13828. declare module BABYLON {
  13829. /**
  13830. * 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.
  13831. * @see https://doc.babylonjs.com/how_to/transformnode
  13832. */
  13833. export class TransformNode extends Node {
  13834. /**
  13835. * Object will not rotate to face the camera
  13836. */
  13837. static BILLBOARDMODE_NONE: number;
  13838. /**
  13839. * Object will rotate to face the camera but only on the x axis
  13840. */
  13841. static BILLBOARDMODE_X: number;
  13842. /**
  13843. * Object will rotate to face the camera but only on the y axis
  13844. */
  13845. static BILLBOARDMODE_Y: number;
  13846. /**
  13847. * Object will rotate to face the camera but only on the z axis
  13848. */
  13849. static BILLBOARDMODE_Z: number;
  13850. /**
  13851. * Object will rotate to face the camera
  13852. */
  13853. static BILLBOARDMODE_ALL: number;
  13854. /**
  13855. * Object will rotate to face the camera's position instead of orientation
  13856. */
  13857. static BILLBOARDMODE_USE_POSITION: number;
  13858. private _forward;
  13859. private _forwardInverted;
  13860. private _up;
  13861. private _right;
  13862. private _rightInverted;
  13863. private _position;
  13864. private _rotation;
  13865. private _rotationQuaternion;
  13866. protected _scaling: Vector3;
  13867. protected _isDirty: boolean;
  13868. private _transformToBoneReferal;
  13869. private _isAbsoluteSynced;
  13870. private _billboardMode;
  13871. /**
  13872. * Gets or sets the billboard mode. Default is 0.
  13873. *
  13874. * | Value | Type | Description |
  13875. * | --- | --- | --- |
  13876. * | 0 | BILLBOARDMODE_NONE | |
  13877. * | 1 | BILLBOARDMODE_X | |
  13878. * | 2 | BILLBOARDMODE_Y | |
  13879. * | 4 | BILLBOARDMODE_Z | |
  13880. * | 7 | BILLBOARDMODE_ALL | |
  13881. *
  13882. */
  13883. billboardMode: number;
  13884. private _preserveParentRotationForBillboard;
  13885. /**
  13886. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13887. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13888. */
  13889. preserveParentRotationForBillboard: boolean;
  13890. /**
  13891. * 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
  13892. */
  13893. scalingDeterminant: number;
  13894. private _infiniteDistance;
  13895. /**
  13896. * Gets or sets the distance of the object to max, often used by skybox
  13897. */
  13898. infiniteDistance: boolean;
  13899. /**
  13900. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13901. * By default the system will update normals to compensate
  13902. */
  13903. ignoreNonUniformScaling: boolean;
  13904. /**
  13905. * 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
  13906. */
  13907. reIntegrateRotationIntoRotationQuaternion: boolean;
  13908. /** @hidden */
  13909. _poseMatrix: Nullable<Matrix>;
  13910. /** @hidden */
  13911. _localMatrix: Matrix;
  13912. private _usePivotMatrix;
  13913. private _absolutePosition;
  13914. private _absoluteScaling;
  13915. private _absoluteRotationQuaternion;
  13916. private _pivotMatrix;
  13917. private _pivotMatrixInverse;
  13918. protected _postMultiplyPivotMatrix: boolean;
  13919. protected _isWorldMatrixFrozen: boolean;
  13920. /** @hidden */
  13921. _indexInSceneTransformNodesArray: number;
  13922. /**
  13923. * An event triggered after the world matrix is updated
  13924. */
  13925. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13926. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13927. /**
  13928. * Gets a string identifying the name of the class
  13929. * @returns "TransformNode" string
  13930. */
  13931. getClassName(): string;
  13932. /**
  13933. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13934. */
  13935. position: Vector3;
  13936. /**
  13937. * 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)).
  13938. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13939. */
  13940. rotation: Vector3;
  13941. /**
  13942. * 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)).
  13943. */
  13944. scaling: Vector3;
  13945. /**
  13946. * 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).
  13947. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13948. */
  13949. rotationQuaternion: Nullable<Quaternion>;
  13950. /**
  13951. * The forward direction of that transform in world space.
  13952. */
  13953. readonly forward: Vector3;
  13954. /**
  13955. * The up direction of that transform in world space.
  13956. */
  13957. readonly up: Vector3;
  13958. /**
  13959. * The right direction of that transform in world space.
  13960. */
  13961. readonly right: Vector3;
  13962. /**
  13963. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13964. * @param matrix the matrix to copy the pose from
  13965. * @returns this TransformNode.
  13966. */
  13967. updatePoseMatrix(matrix: Matrix): TransformNode;
  13968. /**
  13969. * Returns the mesh Pose matrix.
  13970. * @returns the pose matrix
  13971. */
  13972. getPoseMatrix(): Matrix;
  13973. /** @hidden */
  13974. _isSynchronized(): boolean;
  13975. /** @hidden */
  13976. _initCache(): void;
  13977. /**
  13978. * Flag the transform node as dirty (Forcing it to update everything)
  13979. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13980. * @returns this transform node
  13981. */
  13982. markAsDirty(property: string): TransformNode;
  13983. /**
  13984. * Returns the current mesh absolute position.
  13985. * Returns a Vector3.
  13986. */
  13987. readonly absolutePosition: Vector3;
  13988. /**
  13989. * Returns the current mesh absolute scaling.
  13990. * Returns a Vector3.
  13991. */
  13992. readonly absoluteScaling: Vector3;
  13993. /**
  13994. * Returns the current mesh absolute rotation.
  13995. * Returns a Quaternion.
  13996. */
  13997. readonly absoluteRotationQuaternion: Quaternion;
  13998. /**
  13999. * Sets a new matrix to apply before all other transformation
  14000. * @param matrix defines the transform matrix
  14001. * @returns the current TransformNode
  14002. */
  14003. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14004. /**
  14005. * Sets a new pivot matrix to the current node
  14006. * @param matrix defines the new pivot matrix to use
  14007. * @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
  14008. * @returns the current TransformNode
  14009. */
  14010. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14011. /**
  14012. * Returns the mesh pivot matrix.
  14013. * Default : Identity.
  14014. * @returns the matrix
  14015. */
  14016. getPivotMatrix(): Matrix;
  14017. /**
  14018. * Instantiate (when possible) or clone that node with its hierarchy
  14019. * @param newParent defines the new parent to use for the instance (or clone)
  14020. * @param options defines options to configure how copy is done
  14021. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14022. * @returns an instance (or a clone) of the current node with its hiearchy
  14023. */
  14024. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14025. doNotInstantiate: boolean;
  14026. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14027. /**
  14028. * Prevents the World matrix to be computed any longer
  14029. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14030. * @returns the TransformNode.
  14031. */
  14032. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14033. /**
  14034. * Allows back the World matrix computation.
  14035. * @returns the TransformNode.
  14036. */
  14037. unfreezeWorldMatrix(): this;
  14038. /**
  14039. * True if the World matrix has been frozen.
  14040. */
  14041. readonly isWorldMatrixFrozen: boolean;
  14042. /**
  14043. * Retuns the mesh absolute position in the World.
  14044. * @returns a Vector3.
  14045. */
  14046. getAbsolutePosition(): Vector3;
  14047. /**
  14048. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14049. * @param absolutePosition the absolute position to set
  14050. * @returns the TransformNode.
  14051. */
  14052. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14053. /**
  14054. * Sets the mesh position in its local space.
  14055. * @param vector3 the position to set in localspace
  14056. * @returns the TransformNode.
  14057. */
  14058. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14059. /**
  14060. * Returns the mesh position in the local space from the current World matrix values.
  14061. * @returns a new Vector3.
  14062. */
  14063. getPositionExpressedInLocalSpace(): Vector3;
  14064. /**
  14065. * Translates the mesh along the passed Vector3 in its local space.
  14066. * @param vector3 the distance to translate in localspace
  14067. * @returns the TransformNode.
  14068. */
  14069. locallyTranslate(vector3: Vector3): TransformNode;
  14070. private static _lookAtVectorCache;
  14071. /**
  14072. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14073. * @param targetPoint the position (must be in same space as current mesh) to look at
  14074. * @param yawCor optional yaw (y-axis) correction in radians
  14075. * @param pitchCor optional pitch (x-axis) correction in radians
  14076. * @param rollCor optional roll (z-axis) correction in radians
  14077. * @param space the choosen space of the target
  14078. * @returns the TransformNode.
  14079. */
  14080. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14081. /**
  14082. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14083. * This Vector3 is expressed in the World space.
  14084. * @param localAxis axis to rotate
  14085. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14086. */
  14087. getDirection(localAxis: Vector3): Vector3;
  14088. /**
  14089. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14090. * localAxis is expressed in the mesh local space.
  14091. * result is computed in the Wordl space from the mesh World matrix.
  14092. * @param localAxis axis to rotate
  14093. * @param result the resulting transformnode
  14094. * @returns this TransformNode.
  14095. */
  14096. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14097. /**
  14098. * Sets this transform node rotation to the given local axis.
  14099. * @param localAxis the axis in local space
  14100. * @param yawCor optional yaw (y-axis) correction in radians
  14101. * @param pitchCor optional pitch (x-axis) correction in radians
  14102. * @param rollCor optional roll (z-axis) correction in radians
  14103. * @returns this TransformNode
  14104. */
  14105. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14106. /**
  14107. * Sets a new pivot point to the current node
  14108. * @param point defines the new pivot point to use
  14109. * @param space defines if the point is in world or local space (local by default)
  14110. * @returns the current TransformNode
  14111. */
  14112. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14113. /**
  14114. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14115. * @returns the pivot point
  14116. */
  14117. getPivotPoint(): Vector3;
  14118. /**
  14119. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14120. * @param result the vector3 to store the result
  14121. * @returns this TransformNode.
  14122. */
  14123. getPivotPointToRef(result: Vector3): TransformNode;
  14124. /**
  14125. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14126. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14127. */
  14128. getAbsolutePivotPoint(): Vector3;
  14129. /**
  14130. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14131. * @param result vector3 to store the result
  14132. * @returns this TransformNode.
  14133. */
  14134. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14135. /**
  14136. * Defines the passed node as the parent of the current node.
  14137. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14138. * @see https://doc.babylonjs.com/how_to/parenting
  14139. * @param node the node ot set as the parent
  14140. * @returns this TransformNode.
  14141. */
  14142. setParent(node: Nullable<Node>): TransformNode;
  14143. private _nonUniformScaling;
  14144. /**
  14145. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14146. */
  14147. readonly nonUniformScaling: boolean;
  14148. /** @hidden */
  14149. _updateNonUniformScalingState(value: boolean): boolean;
  14150. /**
  14151. * Attach the current TransformNode to another TransformNode associated with a bone
  14152. * @param bone Bone affecting the TransformNode
  14153. * @param affectedTransformNode TransformNode associated with the bone
  14154. * @returns this object
  14155. */
  14156. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14157. /**
  14158. * Detach the transform node if its associated with a bone
  14159. * @returns this object
  14160. */
  14161. detachFromBone(): TransformNode;
  14162. private static _rotationAxisCache;
  14163. /**
  14164. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14165. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14166. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14167. * The passed axis is also normalized.
  14168. * @param axis the axis to rotate around
  14169. * @param amount the amount to rotate in radians
  14170. * @param space Space to rotate in (Default: local)
  14171. * @returns the TransformNode.
  14172. */
  14173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14174. /**
  14175. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14176. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14177. * The passed axis is also normalized. .
  14178. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14179. * @param point the point to rotate around
  14180. * @param axis the axis to rotate around
  14181. * @param amount the amount to rotate in radians
  14182. * @returns the TransformNode
  14183. */
  14184. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14185. /**
  14186. * Translates the mesh along the axis vector for the passed distance in the given space.
  14187. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14188. * @param axis the axis to translate in
  14189. * @param distance the distance to translate
  14190. * @param space Space to rotate in (Default: local)
  14191. * @returns the TransformNode.
  14192. */
  14193. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14194. /**
  14195. * Adds a rotation step to the mesh current rotation.
  14196. * x, y, z are Euler angles expressed in radians.
  14197. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14198. * This means this rotation is made in the mesh local space only.
  14199. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14200. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14201. * ```javascript
  14202. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14203. * ```
  14204. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14205. * 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.
  14206. * @param x Rotation to add
  14207. * @param y Rotation to add
  14208. * @param z Rotation to add
  14209. * @returns the TransformNode.
  14210. */
  14211. addRotation(x: number, y: number, z: number): TransformNode;
  14212. /**
  14213. * @hidden
  14214. */
  14215. protected _getEffectiveParent(): Nullable<Node>;
  14216. /**
  14217. * Computes the world matrix of the node
  14218. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14219. * @returns the world matrix
  14220. */
  14221. computeWorldMatrix(force?: boolean): Matrix;
  14222. protected _afterComputeWorldMatrix(): void;
  14223. /**
  14224. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14225. * @param func callback function to add
  14226. *
  14227. * @returns the TransformNode.
  14228. */
  14229. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14230. /**
  14231. * Removes a registered callback function.
  14232. * @param func callback function to remove
  14233. * @returns the TransformNode.
  14234. */
  14235. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14236. /**
  14237. * Gets the position of the current mesh in camera space
  14238. * @param camera defines the camera to use
  14239. * @returns a position
  14240. */
  14241. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14242. /**
  14243. * Returns the distance from the mesh to the active camera
  14244. * @param camera defines the camera to use
  14245. * @returns the distance
  14246. */
  14247. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14248. /**
  14249. * Clone the current transform node
  14250. * @param name Name of the new clone
  14251. * @param newParent New parent for the clone
  14252. * @param doNotCloneChildren Do not clone children hierarchy
  14253. * @returns the new transform node
  14254. */
  14255. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14256. /**
  14257. * Serializes the objects information.
  14258. * @param currentSerializationObject defines the object to serialize in
  14259. * @returns the serialized object
  14260. */
  14261. serialize(currentSerializationObject?: any): any;
  14262. /**
  14263. * Returns a new TransformNode object parsed from the source provided.
  14264. * @param parsedTransformNode is the source.
  14265. * @param scene the scne the object belongs to
  14266. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14267. * @returns a new TransformNode object parsed from the source provided.
  14268. */
  14269. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14270. /**
  14271. * Get all child-transformNodes of this node
  14272. * @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
  14273. * @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
  14274. * @returns an array of TransformNode
  14275. */
  14276. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14277. /**
  14278. * Releases resources associated with this transform node.
  14279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14281. */
  14282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14283. /**
  14284. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14285. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14286. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14287. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14288. * @returns the current mesh
  14289. */
  14290. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14291. private _syncAbsoluteScalingAndRotation;
  14292. }
  14293. }
  14294. declare module BABYLON {
  14295. /**
  14296. * Defines the types of pose enabled controllers that are supported
  14297. */
  14298. export enum PoseEnabledControllerType {
  14299. /**
  14300. * HTC Vive
  14301. */
  14302. VIVE = 0,
  14303. /**
  14304. * Oculus Rift
  14305. */
  14306. OCULUS = 1,
  14307. /**
  14308. * Windows mixed reality
  14309. */
  14310. WINDOWS = 2,
  14311. /**
  14312. * Samsung gear VR
  14313. */
  14314. GEAR_VR = 3,
  14315. /**
  14316. * Google Daydream
  14317. */
  14318. DAYDREAM = 4,
  14319. /**
  14320. * Generic
  14321. */
  14322. GENERIC = 5
  14323. }
  14324. /**
  14325. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14326. */
  14327. export interface MutableGamepadButton {
  14328. /**
  14329. * Value of the button/trigger
  14330. */
  14331. value: number;
  14332. /**
  14333. * If the button/trigger is currently touched
  14334. */
  14335. touched: boolean;
  14336. /**
  14337. * If the button/trigger is currently pressed
  14338. */
  14339. pressed: boolean;
  14340. }
  14341. /**
  14342. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14343. * @hidden
  14344. */
  14345. export interface ExtendedGamepadButton extends GamepadButton {
  14346. /**
  14347. * If the button/trigger is currently pressed
  14348. */
  14349. readonly pressed: boolean;
  14350. /**
  14351. * If the button/trigger is currently touched
  14352. */
  14353. readonly touched: boolean;
  14354. /**
  14355. * Value of the button/trigger
  14356. */
  14357. readonly value: number;
  14358. }
  14359. /** @hidden */
  14360. export interface _GamePadFactory {
  14361. /**
  14362. * Returns wether or not the current gamepad can be created for this type of controller.
  14363. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14364. * @returns true if it can be created, otherwise false
  14365. */
  14366. canCreate(gamepadInfo: any): boolean;
  14367. /**
  14368. * Creates a new instance of the Gamepad.
  14369. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14370. * @returns the new gamepad instance
  14371. */
  14372. create(gamepadInfo: any): Gamepad;
  14373. }
  14374. /**
  14375. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14376. */
  14377. export class PoseEnabledControllerHelper {
  14378. /** @hidden */
  14379. static _ControllerFactories: _GamePadFactory[];
  14380. /** @hidden */
  14381. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14382. /**
  14383. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14384. * @param vrGamepad the gamepad to initialized
  14385. * @returns a vr controller of the type the gamepad identified as
  14386. */
  14387. static InitiateController(vrGamepad: any): Gamepad;
  14388. }
  14389. /**
  14390. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14391. */
  14392. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14393. /**
  14394. * If the controller is used in a webXR session
  14395. */
  14396. isXR: boolean;
  14397. private _deviceRoomPosition;
  14398. private _deviceRoomRotationQuaternion;
  14399. /**
  14400. * The device position in babylon space
  14401. */
  14402. devicePosition: Vector3;
  14403. /**
  14404. * The device rotation in babylon space
  14405. */
  14406. deviceRotationQuaternion: Quaternion;
  14407. /**
  14408. * The scale factor of the device in babylon space
  14409. */
  14410. deviceScaleFactor: number;
  14411. /**
  14412. * (Likely devicePosition should be used instead) The device position in its room space
  14413. */
  14414. position: Vector3;
  14415. /**
  14416. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14417. */
  14418. rotationQuaternion: Quaternion;
  14419. /**
  14420. * The type of controller (Eg. Windows mixed reality)
  14421. */
  14422. controllerType: PoseEnabledControllerType;
  14423. protected _calculatedPosition: Vector3;
  14424. private _calculatedRotation;
  14425. /**
  14426. * The raw pose from the device
  14427. */
  14428. rawPose: DevicePose;
  14429. private _trackPosition;
  14430. private _maxRotationDistFromHeadset;
  14431. private _draggedRoomRotation;
  14432. /**
  14433. * @hidden
  14434. */
  14435. _disableTrackPosition(fixedPosition: Vector3): void;
  14436. /**
  14437. * Internal, the mesh attached to the controller
  14438. * @hidden
  14439. */
  14440. _mesh: Nullable<AbstractMesh>;
  14441. private _poseControlledCamera;
  14442. private _leftHandSystemQuaternion;
  14443. /**
  14444. * Internal, matrix used to convert room space to babylon space
  14445. * @hidden
  14446. */
  14447. _deviceToWorld: Matrix;
  14448. /**
  14449. * Node to be used when casting a ray from the controller
  14450. * @hidden
  14451. */
  14452. _pointingPoseNode: Nullable<TransformNode>;
  14453. /**
  14454. * Name of the child mesh that can be used to cast a ray from the controller
  14455. */
  14456. static readonly POINTING_POSE: string;
  14457. /**
  14458. * Creates a new PoseEnabledController from a gamepad
  14459. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14460. */
  14461. constructor(browserGamepad: any);
  14462. private _workingMatrix;
  14463. /**
  14464. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14465. */
  14466. update(): void;
  14467. /**
  14468. * Updates only the pose device and mesh without doing any button event checking
  14469. */
  14470. protected _updatePoseAndMesh(): void;
  14471. /**
  14472. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14473. * @param poseData raw pose fromthe device
  14474. */
  14475. updateFromDevice(poseData: DevicePose): void;
  14476. /**
  14477. * @hidden
  14478. */
  14479. _meshAttachedObservable: Observable<AbstractMesh>;
  14480. /**
  14481. * Attaches a mesh to the controller
  14482. * @param mesh the mesh to be attached
  14483. */
  14484. attachToMesh(mesh: AbstractMesh): void;
  14485. /**
  14486. * Attaches the controllers mesh to a camera
  14487. * @param camera the camera the mesh should be attached to
  14488. */
  14489. attachToPoseControlledCamera(camera: TargetCamera): void;
  14490. /**
  14491. * Disposes of the controller
  14492. */
  14493. dispose(): void;
  14494. /**
  14495. * The mesh that is attached to the controller
  14496. */
  14497. readonly mesh: Nullable<AbstractMesh>;
  14498. /**
  14499. * Gets the ray of the controller in the direction the controller is pointing
  14500. * @param length the length the resulting ray should be
  14501. * @returns a ray in the direction the controller is pointing
  14502. */
  14503. getForwardRay(length?: number): Ray;
  14504. }
  14505. }
  14506. declare module BABYLON {
  14507. /**
  14508. * Defines the WebVRController object that represents controllers tracked in 3D space
  14509. */
  14510. export abstract class WebVRController extends PoseEnabledController {
  14511. /**
  14512. * Internal, the default controller model for the controller
  14513. */
  14514. protected _defaultModel: Nullable<AbstractMesh>;
  14515. /**
  14516. * Fired when the trigger state has changed
  14517. */
  14518. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14519. /**
  14520. * Fired when the main button state has changed
  14521. */
  14522. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14523. /**
  14524. * Fired when the secondary button state has changed
  14525. */
  14526. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14527. /**
  14528. * Fired when the pad state has changed
  14529. */
  14530. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14531. /**
  14532. * Fired when controllers stick values have changed
  14533. */
  14534. onPadValuesChangedObservable: Observable<StickValues>;
  14535. /**
  14536. * Array of button availible on the controller
  14537. */
  14538. protected _buttons: Array<MutableGamepadButton>;
  14539. private _onButtonStateChange;
  14540. /**
  14541. * Fired when a controller button's state has changed
  14542. * @param callback the callback containing the button that was modified
  14543. */
  14544. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14545. /**
  14546. * X and Y axis corresponding to the controllers joystick
  14547. */
  14548. pad: StickValues;
  14549. /**
  14550. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14551. */
  14552. hand: string;
  14553. /**
  14554. * The default controller model for the controller
  14555. */
  14556. readonly defaultModel: Nullable<AbstractMesh>;
  14557. /**
  14558. * Creates a new WebVRController from a gamepad
  14559. * @param vrGamepad the gamepad that the WebVRController should be created from
  14560. */
  14561. constructor(vrGamepad: any);
  14562. /**
  14563. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14564. */
  14565. update(): void;
  14566. /**
  14567. * Function to be called when a button is modified
  14568. */
  14569. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14570. /**
  14571. * Loads a mesh and attaches it to the controller
  14572. * @param scene the scene the mesh should be added to
  14573. * @param meshLoaded callback for when the mesh has been loaded
  14574. */
  14575. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14576. private _setButtonValue;
  14577. private _changes;
  14578. private _checkChanges;
  14579. /**
  14580. * Disposes of th webVRCOntroller
  14581. */
  14582. dispose(): void;
  14583. }
  14584. }
  14585. declare module BABYLON {
  14586. /**
  14587. * The HemisphericLight simulates the ambient environment light,
  14588. * so the passed direction is the light reflection direction, not the incoming direction.
  14589. */
  14590. export class HemisphericLight extends Light {
  14591. /**
  14592. * The groundColor is the light in the opposite direction to the one specified during creation.
  14593. * 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.
  14594. */
  14595. groundColor: Color3;
  14596. /**
  14597. * The light reflection direction, not the incoming direction.
  14598. */
  14599. direction: Vector3;
  14600. /**
  14601. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14602. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14603. * The HemisphericLight can't cast shadows.
  14604. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14605. * @param name The friendly name of the light
  14606. * @param direction The direction of the light reflection
  14607. * @param scene The scene the light belongs to
  14608. */
  14609. constructor(name: string, direction: Vector3, scene: Scene);
  14610. protected _buildUniformLayout(): void;
  14611. /**
  14612. * Returns the string "HemisphericLight".
  14613. * @return The class name
  14614. */
  14615. getClassName(): string;
  14616. /**
  14617. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14618. * Returns the updated direction.
  14619. * @param target The target the direction should point to
  14620. * @return The computed direction
  14621. */
  14622. setDirectionToTarget(target: Vector3): Vector3;
  14623. /**
  14624. * Returns the shadow generator associated to the light.
  14625. * @returns Always null for hemispheric lights because it does not support shadows.
  14626. */
  14627. getShadowGenerator(): Nullable<IShadowGenerator>;
  14628. /**
  14629. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14630. * @param effect The effect to update
  14631. * @param lightIndex The index of the light in the effect to update
  14632. * @returns The hemispheric light
  14633. */
  14634. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14635. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14636. /**
  14637. * Computes the world matrix of the node
  14638. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14639. * @param useWasUpdatedFlag defines a reserved property
  14640. * @returns the world matrix
  14641. */
  14642. computeWorldMatrix(): Matrix;
  14643. /**
  14644. * Returns the integer 3.
  14645. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14646. */
  14647. getTypeID(): number;
  14648. /**
  14649. * Prepares the list of defines specific to the light type.
  14650. * @param defines the list of defines
  14651. * @param lightIndex defines the index of the light for the effect
  14652. */
  14653. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /** @hidden */
  14658. export var vrMultiviewToSingleviewPixelShader: {
  14659. name: string;
  14660. shader: string;
  14661. };
  14662. }
  14663. declare module BABYLON {
  14664. /**
  14665. * Renders to multiple views with a single draw call
  14666. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14667. */
  14668. export class MultiviewRenderTarget extends RenderTargetTexture {
  14669. /**
  14670. * Creates a multiview render target
  14671. * @param scene scene used with the render target
  14672. * @param size the size of the render target (used for each view)
  14673. */
  14674. constructor(scene: Scene, size?: number | {
  14675. width: number;
  14676. height: number;
  14677. } | {
  14678. ratio: number;
  14679. });
  14680. /**
  14681. * @hidden
  14682. * @param faceIndex the face index, if its a cube texture
  14683. */
  14684. _bindFrameBuffer(faceIndex?: number): void;
  14685. /**
  14686. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14687. * @returns the view count
  14688. */
  14689. getViewCount(): number;
  14690. }
  14691. }
  14692. declare module BABYLON {
  14693. /**
  14694. * Represents a camera frustum
  14695. */
  14696. export class Frustum {
  14697. /**
  14698. * Gets the planes representing the frustum
  14699. * @param transform matrix to be applied to the returned planes
  14700. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14701. */
  14702. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14703. /**
  14704. * Gets the near frustum plane transformed by the transform matrix
  14705. * @param transform transformation matrix to be applied to the resulting frustum plane
  14706. * @param frustumPlane the resuling frustum plane
  14707. */
  14708. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14709. /**
  14710. * Gets the far frustum plane transformed by the transform matrix
  14711. * @param transform transformation matrix to be applied to the resulting frustum plane
  14712. * @param frustumPlane the resuling frustum plane
  14713. */
  14714. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14715. /**
  14716. * Gets the left frustum plane transformed by the transform matrix
  14717. * @param transform transformation matrix to be applied to the resulting frustum plane
  14718. * @param frustumPlane the resuling frustum plane
  14719. */
  14720. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14721. /**
  14722. * Gets the right frustum plane transformed by the transform matrix
  14723. * @param transform transformation matrix to be applied to the resulting frustum plane
  14724. * @param frustumPlane the resuling frustum plane
  14725. */
  14726. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14727. /**
  14728. * Gets the top frustum plane transformed by the transform matrix
  14729. * @param transform transformation matrix to be applied to the resulting frustum plane
  14730. * @param frustumPlane the resuling frustum plane
  14731. */
  14732. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14733. /**
  14734. * Gets the bottom frustum plane transformed by the transform matrix
  14735. * @param transform transformation matrix to be applied to the resulting frustum plane
  14736. * @param frustumPlane the resuling frustum plane
  14737. */
  14738. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14739. /**
  14740. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14741. * @param transform transformation matrix to be applied to the resulting frustum planes
  14742. * @param frustumPlanes the resuling frustum planes
  14743. */
  14744. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14745. }
  14746. }
  14747. declare module BABYLON {
  14748. interface Engine {
  14749. /**
  14750. * Creates a new multiview render target
  14751. * @param width defines the width of the texture
  14752. * @param height defines the height of the texture
  14753. * @returns the created multiview texture
  14754. */
  14755. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14756. /**
  14757. * Binds a multiview framebuffer to be drawn to
  14758. * @param multiviewTexture texture to bind
  14759. */
  14760. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14761. }
  14762. interface Camera {
  14763. /**
  14764. * @hidden
  14765. * 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)
  14766. */
  14767. _useMultiviewToSingleView: boolean;
  14768. /**
  14769. * @hidden
  14770. * 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)
  14771. */
  14772. _multiviewTexture: Nullable<RenderTargetTexture>;
  14773. /**
  14774. * @hidden
  14775. * ensures the multiview texture of the camera exists and has the specified width/height
  14776. * @param width height to set on the multiview texture
  14777. * @param height width to set on the multiview texture
  14778. */
  14779. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14780. }
  14781. interface Scene {
  14782. /** @hidden */
  14783. _transformMatrixR: Matrix;
  14784. /** @hidden */
  14785. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14786. /** @hidden */
  14787. _createMultiviewUbo(): void;
  14788. /** @hidden */
  14789. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14790. /** @hidden */
  14791. _renderMultiviewToSingleView(camera: Camera): void;
  14792. }
  14793. }
  14794. declare module BABYLON {
  14795. /**
  14796. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14797. * This will not be used for webXR as it supports displaying texture arrays directly
  14798. */
  14799. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14800. /**
  14801. * Initializes a VRMultiviewToSingleview
  14802. * @param name name of the post process
  14803. * @param camera camera to be applied to
  14804. * @param scaleFactor scaling factor to the size of the output texture
  14805. */
  14806. constructor(name: string, camera: Camera, scaleFactor: number);
  14807. }
  14808. }
  14809. declare module BABYLON {
  14810. /**
  14811. * Interface used to define additional presentation attributes
  14812. */
  14813. export interface IVRPresentationAttributes {
  14814. /**
  14815. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  14816. */
  14817. highRefreshRate: boolean;
  14818. /**
  14819. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  14820. */
  14821. foveationLevel: number;
  14822. }
  14823. interface Engine {
  14824. /** @hidden */
  14825. _vrDisplay: any;
  14826. /** @hidden */
  14827. _vrSupported: boolean;
  14828. /** @hidden */
  14829. _oldSize: Size;
  14830. /** @hidden */
  14831. _oldHardwareScaleFactor: number;
  14832. /** @hidden */
  14833. _vrExclusivePointerMode: boolean;
  14834. /** @hidden */
  14835. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14836. /** @hidden */
  14837. _onVRDisplayPointerRestricted: () => void;
  14838. /** @hidden */
  14839. _onVRDisplayPointerUnrestricted: () => void;
  14840. /** @hidden */
  14841. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14842. /** @hidden */
  14843. _onVrDisplayDisconnect: Nullable<() => void>;
  14844. /** @hidden */
  14845. _onVrDisplayPresentChange: Nullable<() => void>;
  14846. /**
  14847. * Observable signaled when VR display mode changes
  14848. */
  14849. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14850. /**
  14851. * Observable signaled when VR request present is complete
  14852. */
  14853. onVRRequestPresentComplete: Observable<boolean>;
  14854. /**
  14855. * Observable signaled when VR request present starts
  14856. */
  14857. onVRRequestPresentStart: Observable<Engine>;
  14858. /**
  14859. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14860. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14861. */
  14862. isInVRExclusivePointerMode: boolean;
  14863. /**
  14864. * Gets a boolean indicating if a webVR device was detected
  14865. * @returns true if a webVR device was detected
  14866. */
  14867. isVRDevicePresent(): boolean;
  14868. /**
  14869. * Gets the current webVR device
  14870. * @returns the current webVR device (or null)
  14871. */
  14872. getVRDevice(): any;
  14873. /**
  14874. * Initializes a webVR display and starts listening to display change events
  14875. * The onVRDisplayChangedObservable will be notified upon these changes
  14876. * @returns A promise containing a VRDisplay and if vr is supported
  14877. */
  14878. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14879. /** @hidden */
  14880. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14881. /**
  14882. * Gets or sets the presentation attributes used to configure VR rendering
  14883. */
  14884. vrPresentationAttributes?: IVRPresentationAttributes;
  14885. /**
  14886. * Call this function to switch to webVR mode
  14887. * Will do nothing if webVR is not supported or if there is no webVR device
  14888. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14889. */
  14890. enableVR(): void;
  14891. /** @hidden */
  14892. _onVRFullScreenTriggered(): void;
  14893. }
  14894. }
  14895. declare module BABYLON {
  14896. /**
  14897. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14898. * IMPORTANT!! The data is right-hand data.
  14899. * @export
  14900. * @interface DevicePose
  14901. */
  14902. export interface DevicePose {
  14903. /**
  14904. * The position of the device, values in array are [x,y,z].
  14905. */
  14906. readonly position: Nullable<Float32Array>;
  14907. /**
  14908. * The linearVelocity of the device, values in array are [x,y,z].
  14909. */
  14910. readonly linearVelocity: Nullable<Float32Array>;
  14911. /**
  14912. * The linearAcceleration of the device, values in array are [x,y,z].
  14913. */
  14914. readonly linearAcceleration: Nullable<Float32Array>;
  14915. /**
  14916. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14917. */
  14918. readonly orientation: Nullable<Float32Array>;
  14919. /**
  14920. * The angularVelocity of the device, values in array are [x,y,z].
  14921. */
  14922. readonly angularVelocity: Nullable<Float32Array>;
  14923. /**
  14924. * The angularAcceleration of the device, values in array are [x,y,z].
  14925. */
  14926. readonly angularAcceleration: Nullable<Float32Array>;
  14927. }
  14928. /**
  14929. * Interface representing a pose controlled object in Babylon.
  14930. * A pose controlled object has both regular pose values as well as pose values
  14931. * from an external device such as a VR head mounted display
  14932. */
  14933. export interface PoseControlled {
  14934. /**
  14935. * The position of the object in babylon space.
  14936. */
  14937. position: Vector3;
  14938. /**
  14939. * The rotation quaternion of the object in babylon space.
  14940. */
  14941. rotationQuaternion: Quaternion;
  14942. /**
  14943. * The position of the device in babylon space.
  14944. */
  14945. devicePosition?: Vector3;
  14946. /**
  14947. * The rotation quaternion of the device in babylon space.
  14948. */
  14949. deviceRotationQuaternion: Quaternion;
  14950. /**
  14951. * The raw pose coming from the device.
  14952. */
  14953. rawPose: Nullable<DevicePose>;
  14954. /**
  14955. * The scale of the device to be used when translating from device space to babylon space.
  14956. */
  14957. deviceScaleFactor: number;
  14958. /**
  14959. * Updates the poseControlled values based on the input device pose.
  14960. * @param poseData the pose data to update the object with
  14961. */
  14962. updateFromDevice(poseData: DevicePose): void;
  14963. }
  14964. /**
  14965. * Set of options to customize the webVRCamera
  14966. */
  14967. export interface WebVROptions {
  14968. /**
  14969. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14970. */
  14971. trackPosition?: boolean;
  14972. /**
  14973. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14974. */
  14975. positionScale?: number;
  14976. /**
  14977. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14978. */
  14979. displayName?: string;
  14980. /**
  14981. * Should the native controller meshes be initialized. (default: true)
  14982. */
  14983. controllerMeshes?: boolean;
  14984. /**
  14985. * Creating a default HemiLight only on controllers. (default: true)
  14986. */
  14987. defaultLightingOnControllers?: boolean;
  14988. /**
  14989. * If you don't want to use the default VR button of the helper. (default: false)
  14990. */
  14991. useCustomVRButton?: boolean;
  14992. /**
  14993. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14994. */
  14995. customVRButton?: HTMLButtonElement;
  14996. /**
  14997. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14998. */
  14999. rayLength?: number;
  15000. /**
  15001. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15002. */
  15003. defaultHeight?: number;
  15004. /**
  15005. * If multiview should be used if availible (default: false)
  15006. */
  15007. useMultiview?: boolean;
  15008. }
  15009. /**
  15010. * This represents a WebVR camera.
  15011. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15012. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15013. */
  15014. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15015. private webVROptions;
  15016. /**
  15017. * @hidden
  15018. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15019. */
  15020. _vrDevice: any;
  15021. /**
  15022. * The rawPose of the vrDevice.
  15023. */
  15024. rawPose: Nullable<DevicePose>;
  15025. private _onVREnabled;
  15026. private _specsVersion;
  15027. private _attached;
  15028. private _frameData;
  15029. protected _descendants: Array<Node>;
  15030. private _deviceRoomPosition;
  15031. /** @hidden */
  15032. _deviceRoomRotationQuaternion: Quaternion;
  15033. private _standingMatrix;
  15034. /**
  15035. * Represents device position in babylon space.
  15036. */
  15037. devicePosition: Vector3;
  15038. /**
  15039. * Represents device rotation in babylon space.
  15040. */
  15041. deviceRotationQuaternion: Quaternion;
  15042. /**
  15043. * The scale of the device to be used when translating from device space to babylon space.
  15044. */
  15045. deviceScaleFactor: number;
  15046. private _deviceToWorld;
  15047. private _worldToDevice;
  15048. /**
  15049. * References to the webVR controllers for the vrDevice.
  15050. */
  15051. controllers: Array<WebVRController>;
  15052. /**
  15053. * Emits an event when a controller is attached.
  15054. */
  15055. onControllersAttachedObservable: Observable<WebVRController[]>;
  15056. /**
  15057. * Emits an event when a controller's mesh has been loaded;
  15058. */
  15059. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15060. /**
  15061. * Emits an event when the HMD's pose has been updated.
  15062. */
  15063. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15064. private _poseSet;
  15065. /**
  15066. * If the rig cameras be used as parent instead of this camera.
  15067. */
  15068. rigParenting: boolean;
  15069. private _lightOnControllers;
  15070. private _defaultHeight?;
  15071. /**
  15072. * Instantiates a WebVRFreeCamera.
  15073. * @param name The name of the WebVRFreeCamera
  15074. * @param position The starting anchor position for the camera
  15075. * @param scene The scene the camera belongs to
  15076. * @param webVROptions a set of customizable options for the webVRCamera
  15077. */
  15078. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15079. /**
  15080. * Gets the device distance from the ground in meters.
  15081. * @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.
  15082. */
  15083. deviceDistanceToRoomGround(): number;
  15084. /**
  15085. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15086. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15087. */
  15088. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15089. /**
  15090. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15091. * @returns A promise with a boolean set to if the standing matrix is supported.
  15092. */
  15093. useStandingMatrixAsync(): Promise<boolean>;
  15094. /**
  15095. * Disposes the camera
  15096. */
  15097. dispose(): void;
  15098. /**
  15099. * Gets a vrController by name.
  15100. * @param name The name of the controller to retreive
  15101. * @returns the controller matching the name specified or null if not found
  15102. */
  15103. getControllerByName(name: string): Nullable<WebVRController>;
  15104. private _leftController;
  15105. /**
  15106. * The controller corresponding to the users left hand.
  15107. */
  15108. readonly leftController: Nullable<WebVRController>;
  15109. private _rightController;
  15110. /**
  15111. * The controller corresponding to the users right hand.
  15112. */
  15113. readonly rightController: Nullable<WebVRController>;
  15114. /**
  15115. * Casts a ray forward from the vrCamera's gaze.
  15116. * @param length Length of the ray (default: 100)
  15117. * @returns the ray corresponding to the gaze
  15118. */
  15119. getForwardRay(length?: number): Ray;
  15120. /**
  15121. * @hidden
  15122. * Updates the camera based on device's frame data
  15123. */
  15124. _checkInputs(): void;
  15125. /**
  15126. * Updates the poseControlled values based on the input device pose.
  15127. * @param poseData Pose coming from the device
  15128. */
  15129. updateFromDevice(poseData: DevicePose): void;
  15130. private _htmlElementAttached;
  15131. private _detachIfAttached;
  15132. /**
  15133. * WebVR's attach control will start broadcasting frames to the device.
  15134. * Note that in certain browsers (chrome for example) this function must be called
  15135. * within a user-interaction callback. Example:
  15136. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15137. *
  15138. * @param element html element to attach the vrDevice to
  15139. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15140. */
  15141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15142. /**
  15143. * Detaches the camera from the html element and disables VR
  15144. *
  15145. * @param element html element to detach from
  15146. */
  15147. detachControl(element: HTMLElement): void;
  15148. /**
  15149. * @returns the name of this class
  15150. */
  15151. getClassName(): string;
  15152. /**
  15153. * Calls resetPose on the vrDisplay
  15154. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15155. */
  15156. resetToCurrentRotation(): void;
  15157. /**
  15158. * @hidden
  15159. * Updates the rig cameras (left and right eye)
  15160. */
  15161. _updateRigCameras(): void;
  15162. private _workingVector;
  15163. private _oneVector;
  15164. private _workingMatrix;
  15165. private updateCacheCalled;
  15166. private _correctPositionIfNotTrackPosition;
  15167. /**
  15168. * @hidden
  15169. * Updates the cached values of the camera
  15170. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15171. */
  15172. _updateCache(ignoreParentClass?: boolean): void;
  15173. /**
  15174. * @hidden
  15175. * Get current device position in babylon world
  15176. */
  15177. _computeDevicePosition(): void;
  15178. /**
  15179. * Updates the current device position and rotation in the babylon world
  15180. */
  15181. update(): void;
  15182. /**
  15183. * @hidden
  15184. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15185. * @returns an identity matrix
  15186. */
  15187. _getViewMatrix(): Matrix;
  15188. private _tmpMatrix;
  15189. /**
  15190. * This function is called by the two RIG cameras.
  15191. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15192. * @hidden
  15193. */
  15194. _getWebVRViewMatrix(): Matrix;
  15195. /** @hidden */
  15196. _getWebVRProjectionMatrix(): Matrix;
  15197. private _onGamepadConnectedObserver;
  15198. private _onGamepadDisconnectedObserver;
  15199. private _updateCacheWhenTrackingDisabledObserver;
  15200. /**
  15201. * Initializes the controllers and their meshes
  15202. */
  15203. initControllers(): void;
  15204. }
  15205. }
  15206. declare module BABYLON {
  15207. /**
  15208. * Size options for a post process
  15209. */
  15210. export type PostProcessOptions = {
  15211. width: number;
  15212. height: number;
  15213. };
  15214. /**
  15215. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15217. */
  15218. export class PostProcess {
  15219. /** Name of the PostProcess. */
  15220. name: string;
  15221. /**
  15222. * Gets or sets the unique id of the post process
  15223. */
  15224. uniqueId: number;
  15225. /**
  15226. * Width of the texture to apply the post process on
  15227. */
  15228. width: number;
  15229. /**
  15230. * Height of the texture to apply the post process on
  15231. */
  15232. height: number;
  15233. /**
  15234. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15235. * @hidden
  15236. */
  15237. _outputTexture: Nullable<InternalTexture>;
  15238. /**
  15239. * Sampling mode used by the shader
  15240. * See https://doc.babylonjs.com/classes/3.1/texture
  15241. */
  15242. renderTargetSamplingMode: number;
  15243. /**
  15244. * Clear color to use when screen clearing
  15245. */
  15246. clearColor: Color4;
  15247. /**
  15248. * If the buffer needs to be cleared before applying the post process. (default: true)
  15249. * Should be set to false if shader will overwrite all previous pixels.
  15250. */
  15251. autoClear: boolean;
  15252. /**
  15253. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15254. */
  15255. alphaMode: number;
  15256. /**
  15257. * Sets the setAlphaBlendConstants of the babylon engine
  15258. */
  15259. alphaConstants: Color4;
  15260. /**
  15261. * Animations to be used for the post processing
  15262. */
  15263. animations: Animation[];
  15264. /**
  15265. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15266. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15267. */
  15268. enablePixelPerfectMode: boolean;
  15269. /**
  15270. * Force the postprocess to be applied without taking in account viewport
  15271. */
  15272. forceFullscreenViewport: boolean;
  15273. /**
  15274. * List of inspectable custom properties (used by the Inspector)
  15275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15276. */
  15277. inspectableCustomProperties: IInspectable[];
  15278. /**
  15279. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15280. *
  15281. * | Value | Type | Description |
  15282. * | ----- | ----------------------------------- | ----------- |
  15283. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15284. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15285. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15286. *
  15287. */
  15288. scaleMode: number;
  15289. /**
  15290. * Force textures to be a power of two (default: false)
  15291. */
  15292. alwaysForcePOT: boolean;
  15293. private _samples;
  15294. /**
  15295. * Number of sample textures (default: 1)
  15296. */
  15297. samples: number;
  15298. /**
  15299. * Modify the scale of the post process to be the same as the viewport (default: false)
  15300. */
  15301. adaptScaleToCurrentViewport: boolean;
  15302. private _camera;
  15303. private _scene;
  15304. private _engine;
  15305. private _options;
  15306. private _reusable;
  15307. private _textureType;
  15308. /**
  15309. * Smart array of input and output textures for the post process.
  15310. * @hidden
  15311. */
  15312. _textures: SmartArray<InternalTexture>;
  15313. /**
  15314. * The index in _textures that corresponds to the output texture.
  15315. * @hidden
  15316. */
  15317. _currentRenderTextureInd: number;
  15318. private _effect;
  15319. private _samplers;
  15320. private _fragmentUrl;
  15321. private _vertexUrl;
  15322. private _parameters;
  15323. private _scaleRatio;
  15324. protected _indexParameters: any;
  15325. private _shareOutputWithPostProcess;
  15326. private _texelSize;
  15327. private _forcedOutputTexture;
  15328. /**
  15329. * Returns the fragment url or shader name used in the post process.
  15330. * @returns the fragment url or name in the shader store.
  15331. */
  15332. getEffectName(): string;
  15333. /**
  15334. * An event triggered when the postprocess is activated.
  15335. */
  15336. onActivateObservable: Observable<Camera>;
  15337. private _onActivateObserver;
  15338. /**
  15339. * A function that is added to the onActivateObservable
  15340. */
  15341. onActivate: Nullable<(camera: Camera) => void>;
  15342. /**
  15343. * An event triggered when the postprocess changes its size.
  15344. */
  15345. onSizeChangedObservable: Observable<PostProcess>;
  15346. private _onSizeChangedObserver;
  15347. /**
  15348. * A function that is added to the onSizeChangedObservable
  15349. */
  15350. onSizeChanged: (postProcess: PostProcess) => void;
  15351. /**
  15352. * An event triggered when the postprocess applies its effect.
  15353. */
  15354. onApplyObservable: Observable<Effect>;
  15355. private _onApplyObserver;
  15356. /**
  15357. * A function that is added to the onApplyObservable
  15358. */
  15359. onApply: (effect: Effect) => void;
  15360. /**
  15361. * An event triggered before rendering the postprocess
  15362. */
  15363. onBeforeRenderObservable: Observable<Effect>;
  15364. private _onBeforeRenderObserver;
  15365. /**
  15366. * A function that is added to the onBeforeRenderObservable
  15367. */
  15368. onBeforeRender: (effect: Effect) => void;
  15369. /**
  15370. * An event triggered after rendering the postprocess
  15371. */
  15372. onAfterRenderObservable: Observable<Effect>;
  15373. private _onAfterRenderObserver;
  15374. /**
  15375. * A function that is added to the onAfterRenderObservable
  15376. */
  15377. onAfterRender: (efect: Effect) => void;
  15378. /**
  15379. * 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
  15380. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15381. */
  15382. inputTexture: InternalTexture;
  15383. /**
  15384. * Gets the camera which post process is applied to.
  15385. * @returns The camera the post process is applied to.
  15386. */
  15387. getCamera(): Camera;
  15388. /**
  15389. * Gets the texel size of the postprocess.
  15390. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15391. */
  15392. readonly texelSize: Vector2;
  15393. /**
  15394. * Creates a new instance PostProcess
  15395. * @param name The name of the PostProcess.
  15396. * @param fragmentUrl The url of the fragment shader to be used.
  15397. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15398. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15399. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15400. * @param camera The camera to apply the render pass to.
  15401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15402. * @param engine The engine which the post process will be applied. (default: current engine)
  15403. * @param reusable If the post process can be reused on the same frame. (default: false)
  15404. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15405. * @param textureType Type of textures used when performing the post process. (default: 0)
  15406. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15407. * @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
  15408. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15409. */
  15410. constructor(
  15411. /** Name of the PostProcess. */
  15412. 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);
  15413. /**
  15414. * Gets a string idenfifying the name of the class
  15415. * @returns "PostProcess" string
  15416. */
  15417. getClassName(): string;
  15418. /**
  15419. * Gets the engine which this post process belongs to.
  15420. * @returns The engine the post process was enabled with.
  15421. */
  15422. getEngine(): Engine;
  15423. /**
  15424. * The effect that is created when initializing the post process.
  15425. * @returns The created effect corresponding the the postprocess.
  15426. */
  15427. getEffect(): Effect;
  15428. /**
  15429. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15430. * @param postProcess The post process to share the output with.
  15431. * @returns This post process.
  15432. */
  15433. shareOutputWith(postProcess: PostProcess): PostProcess;
  15434. /**
  15435. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15436. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15437. */
  15438. useOwnOutput(): void;
  15439. /**
  15440. * Updates the effect with the current post process compile time values and recompiles the shader.
  15441. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15442. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15443. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15444. * @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
  15445. * @param onCompiled Called when the shader has been compiled.
  15446. * @param onError Called if there is an error when compiling a shader.
  15447. */
  15448. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15449. /**
  15450. * The post process is reusable if it can be used multiple times within one frame.
  15451. * @returns If the post process is reusable
  15452. */
  15453. isReusable(): boolean;
  15454. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15455. markTextureDirty(): void;
  15456. /**
  15457. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15458. * 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.
  15459. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15460. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15461. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15462. * @returns The target texture that was bound to be written to.
  15463. */
  15464. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15465. /**
  15466. * If the post process is supported.
  15467. */
  15468. readonly isSupported: boolean;
  15469. /**
  15470. * The aspect ratio of the output texture.
  15471. */
  15472. readonly aspectRatio: number;
  15473. /**
  15474. * Get a value indicating if the post-process is ready to be used
  15475. * @returns true if the post-process is ready (shader is compiled)
  15476. */
  15477. isReady(): boolean;
  15478. /**
  15479. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15480. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15481. */
  15482. apply(): Nullable<Effect>;
  15483. private _disposeTextures;
  15484. /**
  15485. * Disposes the post process.
  15486. * @param camera The camera to dispose the post process on.
  15487. */
  15488. dispose(camera?: Camera): void;
  15489. }
  15490. }
  15491. declare module BABYLON {
  15492. /** @hidden */
  15493. export var kernelBlurVaryingDeclaration: {
  15494. name: string;
  15495. shader: string;
  15496. };
  15497. }
  15498. declare module BABYLON {
  15499. /** @hidden */
  15500. export var kernelBlurFragment: {
  15501. name: string;
  15502. shader: string;
  15503. };
  15504. }
  15505. declare module BABYLON {
  15506. /** @hidden */
  15507. export var kernelBlurFragment2: {
  15508. name: string;
  15509. shader: string;
  15510. };
  15511. }
  15512. declare module BABYLON {
  15513. /** @hidden */
  15514. export var kernelBlurPixelShader: {
  15515. name: string;
  15516. shader: string;
  15517. };
  15518. }
  15519. declare module BABYLON {
  15520. /** @hidden */
  15521. export var kernelBlurVertex: {
  15522. name: string;
  15523. shader: string;
  15524. };
  15525. }
  15526. declare module BABYLON {
  15527. /** @hidden */
  15528. export var kernelBlurVertexShader: {
  15529. name: string;
  15530. shader: string;
  15531. };
  15532. }
  15533. declare module BABYLON {
  15534. /**
  15535. * The Blur Post Process which blurs an image based on a kernel and direction.
  15536. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15537. */
  15538. export class BlurPostProcess extends PostProcess {
  15539. /** The direction in which to blur the image. */
  15540. direction: Vector2;
  15541. private blockCompilation;
  15542. protected _kernel: number;
  15543. protected _idealKernel: number;
  15544. protected _packedFloat: boolean;
  15545. private _staticDefines;
  15546. /**
  15547. * Sets the length in pixels of the blur sample region
  15548. */
  15549. /**
  15550. * Gets the length in pixels of the blur sample region
  15551. */
  15552. kernel: number;
  15553. /**
  15554. * Sets wether or not the blur needs to unpack/repack floats
  15555. */
  15556. /**
  15557. * Gets wether or not the blur is unpacking/repacking floats
  15558. */
  15559. packedFloat: boolean;
  15560. /**
  15561. * Creates a new instance BlurPostProcess
  15562. * @param name The name of the effect.
  15563. * @param direction The direction in which to blur the image.
  15564. * @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.
  15565. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15566. * @param camera The camera to apply the render pass to.
  15567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15568. * @param engine The engine which the post process will be applied. (default: current engine)
  15569. * @param reusable If the post process can be reused on the same frame. (default: false)
  15570. * @param textureType Type of textures used when performing the post process. (default: 0)
  15571. * @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)
  15572. */
  15573. constructor(name: string,
  15574. /** The direction in which to blur the image. */
  15575. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15576. /**
  15577. * Updates the effect with the current post process compile time values and recompiles the shader.
  15578. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15579. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15580. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15581. * @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
  15582. * @param onCompiled Called when the shader has been compiled.
  15583. * @param onError Called if there is an error when compiling a shader.
  15584. */
  15585. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15586. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15587. /**
  15588. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15589. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15590. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15591. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15592. * The gaps between physical kernels are compensated for in the weighting of the samples
  15593. * @param idealKernel Ideal blur kernel.
  15594. * @return Nearest best kernel.
  15595. */
  15596. protected _nearestBestKernel(idealKernel: number): number;
  15597. /**
  15598. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15599. * @param x The point on the Gaussian distribution to sample.
  15600. * @return the value of the Gaussian function at x.
  15601. */
  15602. protected _gaussianWeight(x: number): number;
  15603. /**
  15604. * Generates a string that can be used as a floating point number in GLSL.
  15605. * @param x Value to print.
  15606. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15607. * @return GLSL float string.
  15608. */
  15609. protected _glslFloat(x: number, decimalFigures?: number): string;
  15610. }
  15611. }
  15612. declare module BABYLON {
  15613. /**
  15614. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15615. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15616. * You can then easily use it as a reflectionTexture on a flat surface.
  15617. * In case the surface is not a plane, please consider relying on reflection probes.
  15618. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15619. */
  15620. export class MirrorTexture extends RenderTargetTexture {
  15621. private scene;
  15622. /**
  15623. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15624. * 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.
  15625. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15626. */
  15627. mirrorPlane: Plane;
  15628. /**
  15629. * Define the blur ratio used to blur the reflection if needed.
  15630. */
  15631. blurRatio: number;
  15632. /**
  15633. * Define the adaptive blur kernel used to blur the reflection if needed.
  15634. * This will autocompute the closest best match for the `blurKernel`
  15635. */
  15636. adaptiveBlurKernel: number;
  15637. /**
  15638. * Define the blur kernel used to blur the reflection if needed.
  15639. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15640. */
  15641. blurKernel: number;
  15642. /**
  15643. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15644. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15645. */
  15646. blurKernelX: number;
  15647. /**
  15648. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15649. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15650. */
  15651. blurKernelY: number;
  15652. private _autoComputeBlurKernel;
  15653. protected _onRatioRescale(): void;
  15654. private _updateGammaSpace;
  15655. private _imageProcessingConfigChangeObserver;
  15656. private _transformMatrix;
  15657. private _mirrorMatrix;
  15658. private _savedViewMatrix;
  15659. private _blurX;
  15660. private _blurY;
  15661. private _adaptiveBlurKernel;
  15662. private _blurKernelX;
  15663. private _blurKernelY;
  15664. private _blurRatio;
  15665. /**
  15666. * Instantiates a Mirror Texture.
  15667. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15668. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15669. * You can then easily use it as a reflectionTexture on a flat surface.
  15670. * In case the surface is not a plane, please consider relying on reflection probes.
  15671. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15672. * @param name
  15673. * @param size
  15674. * @param scene
  15675. * @param generateMipMaps
  15676. * @param type
  15677. * @param samplingMode
  15678. * @param generateDepthBuffer
  15679. */
  15680. constructor(name: string, size: number | {
  15681. width: number;
  15682. height: number;
  15683. } | {
  15684. ratio: number;
  15685. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15686. private _preparePostProcesses;
  15687. /**
  15688. * Clone the mirror texture.
  15689. * @returns the cloned texture
  15690. */
  15691. clone(): MirrorTexture;
  15692. /**
  15693. * Serialize the texture to a JSON representation you could use in Parse later on
  15694. * @returns the serialized JSON representation
  15695. */
  15696. serialize(): any;
  15697. /**
  15698. * Dispose the texture and release its associated resources.
  15699. */
  15700. dispose(): void;
  15701. }
  15702. }
  15703. declare module BABYLON {
  15704. /**
  15705. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15706. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15707. */
  15708. export class Texture extends BaseTexture {
  15709. /**
  15710. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15711. */
  15712. static SerializeBuffers: boolean;
  15713. /** @hidden */
  15714. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15715. /** @hidden */
  15716. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15717. /** @hidden */
  15718. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15719. /** nearest is mag = nearest and min = nearest and mip = linear */
  15720. static readonly NEAREST_SAMPLINGMODE: number;
  15721. /** nearest is mag = nearest and min = nearest and mip = linear */
  15722. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15723. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15724. static readonly BILINEAR_SAMPLINGMODE: number;
  15725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15726. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15727. /** Trilinear is mag = linear and min = linear and mip = linear */
  15728. static readonly TRILINEAR_SAMPLINGMODE: number;
  15729. /** Trilinear is mag = linear and min = linear and mip = linear */
  15730. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15731. /** mag = nearest and min = nearest and mip = nearest */
  15732. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15733. /** mag = nearest and min = linear and mip = nearest */
  15734. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15735. /** mag = nearest and min = linear and mip = linear */
  15736. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15737. /** mag = nearest and min = linear and mip = none */
  15738. static readonly NEAREST_LINEAR: number;
  15739. /** mag = nearest and min = nearest and mip = none */
  15740. static readonly NEAREST_NEAREST: number;
  15741. /** mag = linear and min = nearest and mip = nearest */
  15742. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15743. /** mag = linear and min = nearest and mip = linear */
  15744. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15745. /** mag = linear and min = linear and mip = none */
  15746. static readonly LINEAR_LINEAR: number;
  15747. /** mag = linear and min = nearest and mip = none */
  15748. static readonly LINEAR_NEAREST: number;
  15749. /** Explicit coordinates mode */
  15750. static readonly EXPLICIT_MODE: number;
  15751. /** Spherical coordinates mode */
  15752. static readonly SPHERICAL_MODE: number;
  15753. /** Planar coordinates mode */
  15754. static readonly PLANAR_MODE: number;
  15755. /** Cubic coordinates mode */
  15756. static readonly CUBIC_MODE: number;
  15757. /** Projection coordinates mode */
  15758. static readonly PROJECTION_MODE: number;
  15759. /** Inverse Cubic coordinates mode */
  15760. static readonly SKYBOX_MODE: number;
  15761. /** Inverse Cubic coordinates mode */
  15762. static readonly INVCUBIC_MODE: number;
  15763. /** Equirectangular coordinates mode */
  15764. static readonly EQUIRECTANGULAR_MODE: number;
  15765. /** Equirectangular Fixed coordinates mode */
  15766. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15767. /** Equirectangular Fixed Mirrored coordinates mode */
  15768. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15769. /** Texture is not repeating outside of 0..1 UVs */
  15770. static readonly CLAMP_ADDRESSMODE: number;
  15771. /** Texture is repeating outside of 0..1 UVs */
  15772. static readonly WRAP_ADDRESSMODE: number;
  15773. /** Texture is repeating and mirrored */
  15774. static readonly MIRROR_ADDRESSMODE: number;
  15775. /**
  15776. * 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
  15777. */
  15778. static UseSerializedUrlIfAny: boolean;
  15779. /**
  15780. * Define the url of the texture.
  15781. */
  15782. url: Nullable<string>;
  15783. /**
  15784. * Define an offset on the texture to offset the u coordinates of the UVs
  15785. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15786. */
  15787. uOffset: number;
  15788. /**
  15789. * Define an offset on the texture to offset the v coordinates of the UVs
  15790. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15791. */
  15792. vOffset: number;
  15793. /**
  15794. * Define an offset on the texture to scale the u coordinates of the UVs
  15795. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15796. */
  15797. uScale: number;
  15798. /**
  15799. * Define an offset on the texture to scale the v coordinates of the UVs
  15800. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15801. */
  15802. vScale: number;
  15803. /**
  15804. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15805. * @see http://doc.babylonjs.com/how_to/more_materials
  15806. */
  15807. uAng: number;
  15808. /**
  15809. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15810. * @see http://doc.babylonjs.com/how_to/more_materials
  15811. */
  15812. vAng: number;
  15813. /**
  15814. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15815. * @see http://doc.babylonjs.com/how_to/more_materials
  15816. */
  15817. wAng: number;
  15818. /**
  15819. * Defines the center of rotation (U)
  15820. */
  15821. uRotationCenter: number;
  15822. /**
  15823. * Defines the center of rotation (V)
  15824. */
  15825. vRotationCenter: number;
  15826. /**
  15827. * Defines the center of rotation (W)
  15828. */
  15829. wRotationCenter: number;
  15830. /**
  15831. * Are mip maps generated for this texture or not.
  15832. */
  15833. readonly noMipmap: boolean;
  15834. /**
  15835. * List of inspectable custom properties (used by the Inspector)
  15836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15837. */
  15838. inspectableCustomProperties: Nullable<IInspectable[]>;
  15839. private _noMipmap;
  15840. /** @hidden */
  15841. _invertY: boolean;
  15842. private _rowGenerationMatrix;
  15843. private _cachedTextureMatrix;
  15844. private _projectionModeMatrix;
  15845. private _t0;
  15846. private _t1;
  15847. private _t2;
  15848. private _cachedUOffset;
  15849. private _cachedVOffset;
  15850. private _cachedUScale;
  15851. private _cachedVScale;
  15852. private _cachedUAng;
  15853. private _cachedVAng;
  15854. private _cachedWAng;
  15855. private _cachedProjectionMatrixId;
  15856. private _cachedCoordinatesMode;
  15857. /** @hidden */
  15858. protected _initialSamplingMode: number;
  15859. /** @hidden */
  15860. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15861. private _deleteBuffer;
  15862. protected _format: Nullable<number>;
  15863. private _delayedOnLoad;
  15864. private _delayedOnError;
  15865. private _mimeType?;
  15866. /**
  15867. * Observable triggered once the texture has been loaded.
  15868. */
  15869. onLoadObservable: Observable<Texture>;
  15870. protected _isBlocking: boolean;
  15871. /**
  15872. * Is the texture preventing material to render while loading.
  15873. * If false, a default texture will be used instead of the loading one during the preparation step.
  15874. */
  15875. isBlocking: boolean;
  15876. /**
  15877. * Get the current sampling mode associated with the texture.
  15878. */
  15879. readonly samplingMode: number;
  15880. /**
  15881. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15882. */
  15883. readonly invertY: boolean;
  15884. /**
  15885. * Instantiates a new texture.
  15886. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15887. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15888. * @param url defines the url of the picture to load as a texture
  15889. * @param scene defines the scene or engine the texture will belong to
  15890. * @param noMipmap defines if the texture will require mip maps or not
  15891. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15892. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15893. * @param onLoad defines a callback triggered when the texture has been loaded
  15894. * @param onError defines a callback triggered when an error occurred during the loading session
  15895. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15896. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15897. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15898. * @param mimeType defines an optional mime type information
  15899. */
  15900. 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);
  15901. /**
  15902. * Update the url (and optional buffer) of this texture if url was null during construction.
  15903. * @param url the url of the texture
  15904. * @param buffer the buffer of the texture (defaults to null)
  15905. * @param onLoad callback called when the texture is loaded (defaults to null)
  15906. */
  15907. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15908. /**
  15909. * Finish the loading sequence of a texture flagged as delayed load.
  15910. * @hidden
  15911. */
  15912. delayLoad(): void;
  15913. private _prepareRowForTextureGeneration;
  15914. /**
  15915. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15916. * @returns the transform matrix of the texture.
  15917. */
  15918. getTextureMatrix(): Matrix;
  15919. /**
  15920. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15921. * @returns The reflection texture transform
  15922. */
  15923. getReflectionTextureMatrix(): Matrix;
  15924. /**
  15925. * Clones the texture.
  15926. * @returns the cloned texture
  15927. */
  15928. clone(): Texture;
  15929. /**
  15930. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15931. * @returns The JSON representation of the texture
  15932. */
  15933. serialize(): any;
  15934. /**
  15935. * Get the current class name of the texture useful for serialization or dynamic coding.
  15936. * @returns "Texture"
  15937. */
  15938. getClassName(): string;
  15939. /**
  15940. * Dispose the texture and release its associated resources.
  15941. */
  15942. dispose(): void;
  15943. /**
  15944. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15945. * @param parsedTexture Define the JSON representation of the texture
  15946. * @param scene Define the scene the parsed texture should be instantiated in
  15947. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15948. * @returns The parsed texture if successful
  15949. */
  15950. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15951. /**
  15952. * Creates a texture from its base 64 representation.
  15953. * @param data Define the base64 payload without the data: prefix
  15954. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15955. * @param scene Define the scene the texture should belong to
  15956. * @param noMipmap Forces the texture to not create mip map information if true
  15957. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15958. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15959. * @param onLoad define a callback triggered when the texture has been loaded
  15960. * @param onError define a callback triggered when an error occurred during the loading session
  15961. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15962. * @returns the created texture
  15963. */
  15964. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15965. /**
  15966. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15967. * @param data Define the base64 payload without the data: prefix
  15968. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15969. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15970. * @param scene Define the scene the texture should belong to
  15971. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15972. * @param noMipmap Forces the texture to not create mip map information if true
  15973. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15974. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15975. * @param onLoad define a callback triggered when the texture has been loaded
  15976. * @param onError define a callback triggered when an error occurred during the loading session
  15977. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15978. * @returns the created texture
  15979. */
  15980. 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;
  15981. }
  15982. }
  15983. declare module BABYLON {
  15984. /**
  15985. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15986. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15987. */
  15988. export class PostProcessManager {
  15989. private _scene;
  15990. private _indexBuffer;
  15991. private _vertexBuffers;
  15992. /**
  15993. * Creates a new instance PostProcess
  15994. * @param scene The scene that the post process is associated with.
  15995. */
  15996. constructor(scene: Scene);
  15997. private _prepareBuffers;
  15998. private _buildIndexBuffer;
  15999. /**
  16000. * Rebuilds the vertex buffers of the manager.
  16001. * @hidden
  16002. */
  16003. _rebuild(): void;
  16004. /**
  16005. * Prepares a frame to be run through a post process.
  16006. * @param sourceTexture The input texture to the post procesess. (default: null)
  16007. * @param postProcesses An array of post processes to be run. (default: null)
  16008. * @returns True if the post processes were able to be run.
  16009. * @hidden
  16010. */
  16011. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16012. /**
  16013. * Manually render a set of post processes to a texture.
  16014. * @param postProcesses An array of post processes to be run.
  16015. * @param targetTexture The target texture to render to.
  16016. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16017. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16018. * @param lodLevel defines which lod of the texture to render to
  16019. */
  16020. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16021. /**
  16022. * Finalize the result of the output of the postprocesses.
  16023. * @param doNotPresent If true the result will not be displayed to the screen.
  16024. * @param targetTexture The target texture to render to.
  16025. * @param faceIndex The index of the face to bind the target texture to.
  16026. * @param postProcesses The array of post processes to render.
  16027. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16028. * @hidden
  16029. */
  16030. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16031. /**
  16032. * Disposes of the post process manager.
  16033. */
  16034. dispose(): void;
  16035. }
  16036. }
  16037. declare module BABYLON {
  16038. /** Interface used by value gradients (color, factor, ...) */
  16039. export interface IValueGradient {
  16040. /**
  16041. * Gets or sets the gradient value (between 0 and 1)
  16042. */
  16043. gradient: number;
  16044. }
  16045. /** Class used to store color4 gradient */
  16046. export class ColorGradient implements IValueGradient {
  16047. /**
  16048. * Gets or sets the gradient value (between 0 and 1)
  16049. */
  16050. gradient: number;
  16051. /**
  16052. * Gets or sets first associated color
  16053. */
  16054. color1: Color4;
  16055. /**
  16056. * Gets or sets second associated color
  16057. */
  16058. color2?: Color4;
  16059. /**
  16060. * Will get a color picked randomly between color1 and color2.
  16061. * If color2 is undefined then color1 will be used
  16062. * @param result defines the target Color4 to store the result in
  16063. */
  16064. getColorToRef(result: Color4): void;
  16065. }
  16066. /** Class used to store color 3 gradient */
  16067. export class Color3Gradient implements IValueGradient {
  16068. /**
  16069. * Gets or sets the gradient value (between 0 and 1)
  16070. */
  16071. gradient: number;
  16072. /**
  16073. * Gets or sets the associated color
  16074. */
  16075. color: Color3;
  16076. }
  16077. /** Class used to store factor gradient */
  16078. export class FactorGradient implements IValueGradient {
  16079. /**
  16080. * Gets or sets the gradient value (between 0 and 1)
  16081. */
  16082. gradient: number;
  16083. /**
  16084. * Gets or sets first associated factor
  16085. */
  16086. factor1: number;
  16087. /**
  16088. * Gets or sets second associated factor
  16089. */
  16090. factor2?: number;
  16091. /**
  16092. * Will get a number picked randomly between factor1 and factor2.
  16093. * If factor2 is undefined then factor1 will be used
  16094. * @returns the picked number
  16095. */
  16096. getFactor(): number;
  16097. }
  16098. /**
  16099. * Helper used to simplify some generic gradient tasks
  16100. */
  16101. export class GradientHelper {
  16102. /**
  16103. * Gets the current gradient from an array of IValueGradient
  16104. * @param ratio defines the current ratio to get
  16105. * @param gradients defines the array of IValueGradient
  16106. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16107. */
  16108. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16109. }
  16110. }
  16111. declare module BABYLON {
  16112. interface ThinEngine {
  16113. /**
  16114. * Creates a dynamic texture
  16115. * @param width defines the width of the texture
  16116. * @param height defines the height of the texture
  16117. * @param generateMipMaps defines if the engine should generate the mip levels
  16118. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16119. * @returns the dynamic texture inside an InternalTexture
  16120. */
  16121. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16122. /**
  16123. * Update the content of a dynamic texture
  16124. * @param texture defines the texture to update
  16125. * @param canvas defines the canvas containing the source
  16126. * @param invertY defines if data must be stored with Y axis inverted
  16127. * @param premulAlpha defines if alpha is stored as premultiplied
  16128. * @param format defines the format of the data
  16129. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16130. */
  16131. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16132. }
  16133. }
  16134. declare module BABYLON {
  16135. /**
  16136. * Helper class used to generate a canvas to manipulate images
  16137. */
  16138. export class CanvasGenerator {
  16139. /**
  16140. * Create a new canvas (or offscreen canvas depending on the context)
  16141. * @param width defines the expected width
  16142. * @param height defines the expected height
  16143. * @return a new canvas or offscreen canvas
  16144. */
  16145. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16146. }
  16147. }
  16148. declare module BABYLON {
  16149. /**
  16150. * A class extending Texture allowing drawing on a texture
  16151. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16152. */
  16153. export class DynamicTexture extends Texture {
  16154. private _generateMipMaps;
  16155. private _canvas;
  16156. private _context;
  16157. private _engine;
  16158. /**
  16159. * Creates a DynamicTexture
  16160. * @param name defines the name of the texture
  16161. * @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
  16162. * @param scene defines the scene where you want the texture
  16163. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16164. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16165. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16166. */
  16167. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16168. /**
  16169. * Get the current class name of the texture useful for serialization or dynamic coding.
  16170. * @returns "DynamicTexture"
  16171. */
  16172. getClassName(): string;
  16173. /**
  16174. * Gets the current state of canRescale
  16175. */
  16176. readonly canRescale: boolean;
  16177. private _recreate;
  16178. /**
  16179. * Scales the texture
  16180. * @param ratio the scale factor to apply to both width and height
  16181. */
  16182. scale(ratio: number): void;
  16183. /**
  16184. * Resizes the texture
  16185. * @param width the new width
  16186. * @param height the new height
  16187. */
  16188. scaleTo(width: number, height: number): void;
  16189. /**
  16190. * Gets the context of the canvas used by the texture
  16191. * @returns the canvas context of the dynamic texture
  16192. */
  16193. getContext(): CanvasRenderingContext2D;
  16194. /**
  16195. * Clears the texture
  16196. */
  16197. clear(): void;
  16198. /**
  16199. * Updates the texture
  16200. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16201. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16202. */
  16203. update(invertY?: boolean, premulAlpha?: boolean): void;
  16204. /**
  16205. * Draws text onto the texture
  16206. * @param text defines the text to be drawn
  16207. * @param x defines the placement of the text from the left
  16208. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16209. * @param font defines the font to be used with font-style, font-size, font-name
  16210. * @param color defines the color used for the text
  16211. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16212. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16213. * @param update defines whether texture is immediately update (default is true)
  16214. */
  16215. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16216. /**
  16217. * Clones the texture
  16218. * @returns the clone of the texture.
  16219. */
  16220. clone(): DynamicTexture;
  16221. /**
  16222. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16223. * @returns a serialized dynamic texture object
  16224. */
  16225. serialize(): any;
  16226. /** @hidden */
  16227. _rebuild(): void;
  16228. }
  16229. }
  16230. declare module BABYLON {
  16231. interface AbstractScene {
  16232. /**
  16233. * The list of procedural textures added to the scene
  16234. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16235. */
  16236. proceduralTextures: Array<ProceduralTexture>;
  16237. }
  16238. /**
  16239. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16240. * in a given scene.
  16241. */
  16242. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16243. /**
  16244. * The component name helpfull to identify the component in the list of scene components.
  16245. */
  16246. readonly name: string;
  16247. /**
  16248. * The scene the component belongs to.
  16249. */
  16250. scene: Scene;
  16251. /**
  16252. * Creates a new instance of the component for the given scene
  16253. * @param scene Defines the scene to register the component in
  16254. */
  16255. constructor(scene: Scene);
  16256. /**
  16257. * Registers the component in a given scene
  16258. */
  16259. register(): void;
  16260. /**
  16261. * Rebuilds the elements related to this component in case of
  16262. * context lost for instance.
  16263. */
  16264. rebuild(): void;
  16265. /**
  16266. * Disposes the component and the associated ressources.
  16267. */
  16268. dispose(): void;
  16269. private _beforeClear;
  16270. }
  16271. }
  16272. declare module BABYLON {
  16273. interface ThinEngine {
  16274. /**
  16275. * Creates a new render target cube texture
  16276. * @param size defines the size of the texture
  16277. * @param options defines the options used to create the texture
  16278. * @returns a new render target cube texture stored in an InternalTexture
  16279. */
  16280. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16281. }
  16282. }
  16283. declare module BABYLON {
  16284. /** @hidden */
  16285. export var proceduralVertexShader: {
  16286. name: string;
  16287. shader: string;
  16288. };
  16289. }
  16290. declare module BABYLON {
  16291. /**
  16292. * 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.
  16293. * This is the base class of any Procedural texture and contains most of the shareable code.
  16294. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16295. */
  16296. export class ProceduralTexture extends Texture {
  16297. isCube: boolean;
  16298. /**
  16299. * Define if the texture is enabled or not (disabled texture will not render)
  16300. */
  16301. isEnabled: boolean;
  16302. /**
  16303. * Define if the texture must be cleared before rendering (default is true)
  16304. */
  16305. autoClear: boolean;
  16306. /**
  16307. * Callback called when the texture is generated
  16308. */
  16309. onGenerated: () => void;
  16310. /**
  16311. * Event raised when the texture is generated
  16312. */
  16313. onGeneratedObservable: Observable<ProceduralTexture>;
  16314. /** @hidden */
  16315. _generateMipMaps: boolean;
  16316. /** @hidden **/
  16317. _effect: Effect;
  16318. /** @hidden */
  16319. _textures: {
  16320. [key: string]: Texture;
  16321. };
  16322. private _size;
  16323. private _currentRefreshId;
  16324. private _refreshRate;
  16325. private _vertexBuffers;
  16326. private _indexBuffer;
  16327. private _uniforms;
  16328. private _samplers;
  16329. private _fragment;
  16330. private _floats;
  16331. private _ints;
  16332. private _floatsArrays;
  16333. private _colors3;
  16334. private _colors4;
  16335. private _vectors2;
  16336. private _vectors3;
  16337. private _matrices;
  16338. private _fallbackTexture;
  16339. private _fallbackTextureUsed;
  16340. private _engine;
  16341. private _cachedDefines;
  16342. private _contentUpdateId;
  16343. private _contentData;
  16344. /**
  16345. * Instantiates a new procedural texture.
  16346. * 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.
  16347. * This is the base class of any Procedural texture and contains most of the shareable code.
  16348. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16349. * @param name Define the name of the texture
  16350. * @param size Define the size of the texture to create
  16351. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16352. * @param scene Define the scene the texture belongs to
  16353. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16354. * @param generateMipMaps Define if the texture should creates mip maps or not
  16355. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16356. */
  16357. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16358. /**
  16359. * The effect that is created when initializing the post process.
  16360. * @returns The created effect corresponding the the postprocess.
  16361. */
  16362. getEffect(): Effect;
  16363. /**
  16364. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16365. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16366. */
  16367. getContent(): Nullable<ArrayBufferView>;
  16368. private _createIndexBuffer;
  16369. /** @hidden */
  16370. _rebuild(): void;
  16371. /**
  16372. * Resets the texture in order to recreate its associated resources.
  16373. * This can be called in case of context loss
  16374. */
  16375. reset(): void;
  16376. protected _getDefines(): string;
  16377. /**
  16378. * Is the texture ready to be used ? (rendered at least once)
  16379. * @returns true if ready, otherwise, false.
  16380. */
  16381. isReady(): boolean;
  16382. /**
  16383. * Resets the refresh counter of the texture and start bak from scratch.
  16384. * Could be useful to regenerate the texture if it is setup to render only once.
  16385. */
  16386. resetRefreshCounter(): void;
  16387. /**
  16388. * Set the fragment shader to use in order to render the texture.
  16389. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16390. */
  16391. setFragment(fragment: any): void;
  16392. /**
  16393. * Define the refresh rate of the texture or the rendering frequency.
  16394. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16395. */
  16396. refreshRate: number;
  16397. /** @hidden */
  16398. _shouldRender(): boolean;
  16399. /**
  16400. * Get the size the texture is rendering at.
  16401. * @returns the size (texture is always squared)
  16402. */
  16403. getRenderSize(): number;
  16404. /**
  16405. * Resize the texture to new value.
  16406. * @param size Define the new size the texture should have
  16407. * @param generateMipMaps Define whether the new texture should create mip maps
  16408. */
  16409. resize(size: number, generateMipMaps: boolean): void;
  16410. private _checkUniform;
  16411. /**
  16412. * Set a texture in the shader program used to render.
  16413. * @param name Define the name of the uniform samplers as defined in the shader
  16414. * @param texture Define the texture to bind to this sampler
  16415. * @return the texture itself allowing "fluent" like uniform updates
  16416. */
  16417. setTexture(name: string, texture: Texture): ProceduralTexture;
  16418. /**
  16419. * Set a float in the shader.
  16420. * @param name Define the name of the uniform as defined in the shader
  16421. * @param value Define the value to give to the uniform
  16422. * @return the texture itself allowing "fluent" like uniform updates
  16423. */
  16424. setFloat(name: string, value: number): ProceduralTexture;
  16425. /**
  16426. * Set a int in the shader.
  16427. * @param name Define the name of the uniform as defined in the shader
  16428. * @param value Define the value to give to the uniform
  16429. * @return the texture itself allowing "fluent" like uniform updates
  16430. */
  16431. setInt(name: string, value: number): ProceduralTexture;
  16432. /**
  16433. * Set an array of floats in the shader.
  16434. * @param name Define the name of the uniform as defined in the shader
  16435. * @param value Define the value to give to the uniform
  16436. * @return the texture itself allowing "fluent" like uniform updates
  16437. */
  16438. setFloats(name: string, value: number[]): ProceduralTexture;
  16439. /**
  16440. * Set a vec3 in the shader from a Color3.
  16441. * @param name Define the name of the uniform as defined in the shader
  16442. * @param value Define the value to give to the uniform
  16443. * @return the texture itself allowing "fluent" like uniform updates
  16444. */
  16445. setColor3(name: string, value: Color3): ProceduralTexture;
  16446. /**
  16447. * Set a vec4 in the shader from a Color4.
  16448. * @param name Define the name of the uniform as defined in the shader
  16449. * @param value Define the value to give to the uniform
  16450. * @return the texture itself allowing "fluent" like uniform updates
  16451. */
  16452. setColor4(name: string, value: Color4): ProceduralTexture;
  16453. /**
  16454. * Set a vec2 in the shader from a Vector2.
  16455. * @param name Define the name of the uniform as defined in the shader
  16456. * @param value Define the value to give to the uniform
  16457. * @return the texture itself allowing "fluent" like uniform updates
  16458. */
  16459. setVector2(name: string, value: Vector2): ProceduralTexture;
  16460. /**
  16461. * Set a vec3 in the shader from a Vector3.
  16462. * @param name Define the name of the uniform as defined in the shader
  16463. * @param value Define the value to give to the uniform
  16464. * @return the texture itself allowing "fluent" like uniform updates
  16465. */
  16466. setVector3(name: string, value: Vector3): ProceduralTexture;
  16467. /**
  16468. * Set a mat4 in the shader from a MAtrix.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the texture itself allowing "fluent" like uniform updates
  16472. */
  16473. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16474. /**
  16475. * Render the texture to its associated render target.
  16476. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16477. */
  16478. render(useCameraPostProcess?: boolean): void;
  16479. /**
  16480. * Clone the texture.
  16481. * @returns the cloned texture
  16482. */
  16483. clone(): ProceduralTexture;
  16484. /**
  16485. * Dispose the texture and release its asoociated resources.
  16486. */
  16487. dispose(): void;
  16488. }
  16489. }
  16490. declare module BABYLON {
  16491. /**
  16492. * This represents the base class for particle system in Babylon.
  16493. * 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.
  16494. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16495. * @example https://doc.babylonjs.com/babylon101/particles
  16496. */
  16497. export class BaseParticleSystem {
  16498. /**
  16499. * Source color is added to the destination color without alpha affecting the result
  16500. */
  16501. static BLENDMODE_ONEONE: number;
  16502. /**
  16503. * Blend current color and particle color using particle’s alpha
  16504. */
  16505. static BLENDMODE_STANDARD: number;
  16506. /**
  16507. * Add current color and particle color multiplied by particle’s alpha
  16508. */
  16509. static BLENDMODE_ADD: number;
  16510. /**
  16511. * Multiply current color with particle color
  16512. */
  16513. static BLENDMODE_MULTIPLY: number;
  16514. /**
  16515. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16516. */
  16517. static BLENDMODE_MULTIPLYADD: number;
  16518. /**
  16519. * List of animations used by the particle system.
  16520. */
  16521. animations: Animation[];
  16522. /**
  16523. * The id of the Particle system.
  16524. */
  16525. id: string;
  16526. /**
  16527. * The friendly name of the Particle system.
  16528. */
  16529. name: string;
  16530. /**
  16531. * The rendering group used by the Particle system to chose when to render.
  16532. */
  16533. renderingGroupId: number;
  16534. /**
  16535. * The emitter represents the Mesh or position we are attaching the particle system to.
  16536. */
  16537. emitter: Nullable<AbstractMesh | Vector3>;
  16538. /**
  16539. * The maximum number of particles to emit per frame
  16540. */
  16541. emitRate: number;
  16542. /**
  16543. * If you want to launch only a few particles at once, that can be done, as well.
  16544. */
  16545. manualEmitCount: number;
  16546. /**
  16547. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16548. */
  16549. updateSpeed: number;
  16550. /**
  16551. * The amount of time the particle system is running (depends of the overall update speed).
  16552. */
  16553. targetStopDuration: number;
  16554. /**
  16555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16556. */
  16557. disposeOnStop: boolean;
  16558. /**
  16559. * Minimum power of emitting particles.
  16560. */
  16561. minEmitPower: number;
  16562. /**
  16563. * Maximum power of emitting particles.
  16564. */
  16565. maxEmitPower: number;
  16566. /**
  16567. * Minimum life time of emitting particles.
  16568. */
  16569. minLifeTime: number;
  16570. /**
  16571. * Maximum life time of emitting particles.
  16572. */
  16573. maxLifeTime: number;
  16574. /**
  16575. * Minimum Size of emitting particles.
  16576. */
  16577. minSize: number;
  16578. /**
  16579. * Maximum Size of emitting particles.
  16580. */
  16581. maxSize: number;
  16582. /**
  16583. * Minimum scale of emitting particles on X axis.
  16584. */
  16585. minScaleX: number;
  16586. /**
  16587. * Maximum scale of emitting particles on X axis.
  16588. */
  16589. maxScaleX: number;
  16590. /**
  16591. * Minimum scale of emitting particles on Y axis.
  16592. */
  16593. minScaleY: number;
  16594. /**
  16595. * Maximum scale of emitting particles on Y axis.
  16596. */
  16597. maxScaleY: number;
  16598. /**
  16599. * Gets or sets the minimal initial rotation in radians.
  16600. */
  16601. minInitialRotation: number;
  16602. /**
  16603. * Gets or sets the maximal initial rotation in radians.
  16604. */
  16605. maxInitialRotation: number;
  16606. /**
  16607. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16608. */
  16609. minAngularSpeed: number;
  16610. /**
  16611. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16612. */
  16613. maxAngularSpeed: number;
  16614. /**
  16615. * The texture used to render each particle. (this can be a spritesheet)
  16616. */
  16617. particleTexture: Nullable<Texture>;
  16618. /**
  16619. * The layer mask we are rendering the particles through.
  16620. */
  16621. layerMask: number;
  16622. /**
  16623. * This can help using your own shader to render the particle system.
  16624. * The according effect will be created
  16625. */
  16626. customShader: any;
  16627. /**
  16628. * By default particle system starts as soon as they are created. This prevents the
  16629. * automatic start to happen and let you decide when to start emitting particles.
  16630. */
  16631. preventAutoStart: boolean;
  16632. private _noiseTexture;
  16633. /**
  16634. * Gets or sets a texture used to add random noise to particle positions
  16635. */
  16636. noiseTexture: Nullable<ProceduralTexture>;
  16637. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16638. noiseStrength: Vector3;
  16639. /**
  16640. * Callback triggered when the particle animation is ending.
  16641. */
  16642. onAnimationEnd: Nullable<() => void>;
  16643. /**
  16644. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16645. */
  16646. blendMode: number;
  16647. /**
  16648. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16649. * to override the particles.
  16650. */
  16651. forceDepthWrite: boolean;
  16652. /** 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 */
  16653. preWarmCycles: number;
  16654. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16655. preWarmStepOffset: number;
  16656. /**
  16657. * 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)
  16658. */
  16659. spriteCellChangeSpeed: number;
  16660. /**
  16661. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16662. */
  16663. startSpriteCellID: number;
  16664. /**
  16665. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16666. */
  16667. endSpriteCellID: number;
  16668. /**
  16669. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16670. */
  16671. spriteCellWidth: number;
  16672. /**
  16673. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16674. */
  16675. spriteCellHeight: number;
  16676. /**
  16677. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16678. */
  16679. spriteRandomStartCell: boolean;
  16680. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16681. translationPivot: Vector2;
  16682. /** @hidden */
  16683. protected _isAnimationSheetEnabled: boolean;
  16684. /**
  16685. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16686. */
  16687. beginAnimationOnStart: boolean;
  16688. /**
  16689. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16690. */
  16691. beginAnimationFrom: number;
  16692. /**
  16693. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16694. */
  16695. beginAnimationTo: number;
  16696. /**
  16697. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16698. */
  16699. beginAnimationLoop: boolean;
  16700. /**
  16701. * Gets or sets a world offset applied to all particles
  16702. */
  16703. worldOffset: Vector3;
  16704. /**
  16705. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16706. */
  16707. isAnimationSheetEnabled: boolean;
  16708. /**
  16709. * Get hosting scene
  16710. * @returns the scene
  16711. */
  16712. getScene(): Scene;
  16713. /**
  16714. * You can use gravity if you want to give an orientation to your particles.
  16715. */
  16716. gravity: Vector3;
  16717. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16718. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16719. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16720. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16721. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16722. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16723. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16724. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16725. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16726. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16727. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16728. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16729. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16730. /**
  16731. * Defines the delay in milliseconds before starting the system (0 by default)
  16732. */
  16733. startDelay: number;
  16734. /**
  16735. * Gets the current list of drag gradients.
  16736. * You must use addDragGradient and removeDragGradient to udpate this list
  16737. * @returns the list of drag gradients
  16738. */
  16739. getDragGradients(): Nullable<Array<FactorGradient>>;
  16740. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16741. limitVelocityDamping: number;
  16742. /**
  16743. * Gets the current list of limit velocity gradients.
  16744. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16745. * @returns the list of limit velocity gradients
  16746. */
  16747. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16748. /**
  16749. * Gets the current list of color gradients.
  16750. * You must use addColorGradient and removeColorGradient to udpate this list
  16751. * @returns the list of color gradients
  16752. */
  16753. getColorGradients(): Nullable<Array<ColorGradient>>;
  16754. /**
  16755. * Gets the current list of size gradients.
  16756. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16757. * @returns the list of size gradients
  16758. */
  16759. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16760. /**
  16761. * Gets the current list of color remap gradients.
  16762. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16763. * @returns the list of color remap gradients
  16764. */
  16765. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16766. /**
  16767. * Gets the current list of alpha remap gradients.
  16768. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16769. * @returns the list of alpha remap gradients
  16770. */
  16771. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16772. /**
  16773. * Gets the current list of life time gradients.
  16774. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16775. * @returns the list of life time gradients
  16776. */
  16777. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16778. /**
  16779. * Gets the current list of angular speed gradients.
  16780. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16781. * @returns the list of angular speed gradients
  16782. */
  16783. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16784. /**
  16785. * Gets the current list of velocity gradients.
  16786. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16787. * @returns the list of velocity gradients
  16788. */
  16789. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16790. /**
  16791. * Gets the current list of start size gradients.
  16792. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16793. * @returns the list of start size gradients
  16794. */
  16795. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16796. /**
  16797. * Gets the current list of emit rate gradients.
  16798. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16799. * @returns the list of emit rate gradients
  16800. */
  16801. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16802. /**
  16803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16804. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16805. */
  16806. direction1: Vector3;
  16807. /**
  16808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16809. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16810. */
  16811. direction2: Vector3;
  16812. /**
  16813. * 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.
  16814. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16815. */
  16816. minEmitBox: Vector3;
  16817. /**
  16818. * 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.
  16819. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16820. */
  16821. maxEmitBox: Vector3;
  16822. /**
  16823. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16824. */
  16825. color1: Color4;
  16826. /**
  16827. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16828. */
  16829. color2: Color4;
  16830. /**
  16831. * Color the particle will have at the end of its lifetime
  16832. */
  16833. colorDead: Color4;
  16834. /**
  16835. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16836. */
  16837. textureMask: Color4;
  16838. /**
  16839. * The particle emitter type defines the emitter used by the particle system.
  16840. * It can be for example box, sphere, or cone...
  16841. */
  16842. particleEmitterType: IParticleEmitterType;
  16843. /** @hidden */
  16844. _isSubEmitter: boolean;
  16845. /**
  16846. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16847. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16848. */
  16849. billboardMode: number;
  16850. protected _isBillboardBased: boolean;
  16851. /**
  16852. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16853. */
  16854. isBillboardBased: boolean;
  16855. /**
  16856. * The scene the particle system belongs to.
  16857. */
  16858. protected _scene: Scene;
  16859. /**
  16860. * Local cache of defines for image processing.
  16861. */
  16862. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16863. /**
  16864. * Default configuration related to image processing available in the standard Material.
  16865. */
  16866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16867. /**
  16868. * Gets the image processing configuration used either in this material.
  16869. */
  16870. /**
  16871. * Sets the Default image processing configuration used either in the this material.
  16872. *
  16873. * If sets to null, the scene one is in use.
  16874. */
  16875. imageProcessingConfiguration: ImageProcessingConfiguration;
  16876. /**
  16877. * Attaches a new image processing configuration to the Standard Material.
  16878. * @param configuration
  16879. */
  16880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16881. /** @hidden */
  16882. protected _reset(): void;
  16883. /** @hidden */
  16884. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16885. /**
  16886. * Instantiates a particle system.
  16887. * 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.
  16888. * @param name The name of the particle system
  16889. */
  16890. constructor(name: string);
  16891. /**
  16892. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16893. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16894. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16895. * @returns the emitter
  16896. */
  16897. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16898. /**
  16899. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16900. * @param radius The radius of the hemisphere to emit from
  16901. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16902. * @returns the emitter
  16903. */
  16904. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16905. /**
  16906. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16907. * @param radius The radius of the sphere to emit from
  16908. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16909. * @returns the emitter
  16910. */
  16911. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16912. /**
  16913. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16914. * @param radius The radius of the sphere to emit from
  16915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16917. * @returns the emitter
  16918. */
  16919. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16920. /**
  16921. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16922. * @param radius The radius of the emission cylinder
  16923. * @param height The height of the emission cylinder
  16924. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16925. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16926. * @returns the emitter
  16927. */
  16928. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16929. /**
  16930. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16931. * @param radius The radius of the cylinder to emit from
  16932. * @param height The height of the emission cylinder
  16933. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16936. * @returns the emitter
  16937. */
  16938. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16939. /**
  16940. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16941. * @param radius The radius of the cone to emit from
  16942. * @param angle The base angle of the cone
  16943. * @returns the emitter
  16944. */
  16945. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16946. /**
  16947. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16948. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16949. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16950. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16951. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16952. * @returns the emitter
  16953. */
  16954. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16955. }
  16956. }
  16957. declare module BABYLON {
  16958. /**
  16959. * Type of sub emitter
  16960. */
  16961. export enum SubEmitterType {
  16962. /**
  16963. * Attached to the particle over it's lifetime
  16964. */
  16965. ATTACHED = 0,
  16966. /**
  16967. * Created when the particle dies
  16968. */
  16969. END = 1
  16970. }
  16971. /**
  16972. * Sub emitter class used to emit particles from an existing particle
  16973. */
  16974. export class SubEmitter {
  16975. /**
  16976. * the particle system to be used by the sub emitter
  16977. */
  16978. particleSystem: ParticleSystem;
  16979. /**
  16980. * Type of the submitter (Default: END)
  16981. */
  16982. type: SubEmitterType;
  16983. /**
  16984. * 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)
  16985. * Note: This only is supported when using an emitter of type Mesh
  16986. */
  16987. inheritDirection: boolean;
  16988. /**
  16989. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16990. */
  16991. inheritedVelocityAmount: number;
  16992. /**
  16993. * Creates a sub emitter
  16994. * @param particleSystem the particle system to be used by the sub emitter
  16995. */
  16996. constructor(
  16997. /**
  16998. * the particle system to be used by the sub emitter
  16999. */
  17000. particleSystem: ParticleSystem);
  17001. /**
  17002. * Clones the sub emitter
  17003. * @returns the cloned sub emitter
  17004. */
  17005. clone(): SubEmitter;
  17006. /**
  17007. * Serialize current object to a JSON object
  17008. * @returns the serialized object
  17009. */
  17010. serialize(): any;
  17011. /** @hidden */
  17012. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17013. /**
  17014. * Creates a new SubEmitter from a serialized JSON version
  17015. * @param serializationObject defines the JSON object to read from
  17016. * @param scene defines the hosting scene
  17017. * @param rootUrl defines the rootUrl for data loading
  17018. * @returns a new SubEmitter
  17019. */
  17020. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17021. /** Release associated resources */
  17022. dispose(): void;
  17023. }
  17024. }
  17025. declare module BABYLON {
  17026. /** @hidden */
  17027. export var clipPlaneFragmentDeclaration: {
  17028. name: string;
  17029. shader: string;
  17030. };
  17031. }
  17032. declare module BABYLON {
  17033. /** @hidden */
  17034. export var imageProcessingDeclaration: {
  17035. name: string;
  17036. shader: string;
  17037. };
  17038. }
  17039. declare module BABYLON {
  17040. /** @hidden */
  17041. export var imageProcessingFunctions: {
  17042. name: string;
  17043. shader: string;
  17044. };
  17045. }
  17046. declare module BABYLON {
  17047. /** @hidden */
  17048. export var clipPlaneFragment: {
  17049. name: string;
  17050. shader: string;
  17051. };
  17052. }
  17053. declare module BABYLON {
  17054. /** @hidden */
  17055. export var particlesPixelShader: {
  17056. name: string;
  17057. shader: string;
  17058. };
  17059. }
  17060. declare module BABYLON {
  17061. /** @hidden */
  17062. export var clipPlaneVertexDeclaration: {
  17063. name: string;
  17064. shader: string;
  17065. };
  17066. }
  17067. declare module BABYLON {
  17068. /** @hidden */
  17069. export var clipPlaneVertex: {
  17070. name: string;
  17071. shader: string;
  17072. };
  17073. }
  17074. declare module BABYLON {
  17075. /** @hidden */
  17076. export var particlesVertexShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module BABYLON {
  17082. /**
  17083. * This represents a particle system in Babylon.
  17084. * 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.
  17085. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17086. * @example https://doc.babylonjs.com/babylon101/particles
  17087. */
  17088. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17089. /**
  17090. * Billboard mode will only apply to Y axis
  17091. */
  17092. static readonly BILLBOARDMODE_Y: number;
  17093. /**
  17094. * Billboard mode will apply to all axes
  17095. */
  17096. static readonly BILLBOARDMODE_ALL: number;
  17097. /**
  17098. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17099. */
  17100. static readonly BILLBOARDMODE_STRETCHED: number;
  17101. /**
  17102. * This function can be defined to provide custom update for active particles.
  17103. * This function will be called instead of regular update (age, position, color, etc.).
  17104. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17105. */
  17106. updateFunction: (particles: Particle[]) => void;
  17107. private _emitterWorldMatrix;
  17108. /**
  17109. * This function can be defined to specify initial direction for every new particle.
  17110. * It by default use the emitterType defined function
  17111. */
  17112. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17113. /**
  17114. * This function can be defined to specify initial position for every new particle.
  17115. * It by default use the emitterType defined function
  17116. */
  17117. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17118. /**
  17119. * @hidden
  17120. */
  17121. _inheritedVelocityOffset: Vector3;
  17122. /**
  17123. * An event triggered when the system is disposed
  17124. */
  17125. onDisposeObservable: Observable<ParticleSystem>;
  17126. private _onDisposeObserver;
  17127. /**
  17128. * Sets a callback that will be triggered when the system is disposed
  17129. */
  17130. onDispose: () => void;
  17131. private _particles;
  17132. private _epsilon;
  17133. private _capacity;
  17134. private _stockParticles;
  17135. private _newPartsExcess;
  17136. private _vertexData;
  17137. private _vertexBuffer;
  17138. private _vertexBuffers;
  17139. private _spriteBuffer;
  17140. private _indexBuffer;
  17141. private _effect;
  17142. private _customEffect;
  17143. private _cachedDefines;
  17144. private _scaledColorStep;
  17145. private _colorDiff;
  17146. private _scaledDirection;
  17147. private _scaledGravity;
  17148. private _currentRenderId;
  17149. private _alive;
  17150. private _useInstancing;
  17151. private _started;
  17152. private _stopped;
  17153. private _actualFrame;
  17154. private _scaledUpdateSpeed;
  17155. private _vertexBufferSize;
  17156. /** @hidden */
  17157. _currentEmitRateGradient: Nullable<FactorGradient>;
  17158. /** @hidden */
  17159. _currentEmitRate1: number;
  17160. /** @hidden */
  17161. _currentEmitRate2: number;
  17162. /** @hidden */
  17163. _currentStartSizeGradient: Nullable<FactorGradient>;
  17164. /** @hidden */
  17165. _currentStartSize1: number;
  17166. /** @hidden */
  17167. _currentStartSize2: number;
  17168. private readonly _rawTextureWidth;
  17169. private _rampGradientsTexture;
  17170. private _useRampGradients;
  17171. /** Gets or sets a boolean indicating that ramp gradients must be used
  17172. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17173. */
  17174. useRampGradients: boolean;
  17175. /**
  17176. * 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.
  17177. * 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: [])
  17178. */
  17179. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17180. private _subEmitters;
  17181. /**
  17182. * @hidden
  17183. * If the particle systems emitter should be disposed when the particle system is disposed
  17184. */
  17185. _disposeEmitterOnDispose: boolean;
  17186. /**
  17187. * The current active Sub-systems, this property is used by the root particle system only.
  17188. */
  17189. activeSubSystems: Array<ParticleSystem>;
  17190. private _rootParticleSystem;
  17191. /**
  17192. * Gets the current list of active particles
  17193. */
  17194. readonly particles: Particle[];
  17195. /**
  17196. * Returns the string "ParticleSystem"
  17197. * @returns a string containing the class name
  17198. */
  17199. getClassName(): string;
  17200. /**
  17201. * Instantiates a particle system.
  17202. * 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.
  17203. * @param name The name of the particle system
  17204. * @param capacity The max number of particles alive at the same time
  17205. * @param scene The scene the particle system belongs to
  17206. * @param customEffect a custom effect used to change the way particles are rendered by default
  17207. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17208. * @param epsilon Offset used to render the particles
  17209. */
  17210. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17211. private _addFactorGradient;
  17212. private _removeFactorGradient;
  17213. /**
  17214. * Adds a new life time gradient
  17215. * @param gradient defines the gradient to use (between 0 and 1)
  17216. * @param factor defines the life time factor to affect to the specified gradient
  17217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17218. * @returns the current particle system
  17219. */
  17220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17221. /**
  17222. * Remove a specific life time gradient
  17223. * @param gradient defines the gradient to remove
  17224. * @returns the current particle system
  17225. */
  17226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17227. /**
  17228. * Adds a new size gradient
  17229. * @param gradient defines the gradient to use (between 0 and 1)
  17230. * @param factor defines the size factor to affect to the specified gradient
  17231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17232. * @returns the current particle system
  17233. */
  17234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17235. /**
  17236. * Remove a specific size gradient
  17237. * @param gradient defines the gradient to remove
  17238. * @returns the current particle system
  17239. */
  17240. removeSizeGradient(gradient: number): IParticleSystem;
  17241. /**
  17242. * Adds a new color remap gradient
  17243. * @param gradient defines the gradient to use (between 0 and 1)
  17244. * @param min defines the color remap minimal range
  17245. * @param max defines the color remap maximal range
  17246. * @returns the current particle system
  17247. */
  17248. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17249. /**
  17250. * Remove a specific color remap gradient
  17251. * @param gradient defines the gradient to remove
  17252. * @returns the current particle system
  17253. */
  17254. removeColorRemapGradient(gradient: number): IParticleSystem;
  17255. /**
  17256. * Adds a new alpha remap gradient
  17257. * @param gradient defines the gradient to use (between 0 and 1)
  17258. * @param min defines the alpha remap minimal range
  17259. * @param max defines the alpha remap maximal range
  17260. * @returns the current particle system
  17261. */
  17262. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17263. /**
  17264. * Remove a specific alpha remap gradient
  17265. * @param gradient defines the gradient to remove
  17266. * @returns the current particle system
  17267. */
  17268. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17269. /**
  17270. * Adds a new angular speed gradient
  17271. * @param gradient defines the gradient to use (between 0 and 1)
  17272. * @param factor defines the angular speed to affect to the specified gradient
  17273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17274. * @returns the current particle system
  17275. */
  17276. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17277. /**
  17278. * Remove a specific angular speed gradient
  17279. * @param gradient defines the gradient to remove
  17280. * @returns the current particle system
  17281. */
  17282. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17283. /**
  17284. * Adds a new velocity gradient
  17285. * @param gradient defines the gradient to use (between 0 and 1)
  17286. * @param factor defines the velocity to affect to the specified gradient
  17287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17288. * @returns the current particle system
  17289. */
  17290. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17291. /**
  17292. * Remove a specific velocity gradient
  17293. * @param gradient defines the gradient to remove
  17294. * @returns the current particle system
  17295. */
  17296. removeVelocityGradient(gradient: number): IParticleSystem;
  17297. /**
  17298. * Adds a new limit velocity gradient
  17299. * @param gradient defines the gradient to use (between 0 and 1)
  17300. * @param factor defines the limit velocity value to affect to the specified gradient
  17301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17302. * @returns the current particle system
  17303. */
  17304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17305. /**
  17306. * Remove a specific limit velocity gradient
  17307. * @param gradient defines the gradient to remove
  17308. * @returns the current particle system
  17309. */
  17310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17311. /**
  17312. * Adds a new drag gradient
  17313. * @param gradient defines the gradient to use (between 0 and 1)
  17314. * @param factor defines the drag value to affect to the specified gradient
  17315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17316. * @returns the current particle system
  17317. */
  17318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17319. /**
  17320. * Remove a specific drag gradient
  17321. * @param gradient defines the gradient to remove
  17322. * @returns the current particle system
  17323. */
  17324. removeDragGradient(gradient: number): IParticleSystem;
  17325. /**
  17326. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17327. * @param gradient defines the gradient to use (between 0 and 1)
  17328. * @param factor defines the emit rate value to affect to the specified gradient
  17329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17330. * @returns the current particle system
  17331. */
  17332. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17333. /**
  17334. * Remove a specific emit rate gradient
  17335. * @param gradient defines the gradient to remove
  17336. * @returns the current particle system
  17337. */
  17338. removeEmitRateGradient(gradient: number): IParticleSystem;
  17339. /**
  17340. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17341. * @param gradient defines the gradient to use (between 0 and 1)
  17342. * @param factor defines the start size value to affect to the specified gradient
  17343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17344. * @returns the current particle system
  17345. */
  17346. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17347. /**
  17348. * Remove a specific start size gradient
  17349. * @param gradient defines the gradient to remove
  17350. * @returns the current particle system
  17351. */
  17352. removeStartSizeGradient(gradient: number): IParticleSystem;
  17353. private _createRampGradientTexture;
  17354. /**
  17355. * Gets the current list of ramp gradients.
  17356. * You must use addRampGradient and removeRampGradient to udpate this list
  17357. * @returns the list of ramp gradients
  17358. */
  17359. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17360. /**
  17361. * Adds a new ramp gradient used to remap particle colors
  17362. * @param gradient defines the gradient to use (between 0 and 1)
  17363. * @param color defines the color to affect to the specified gradient
  17364. * @returns the current particle system
  17365. */
  17366. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17367. /**
  17368. * Remove a specific ramp gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeRampGradient(gradient: number): ParticleSystem;
  17373. /**
  17374. * Adds a new color gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param color1 defines the color to affect to the specified gradient
  17377. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17378. * @returns this particle system
  17379. */
  17380. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17381. /**
  17382. * Remove a specific color gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns this particle system
  17385. */
  17386. removeColorGradient(gradient: number): IParticleSystem;
  17387. private _fetchR;
  17388. protected _reset(): void;
  17389. private _resetEffect;
  17390. private _createVertexBuffers;
  17391. private _createIndexBuffer;
  17392. /**
  17393. * Gets the maximum number of particles active at the same time.
  17394. * @returns The max number of active particles.
  17395. */
  17396. getCapacity(): number;
  17397. /**
  17398. * Gets whether there are still active particles in the system.
  17399. * @returns True if it is alive, otherwise false.
  17400. */
  17401. isAlive(): boolean;
  17402. /**
  17403. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17404. * @returns True if it has been started, otherwise false.
  17405. */
  17406. isStarted(): boolean;
  17407. private _prepareSubEmitterInternalArray;
  17408. /**
  17409. * Starts the particle system and begins to emit
  17410. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17411. */
  17412. start(delay?: number): void;
  17413. /**
  17414. * Stops the particle system.
  17415. * @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.
  17416. */
  17417. stop(stopSubEmitters?: boolean): void;
  17418. /**
  17419. * Remove all active particles
  17420. */
  17421. reset(): void;
  17422. /**
  17423. * @hidden (for internal use only)
  17424. */
  17425. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17426. /**
  17427. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17428. * Its lifetime will start back at 0.
  17429. */
  17430. recycleParticle: (particle: Particle) => void;
  17431. private _stopSubEmitters;
  17432. private _createParticle;
  17433. private _removeFromRoot;
  17434. private _emitFromParticle;
  17435. private _update;
  17436. /** @hidden */
  17437. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17438. /** @hidden */
  17439. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17440. /** @hidden */
  17441. private _getEffect;
  17442. /**
  17443. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17444. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17445. */
  17446. animate(preWarmOnly?: boolean): void;
  17447. private _appendParticleVertices;
  17448. /**
  17449. * Rebuilds the particle system.
  17450. */
  17451. rebuild(): void;
  17452. /**
  17453. * Is this system ready to be used/rendered
  17454. * @return true if the system is ready
  17455. */
  17456. isReady(): boolean;
  17457. private _render;
  17458. /**
  17459. * Renders the particle system in its current state.
  17460. * @returns the current number of particles
  17461. */
  17462. render(): number;
  17463. /**
  17464. * Disposes the particle system and free the associated resources
  17465. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17466. */
  17467. dispose(disposeTexture?: boolean): void;
  17468. /**
  17469. * Clones the particle system.
  17470. * @param name The name of the cloned object
  17471. * @param newEmitter The new emitter to use
  17472. * @returns the cloned particle system
  17473. */
  17474. clone(name: string, newEmitter: any): ParticleSystem;
  17475. /**
  17476. * Serializes the particle system to a JSON object.
  17477. * @returns the JSON object
  17478. */
  17479. serialize(): any;
  17480. /** @hidden */
  17481. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17482. /** @hidden */
  17483. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17484. /**
  17485. * Parses a JSON object to create a particle system.
  17486. * @param parsedParticleSystem The JSON object to parse
  17487. * @param scene The scene to create the particle system in
  17488. * @param rootUrl The root url to use to load external dependencies like texture
  17489. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17490. * @returns the Parsed particle system
  17491. */
  17492. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17493. }
  17494. }
  17495. declare module BABYLON {
  17496. /**
  17497. * A particle represents one of the element emitted by a particle system.
  17498. * This is mainly define by its coordinates, direction, velocity and age.
  17499. */
  17500. export class Particle {
  17501. /**
  17502. * The particle system the particle belongs to.
  17503. */
  17504. particleSystem: ParticleSystem;
  17505. private static _Count;
  17506. /**
  17507. * Unique ID of the particle
  17508. */
  17509. id: number;
  17510. /**
  17511. * The world position of the particle in the scene.
  17512. */
  17513. position: Vector3;
  17514. /**
  17515. * The world direction of the particle in the scene.
  17516. */
  17517. direction: Vector3;
  17518. /**
  17519. * The color of the particle.
  17520. */
  17521. color: Color4;
  17522. /**
  17523. * The color change of the particle per step.
  17524. */
  17525. colorStep: Color4;
  17526. /**
  17527. * Defines how long will the life of the particle be.
  17528. */
  17529. lifeTime: number;
  17530. /**
  17531. * The current age of the particle.
  17532. */
  17533. age: number;
  17534. /**
  17535. * The current size of the particle.
  17536. */
  17537. size: number;
  17538. /**
  17539. * The current scale of the particle.
  17540. */
  17541. scale: Vector2;
  17542. /**
  17543. * The current angle of the particle.
  17544. */
  17545. angle: number;
  17546. /**
  17547. * Defines how fast is the angle changing.
  17548. */
  17549. angularSpeed: number;
  17550. /**
  17551. * Defines the cell index used by the particle to be rendered from a sprite.
  17552. */
  17553. cellIndex: number;
  17554. /**
  17555. * The information required to support color remapping
  17556. */
  17557. remapData: Vector4;
  17558. /** @hidden */
  17559. _randomCellOffset?: number;
  17560. /** @hidden */
  17561. _initialDirection: Nullable<Vector3>;
  17562. /** @hidden */
  17563. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17564. /** @hidden */
  17565. _initialStartSpriteCellID: number;
  17566. /** @hidden */
  17567. _initialEndSpriteCellID: number;
  17568. /** @hidden */
  17569. _currentColorGradient: Nullable<ColorGradient>;
  17570. /** @hidden */
  17571. _currentColor1: Color4;
  17572. /** @hidden */
  17573. _currentColor2: Color4;
  17574. /** @hidden */
  17575. _currentSizeGradient: Nullable<FactorGradient>;
  17576. /** @hidden */
  17577. _currentSize1: number;
  17578. /** @hidden */
  17579. _currentSize2: number;
  17580. /** @hidden */
  17581. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17582. /** @hidden */
  17583. _currentAngularSpeed1: number;
  17584. /** @hidden */
  17585. _currentAngularSpeed2: number;
  17586. /** @hidden */
  17587. _currentVelocityGradient: Nullable<FactorGradient>;
  17588. /** @hidden */
  17589. _currentVelocity1: number;
  17590. /** @hidden */
  17591. _currentVelocity2: number;
  17592. /** @hidden */
  17593. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17594. /** @hidden */
  17595. _currentLimitVelocity1: number;
  17596. /** @hidden */
  17597. _currentLimitVelocity2: number;
  17598. /** @hidden */
  17599. _currentDragGradient: Nullable<FactorGradient>;
  17600. /** @hidden */
  17601. _currentDrag1: number;
  17602. /** @hidden */
  17603. _currentDrag2: number;
  17604. /** @hidden */
  17605. _randomNoiseCoordinates1: Vector3;
  17606. /** @hidden */
  17607. _randomNoiseCoordinates2: Vector3;
  17608. /**
  17609. * Creates a new instance Particle
  17610. * @param particleSystem the particle system the particle belongs to
  17611. */
  17612. constructor(
  17613. /**
  17614. * The particle system the particle belongs to.
  17615. */
  17616. particleSystem: ParticleSystem);
  17617. private updateCellInfoFromSystem;
  17618. /**
  17619. * Defines how the sprite cell index is updated for the particle
  17620. */
  17621. updateCellIndex(): void;
  17622. /** @hidden */
  17623. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17624. /** @hidden */
  17625. _inheritParticleInfoToSubEmitters(): void;
  17626. /** @hidden */
  17627. _reset(): void;
  17628. /**
  17629. * Copy the properties of particle to another one.
  17630. * @param other the particle to copy the information to.
  17631. */
  17632. copyTo(other: Particle): void;
  17633. }
  17634. }
  17635. declare module BABYLON {
  17636. /**
  17637. * Particle emitter represents a volume emitting particles.
  17638. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17639. */
  17640. export interface IParticleEmitterType {
  17641. /**
  17642. * Called by the particle System when the direction is computed for the created particle.
  17643. * @param worldMatrix is the world matrix of the particle system
  17644. * @param directionToUpdate is the direction vector to update with the result
  17645. * @param particle is the particle we are computed the direction for
  17646. */
  17647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17648. /**
  17649. * Called by the particle System when the position is computed for the created particle.
  17650. * @param worldMatrix is the world matrix of the particle system
  17651. * @param positionToUpdate is the position vector to update with the result
  17652. * @param particle is the particle we are computed the position for
  17653. */
  17654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17655. /**
  17656. * Clones the current emitter and returns a copy of it
  17657. * @returns the new emitter
  17658. */
  17659. clone(): IParticleEmitterType;
  17660. /**
  17661. * Called by the GPUParticleSystem to setup the update shader
  17662. * @param effect defines the update shader
  17663. */
  17664. applyToShader(effect: Effect): void;
  17665. /**
  17666. * Returns a string to use to update the GPU particles update shader
  17667. * @returns the effect defines string
  17668. */
  17669. getEffectDefines(): string;
  17670. /**
  17671. * Returns a string representing the class name
  17672. * @returns a string containing the class name
  17673. */
  17674. getClassName(): string;
  17675. /**
  17676. * Serializes the particle system to a JSON object.
  17677. * @returns the JSON object
  17678. */
  17679. serialize(): any;
  17680. /**
  17681. * Parse properties from a JSON object
  17682. * @param serializationObject defines the JSON object
  17683. */
  17684. parse(serializationObject: any): void;
  17685. }
  17686. }
  17687. declare module BABYLON {
  17688. /**
  17689. * Particle emitter emitting particles from the inside of a box.
  17690. * It emits the particles randomly between 2 given directions.
  17691. */
  17692. export class BoxParticleEmitter implements IParticleEmitterType {
  17693. /**
  17694. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17695. */
  17696. direction1: Vector3;
  17697. /**
  17698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17699. */
  17700. direction2: Vector3;
  17701. /**
  17702. * 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.
  17703. */
  17704. minEmitBox: Vector3;
  17705. /**
  17706. * 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.
  17707. */
  17708. maxEmitBox: Vector3;
  17709. /**
  17710. * Creates a new instance BoxParticleEmitter
  17711. */
  17712. constructor();
  17713. /**
  17714. * Called by the particle System when the direction is computed for the created particle.
  17715. * @param worldMatrix is the world matrix of the particle system
  17716. * @param directionToUpdate is the direction vector to update with the result
  17717. * @param particle is the particle we are computed the direction for
  17718. */
  17719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17720. /**
  17721. * Called by the particle System when the position is computed for the created particle.
  17722. * @param worldMatrix is the world matrix of the particle system
  17723. * @param positionToUpdate is the position vector to update with the result
  17724. * @param particle is the particle we are computed the position for
  17725. */
  17726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17727. /**
  17728. * Clones the current emitter and returns a copy of it
  17729. * @returns the new emitter
  17730. */
  17731. clone(): BoxParticleEmitter;
  17732. /**
  17733. * Called by the GPUParticleSystem to setup the update shader
  17734. * @param effect defines the update shader
  17735. */
  17736. applyToShader(effect: Effect): void;
  17737. /**
  17738. * Returns a string to use to update the GPU particles update shader
  17739. * @returns a string containng the defines string
  17740. */
  17741. getEffectDefines(): string;
  17742. /**
  17743. * Returns the string "BoxParticleEmitter"
  17744. * @returns a string containing the class name
  17745. */
  17746. getClassName(): string;
  17747. /**
  17748. * Serializes the particle system to a JSON object.
  17749. * @returns the JSON object
  17750. */
  17751. serialize(): any;
  17752. /**
  17753. * Parse properties from a JSON object
  17754. * @param serializationObject defines the JSON object
  17755. */
  17756. parse(serializationObject: any): void;
  17757. }
  17758. }
  17759. declare module BABYLON {
  17760. /**
  17761. * Particle emitter emitting particles from the inside of a cone.
  17762. * It emits the particles alongside the cone volume from the base to the particle.
  17763. * The emission direction might be randomized.
  17764. */
  17765. export class ConeParticleEmitter implements IParticleEmitterType {
  17766. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17767. directionRandomizer: number;
  17768. private _radius;
  17769. private _angle;
  17770. private _height;
  17771. /**
  17772. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17773. */
  17774. radiusRange: number;
  17775. /**
  17776. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17777. */
  17778. heightRange: number;
  17779. /**
  17780. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17781. */
  17782. emitFromSpawnPointOnly: boolean;
  17783. /**
  17784. * Gets or sets the radius of the emission cone
  17785. */
  17786. radius: number;
  17787. /**
  17788. * Gets or sets the angle of the emission cone
  17789. */
  17790. angle: number;
  17791. private _buildHeight;
  17792. /**
  17793. * Creates a new instance ConeParticleEmitter
  17794. * @param radius the radius of the emission cone (1 by default)
  17795. * @param angle the cone base angle (PI by default)
  17796. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17797. */
  17798. constructor(radius?: number, angle?: number,
  17799. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17800. directionRandomizer?: number);
  17801. /**
  17802. * Called by the particle System when the direction is computed for the created particle.
  17803. * @param worldMatrix is the world matrix of the particle system
  17804. * @param directionToUpdate is the direction vector to update with the result
  17805. * @param particle is the particle we are computed the direction for
  17806. */
  17807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17808. /**
  17809. * Called by the particle System when the position is computed for the created particle.
  17810. * @param worldMatrix is the world matrix of the particle system
  17811. * @param positionToUpdate is the position vector to update with the result
  17812. * @param particle is the particle we are computed the position for
  17813. */
  17814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17815. /**
  17816. * Clones the current emitter and returns a copy of it
  17817. * @returns the new emitter
  17818. */
  17819. clone(): ConeParticleEmitter;
  17820. /**
  17821. * Called by the GPUParticleSystem to setup the update shader
  17822. * @param effect defines the update shader
  17823. */
  17824. applyToShader(effect: Effect): void;
  17825. /**
  17826. * Returns a string to use to update the GPU particles update shader
  17827. * @returns a string containng the defines string
  17828. */
  17829. getEffectDefines(): string;
  17830. /**
  17831. * Returns the string "ConeParticleEmitter"
  17832. * @returns a string containing the class name
  17833. */
  17834. getClassName(): string;
  17835. /**
  17836. * Serializes the particle system to a JSON object.
  17837. * @returns the JSON object
  17838. */
  17839. serialize(): any;
  17840. /**
  17841. * Parse properties from a JSON object
  17842. * @param serializationObject defines the JSON object
  17843. */
  17844. parse(serializationObject: any): void;
  17845. }
  17846. }
  17847. declare module BABYLON {
  17848. /**
  17849. * Particle emitter emitting particles from the inside of a cylinder.
  17850. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17851. */
  17852. export class CylinderParticleEmitter implements IParticleEmitterType {
  17853. /**
  17854. * The radius of the emission cylinder.
  17855. */
  17856. radius: number;
  17857. /**
  17858. * The height of the emission cylinder.
  17859. */
  17860. height: number;
  17861. /**
  17862. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17863. */
  17864. radiusRange: number;
  17865. /**
  17866. * How much to randomize the particle direction [0-1].
  17867. */
  17868. directionRandomizer: number;
  17869. /**
  17870. * Creates a new instance CylinderParticleEmitter
  17871. * @param radius the radius of the emission cylinder (1 by default)
  17872. * @param height the height of the emission cylinder (1 by default)
  17873. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17874. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17875. */
  17876. constructor(
  17877. /**
  17878. * The radius of the emission cylinder.
  17879. */
  17880. radius?: number,
  17881. /**
  17882. * The height of the emission cylinder.
  17883. */
  17884. height?: number,
  17885. /**
  17886. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17887. */
  17888. radiusRange?: number,
  17889. /**
  17890. * How much to randomize the particle direction [0-1].
  17891. */
  17892. directionRandomizer?: number);
  17893. /**
  17894. * Called by the particle System when the direction is computed for the created particle.
  17895. * @param worldMatrix is the world matrix of the particle system
  17896. * @param directionToUpdate is the direction vector to update with the result
  17897. * @param particle is the particle we are computed the direction for
  17898. */
  17899. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17900. /**
  17901. * Called by the particle System when the position is computed for the created particle.
  17902. * @param worldMatrix is the world matrix of the particle system
  17903. * @param positionToUpdate is the position vector to update with the result
  17904. * @param particle is the particle we are computed the position for
  17905. */
  17906. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17907. /**
  17908. * Clones the current emitter and returns a copy of it
  17909. * @returns the new emitter
  17910. */
  17911. clone(): CylinderParticleEmitter;
  17912. /**
  17913. * Called by the GPUParticleSystem to setup the update shader
  17914. * @param effect defines the update shader
  17915. */
  17916. applyToShader(effect: Effect): void;
  17917. /**
  17918. * Returns a string to use to update the GPU particles update shader
  17919. * @returns a string containng the defines string
  17920. */
  17921. getEffectDefines(): string;
  17922. /**
  17923. * Returns the string "CylinderParticleEmitter"
  17924. * @returns a string containing the class name
  17925. */
  17926. getClassName(): string;
  17927. /**
  17928. * Serializes the particle system to a JSON object.
  17929. * @returns the JSON object
  17930. */
  17931. serialize(): any;
  17932. /**
  17933. * Parse properties from a JSON object
  17934. * @param serializationObject defines the JSON object
  17935. */
  17936. parse(serializationObject: any): void;
  17937. }
  17938. /**
  17939. * Particle emitter emitting particles from the inside of a cylinder.
  17940. * It emits the particles randomly between two vectors.
  17941. */
  17942. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17943. /**
  17944. * The min limit of the emission direction.
  17945. */
  17946. direction1: Vector3;
  17947. /**
  17948. * The max limit of the emission direction.
  17949. */
  17950. direction2: Vector3;
  17951. /**
  17952. * Creates a new instance CylinderDirectedParticleEmitter
  17953. * @param radius the radius of the emission cylinder (1 by default)
  17954. * @param height the height of the emission cylinder (1 by default)
  17955. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17956. * @param direction1 the min limit of the emission direction (up vector by default)
  17957. * @param direction2 the max limit of the emission direction (up vector by default)
  17958. */
  17959. constructor(radius?: number, height?: number, radiusRange?: number,
  17960. /**
  17961. * The min limit of the emission direction.
  17962. */
  17963. direction1?: Vector3,
  17964. /**
  17965. * The max limit of the emission direction.
  17966. */
  17967. direction2?: Vector3);
  17968. /**
  17969. * Called by the particle System when the direction is computed for the created particle.
  17970. * @param worldMatrix is the world matrix of the particle system
  17971. * @param directionToUpdate is the direction vector to update with the result
  17972. * @param particle is the particle we are computed the direction for
  17973. */
  17974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17975. /**
  17976. * Clones the current emitter and returns a copy of it
  17977. * @returns the new emitter
  17978. */
  17979. clone(): CylinderDirectedParticleEmitter;
  17980. /**
  17981. * Called by the GPUParticleSystem to setup the update shader
  17982. * @param effect defines the update shader
  17983. */
  17984. applyToShader(effect: Effect): void;
  17985. /**
  17986. * Returns a string to use to update the GPU particles update shader
  17987. * @returns a string containng the defines string
  17988. */
  17989. getEffectDefines(): string;
  17990. /**
  17991. * Returns the string "CylinderDirectedParticleEmitter"
  17992. * @returns a string containing the class name
  17993. */
  17994. getClassName(): string;
  17995. /**
  17996. * Serializes the particle system to a JSON object.
  17997. * @returns the JSON object
  17998. */
  17999. serialize(): any;
  18000. /**
  18001. * Parse properties from a JSON object
  18002. * @param serializationObject defines the JSON object
  18003. */
  18004. parse(serializationObject: any): void;
  18005. }
  18006. }
  18007. declare module BABYLON {
  18008. /**
  18009. * Particle emitter emitting particles from the inside of a hemisphere.
  18010. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18011. */
  18012. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18013. /**
  18014. * The radius of the emission hemisphere.
  18015. */
  18016. radius: number;
  18017. /**
  18018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18019. */
  18020. radiusRange: number;
  18021. /**
  18022. * How much to randomize the particle direction [0-1].
  18023. */
  18024. directionRandomizer: number;
  18025. /**
  18026. * Creates a new instance HemisphericParticleEmitter
  18027. * @param radius the radius of the emission hemisphere (1 by default)
  18028. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18029. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18030. */
  18031. constructor(
  18032. /**
  18033. * The radius of the emission hemisphere.
  18034. */
  18035. radius?: number,
  18036. /**
  18037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18038. */
  18039. radiusRange?: number,
  18040. /**
  18041. * How much to randomize the particle direction [0-1].
  18042. */
  18043. directionRandomizer?: number);
  18044. /**
  18045. * Called by the particle System when the direction is computed for the created particle.
  18046. * @param worldMatrix is the world matrix of the particle system
  18047. * @param directionToUpdate is the direction vector to update with the result
  18048. * @param particle is the particle we are computed the direction for
  18049. */
  18050. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18051. /**
  18052. * Called by the particle System when the position is computed for the created particle.
  18053. * @param worldMatrix is the world matrix of the particle system
  18054. * @param positionToUpdate is the position vector to update with the result
  18055. * @param particle is the particle we are computed the position for
  18056. */
  18057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18058. /**
  18059. * Clones the current emitter and returns a copy of it
  18060. * @returns the new emitter
  18061. */
  18062. clone(): HemisphericParticleEmitter;
  18063. /**
  18064. * Called by the GPUParticleSystem to setup the update shader
  18065. * @param effect defines the update shader
  18066. */
  18067. applyToShader(effect: Effect): void;
  18068. /**
  18069. * Returns a string to use to update the GPU particles update shader
  18070. * @returns a string containng the defines string
  18071. */
  18072. getEffectDefines(): string;
  18073. /**
  18074. * Returns the string "HemisphericParticleEmitter"
  18075. * @returns a string containing the class name
  18076. */
  18077. getClassName(): string;
  18078. /**
  18079. * Serializes the particle system to a JSON object.
  18080. * @returns the JSON object
  18081. */
  18082. serialize(): any;
  18083. /**
  18084. * Parse properties from a JSON object
  18085. * @param serializationObject defines the JSON object
  18086. */
  18087. parse(serializationObject: any): void;
  18088. }
  18089. }
  18090. declare module BABYLON {
  18091. /**
  18092. * Particle emitter emitting particles from a point.
  18093. * It emits the particles randomly between 2 given directions.
  18094. */
  18095. export class PointParticleEmitter implements IParticleEmitterType {
  18096. /**
  18097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18098. */
  18099. direction1: Vector3;
  18100. /**
  18101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18102. */
  18103. direction2: Vector3;
  18104. /**
  18105. * Creates a new instance PointParticleEmitter
  18106. */
  18107. constructor();
  18108. /**
  18109. * Called by the particle System when the direction is computed for the created particle.
  18110. * @param worldMatrix is the world matrix of the particle system
  18111. * @param directionToUpdate is the direction vector to update with the result
  18112. * @param particle is the particle we are computed the direction for
  18113. */
  18114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18115. /**
  18116. * Called by the particle System when the position is computed for the created particle.
  18117. * @param worldMatrix is the world matrix of the particle system
  18118. * @param positionToUpdate is the position vector to update with the result
  18119. * @param particle is the particle we are computed the position for
  18120. */
  18121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18122. /**
  18123. * Clones the current emitter and returns a copy of it
  18124. * @returns the new emitter
  18125. */
  18126. clone(): PointParticleEmitter;
  18127. /**
  18128. * Called by the GPUParticleSystem to setup the update shader
  18129. * @param effect defines the update shader
  18130. */
  18131. applyToShader(effect: Effect): void;
  18132. /**
  18133. * Returns a string to use to update the GPU particles update shader
  18134. * @returns a string containng the defines string
  18135. */
  18136. getEffectDefines(): string;
  18137. /**
  18138. * Returns the string "PointParticleEmitter"
  18139. * @returns a string containing the class name
  18140. */
  18141. getClassName(): string;
  18142. /**
  18143. * Serializes the particle system to a JSON object.
  18144. * @returns the JSON object
  18145. */
  18146. serialize(): any;
  18147. /**
  18148. * Parse properties from a JSON object
  18149. * @param serializationObject defines the JSON object
  18150. */
  18151. parse(serializationObject: any): void;
  18152. }
  18153. }
  18154. declare module BABYLON {
  18155. /**
  18156. * Particle emitter emitting particles from the inside of a sphere.
  18157. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18158. */
  18159. export class SphereParticleEmitter implements IParticleEmitterType {
  18160. /**
  18161. * The radius of the emission sphere.
  18162. */
  18163. radius: number;
  18164. /**
  18165. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18166. */
  18167. radiusRange: number;
  18168. /**
  18169. * How much to randomize the particle direction [0-1].
  18170. */
  18171. directionRandomizer: number;
  18172. /**
  18173. * Creates a new instance SphereParticleEmitter
  18174. * @param radius the radius of the emission sphere (1 by default)
  18175. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18176. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18177. */
  18178. constructor(
  18179. /**
  18180. * The radius of the emission sphere.
  18181. */
  18182. radius?: number,
  18183. /**
  18184. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18185. */
  18186. radiusRange?: number,
  18187. /**
  18188. * How much to randomize the particle direction [0-1].
  18189. */
  18190. directionRandomizer?: number);
  18191. /**
  18192. * Called by the particle System when the direction is computed for the created particle.
  18193. * @param worldMatrix is the world matrix of the particle system
  18194. * @param directionToUpdate is the direction vector to update with the result
  18195. * @param particle is the particle we are computed the direction for
  18196. */
  18197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18198. /**
  18199. * Called by the particle System when the position is computed for the created particle.
  18200. * @param worldMatrix is the world matrix of the particle system
  18201. * @param positionToUpdate is the position vector to update with the result
  18202. * @param particle is the particle we are computed the position for
  18203. */
  18204. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18205. /**
  18206. * Clones the current emitter and returns a copy of it
  18207. * @returns the new emitter
  18208. */
  18209. clone(): SphereParticleEmitter;
  18210. /**
  18211. * Called by the GPUParticleSystem to setup the update shader
  18212. * @param effect defines the update shader
  18213. */
  18214. applyToShader(effect: Effect): void;
  18215. /**
  18216. * Returns a string to use to update the GPU particles update shader
  18217. * @returns a string containng the defines string
  18218. */
  18219. getEffectDefines(): string;
  18220. /**
  18221. * Returns the string "SphereParticleEmitter"
  18222. * @returns a string containing the class name
  18223. */
  18224. getClassName(): string;
  18225. /**
  18226. * Serializes the particle system to a JSON object.
  18227. * @returns the JSON object
  18228. */
  18229. serialize(): any;
  18230. /**
  18231. * Parse properties from a JSON object
  18232. * @param serializationObject defines the JSON object
  18233. */
  18234. parse(serializationObject: any): void;
  18235. }
  18236. /**
  18237. * Particle emitter emitting particles from the inside of a sphere.
  18238. * It emits the particles randomly between two vectors.
  18239. */
  18240. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18241. /**
  18242. * The min limit of the emission direction.
  18243. */
  18244. direction1: Vector3;
  18245. /**
  18246. * The max limit of the emission direction.
  18247. */
  18248. direction2: Vector3;
  18249. /**
  18250. * Creates a new instance SphereDirectedParticleEmitter
  18251. * @param radius the radius of the emission sphere (1 by default)
  18252. * @param direction1 the min limit of the emission direction (up vector by default)
  18253. * @param direction2 the max limit of the emission direction (up vector by default)
  18254. */
  18255. constructor(radius?: number,
  18256. /**
  18257. * The min limit of the emission direction.
  18258. */
  18259. direction1?: Vector3,
  18260. /**
  18261. * The max limit of the emission direction.
  18262. */
  18263. direction2?: Vector3);
  18264. /**
  18265. * Called by the particle System when the direction is computed for the created particle.
  18266. * @param worldMatrix is the world matrix of the particle system
  18267. * @param directionToUpdate is the direction vector to update with the result
  18268. * @param particle is the particle we are computed the direction for
  18269. */
  18270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18271. /**
  18272. * Clones the current emitter and returns a copy of it
  18273. * @returns the new emitter
  18274. */
  18275. clone(): SphereDirectedParticleEmitter;
  18276. /**
  18277. * Called by the GPUParticleSystem to setup the update shader
  18278. * @param effect defines the update shader
  18279. */
  18280. applyToShader(effect: Effect): void;
  18281. /**
  18282. * Returns a string to use to update the GPU particles update shader
  18283. * @returns a string containng the defines string
  18284. */
  18285. getEffectDefines(): string;
  18286. /**
  18287. * Returns the string "SphereDirectedParticleEmitter"
  18288. * @returns a string containing the class name
  18289. */
  18290. getClassName(): string;
  18291. /**
  18292. * Serializes the particle system to a JSON object.
  18293. * @returns the JSON object
  18294. */
  18295. serialize(): any;
  18296. /**
  18297. * Parse properties from a JSON object
  18298. * @param serializationObject defines the JSON object
  18299. */
  18300. parse(serializationObject: any): void;
  18301. }
  18302. }
  18303. declare module BABYLON {
  18304. /**
  18305. * Interface representing a particle system in Babylon.js.
  18306. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18307. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18308. */
  18309. export interface IParticleSystem {
  18310. /**
  18311. * List of animations used by the particle system.
  18312. */
  18313. animations: Animation[];
  18314. /**
  18315. * The id of the Particle system.
  18316. */
  18317. id: string;
  18318. /**
  18319. * The name of the Particle system.
  18320. */
  18321. name: string;
  18322. /**
  18323. * The emitter represents the Mesh or position we are attaching the particle system to.
  18324. */
  18325. emitter: Nullable<AbstractMesh | Vector3>;
  18326. /**
  18327. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18328. */
  18329. isBillboardBased: boolean;
  18330. /**
  18331. * The rendering group used by the Particle system to chose when to render.
  18332. */
  18333. renderingGroupId: number;
  18334. /**
  18335. * The layer mask we are rendering the particles through.
  18336. */
  18337. layerMask: number;
  18338. /**
  18339. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18340. */
  18341. updateSpeed: number;
  18342. /**
  18343. * The amount of time the particle system is running (depends of the overall update speed).
  18344. */
  18345. targetStopDuration: number;
  18346. /**
  18347. * The texture used to render each particle. (this can be a spritesheet)
  18348. */
  18349. particleTexture: Nullable<Texture>;
  18350. /**
  18351. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18352. */
  18353. blendMode: number;
  18354. /**
  18355. * Minimum life time of emitting particles.
  18356. */
  18357. minLifeTime: number;
  18358. /**
  18359. * Maximum life time of emitting particles.
  18360. */
  18361. maxLifeTime: number;
  18362. /**
  18363. * Minimum Size of emitting particles.
  18364. */
  18365. minSize: number;
  18366. /**
  18367. * Maximum Size of emitting particles.
  18368. */
  18369. maxSize: number;
  18370. /**
  18371. * Minimum scale of emitting particles on X axis.
  18372. */
  18373. minScaleX: number;
  18374. /**
  18375. * Maximum scale of emitting particles on X axis.
  18376. */
  18377. maxScaleX: number;
  18378. /**
  18379. * Minimum scale of emitting particles on Y axis.
  18380. */
  18381. minScaleY: number;
  18382. /**
  18383. * Maximum scale of emitting particles on Y axis.
  18384. */
  18385. maxScaleY: number;
  18386. /**
  18387. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18388. */
  18389. color1: Color4;
  18390. /**
  18391. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18392. */
  18393. color2: Color4;
  18394. /**
  18395. * Color the particle will have at the end of its lifetime.
  18396. */
  18397. colorDead: Color4;
  18398. /**
  18399. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18400. */
  18401. emitRate: number;
  18402. /**
  18403. * You can use gravity if you want to give an orientation to your particles.
  18404. */
  18405. gravity: Vector3;
  18406. /**
  18407. * Minimum power of emitting particles.
  18408. */
  18409. minEmitPower: number;
  18410. /**
  18411. * Maximum power of emitting particles.
  18412. */
  18413. maxEmitPower: number;
  18414. /**
  18415. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18416. */
  18417. minAngularSpeed: number;
  18418. /**
  18419. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18420. */
  18421. maxAngularSpeed: number;
  18422. /**
  18423. * Gets or sets the minimal initial rotation in radians.
  18424. */
  18425. minInitialRotation: number;
  18426. /**
  18427. * Gets or sets the maximal initial rotation in radians.
  18428. */
  18429. maxInitialRotation: number;
  18430. /**
  18431. * The particle emitter type defines the emitter used by the particle system.
  18432. * It can be for example box, sphere, or cone...
  18433. */
  18434. particleEmitterType: Nullable<IParticleEmitterType>;
  18435. /**
  18436. * Defines the delay in milliseconds before starting the system (0 by default)
  18437. */
  18438. startDelay: number;
  18439. /**
  18440. * 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
  18441. */
  18442. preWarmCycles: number;
  18443. /**
  18444. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18445. */
  18446. preWarmStepOffset: number;
  18447. /**
  18448. * 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)
  18449. */
  18450. spriteCellChangeSpeed: number;
  18451. /**
  18452. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18453. */
  18454. startSpriteCellID: number;
  18455. /**
  18456. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18457. */
  18458. endSpriteCellID: number;
  18459. /**
  18460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18461. */
  18462. spriteCellWidth: number;
  18463. /**
  18464. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18465. */
  18466. spriteCellHeight: number;
  18467. /**
  18468. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18469. */
  18470. spriteRandomStartCell: boolean;
  18471. /**
  18472. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18473. */
  18474. isAnimationSheetEnabled: boolean;
  18475. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18476. translationPivot: Vector2;
  18477. /**
  18478. * Gets or sets a texture used to add random noise to particle positions
  18479. */
  18480. noiseTexture: Nullable<BaseTexture>;
  18481. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18482. noiseStrength: Vector3;
  18483. /**
  18484. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18485. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18486. */
  18487. billboardMode: number;
  18488. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18489. limitVelocityDamping: number;
  18490. /**
  18491. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18492. */
  18493. beginAnimationOnStart: boolean;
  18494. /**
  18495. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18496. */
  18497. beginAnimationFrom: number;
  18498. /**
  18499. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18500. */
  18501. beginAnimationTo: number;
  18502. /**
  18503. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18504. */
  18505. beginAnimationLoop: boolean;
  18506. /**
  18507. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18508. */
  18509. disposeOnStop: boolean;
  18510. /**
  18511. * Gets the maximum number of particles active at the same time.
  18512. * @returns The max number of active particles.
  18513. */
  18514. getCapacity(): number;
  18515. /**
  18516. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18517. * @returns True if it has been started, otherwise false.
  18518. */
  18519. isStarted(): boolean;
  18520. /**
  18521. * Animates the particle system for this frame.
  18522. */
  18523. animate(): void;
  18524. /**
  18525. * Renders the particle system in its current state.
  18526. * @returns the current number of particles
  18527. */
  18528. render(): number;
  18529. /**
  18530. * Dispose the particle system and frees its associated resources.
  18531. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18532. */
  18533. dispose(disposeTexture?: boolean): void;
  18534. /**
  18535. * Clones the particle system.
  18536. * @param name The name of the cloned object
  18537. * @param newEmitter The new emitter to use
  18538. * @returns the cloned particle system
  18539. */
  18540. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18541. /**
  18542. * Serializes the particle system to a JSON object.
  18543. * @returns the JSON object
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Rebuild the particle system
  18548. */
  18549. rebuild(): void;
  18550. /**
  18551. * Starts the particle system and begins to emit
  18552. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18553. */
  18554. start(delay?: number): void;
  18555. /**
  18556. * Stops the particle system.
  18557. */
  18558. stop(): void;
  18559. /**
  18560. * Remove all active particles
  18561. */
  18562. reset(): void;
  18563. /**
  18564. * Is this system ready to be used/rendered
  18565. * @return true if the system is ready
  18566. */
  18567. isReady(): boolean;
  18568. /**
  18569. * Adds a new color gradient
  18570. * @param gradient defines the gradient to use (between 0 and 1)
  18571. * @param color1 defines the color to affect to the specified gradient
  18572. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18573. * @returns the current particle system
  18574. */
  18575. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18576. /**
  18577. * Remove a specific color gradient
  18578. * @param gradient defines the gradient to remove
  18579. * @returns the current particle system
  18580. */
  18581. removeColorGradient(gradient: number): IParticleSystem;
  18582. /**
  18583. * Adds a new size gradient
  18584. * @param gradient defines the gradient to use (between 0 and 1)
  18585. * @param factor defines the size factor to affect to the specified gradient
  18586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18587. * @returns the current particle system
  18588. */
  18589. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18590. /**
  18591. * Remove a specific size gradient
  18592. * @param gradient defines the gradient to remove
  18593. * @returns the current particle system
  18594. */
  18595. removeSizeGradient(gradient: number): IParticleSystem;
  18596. /**
  18597. * Gets the current list of color gradients.
  18598. * You must use addColorGradient and removeColorGradient to udpate this list
  18599. * @returns the list of color gradients
  18600. */
  18601. getColorGradients(): Nullable<Array<ColorGradient>>;
  18602. /**
  18603. * Gets the current list of size gradients.
  18604. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18605. * @returns the list of size gradients
  18606. */
  18607. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18608. /**
  18609. * Gets the current list of angular speed gradients.
  18610. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18611. * @returns the list of angular speed gradients
  18612. */
  18613. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18614. /**
  18615. * Adds a new angular speed gradient
  18616. * @param gradient defines the gradient to use (between 0 and 1)
  18617. * @param factor defines the angular speed to affect to the specified gradient
  18618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18619. * @returns the current particle system
  18620. */
  18621. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18622. /**
  18623. * Remove a specific angular speed gradient
  18624. * @param gradient defines the gradient to remove
  18625. * @returns the current particle system
  18626. */
  18627. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18628. /**
  18629. * Gets the current list of velocity gradients.
  18630. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18631. * @returns the list of velocity gradients
  18632. */
  18633. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18634. /**
  18635. * Adds a new velocity gradient
  18636. * @param gradient defines the gradient to use (between 0 and 1)
  18637. * @param factor defines the velocity to affect to the specified gradient
  18638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18639. * @returns the current particle system
  18640. */
  18641. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18642. /**
  18643. * Remove a specific velocity gradient
  18644. * @param gradient defines the gradient to remove
  18645. * @returns the current particle system
  18646. */
  18647. removeVelocityGradient(gradient: number): IParticleSystem;
  18648. /**
  18649. * Gets the current list of limit velocity gradients.
  18650. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18651. * @returns the list of limit velocity gradients
  18652. */
  18653. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18654. /**
  18655. * Adds a new limit velocity gradient
  18656. * @param gradient defines the gradient to use (between 0 and 1)
  18657. * @param factor defines the limit velocity to affect to the specified gradient
  18658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18659. * @returns the current particle system
  18660. */
  18661. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18662. /**
  18663. * Remove a specific limit velocity gradient
  18664. * @param gradient defines the gradient to remove
  18665. * @returns the current particle system
  18666. */
  18667. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18668. /**
  18669. * Adds a new drag gradient
  18670. * @param gradient defines the gradient to use (between 0 and 1)
  18671. * @param factor defines the drag to affect to the specified gradient
  18672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18673. * @returns the current particle system
  18674. */
  18675. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18676. /**
  18677. * Remove a specific drag gradient
  18678. * @param gradient defines the gradient to remove
  18679. * @returns the current particle system
  18680. */
  18681. removeDragGradient(gradient: number): IParticleSystem;
  18682. /**
  18683. * Gets the current list of drag gradients.
  18684. * You must use addDragGradient and removeDragGradient to udpate this list
  18685. * @returns the list of drag gradients
  18686. */
  18687. getDragGradients(): Nullable<Array<FactorGradient>>;
  18688. /**
  18689. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18690. * @param gradient defines the gradient to use (between 0 and 1)
  18691. * @param factor defines the emit rate to affect to the specified gradient
  18692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18693. * @returns the current particle system
  18694. */
  18695. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18696. /**
  18697. * Remove a specific emit rate gradient
  18698. * @param gradient defines the gradient to remove
  18699. * @returns the current particle system
  18700. */
  18701. removeEmitRateGradient(gradient: number): IParticleSystem;
  18702. /**
  18703. * Gets the current list of emit rate gradients.
  18704. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18705. * @returns the list of emit rate gradients
  18706. */
  18707. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18708. /**
  18709. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18710. * @param gradient defines the gradient to use (between 0 and 1)
  18711. * @param factor defines the start size to affect to the specified gradient
  18712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18713. * @returns the current particle system
  18714. */
  18715. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18716. /**
  18717. * Remove a specific start size gradient
  18718. * @param gradient defines the gradient to remove
  18719. * @returns the current particle system
  18720. */
  18721. removeStartSizeGradient(gradient: number): IParticleSystem;
  18722. /**
  18723. * Gets the current list of start size gradients.
  18724. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18725. * @returns the list of start size gradients
  18726. */
  18727. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18728. /**
  18729. * Adds a new life time gradient
  18730. * @param gradient defines the gradient to use (between 0 and 1)
  18731. * @param factor defines the life time factor to affect to the specified gradient
  18732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18733. * @returns the current particle system
  18734. */
  18735. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18736. /**
  18737. * Remove a specific life time gradient
  18738. * @param gradient defines the gradient to remove
  18739. * @returns the current particle system
  18740. */
  18741. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18742. /**
  18743. * Gets the current list of life time gradients.
  18744. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18745. * @returns the list of life time gradients
  18746. */
  18747. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18748. /**
  18749. * Gets the current list of color gradients.
  18750. * You must use addColorGradient and removeColorGradient to udpate this list
  18751. * @returns the list of color gradients
  18752. */
  18753. getColorGradients(): Nullable<Array<ColorGradient>>;
  18754. /**
  18755. * Adds a new ramp gradient used to remap particle colors
  18756. * @param gradient defines the gradient to use (between 0 and 1)
  18757. * @param color defines the color to affect to the specified gradient
  18758. * @returns the current particle system
  18759. */
  18760. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18761. /**
  18762. * Gets the current list of ramp gradients.
  18763. * You must use addRampGradient and removeRampGradient to udpate this list
  18764. * @returns the list of ramp gradients
  18765. */
  18766. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18767. /** Gets or sets a boolean indicating that ramp gradients must be used
  18768. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18769. */
  18770. useRampGradients: boolean;
  18771. /**
  18772. * Adds a new color remap gradient
  18773. * @param gradient defines the gradient to use (between 0 and 1)
  18774. * @param min defines the color remap minimal range
  18775. * @param max defines the color remap maximal range
  18776. * @returns the current particle system
  18777. */
  18778. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18779. /**
  18780. * Gets the current list of color remap gradients.
  18781. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18782. * @returns the list of color remap gradients
  18783. */
  18784. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18785. /**
  18786. * Adds a new alpha remap gradient
  18787. * @param gradient defines the gradient to use (between 0 and 1)
  18788. * @param min defines the alpha remap minimal range
  18789. * @param max defines the alpha remap maximal range
  18790. * @returns the current particle system
  18791. */
  18792. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18793. /**
  18794. * Gets the current list of alpha remap gradients.
  18795. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18796. * @returns the list of alpha remap gradients
  18797. */
  18798. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18799. /**
  18800. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18803. * @returns the emitter
  18804. */
  18805. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18806. /**
  18807. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18808. * @param radius The radius of the hemisphere to emit from
  18809. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18810. * @returns the emitter
  18811. */
  18812. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18813. /**
  18814. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18815. * @param radius The radius of the sphere to emit from
  18816. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18817. * @returns the emitter
  18818. */
  18819. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18820. /**
  18821. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18822. * @param radius The radius of the sphere to emit from
  18823. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18824. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18825. * @returns the emitter
  18826. */
  18827. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18828. /**
  18829. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18830. * @param radius The radius of the emission cylinder
  18831. * @param height The height of the emission cylinder
  18832. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18833. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18834. * @returns the emitter
  18835. */
  18836. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18837. /**
  18838. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18839. * @param radius The radius of the cylinder to emit from
  18840. * @param height The height of the emission cylinder
  18841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18842. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18843. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18844. * @returns the emitter
  18845. */
  18846. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18847. /**
  18848. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18849. * @param radius The radius of the cone to emit from
  18850. * @param angle The base angle of the cone
  18851. * @returns the emitter
  18852. */
  18853. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18854. /**
  18855. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18858. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18859. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18860. * @returns the emitter
  18861. */
  18862. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18863. /**
  18864. * Get hosting scene
  18865. * @returns the scene
  18866. */
  18867. getScene(): Scene;
  18868. }
  18869. }
  18870. declare module BABYLON {
  18871. /**
  18872. * Creates an instance based on a source mesh.
  18873. */
  18874. export class InstancedMesh extends AbstractMesh {
  18875. private _sourceMesh;
  18876. private _currentLOD;
  18877. /** @hidden */
  18878. _indexInSourceMeshInstanceArray: number;
  18879. constructor(name: string, source: Mesh);
  18880. /**
  18881. * Returns the string "InstancedMesh".
  18882. */
  18883. getClassName(): string;
  18884. /** Gets the list of lights affecting that mesh */
  18885. readonly lightSources: Light[];
  18886. _resyncLightSources(): void;
  18887. _resyncLighSource(light: Light): void;
  18888. _removeLightSource(light: Light, dispose: boolean): void;
  18889. /**
  18890. * If the source mesh receives shadows
  18891. */
  18892. readonly receiveShadows: boolean;
  18893. /**
  18894. * The material of the source mesh
  18895. */
  18896. readonly material: Nullable<Material>;
  18897. /**
  18898. * Visibility of the source mesh
  18899. */
  18900. readonly visibility: number;
  18901. /**
  18902. * Skeleton of the source mesh
  18903. */
  18904. readonly skeleton: Nullable<Skeleton>;
  18905. /**
  18906. * Rendering ground id of the source mesh
  18907. */
  18908. renderingGroupId: number;
  18909. /**
  18910. * Returns the total number of vertices (integer).
  18911. */
  18912. getTotalVertices(): number;
  18913. /**
  18914. * Returns a positive integer : the total number of indices in this mesh geometry.
  18915. * @returns the numner of indices or zero if the mesh has no geometry.
  18916. */
  18917. getTotalIndices(): number;
  18918. /**
  18919. * The source mesh of the instance
  18920. */
  18921. readonly sourceMesh: Mesh;
  18922. /**
  18923. * Is this node ready to be used/rendered
  18924. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18925. * @return {boolean} is it ready
  18926. */
  18927. isReady(completeCheck?: boolean): boolean;
  18928. /**
  18929. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18930. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18931. * @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.
  18932. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18933. */
  18934. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18935. /**
  18936. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18937. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18938. * The `data` are either a numeric array either a Float32Array.
  18939. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18940. * 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).
  18941. * Note that a new underlying VertexBuffer object is created each call.
  18942. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18943. *
  18944. * Possible `kind` values :
  18945. * - VertexBuffer.PositionKind
  18946. * - VertexBuffer.UVKind
  18947. * - VertexBuffer.UV2Kind
  18948. * - VertexBuffer.UV3Kind
  18949. * - VertexBuffer.UV4Kind
  18950. * - VertexBuffer.UV5Kind
  18951. * - VertexBuffer.UV6Kind
  18952. * - VertexBuffer.ColorKind
  18953. * - VertexBuffer.MatricesIndicesKind
  18954. * - VertexBuffer.MatricesIndicesExtraKind
  18955. * - VertexBuffer.MatricesWeightsKind
  18956. * - VertexBuffer.MatricesWeightsExtraKind
  18957. *
  18958. * Returns the Mesh.
  18959. */
  18960. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18961. /**
  18962. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18963. * If the mesh has no geometry, it is simply returned as it is.
  18964. * The `data` are either a numeric array either a Float32Array.
  18965. * No new underlying VertexBuffer object is created.
  18966. * 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.
  18967. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18968. *
  18969. * Possible `kind` values :
  18970. * - VertexBuffer.PositionKind
  18971. * - VertexBuffer.UVKind
  18972. * - VertexBuffer.UV2Kind
  18973. * - VertexBuffer.UV3Kind
  18974. * - VertexBuffer.UV4Kind
  18975. * - VertexBuffer.UV5Kind
  18976. * - VertexBuffer.UV6Kind
  18977. * - VertexBuffer.ColorKind
  18978. * - VertexBuffer.MatricesIndicesKind
  18979. * - VertexBuffer.MatricesIndicesExtraKind
  18980. * - VertexBuffer.MatricesWeightsKind
  18981. * - VertexBuffer.MatricesWeightsExtraKind
  18982. *
  18983. * Returns the Mesh.
  18984. */
  18985. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18986. /**
  18987. * Sets the mesh indices.
  18988. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18989. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18990. * This method creates a new index buffer each call.
  18991. * Returns the Mesh.
  18992. */
  18993. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18994. /**
  18995. * Boolean : True if the mesh owns the requested kind of data.
  18996. */
  18997. isVerticesDataPresent(kind: string): boolean;
  18998. /**
  18999. * Returns an array of indices (IndicesArray).
  19000. */
  19001. getIndices(): Nullable<IndicesArray>;
  19002. readonly _positions: Nullable<Vector3[]>;
  19003. /**
  19004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19005. * This means the mesh underlying bounding box and sphere are recomputed.
  19006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19007. * @returns the current mesh
  19008. */
  19009. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19010. /** @hidden */
  19011. _preActivate(): InstancedMesh;
  19012. /** @hidden */
  19013. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19014. /** @hidden */
  19015. _postActivate(): void;
  19016. getWorldMatrix(): Matrix;
  19017. readonly isAnInstance: boolean;
  19018. /**
  19019. * Returns the current associated LOD AbstractMesh.
  19020. */
  19021. getLOD(camera: Camera): AbstractMesh;
  19022. /** @hidden */
  19023. _syncSubMeshes(): InstancedMesh;
  19024. /** @hidden */
  19025. _generatePointsArray(): boolean;
  19026. /**
  19027. * Creates a new InstancedMesh from the current mesh.
  19028. * - name (string) : the cloned mesh name
  19029. * - newParent (optional Node) : the optional Node to parent the clone to.
  19030. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19031. *
  19032. * Returns the clone.
  19033. */
  19034. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19035. /**
  19036. * Disposes the InstancedMesh.
  19037. * Returns nothing.
  19038. */
  19039. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19040. }
  19041. interface Mesh {
  19042. /**
  19043. * Register a custom buffer that will be instanced
  19044. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19045. * @param kind defines the buffer kind
  19046. * @param stride defines the stride in floats
  19047. */
  19048. registerInstancedBuffer(kind: string, stride: number): void;
  19049. /** @hidden */
  19050. _userInstancedBuffersStorage: {
  19051. data: {
  19052. [key: string]: Float32Array;
  19053. };
  19054. sizes: {
  19055. [key: string]: number;
  19056. };
  19057. vertexBuffers: {
  19058. [key: string]: Nullable<VertexBuffer>;
  19059. };
  19060. strides: {
  19061. [key: string]: number;
  19062. };
  19063. };
  19064. }
  19065. interface AbstractMesh {
  19066. /**
  19067. * Object used to store instanced buffers defined by user
  19068. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19069. */
  19070. instancedBuffers: {
  19071. [key: string]: any;
  19072. };
  19073. }
  19074. }
  19075. declare module BABYLON {
  19076. /**
  19077. * Defines the options associated with the creation of a shader material.
  19078. */
  19079. export interface IShaderMaterialOptions {
  19080. /**
  19081. * Does the material work in alpha blend mode
  19082. */
  19083. needAlphaBlending: boolean;
  19084. /**
  19085. * Does the material work in alpha test mode
  19086. */
  19087. needAlphaTesting: boolean;
  19088. /**
  19089. * The list of attribute names used in the shader
  19090. */
  19091. attributes: string[];
  19092. /**
  19093. * The list of unifrom names used in the shader
  19094. */
  19095. uniforms: string[];
  19096. /**
  19097. * The list of UBO names used in the shader
  19098. */
  19099. uniformBuffers: string[];
  19100. /**
  19101. * The list of sampler names used in the shader
  19102. */
  19103. samplers: string[];
  19104. /**
  19105. * The list of defines used in the shader
  19106. */
  19107. defines: string[];
  19108. }
  19109. /**
  19110. * 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.
  19111. *
  19112. * This returned material effects how the mesh will look based on the code in the shaders.
  19113. *
  19114. * @see http://doc.babylonjs.com/how_to/shader_material
  19115. */
  19116. export class ShaderMaterial extends Material {
  19117. private _shaderPath;
  19118. private _options;
  19119. private _textures;
  19120. private _textureArrays;
  19121. private _floats;
  19122. private _ints;
  19123. private _floatsArrays;
  19124. private _colors3;
  19125. private _colors3Arrays;
  19126. private _colors4;
  19127. private _colors4Arrays;
  19128. private _vectors2;
  19129. private _vectors3;
  19130. private _vectors4;
  19131. private _matrices;
  19132. private _matrices3x3;
  19133. private _matrices2x2;
  19134. private _vectors2Arrays;
  19135. private _vectors3Arrays;
  19136. private _vectors4Arrays;
  19137. private _cachedWorldViewMatrix;
  19138. private _cachedWorldViewProjectionMatrix;
  19139. private _renderId;
  19140. /**
  19141. * Instantiate a new shader material.
  19142. * 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.
  19143. * This returned material effects how the mesh will look based on the code in the shaders.
  19144. * @see http://doc.babylonjs.com/how_to/shader_material
  19145. * @param name Define the name of the material in the scene
  19146. * @param scene Define the scene the material belongs to
  19147. * @param shaderPath Defines the route to the shader code in one of three ways:
  19148. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19149. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19150. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19151. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19152. * @param options Define the options used to create the shader
  19153. */
  19154. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19155. /**
  19156. * Gets the options used to compile the shader.
  19157. * They can be modified to trigger a new compilation
  19158. */
  19159. readonly options: IShaderMaterialOptions;
  19160. /**
  19161. * Gets the current class name of the material e.g. "ShaderMaterial"
  19162. * Mainly use in serialization.
  19163. * @returns the class name
  19164. */
  19165. getClassName(): string;
  19166. /**
  19167. * Specifies if the material will require alpha blending
  19168. * @returns a boolean specifying if alpha blending is needed
  19169. */
  19170. needAlphaBlending(): boolean;
  19171. /**
  19172. * Specifies if this material should be rendered in alpha test mode
  19173. * @returns a boolean specifying if an alpha test is needed.
  19174. */
  19175. needAlphaTesting(): boolean;
  19176. private _checkUniform;
  19177. /**
  19178. * Set a texture in the shader.
  19179. * @param name Define the name of the uniform samplers as defined in the shader
  19180. * @param texture Define the texture to bind to this sampler
  19181. * @return the material itself allowing "fluent" like uniform updates
  19182. */
  19183. setTexture(name: string, texture: Texture): ShaderMaterial;
  19184. /**
  19185. * Set a texture array in the shader.
  19186. * @param name Define the name of the uniform sampler array as defined in the shader
  19187. * @param textures Define the list of textures to bind to this sampler
  19188. * @return the material itself allowing "fluent" like uniform updates
  19189. */
  19190. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19191. /**
  19192. * Set a float in the shader.
  19193. * @param name Define the name of the uniform as defined in the shader
  19194. * @param value Define the value to give to the uniform
  19195. * @return the material itself allowing "fluent" like uniform updates
  19196. */
  19197. setFloat(name: string, value: number): ShaderMaterial;
  19198. /**
  19199. * Set a int in the shader.
  19200. * @param name Define the name of the uniform as defined in the shader
  19201. * @param value Define the value to give to the uniform
  19202. * @return the material itself allowing "fluent" like uniform updates
  19203. */
  19204. setInt(name: string, value: number): ShaderMaterial;
  19205. /**
  19206. * Set an array of floats in the shader.
  19207. * @param name Define the name of the uniform as defined in the shader
  19208. * @param value Define the value to give to the uniform
  19209. * @return the material itself allowing "fluent" like uniform updates
  19210. */
  19211. setFloats(name: string, value: number[]): ShaderMaterial;
  19212. /**
  19213. * Set a vec3 in the shader from a Color3.
  19214. * @param name Define the name of the uniform as defined in the shader
  19215. * @param value Define the value to give to the uniform
  19216. * @return the material itself allowing "fluent" like uniform updates
  19217. */
  19218. setColor3(name: string, value: Color3): ShaderMaterial;
  19219. /**
  19220. * Set a vec3 array in the shader from a Color3 array.
  19221. * @param name Define the name of the uniform as defined in the shader
  19222. * @param value Define the value to give to the uniform
  19223. * @return the material itself allowing "fluent" like uniform updates
  19224. */
  19225. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19226. /**
  19227. * Set a vec4 in the shader from a Color4.
  19228. * @param name Define the name of the uniform as defined in the shader
  19229. * @param value Define the value to give to the uniform
  19230. * @return the material itself allowing "fluent" like uniform updates
  19231. */
  19232. setColor4(name: string, value: Color4): ShaderMaterial;
  19233. /**
  19234. * Set a vec4 array in the shader from a Color4 array.
  19235. * @param name Define the name of the uniform as defined in the shader
  19236. * @param value Define the value to give to the uniform
  19237. * @return the material itself allowing "fluent" like uniform updates
  19238. */
  19239. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19240. /**
  19241. * Set a vec2 in the shader from a Vector2.
  19242. * @param name Define the name of the uniform as defined in the shader
  19243. * @param value Define the value to give to the uniform
  19244. * @return the material itself allowing "fluent" like uniform updates
  19245. */
  19246. setVector2(name: string, value: Vector2): ShaderMaterial;
  19247. /**
  19248. * Set a vec3 in the shader from a Vector3.
  19249. * @param name Define the name of the uniform as defined in the shader
  19250. * @param value Define the value to give to the uniform
  19251. * @return the material itself allowing "fluent" like uniform updates
  19252. */
  19253. setVector3(name: string, value: Vector3): ShaderMaterial;
  19254. /**
  19255. * Set a vec4 in the shader from a Vector4.
  19256. * @param name Define the name of the uniform as defined in the shader
  19257. * @param value Define the value to give to the uniform
  19258. * @return the material itself allowing "fluent" like uniform updates
  19259. */
  19260. setVector4(name: string, value: Vector4): ShaderMaterial;
  19261. /**
  19262. * Set a mat4 in the shader from a Matrix.
  19263. * @param name Define the name of the uniform as defined in the shader
  19264. * @param value Define the value to give to the uniform
  19265. * @return the material itself allowing "fluent" like uniform updates
  19266. */
  19267. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19268. /**
  19269. * Set a mat3 in the shader from a Float32Array.
  19270. * @param name Define the name of the uniform as defined in the shader
  19271. * @param value Define the value to give to the uniform
  19272. * @return the material itself allowing "fluent" like uniform updates
  19273. */
  19274. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19275. /**
  19276. * Set a mat2 in the shader from a Float32Array.
  19277. * @param name Define the name of the uniform as defined in the shader
  19278. * @param value Define the value to give to the uniform
  19279. * @return the material itself allowing "fluent" like uniform updates
  19280. */
  19281. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19282. /**
  19283. * Set a vec2 array in the shader from a number array.
  19284. * @param name Define the name of the uniform as defined in the shader
  19285. * @param value Define the value to give to the uniform
  19286. * @return the material itself allowing "fluent" like uniform updates
  19287. */
  19288. setArray2(name: string, value: number[]): ShaderMaterial;
  19289. /**
  19290. * Set a vec3 array in the shader from a number array.
  19291. * @param name Define the name of the uniform as defined in the shader
  19292. * @param value Define the value to give to the uniform
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setArray3(name: string, value: number[]): ShaderMaterial;
  19296. /**
  19297. * Set a vec4 array in the shader from a number array.
  19298. * @param name Define the name of the uniform as defined in the shader
  19299. * @param value Define the value to give to the uniform
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setArray4(name: string, value: number[]): ShaderMaterial;
  19303. private _checkCache;
  19304. /**
  19305. * Specifies that the submesh is ready to be used
  19306. * @param mesh defines the mesh to check
  19307. * @param subMesh defines which submesh to check
  19308. * @param useInstances specifies that instances should be used
  19309. * @returns a boolean indicating that the submesh is ready or not
  19310. */
  19311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19312. /**
  19313. * Checks if the material is ready to render the requested mesh
  19314. * @param mesh Define the mesh to render
  19315. * @param useInstances Define whether or not the material is used with instances
  19316. * @returns true if ready, otherwise false
  19317. */
  19318. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19319. /**
  19320. * Binds the world matrix to the material
  19321. * @param world defines the world transformation matrix
  19322. */
  19323. bindOnlyWorldMatrix(world: Matrix): void;
  19324. /**
  19325. * Binds the material to the mesh
  19326. * @param world defines the world transformation matrix
  19327. * @param mesh defines the mesh to bind the material to
  19328. */
  19329. bind(world: Matrix, mesh?: Mesh): void;
  19330. /**
  19331. * Gets the active textures from the material
  19332. * @returns an array of textures
  19333. */
  19334. getActiveTextures(): BaseTexture[];
  19335. /**
  19336. * Specifies if the material uses a texture
  19337. * @param texture defines the texture to check against the material
  19338. * @returns a boolean specifying if the material uses the texture
  19339. */
  19340. hasTexture(texture: BaseTexture): boolean;
  19341. /**
  19342. * Makes a duplicate of the material, and gives it a new name
  19343. * @param name defines the new name for the duplicated material
  19344. * @returns the cloned material
  19345. */
  19346. clone(name: string): ShaderMaterial;
  19347. /**
  19348. * Disposes the material
  19349. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19350. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19351. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19352. */
  19353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19354. /**
  19355. * Serializes this material in a JSON representation
  19356. * @returns the serialized material object
  19357. */
  19358. serialize(): any;
  19359. /**
  19360. * Creates a shader material from parsed shader material data
  19361. * @param source defines the JSON represnetation of the material
  19362. * @param scene defines the hosting scene
  19363. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19364. * @returns a new material
  19365. */
  19366. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19367. }
  19368. }
  19369. declare module BABYLON {
  19370. /** @hidden */
  19371. export var colorPixelShader: {
  19372. name: string;
  19373. shader: string;
  19374. };
  19375. }
  19376. declare module BABYLON {
  19377. /** @hidden */
  19378. export var colorVertexShader: {
  19379. name: string;
  19380. shader: string;
  19381. };
  19382. }
  19383. declare module BABYLON {
  19384. /**
  19385. * Line mesh
  19386. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19387. */
  19388. export class LinesMesh extends Mesh {
  19389. /**
  19390. * If vertex color should be applied to the mesh
  19391. */
  19392. readonly useVertexColor?: boolean | undefined;
  19393. /**
  19394. * If vertex alpha should be applied to the mesh
  19395. */
  19396. readonly useVertexAlpha?: boolean | undefined;
  19397. /**
  19398. * Color of the line (Default: White)
  19399. */
  19400. color: Color3;
  19401. /**
  19402. * Alpha of the line (Default: 1)
  19403. */
  19404. alpha: number;
  19405. /**
  19406. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19407. * This margin is expressed in world space coordinates, so its value may vary.
  19408. * Default value is 0.1
  19409. */
  19410. intersectionThreshold: number;
  19411. private _colorShader;
  19412. private color4;
  19413. /**
  19414. * Creates a new LinesMesh
  19415. * @param name defines the name
  19416. * @param scene defines the hosting scene
  19417. * @param parent defines the parent mesh if any
  19418. * @param source defines the optional source LinesMesh used to clone data from
  19419. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19420. * When false, achieved by calling a clone(), also passing False.
  19421. * This will make creation of children, recursive.
  19422. * @param useVertexColor defines if this LinesMesh supports vertex color
  19423. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19424. */
  19425. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19426. /**
  19427. * If vertex color should be applied to the mesh
  19428. */
  19429. useVertexColor?: boolean | undefined,
  19430. /**
  19431. * If vertex alpha should be applied to the mesh
  19432. */
  19433. useVertexAlpha?: boolean | undefined);
  19434. private _addClipPlaneDefine;
  19435. private _removeClipPlaneDefine;
  19436. isReady(): boolean;
  19437. /**
  19438. * Returns the string "LineMesh"
  19439. */
  19440. getClassName(): string;
  19441. /**
  19442. * @hidden
  19443. */
  19444. /**
  19445. * @hidden
  19446. */
  19447. material: Material;
  19448. /**
  19449. * @hidden
  19450. */
  19451. readonly checkCollisions: boolean;
  19452. /** @hidden */
  19453. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19454. /** @hidden */
  19455. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19456. /**
  19457. * Disposes of the line mesh
  19458. * @param doNotRecurse If children should be disposed
  19459. */
  19460. dispose(doNotRecurse?: boolean): void;
  19461. /**
  19462. * Returns a new LineMesh object cloned from the current one.
  19463. */
  19464. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19465. /**
  19466. * Creates a new InstancedLinesMesh object from the mesh model.
  19467. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19468. * @param name defines the name of the new instance
  19469. * @returns a new InstancedLinesMesh
  19470. */
  19471. createInstance(name: string): InstancedLinesMesh;
  19472. }
  19473. /**
  19474. * Creates an instance based on a source LinesMesh
  19475. */
  19476. export class InstancedLinesMesh extends InstancedMesh {
  19477. /**
  19478. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19479. * This margin is expressed in world space coordinates, so its value may vary.
  19480. * Initilized with the intersectionThreshold value of the source LinesMesh
  19481. */
  19482. intersectionThreshold: number;
  19483. constructor(name: string, source: LinesMesh);
  19484. /**
  19485. * Returns the string "InstancedLinesMesh".
  19486. */
  19487. getClassName(): string;
  19488. }
  19489. }
  19490. declare module BABYLON {
  19491. /** @hidden */
  19492. export var linePixelShader: {
  19493. name: string;
  19494. shader: string;
  19495. };
  19496. }
  19497. declare module BABYLON {
  19498. /** @hidden */
  19499. export var lineVertexShader: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module BABYLON {
  19505. interface AbstractMesh {
  19506. /**
  19507. * Gets the edgesRenderer associated with the mesh
  19508. */
  19509. edgesRenderer: Nullable<EdgesRenderer>;
  19510. }
  19511. interface LinesMesh {
  19512. /**
  19513. * Enables the edge rendering mode on the mesh.
  19514. * This mode makes the mesh edges visible
  19515. * @param epsilon defines the maximal distance between two angles to detect a face
  19516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19517. * @returns the currentAbstractMesh
  19518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19519. */
  19520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19521. }
  19522. interface InstancedLinesMesh {
  19523. /**
  19524. * Enables the edge rendering mode on the mesh.
  19525. * This mode makes the mesh edges visible
  19526. * @param epsilon defines the maximal distance between two angles to detect a face
  19527. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19528. * @returns the current InstancedLinesMesh
  19529. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19530. */
  19531. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19532. }
  19533. /**
  19534. * Defines the minimum contract an Edges renderer should follow.
  19535. */
  19536. export interface IEdgesRenderer extends IDisposable {
  19537. /**
  19538. * Gets or sets a boolean indicating if the edgesRenderer is active
  19539. */
  19540. isEnabled: boolean;
  19541. /**
  19542. * Renders the edges of the attached mesh,
  19543. */
  19544. render(): void;
  19545. /**
  19546. * Checks wether or not the edges renderer is ready to render.
  19547. * @return true if ready, otherwise false.
  19548. */
  19549. isReady(): boolean;
  19550. }
  19551. /**
  19552. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19553. */
  19554. export class EdgesRenderer implements IEdgesRenderer {
  19555. /**
  19556. * Define the size of the edges with an orthographic camera
  19557. */
  19558. edgesWidthScalerForOrthographic: number;
  19559. /**
  19560. * Define the size of the edges with a perspective camera
  19561. */
  19562. edgesWidthScalerForPerspective: number;
  19563. protected _source: AbstractMesh;
  19564. protected _linesPositions: number[];
  19565. protected _linesNormals: number[];
  19566. protected _linesIndices: number[];
  19567. protected _epsilon: number;
  19568. protected _indicesCount: number;
  19569. protected _lineShader: ShaderMaterial;
  19570. protected _ib: DataBuffer;
  19571. protected _buffers: {
  19572. [key: string]: Nullable<VertexBuffer>;
  19573. };
  19574. protected _checkVerticesInsteadOfIndices: boolean;
  19575. private _meshRebuildObserver;
  19576. private _meshDisposeObserver;
  19577. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19578. isEnabled: boolean;
  19579. /**
  19580. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19581. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19582. * @param source Mesh used to create edges
  19583. * @param epsilon sum of angles in adjacency to check for edge
  19584. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19585. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19586. */
  19587. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19588. protected _prepareRessources(): void;
  19589. /** @hidden */
  19590. _rebuild(): void;
  19591. /**
  19592. * Releases the required resources for the edges renderer
  19593. */
  19594. dispose(): void;
  19595. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19596. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19597. /**
  19598. * Checks if the pair of p0 and p1 is en edge
  19599. * @param faceIndex
  19600. * @param edge
  19601. * @param faceNormals
  19602. * @param p0
  19603. * @param p1
  19604. * @private
  19605. */
  19606. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19607. /**
  19608. * push line into the position, normal and index buffer
  19609. * @protected
  19610. */
  19611. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19612. /**
  19613. * Generates lines edges from adjacencjes
  19614. * @private
  19615. */
  19616. _generateEdgesLines(): void;
  19617. /**
  19618. * Checks wether or not the edges renderer is ready to render.
  19619. * @return true if ready, otherwise false.
  19620. */
  19621. isReady(): boolean;
  19622. /**
  19623. * Renders the edges of the attached mesh,
  19624. */
  19625. render(): void;
  19626. }
  19627. /**
  19628. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19629. */
  19630. export class LineEdgesRenderer extends EdgesRenderer {
  19631. /**
  19632. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19633. * @param source LineMesh used to generate edges
  19634. * @param epsilon not important (specified angle for edge detection)
  19635. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19636. */
  19637. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19638. /**
  19639. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19640. */
  19641. _generateEdgesLines(): void;
  19642. }
  19643. }
  19644. declare module BABYLON {
  19645. /**
  19646. * This represents the object necessary to create a rendering group.
  19647. * This is exclusively used and created by the rendering manager.
  19648. * To modify the behavior, you use the available helpers in your scene or meshes.
  19649. * @hidden
  19650. */
  19651. export class RenderingGroup {
  19652. index: number;
  19653. private static _zeroVector;
  19654. private _scene;
  19655. private _opaqueSubMeshes;
  19656. private _transparentSubMeshes;
  19657. private _alphaTestSubMeshes;
  19658. private _depthOnlySubMeshes;
  19659. private _particleSystems;
  19660. private _spriteManagers;
  19661. private _opaqueSortCompareFn;
  19662. private _alphaTestSortCompareFn;
  19663. private _transparentSortCompareFn;
  19664. private _renderOpaque;
  19665. private _renderAlphaTest;
  19666. private _renderTransparent;
  19667. /** @hidden */
  19668. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19669. onBeforeTransparentRendering: () => void;
  19670. /**
  19671. * Set the opaque sort comparison function.
  19672. * If null the sub meshes will be render in the order they were created
  19673. */
  19674. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19675. /**
  19676. * Set the alpha test sort comparison function.
  19677. * If null the sub meshes will be render in the order they were created
  19678. */
  19679. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19680. /**
  19681. * Set the transparent sort comparison function.
  19682. * If null the sub meshes will be render in the order they were created
  19683. */
  19684. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19685. /**
  19686. * Creates a new rendering group.
  19687. * @param index The rendering group index
  19688. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19689. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19690. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19691. */
  19692. 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>);
  19693. /**
  19694. * Render all the sub meshes contained in the group.
  19695. * @param customRenderFunction Used to override the default render behaviour of the group.
  19696. * @returns true if rendered some submeshes.
  19697. */
  19698. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19699. /**
  19700. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19701. * @param subMeshes The submeshes to render
  19702. */
  19703. private renderOpaqueSorted;
  19704. /**
  19705. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19706. * @param subMeshes The submeshes to render
  19707. */
  19708. private renderAlphaTestSorted;
  19709. /**
  19710. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19711. * @param subMeshes The submeshes to render
  19712. */
  19713. private renderTransparentSorted;
  19714. /**
  19715. * Renders the submeshes in a specified order.
  19716. * @param subMeshes The submeshes to sort before render
  19717. * @param sortCompareFn The comparison function use to sort
  19718. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19719. * @param transparent Specifies to activate blending if true
  19720. */
  19721. private static renderSorted;
  19722. /**
  19723. * Renders the submeshes in the order they were dispatched (no sort applied).
  19724. * @param subMeshes The submeshes to render
  19725. */
  19726. private static renderUnsorted;
  19727. /**
  19728. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19729. * are rendered back to front if in the same alpha index.
  19730. *
  19731. * @param a The first submesh
  19732. * @param b The second submesh
  19733. * @returns The result of the comparison
  19734. */
  19735. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19736. /**
  19737. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19738. * are rendered back to front.
  19739. *
  19740. * @param a The first submesh
  19741. * @param b The second submesh
  19742. * @returns The result of the comparison
  19743. */
  19744. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19745. /**
  19746. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19747. * are rendered front to back (prevent overdraw).
  19748. *
  19749. * @param a The first submesh
  19750. * @param b The second submesh
  19751. * @returns The result of the comparison
  19752. */
  19753. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19754. /**
  19755. * Resets the different lists of submeshes to prepare a new frame.
  19756. */
  19757. prepare(): void;
  19758. dispose(): void;
  19759. /**
  19760. * Inserts the submesh in its correct queue depending on its material.
  19761. * @param subMesh The submesh to dispatch
  19762. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19763. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19764. */
  19765. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19766. dispatchSprites(spriteManager: ISpriteManager): void;
  19767. dispatchParticles(particleSystem: IParticleSystem): void;
  19768. private _renderParticles;
  19769. private _renderSprites;
  19770. }
  19771. }
  19772. declare module BABYLON {
  19773. /**
  19774. * Interface describing the different options available in the rendering manager
  19775. * regarding Auto Clear between groups.
  19776. */
  19777. export interface IRenderingManagerAutoClearSetup {
  19778. /**
  19779. * Defines whether or not autoclear is enable.
  19780. */
  19781. autoClear: boolean;
  19782. /**
  19783. * Defines whether or not to autoclear the depth buffer.
  19784. */
  19785. depth: boolean;
  19786. /**
  19787. * Defines whether or not to autoclear the stencil buffer.
  19788. */
  19789. stencil: boolean;
  19790. }
  19791. /**
  19792. * This class is used by the onRenderingGroupObservable
  19793. */
  19794. export class RenderingGroupInfo {
  19795. /**
  19796. * The Scene that being rendered
  19797. */
  19798. scene: Scene;
  19799. /**
  19800. * The camera currently used for the rendering pass
  19801. */
  19802. camera: Nullable<Camera>;
  19803. /**
  19804. * The ID of the renderingGroup being processed
  19805. */
  19806. renderingGroupId: number;
  19807. }
  19808. /**
  19809. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19810. * It is enable to manage the different groups as well as the different necessary sort functions.
  19811. * This should not be used directly aside of the few static configurations
  19812. */
  19813. export class RenderingManager {
  19814. /**
  19815. * The max id used for rendering groups (not included)
  19816. */
  19817. static MAX_RENDERINGGROUPS: number;
  19818. /**
  19819. * The min id used for rendering groups (included)
  19820. */
  19821. static MIN_RENDERINGGROUPS: number;
  19822. /**
  19823. * Used to globally prevent autoclearing scenes.
  19824. */
  19825. static AUTOCLEAR: boolean;
  19826. /**
  19827. * @hidden
  19828. */
  19829. _useSceneAutoClearSetup: boolean;
  19830. private _scene;
  19831. private _renderingGroups;
  19832. private _depthStencilBufferAlreadyCleaned;
  19833. private _autoClearDepthStencil;
  19834. private _customOpaqueSortCompareFn;
  19835. private _customAlphaTestSortCompareFn;
  19836. private _customTransparentSortCompareFn;
  19837. private _renderingGroupInfo;
  19838. /**
  19839. * Instantiates a new rendering group for a particular scene
  19840. * @param scene Defines the scene the groups belongs to
  19841. */
  19842. constructor(scene: Scene);
  19843. private _clearDepthStencilBuffer;
  19844. /**
  19845. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19846. * @hidden
  19847. */
  19848. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19849. /**
  19850. * Resets the different information of the group to prepare a new frame
  19851. * @hidden
  19852. */
  19853. reset(): void;
  19854. /**
  19855. * Dispose and release the group and its associated resources.
  19856. * @hidden
  19857. */
  19858. dispose(): void;
  19859. /**
  19860. * Clear the info related to rendering groups preventing retention points during dispose.
  19861. */
  19862. freeRenderingGroups(): void;
  19863. private _prepareRenderingGroup;
  19864. /**
  19865. * Add a sprite manager to the rendering manager in order to render it this frame.
  19866. * @param spriteManager Define the sprite manager to render
  19867. */
  19868. dispatchSprites(spriteManager: ISpriteManager): void;
  19869. /**
  19870. * Add a particle system to the rendering manager in order to render it this frame.
  19871. * @param particleSystem Define the particle system to render
  19872. */
  19873. dispatchParticles(particleSystem: IParticleSystem): void;
  19874. /**
  19875. * Add a submesh to the manager in order to render it this frame
  19876. * @param subMesh The submesh to dispatch
  19877. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19878. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19879. */
  19880. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19881. /**
  19882. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19883. * This allowed control for front to back rendering or reversly depending of the special needs.
  19884. *
  19885. * @param renderingGroupId The rendering group id corresponding to its index
  19886. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19887. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19888. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19889. */
  19890. 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;
  19891. /**
  19892. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19893. *
  19894. * @param renderingGroupId The rendering group id corresponding to its index
  19895. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19896. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19897. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19898. */
  19899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19900. /**
  19901. * Gets the current auto clear configuration for one rendering group of the rendering
  19902. * manager.
  19903. * @param index the rendering group index to get the information for
  19904. * @returns The auto clear setup for the requested rendering group
  19905. */
  19906. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19907. }
  19908. }
  19909. declare module BABYLON {
  19910. /**
  19911. * This Helps creating a texture that will be created from a camera in your scene.
  19912. * It is basically a dynamic texture that could be used to create special effects for instance.
  19913. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19914. */
  19915. export class RenderTargetTexture extends Texture {
  19916. isCube: boolean;
  19917. /**
  19918. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19919. */
  19920. static readonly REFRESHRATE_RENDER_ONCE: number;
  19921. /**
  19922. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19923. */
  19924. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19925. /**
  19926. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19927. * the central point of your effect and can save a lot of performances.
  19928. */
  19929. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19930. /**
  19931. * Use this predicate to dynamically define the list of mesh you want to render.
  19932. * If set, the renderList property will be overwritten.
  19933. */
  19934. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19935. private _renderList;
  19936. /**
  19937. * Use this list to define the list of mesh you want to render.
  19938. */
  19939. renderList: Nullable<Array<AbstractMesh>>;
  19940. private _hookArray;
  19941. /**
  19942. * Define if particles should be rendered in your texture.
  19943. */
  19944. renderParticles: boolean;
  19945. /**
  19946. * Define if sprites should be rendered in your texture.
  19947. */
  19948. renderSprites: boolean;
  19949. /**
  19950. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19951. */
  19952. coordinatesMode: number;
  19953. /**
  19954. * Define the camera used to render the texture.
  19955. */
  19956. activeCamera: Nullable<Camera>;
  19957. /**
  19958. * Override the render function of the texture with your own one.
  19959. */
  19960. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19961. /**
  19962. * Define if camera post processes should be use while rendering the texture.
  19963. */
  19964. useCameraPostProcesses: boolean;
  19965. /**
  19966. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19967. */
  19968. ignoreCameraViewport: boolean;
  19969. private _postProcessManager;
  19970. private _postProcesses;
  19971. private _resizeObserver;
  19972. /**
  19973. * An event triggered when the texture is unbind.
  19974. */
  19975. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19976. /**
  19977. * An event triggered when the texture is unbind.
  19978. */
  19979. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19980. private _onAfterUnbindObserver;
  19981. /**
  19982. * Set a after unbind callback in the texture.
  19983. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19984. */
  19985. onAfterUnbind: () => void;
  19986. /**
  19987. * An event triggered before rendering the texture
  19988. */
  19989. onBeforeRenderObservable: Observable<number>;
  19990. private _onBeforeRenderObserver;
  19991. /**
  19992. * Set a before render callback in the texture.
  19993. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19994. */
  19995. onBeforeRender: (faceIndex: number) => void;
  19996. /**
  19997. * An event triggered after rendering the texture
  19998. */
  19999. onAfterRenderObservable: Observable<number>;
  20000. private _onAfterRenderObserver;
  20001. /**
  20002. * Set a after render callback in the texture.
  20003. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20004. */
  20005. onAfterRender: (faceIndex: number) => void;
  20006. /**
  20007. * An event triggered after the texture clear
  20008. */
  20009. onClearObservable: Observable<Engine>;
  20010. private _onClearObserver;
  20011. /**
  20012. * Set a clear callback in the texture.
  20013. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20014. */
  20015. onClear: (Engine: Engine) => void;
  20016. /**
  20017. * An event triggered when the texture is resized.
  20018. */
  20019. onResizeObservable: Observable<RenderTargetTexture>;
  20020. /**
  20021. * Define the clear color of the Render Target if it should be different from the scene.
  20022. */
  20023. clearColor: Color4;
  20024. protected _size: number | {
  20025. width: number;
  20026. height: number;
  20027. };
  20028. protected _initialSizeParameter: number | {
  20029. width: number;
  20030. height: number;
  20031. } | {
  20032. ratio: number;
  20033. };
  20034. protected _sizeRatio: Nullable<number>;
  20035. /** @hidden */
  20036. _generateMipMaps: boolean;
  20037. protected _renderingManager: RenderingManager;
  20038. /** @hidden */
  20039. _waitingRenderList: string[];
  20040. protected _doNotChangeAspectRatio: boolean;
  20041. protected _currentRefreshId: number;
  20042. protected _refreshRate: number;
  20043. protected _textureMatrix: Matrix;
  20044. protected _samples: number;
  20045. protected _renderTargetOptions: RenderTargetCreationOptions;
  20046. /**
  20047. * Gets render target creation options that were used.
  20048. */
  20049. readonly renderTargetOptions: RenderTargetCreationOptions;
  20050. protected _engine: Engine;
  20051. protected _onRatioRescale(): void;
  20052. /**
  20053. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20054. * It must define where the camera used to render the texture is set
  20055. */
  20056. boundingBoxPosition: Vector3;
  20057. private _boundingBoxSize;
  20058. /**
  20059. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20060. * When defined, the cubemap will switch to local mode
  20061. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20062. * @example https://www.babylonjs-playground.com/#RNASML
  20063. */
  20064. boundingBoxSize: Vector3;
  20065. /**
  20066. * In case the RTT has been created with a depth texture, get the associated
  20067. * depth texture.
  20068. * Otherwise, return null.
  20069. */
  20070. depthStencilTexture: Nullable<InternalTexture>;
  20071. /**
  20072. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20073. * or used a shadow, depth texture...
  20074. * @param name The friendly name of the texture
  20075. * @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)
  20076. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20077. * @param generateMipMaps True if mip maps need to be generated after render.
  20078. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20079. * @param type The type of the buffer in the RTT (int, half float, float...)
  20080. * @param isCube True if a cube texture needs to be created
  20081. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20082. * @param generateDepthBuffer True to generate a depth buffer
  20083. * @param generateStencilBuffer True to generate a stencil buffer
  20084. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20085. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20086. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20087. */
  20088. constructor(name: string, size: number | {
  20089. width: number;
  20090. height: number;
  20091. } | {
  20092. ratio: number;
  20093. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20094. /**
  20095. * Creates a depth stencil texture.
  20096. * This is only available in WebGL 2 or with the depth texture extension available.
  20097. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20098. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20099. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20100. */
  20101. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20102. private _processSizeParameter;
  20103. /**
  20104. * Define the number of samples to use in case of MSAA.
  20105. * It defaults to one meaning no MSAA has been enabled.
  20106. */
  20107. samples: number;
  20108. /**
  20109. * Resets the refresh counter of the texture and start bak from scratch.
  20110. * Could be useful to regenerate the texture if it is setup to render only once.
  20111. */
  20112. resetRefreshCounter(): void;
  20113. /**
  20114. * Define the refresh rate of the texture or the rendering frequency.
  20115. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20116. */
  20117. refreshRate: number;
  20118. /**
  20119. * Adds a post process to the render target rendering passes.
  20120. * @param postProcess define the post process to add
  20121. */
  20122. addPostProcess(postProcess: PostProcess): void;
  20123. /**
  20124. * Clear all the post processes attached to the render target
  20125. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20126. */
  20127. clearPostProcesses(dispose?: boolean): void;
  20128. /**
  20129. * Remove one of the post process from the list of attached post processes to the texture
  20130. * @param postProcess define the post process to remove from the list
  20131. */
  20132. removePostProcess(postProcess: PostProcess): void;
  20133. /** @hidden */
  20134. _shouldRender(): boolean;
  20135. /**
  20136. * Gets the actual render size of the texture.
  20137. * @returns the width of the render size
  20138. */
  20139. getRenderSize(): number;
  20140. /**
  20141. * Gets the actual render width of the texture.
  20142. * @returns the width of the render size
  20143. */
  20144. getRenderWidth(): number;
  20145. /**
  20146. * Gets the actual render height of the texture.
  20147. * @returns the height of the render size
  20148. */
  20149. getRenderHeight(): number;
  20150. /**
  20151. * Get if the texture can be rescaled or not.
  20152. */
  20153. readonly canRescale: boolean;
  20154. /**
  20155. * Resize the texture using a ratio.
  20156. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20157. */
  20158. scale(ratio: number): void;
  20159. /**
  20160. * Get the texture reflection matrix used to rotate/transform the reflection.
  20161. * @returns the reflection matrix
  20162. */
  20163. getReflectionTextureMatrix(): Matrix;
  20164. /**
  20165. * Resize the texture to a new desired size.
  20166. * Be carrefull as it will recreate all the data in the new texture.
  20167. * @param size Define the new size. It can be:
  20168. * - a number for squared texture,
  20169. * - an object containing { width: number, height: number }
  20170. * - or an object containing a ratio { ratio: number }
  20171. */
  20172. resize(size: number | {
  20173. width: number;
  20174. height: number;
  20175. } | {
  20176. ratio: number;
  20177. }): void;
  20178. /**
  20179. * Renders all the objects from the render list into the texture.
  20180. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20181. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20182. */
  20183. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20184. private _bestReflectionRenderTargetDimension;
  20185. /**
  20186. * @hidden
  20187. * @param faceIndex face index to bind to if this is a cubetexture
  20188. */
  20189. _bindFrameBuffer(faceIndex?: number): void;
  20190. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20191. private renderToTarget;
  20192. /**
  20193. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20194. * This allowed control for front to back rendering or reversly depending of the special needs.
  20195. *
  20196. * @param renderingGroupId The rendering group id corresponding to its index
  20197. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20198. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20199. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20200. */
  20201. 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;
  20202. /**
  20203. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20204. *
  20205. * @param renderingGroupId The rendering group id corresponding to its index
  20206. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20207. */
  20208. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20209. /**
  20210. * Clones the texture.
  20211. * @returns the cloned texture
  20212. */
  20213. clone(): RenderTargetTexture;
  20214. /**
  20215. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20216. * @returns The JSON representation of the texture
  20217. */
  20218. serialize(): any;
  20219. /**
  20220. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20221. */
  20222. disposeFramebufferObjects(): void;
  20223. /**
  20224. * Dispose the texture and release its associated resources.
  20225. */
  20226. dispose(): void;
  20227. /** @hidden */
  20228. _rebuild(): void;
  20229. /**
  20230. * Clear the info related to rendering groups preventing retention point in material dispose.
  20231. */
  20232. freeRenderingGroups(): void;
  20233. /**
  20234. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20235. * @returns the view count
  20236. */
  20237. getViewCount(): number;
  20238. }
  20239. }
  20240. declare module BABYLON {
  20241. /**
  20242. * Options for compiling materials.
  20243. */
  20244. export interface IMaterialCompilationOptions {
  20245. /**
  20246. * Defines whether clip planes are enabled.
  20247. */
  20248. clipPlane: boolean;
  20249. /**
  20250. * Defines whether instances are enabled.
  20251. */
  20252. useInstances: boolean;
  20253. }
  20254. /**
  20255. * Base class for the main features of a material in Babylon.js
  20256. */
  20257. export class Material implements IAnimatable {
  20258. /**
  20259. * Returns the triangle fill mode
  20260. */
  20261. static readonly TriangleFillMode: number;
  20262. /**
  20263. * Returns the wireframe mode
  20264. */
  20265. static readonly WireFrameFillMode: number;
  20266. /**
  20267. * Returns the point fill mode
  20268. */
  20269. static readonly PointFillMode: number;
  20270. /**
  20271. * Returns the point list draw mode
  20272. */
  20273. static readonly PointListDrawMode: number;
  20274. /**
  20275. * Returns the line list draw mode
  20276. */
  20277. static readonly LineListDrawMode: number;
  20278. /**
  20279. * Returns the line loop draw mode
  20280. */
  20281. static readonly LineLoopDrawMode: number;
  20282. /**
  20283. * Returns the line strip draw mode
  20284. */
  20285. static readonly LineStripDrawMode: number;
  20286. /**
  20287. * Returns the triangle strip draw mode
  20288. */
  20289. static readonly TriangleStripDrawMode: number;
  20290. /**
  20291. * Returns the triangle fan draw mode
  20292. */
  20293. static readonly TriangleFanDrawMode: number;
  20294. /**
  20295. * Stores the clock-wise side orientation
  20296. */
  20297. static readonly ClockWiseSideOrientation: number;
  20298. /**
  20299. * Stores the counter clock-wise side orientation
  20300. */
  20301. static readonly CounterClockWiseSideOrientation: number;
  20302. /**
  20303. * The dirty texture flag value
  20304. */
  20305. static readonly TextureDirtyFlag: number;
  20306. /**
  20307. * The dirty light flag value
  20308. */
  20309. static readonly LightDirtyFlag: number;
  20310. /**
  20311. * The dirty fresnel flag value
  20312. */
  20313. static readonly FresnelDirtyFlag: number;
  20314. /**
  20315. * The dirty attribute flag value
  20316. */
  20317. static readonly AttributesDirtyFlag: number;
  20318. /**
  20319. * The dirty misc flag value
  20320. */
  20321. static readonly MiscDirtyFlag: number;
  20322. /**
  20323. * The all dirty flag value
  20324. */
  20325. static readonly AllDirtyFlag: number;
  20326. /**
  20327. * The ID of the material
  20328. */
  20329. id: string;
  20330. /**
  20331. * Gets or sets the unique id of the material
  20332. */
  20333. uniqueId: number;
  20334. /**
  20335. * The name of the material
  20336. */
  20337. name: string;
  20338. /**
  20339. * Gets or sets user defined metadata
  20340. */
  20341. metadata: any;
  20342. /**
  20343. * For internal use only. Please do not use.
  20344. */
  20345. reservedDataStore: any;
  20346. /**
  20347. * Specifies if the ready state should be checked on each call
  20348. */
  20349. checkReadyOnEveryCall: boolean;
  20350. /**
  20351. * Specifies if the ready state should be checked once
  20352. */
  20353. checkReadyOnlyOnce: boolean;
  20354. /**
  20355. * The state of the material
  20356. */
  20357. state: string;
  20358. /**
  20359. * The alpha value of the material
  20360. */
  20361. protected _alpha: number;
  20362. /**
  20363. * List of inspectable custom properties (used by the Inspector)
  20364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20365. */
  20366. inspectableCustomProperties: IInspectable[];
  20367. /**
  20368. * Sets the alpha value of the material
  20369. */
  20370. /**
  20371. * Gets the alpha value of the material
  20372. */
  20373. alpha: number;
  20374. /**
  20375. * Specifies if back face culling is enabled
  20376. */
  20377. protected _backFaceCulling: boolean;
  20378. /**
  20379. * Sets the back-face culling state
  20380. */
  20381. /**
  20382. * Gets the back-face culling state
  20383. */
  20384. backFaceCulling: boolean;
  20385. /**
  20386. * Stores the value for side orientation
  20387. */
  20388. sideOrientation: number;
  20389. /**
  20390. * Callback triggered when the material is compiled
  20391. */
  20392. onCompiled: Nullable<(effect: Effect) => void>;
  20393. /**
  20394. * Callback triggered when an error occurs
  20395. */
  20396. onError: Nullable<(effect: Effect, errors: string) => void>;
  20397. /**
  20398. * Callback triggered to get the render target textures
  20399. */
  20400. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20401. /**
  20402. * Gets a boolean indicating that current material needs to register RTT
  20403. */
  20404. readonly hasRenderTargetTextures: boolean;
  20405. /**
  20406. * Specifies if the material should be serialized
  20407. */
  20408. doNotSerialize: boolean;
  20409. /**
  20410. * @hidden
  20411. */
  20412. _storeEffectOnSubMeshes: boolean;
  20413. /**
  20414. * Stores the animations for the material
  20415. */
  20416. animations: Nullable<Array<Animation>>;
  20417. /**
  20418. * An event triggered when the material is disposed
  20419. */
  20420. onDisposeObservable: Observable<Material>;
  20421. /**
  20422. * An observer which watches for dispose events
  20423. */
  20424. private _onDisposeObserver;
  20425. private _onUnBindObservable;
  20426. /**
  20427. * Called during a dispose event
  20428. */
  20429. onDispose: () => void;
  20430. private _onBindObservable;
  20431. /**
  20432. * An event triggered when the material is bound
  20433. */
  20434. readonly onBindObservable: Observable<AbstractMesh>;
  20435. /**
  20436. * An observer which watches for bind events
  20437. */
  20438. private _onBindObserver;
  20439. /**
  20440. * Called during a bind event
  20441. */
  20442. onBind: (Mesh: AbstractMesh) => void;
  20443. /**
  20444. * An event triggered when the material is unbound
  20445. */
  20446. readonly onUnBindObservable: Observable<Material>;
  20447. /**
  20448. * Stores the value of the alpha mode
  20449. */
  20450. private _alphaMode;
  20451. /**
  20452. * Sets the value of the alpha mode.
  20453. *
  20454. * | Value | Type | Description |
  20455. * | --- | --- | --- |
  20456. * | 0 | ALPHA_DISABLE | |
  20457. * | 1 | ALPHA_ADD | |
  20458. * | 2 | ALPHA_COMBINE | |
  20459. * | 3 | ALPHA_SUBTRACT | |
  20460. * | 4 | ALPHA_MULTIPLY | |
  20461. * | 5 | ALPHA_MAXIMIZED | |
  20462. * | 6 | ALPHA_ONEONE | |
  20463. * | 7 | ALPHA_PREMULTIPLIED | |
  20464. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20465. * | 9 | ALPHA_INTERPOLATE | |
  20466. * | 10 | ALPHA_SCREENMODE | |
  20467. *
  20468. */
  20469. /**
  20470. * Gets the value of the alpha mode
  20471. */
  20472. alphaMode: number;
  20473. /**
  20474. * Stores the state of the need depth pre-pass value
  20475. */
  20476. private _needDepthPrePass;
  20477. /**
  20478. * Sets the need depth pre-pass value
  20479. */
  20480. /**
  20481. * Gets the depth pre-pass value
  20482. */
  20483. needDepthPrePass: boolean;
  20484. /**
  20485. * Specifies if depth writing should be disabled
  20486. */
  20487. disableDepthWrite: boolean;
  20488. /**
  20489. * Specifies if depth writing should be forced
  20490. */
  20491. forceDepthWrite: boolean;
  20492. /**
  20493. * Specifies if there should be a separate pass for culling
  20494. */
  20495. separateCullingPass: boolean;
  20496. /**
  20497. * Stores the state specifing if fog should be enabled
  20498. */
  20499. private _fogEnabled;
  20500. /**
  20501. * Sets the state for enabling fog
  20502. */
  20503. /**
  20504. * Gets the value of the fog enabled state
  20505. */
  20506. fogEnabled: boolean;
  20507. /**
  20508. * Stores the size of points
  20509. */
  20510. pointSize: number;
  20511. /**
  20512. * Stores the z offset value
  20513. */
  20514. zOffset: number;
  20515. /**
  20516. * Gets a value specifying if wireframe mode is enabled
  20517. */
  20518. /**
  20519. * Sets the state of wireframe mode
  20520. */
  20521. wireframe: boolean;
  20522. /**
  20523. * Gets the value specifying if point clouds are enabled
  20524. */
  20525. /**
  20526. * Sets the state of point cloud mode
  20527. */
  20528. pointsCloud: boolean;
  20529. /**
  20530. * Gets the material fill mode
  20531. */
  20532. /**
  20533. * Sets the material fill mode
  20534. */
  20535. fillMode: number;
  20536. /**
  20537. * @hidden
  20538. * Stores the effects for the material
  20539. */
  20540. _effect: Nullable<Effect>;
  20541. /**
  20542. * @hidden
  20543. * Specifies if the material was previously ready
  20544. */
  20545. _wasPreviouslyReady: boolean;
  20546. /**
  20547. * Specifies if uniform buffers should be used
  20548. */
  20549. private _useUBO;
  20550. /**
  20551. * Stores a reference to the scene
  20552. */
  20553. private _scene;
  20554. /**
  20555. * Stores the fill mode state
  20556. */
  20557. private _fillMode;
  20558. /**
  20559. * Specifies if the depth write state should be cached
  20560. */
  20561. private _cachedDepthWriteState;
  20562. /**
  20563. * Stores the uniform buffer
  20564. */
  20565. protected _uniformBuffer: UniformBuffer;
  20566. /** @hidden */
  20567. _indexInSceneMaterialArray: number;
  20568. /** @hidden */
  20569. meshMap: Nullable<{
  20570. [id: string]: AbstractMesh | undefined;
  20571. }>;
  20572. /**
  20573. * Creates a material instance
  20574. * @param name defines the name of the material
  20575. * @param scene defines the scene to reference
  20576. * @param doNotAdd specifies if the material should be added to the scene
  20577. */
  20578. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20579. /**
  20580. * Returns a string representation of the current material
  20581. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20582. * @returns a string with material information
  20583. */
  20584. toString(fullDetails?: boolean): string;
  20585. /**
  20586. * Gets the class name of the material
  20587. * @returns a string with the class name of the material
  20588. */
  20589. getClassName(): string;
  20590. /**
  20591. * Specifies if updates for the material been locked
  20592. */
  20593. readonly isFrozen: boolean;
  20594. /**
  20595. * Locks updates for the material
  20596. */
  20597. freeze(): void;
  20598. /**
  20599. * Unlocks updates for the material
  20600. */
  20601. unfreeze(): void;
  20602. /**
  20603. * Specifies if the material is ready to be used
  20604. * @param mesh defines the mesh to check
  20605. * @param useInstances specifies if instances should be used
  20606. * @returns a boolean indicating if the material is ready to be used
  20607. */
  20608. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20609. /**
  20610. * Specifies that the submesh is ready to be used
  20611. * @param mesh defines the mesh to check
  20612. * @param subMesh defines which submesh to check
  20613. * @param useInstances specifies that instances should be used
  20614. * @returns a boolean indicating that the submesh is ready or not
  20615. */
  20616. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20617. /**
  20618. * Returns the material effect
  20619. * @returns the effect associated with the material
  20620. */
  20621. getEffect(): Nullable<Effect>;
  20622. /**
  20623. * Returns the current scene
  20624. * @returns a Scene
  20625. */
  20626. getScene(): Scene;
  20627. /**
  20628. * Specifies if the material will require alpha blending
  20629. * @returns a boolean specifying if alpha blending is needed
  20630. */
  20631. needAlphaBlending(): boolean;
  20632. /**
  20633. * Specifies if the mesh will require alpha blending
  20634. * @param mesh defines the mesh to check
  20635. * @returns a boolean specifying if alpha blending is needed for the mesh
  20636. */
  20637. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20638. /**
  20639. * Specifies if this material should be rendered in alpha test mode
  20640. * @returns a boolean specifying if an alpha test is needed.
  20641. */
  20642. needAlphaTesting(): boolean;
  20643. /**
  20644. * Gets the texture used for the alpha test
  20645. * @returns the texture to use for alpha testing
  20646. */
  20647. getAlphaTestTexture(): Nullable<BaseTexture>;
  20648. /**
  20649. * Marks the material to indicate that it needs to be re-calculated
  20650. */
  20651. markDirty(): void;
  20652. /** @hidden */
  20653. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20654. /**
  20655. * Binds the material to the mesh
  20656. * @param world defines the world transformation matrix
  20657. * @param mesh defines the mesh to bind the material to
  20658. */
  20659. bind(world: Matrix, mesh?: Mesh): void;
  20660. /**
  20661. * Binds the submesh to the material
  20662. * @param world defines the world transformation matrix
  20663. * @param mesh defines the mesh containing the submesh
  20664. * @param subMesh defines the submesh to bind the material to
  20665. */
  20666. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20667. /**
  20668. * Binds the world matrix to the material
  20669. * @param world defines the world transformation matrix
  20670. */
  20671. bindOnlyWorldMatrix(world: Matrix): void;
  20672. /**
  20673. * Binds the scene's uniform buffer to the effect.
  20674. * @param effect defines the effect to bind to the scene uniform buffer
  20675. * @param sceneUbo defines the uniform buffer storing scene data
  20676. */
  20677. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20678. /**
  20679. * Binds the view matrix to the effect
  20680. * @param effect defines the effect to bind the view matrix to
  20681. */
  20682. bindView(effect: Effect): void;
  20683. /**
  20684. * Binds the view projection matrix to the effect
  20685. * @param effect defines the effect to bind the view projection matrix to
  20686. */
  20687. bindViewProjection(effect: Effect): void;
  20688. /**
  20689. * Specifies if material alpha testing should be turned on for the mesh
  20690. * @param mesh defines the mesh to check
  20691. */
  20692. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20693. /**
  20694. * Processes to execute after binding the material to a mesh
  20695. * @param mesh defines the rendered mesh
  20696. */
  20697. protected _afterBind(mesh?: Mesh): void;
  20698. /**
  20699. * Unbinds the material from the mesh
  20700. */
  20701. unbind(): void;
  20702. /**
  20703. * Gets the active textures from the material
  20704. * @returns an array of textures
  20705. */
  20706. getActiveTextures(): BaseTexture[];
  20707. /**
  20708. * Specifies if the material uses a texture
  20709. * @param texture defines the texture to check against the material
  20710. * @returns a boolean specifying if the material uses the texture
  20711. */
  20712. hasTexture(texture: BaseTexture): boolean;
  20713. /**
  20714. * Makes a duplicate of the material, and gives it a new name
  20715. * @param name defines the new name for the duplicated material
  20716. * @returns the cloned material
  20717. */
  20718. clone(name: string): Nullable<Material>;
  20719. /**
  20720. * Gets the meshes bound to the material
  20721. * @returns an array of meshes bound to the material
  20722. */
  20723. getBindedMeshes(): AbstractMesh[];
  20724. /**
  20725. * Force shader compilation
  20726. * @param mesh defines the mesh associated with this material
  20727. * @param onCompiled defines a function to execute once the material is compiled
  20728. * @param options defines the options to configure the compilation
  20729. * @param onError defines a function to execute if the material fails compiling
  20730. */
  20731. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20732. /**
  20733. * Force shader compilation
  20734. * @param mesh defines the mesh that will use this material
  20735. * @param options defines additional options for compiling the shaders
  20736. * @returns a promise that resolves when the compilation completes
  20737. */
  20738. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20739. private static readonly _AllDirtyCallBack;
  20740. private static readonly _ImageProcessingDirtyCallBack;
  20741. private static readonly _TextureDirtyCallBack;
  20742. private static readonly _FresnelDirtyCallBack;
  20743. private static readonly _MiscDirtyCallBack;
  20744. private static readonly _LightsDirtyCallBack;
  20745. private static readonly _AttributeDirtyCallBack;
  20746. private static _FresnelAndMiscDirtyCallBack;
  20747. private static _TextureAndMiscDirtyCallBack;
  20748. private static readonly _DirtyCallbackArray;
  20749. private static readonly _RunDirtyCallBacks;
  20750. /**
  20751. * Marks a define in the material to indicate that it needs to be re-computed
  20752. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20753. */
  20754. markAsDirty(flag: number): void;
  20755. /**
  20756. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20757. * @param func defines a function which checks material defines against the submeshes
  20758. */
  20759. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20760. /**
  20761. * Indicates that we need to re-calculated for all submeshes
  20762. */
  20763. protected _markAllSubMeshesAsAllDirty(): void;
  20764. /**
  20765. * Indicates that image processing needs to be re-calculated for all submeshes
  20766. */
  20767. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20768. /**
  20769. * Indicates that textures need to be re-calculated for all submeshes
  20770. */
  20771. protected _markAllSubMeshesAsTexturesDirty(): void;
  20772. /**
  20773. * Indicates that fresnel needs to be re-calculated for all submeshes
  20774. */
  20775. protected _markAllSubMeshesAsFresnelDirty(): void;
  20776. /**
  20777. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20778. */
  20779. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20780. /**
  20781. * Indicates that lights need to be re-calculated for all submeshes
  20782. */
  20783. protected _markAllSubMeshesAsLightsDirty(): void;
  20784. /**
  20785. * Indicates that attributes need to be re-calculated for all submeshes
  20786. */
  20787. protected _markAllSubMeshesAsAttributesDirty(): void;
  20788. /**
  20789. * Indicates that misc needs to be re-calculated for all submeshes
  20790. */
  20791. protected _markAllSubMeshesAsMiscDirty(): void;
  20792. /**
  20793. * Indicates that textures and misc need to be re-calculated for all submeshes
  20794. */
  20795. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20796. /**
  20797. * Disposes the material
  20798. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20799. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20800. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20801. */
  20802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20803. /** @hidden */
  20804. private releaseVertexArrayObject;
  20805. /**
  20806. * Serializes this material
  20807. * @returns the serialized material object
  20808. */
  20809. serialize(): any;
  20810. /**
  20811. * Creates a material from parsed material data
  20812. * @param parsedMaterial defines parsed material data
  20813. * @param scene defines the hosting scene
  20814. * @param rootUrl defines the root URL to use to load textures
  20815. * @returns a new material
  20816. */
  20817. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20818. }
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20823. * separate meshes. This can be use to improve performances.
  20824. * @see http://doc.babylonjs.com/how_to/multi_materials
  20825. */
  20826. export class MultiMaterial extends Material {
  20827. private _subMaterials;
  20828. /**
  20829. * Gets or Sets the list of Materials used within the multi material.
  20830. * They need to be ordered according to the submeshes order in the associated mesh
  20831. */
  20832. subMaterials: Nullable<Material>[];
  20833. /**
  20834. * Function used to align with Node.getChildren()
  20835. * @returns the list of Materials used within the multi material
  20836. */
  20837. getChildren(): Nullable<Material>[];
  20838. /**
  20839. * Instantiates a new Multi Material
  20840. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20841. * separate meshes. This can be use to improve performances.
  20842. * @see http://doc.babylonjs.com/how_to/multi_materials
  20843. * @param name Define the name in the scene
  20844. * @param scene Define the scene the material belongs to
  20845. */
  20846. constructor(name: string, scene: Scene);
  20847. private _hookArray;
  20848. /**
  20849. * Get one of the submaterial by its index in the submaterials array
  20850. * @param index The index to look the sub material at
  20851. * @returns The Material if the index has been defined
  20852. */
  20853. getSubMaterial(index: number): Nullable<Material>;
  20854. /**
  20855. * Get the list of active textures for the whole sub materials list.
  20856. * @returns All the textures that will be used during the rendering
  20857. */
  20858. getActiveTextures(): BaseTexture[];
  20859. /**
  20860. * Gets the current class name of the material e.g. "MultiMaterial"
  20861. * Mainly use in serialization.
  20862. * @returns the class name
  20863. */
  20864. getClassName(): string;
  20865. /**
  20866. * Checks if the material is ready to render the requested sub mesh
  20867. * @param mesh Define the mesh the submesh belongs to
  20868. * @param subMesh Define the sub mesh to look readyness for
  20869. * @param useInstances Define whether or not the material is used with instances
  20870. * @returns true if ready, otherwise false
  20871. */
  20872. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20873. /**
  20874. * Clones the current material and its related sub materials
  20875. * @param name Define the name of the newly cloned material
  20876. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20877. * @returns the cloned material
  20878. */
  20879. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20880. /**
  20881. * Serializes the materials into a JSON representation.
  20882. * @returns the JSON representation
  20883. */
  20884. serialize(): any;
  20885. /**
  20886. * Dispose the material and release its associated resources
  20887. * @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)
  20888. * @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)
  20889. * @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)
  20890. */
  20891. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20892. /**
  20893. * Creates a MultiMaterial from parsed MultiMaterial data.
  20894. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20895. * @param scene defines the hosting scene
  20896. * @returns a new MultiMaterial
  20897. */
  20898. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20899. }
  20900. }
  20901. declare module BABYLON {
  20902. /**
  20903. * Base class for submeshes
  20904. */
  20905. export class BaseSubMesh {
  20906. /** @hidden */
  20907. _materialDefines: Nullable<MaterialDefines>;
  20908. /** @hidden */
  20909. _materialEffect: Nullable<Effect>;
  20910. /**
  20911. * Gets associated effect
  20912. */
  20913. readonly effect: Nullable<Effect>;
  20914. /**
  20915. * Sets associated effect (effect used to render this submesh)
  20916. * @param effect defines the effect to associate with
  20917. * @param defines defines the set of defines used to compile this effect
  20918. */
  20919. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20920. }
  20921. /**
  20922. * Defines a subdivision inside a mesh
  20923. */
  20924. export class SubMesh extends BaseSubMesh implements ICullable {
  20925. /** the material index to use */
  20926. materialIndex: number;
  20927. /** vertex index start */
  20928. verticesStart: number;
  20929. /** vertices count */
  20930. verticesCount: number;
  20931. /** index start */
  20932. indexStart: number;
  20933. /** indices count */
  20934. indexCount: number;
  20935. /** @hidden */
  20936. _linesIndexCount: number;
  20937. private _mesh;
  20938. private _renderingMesh;
  20939. private _boundingInfo;
  20940. private _linesIndexBuffer;
  20941. /** @hidden */
  20942. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20943. /** @hidden */
  20944. _trianglePlanes: Plane[];
  20945. /** @hidden */
  20946. _lastColliderTransformMatrix: Nullable<Matrix>;
  20947. /** @hidden */
  20948. _renderId: number;
  20949. /** @hidden */
  20950. _alphaIndex: number;
  20951. /** @hidden */
  20952. _distanceToCamera: number;
  20953. /** @hidden */
  20954. _id: number;
  20955. private _currentMaterial;
  20956. /**
  20957. * Add a new submesh to a mesh
  20958. * @param materialIndex defines the material index to use
  20959. * @param verticesStart defines vertex index start
  20960. * @param verticesCount defines vertices count
  20961. * @param indexStart defines index start
  20962. * @param indexCount defines indices count
  20963. * @param mesh defines the parent mesh
  20964. * @param renderingMesh defines an optional rendering mesh
  20965. * @param createBoundingBox defines if bounding box should be created for this submesh
  20966. * @returns the new submesh
  20967. */
  20968. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20969. /**
  20970. * Creates a new submesh
  20971. * @param materialIndex defines the material index to use
  20972. * @param verticesStart defines vertex index start
  20973. * @param verticesCount defines vertices count
  20974. * @param indexStart defines index start
  20975. * @param indexCount defines indices count
  20976. * @param mesh defines the parent mesh
  20977. * @param renderingMesh defines an optional rendering mesh
  20978. * @param createBoundingBox defines if bounding box should be created for this submesh
  20979. */
  20980. constructor(
  20981. /** the material index to use */
  20982. materialIndex: number,
  20983. /** vertex index start */
  20984. verticesStart: number,
  20985. /** vertices count */
  20986. verticesCount: number,
  20987. /** index start */
  20988. indexStart: number,
  20989. /** indices count */
  20990. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20991. /**
  20992. * Returns true if this submesh covers the entire parent mesh
  20993. * @ignorenaming
  20994. */
  20995. readonly IsGlobal: boolean;
  20996. /**
  20997. * Returns the submesh BoudingInfo object
  20998. * @returns current bounding info (or mesh's one if the submesh is global)
  20999. */
  21000. getBoundingInfo(): BoundingInfo;
  21001. /**
  21002. * Sets the submesh BoundingInfo
  21003. * @param boundingInfo defines the new bounding info to use
  21004. * @returns the SubMesh
  21005. */
  21006. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21007. /**
  21008. * Returns the mesh of the current submesh
  21009. * @return the parent mesh
  21010. */
  21011. getMesh(): AbstractMesh;
  21012. /**
  21013. * Returns the rendering mesh of the submesh
  21014. * @returns the rendering mesh (could be different from parent mesh)
  21015. */
  21016. getRenderingMesh(): Mesh;
  21017. /**
  21018. * Returns the submesh material
  21019. * @returns null or the current material
  21020. */
  21021. getMaterial(): Nullable<Material>;
  21022. /**
  21023. * Sets a new updated BoundingInfo object to the submesh
  21024. * @param data defines an optional position array to use to determine the bounding info
  21025. * @returns the SubMesh
  21026. */
  21027. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21028. /** @hidden */
  21029. _checkCollision(collider: Collider): boolean;
  21030. /**
  21031. * Updates the submesh BoundingInfo
  21032. * @param world defines the world matrix to use to update the bounding info
  21033. * @returns the submesh
  21034. */
  21035. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21036. /**
  21037. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21038. * @param frustumPlanes defines the frustum planes
  21039. * @returns true if the submesh is intersecting with the frustum
  21040. */
  21041. isInFrustum(frustumPlanes: Plane[]): boolean;
  21042. /**
  21043. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21044. * @param frustumPlanes defines the frustum planes
  21045. * @returns true if the submesh is inside the frustum
  21046. */
  21047. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21048. /**
  21049. * Renders the submesh
  21050. * @param enableAlphaMode defines if alpha needs to be used
  21051. * @returns the submesh
  21052. */
  21053. render(enableAlphaMode: boolean): SubMesh;
  21054. /**
  21055. * @hidden
  21056. */
  21057. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21058. /**
  21059. * Checks if the submesh intersects with a ray
  21060. * @param ray defines the ray to test
  21061. * @returns true is the passed ray intersects the submesh bounding box
  21062. */
  21063. canIntersects(ray: Ray): boolean;
  21064. /**
  21065. * Intersects current submesh with a ray
  21066. * @param ray defines the ray to test
  21067. * @param positions defines mesh's positions array
  21068. * @param indices defines mesh's indices array
  21069. * @param fastCheck defines if only bounding info should be used
  21070. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21071. * @returns intersection info or null if no intersection
  21072. */
  21073. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21074. /** @hidden */
  21075. private _intersectLines;
  21076. /** @hidden */
  21077. private _intersectUnIndexedLines;
  21078. /** @hidden */
  21079. private _intersectTriangles;
  21080. /** @hidden */
  21081. private _intersectUnIndexedTriangles;
  21082. /** @hidden */
  21083. _rebuild(): void;
  21084. /**
  21085. * Creates a new submesh from the passed mesh
  21086. * @param newMesh defines the new hosting mesh
  21087. * @param newRenderingMesh defines an optional rendering mesh
  21088. * @returns the new submesh
  21089. */
  21090. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21091. /**
  21092. * Release associated resources
  21093. */
  21094. dispose(): void;
  21095. /**
  21096. * Gets the class name
  21097. * @returns the string "SubMesh".
  21098. */
  21099. getClassName(): string;
  21100. /**
  21101. * Creates a new submesh from indices data
  21102. * @param materialIndex the index of the main mesh material
  21103. * @param startIndex the index where to start the copy in the mesh indices array
  21104. * @param indexCount the number of indices to copy then from the startIndex
  21105. * @param mesh the main mesh to create the submesh from
  21106. * @param renderingMesh the optional rendering mesh
  21107. * @returns a new submesh
  21108. */
  21109. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21110. }
  21111. }
  21112. declare module BABYLON {
  21113. /**
  21114. * Class used to represent data loading progression
  21115. */
  21116. export class SceneLoaderFlags {
  21117. private static _ForceFullSceneLoadingForIncremental;
  21118. private static _ShowLoadingScreen;
  21119. private static _CleanBoneMatrixWeights;
  21120. private static _loggingLevel;
  21121. /**
  21122. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21123. */
  21124. static ForceFullSceneLoadingForIncremental: boolean;
  21125. /**
  21126. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21127. */
  21128. static ShowLoadingScreen: boolean;
  21129. /**
  21130. * Defines the current logging level (while loading the scene)
  21131. * @ignorenaming
  21132. */
  21133. static loggingLevel: number;
  21134. /**
  21135. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21136. */
  21137. static CleanBoneMatrixWeights: boolean;
  21138. }
  21139. }
  21140. declare module BABYLON {
  21141. /**
  21142. * Class used to store geometry data (vertex buffers + index buffer)
  21143. */
  21144. export class Geometry implements IGetSetVerticesData {
  21145. /**
  21146. * Gets or sets the ID of the geometry
  21147. */
  21148. id: string;
  21149. /**
  21150. * Gets or sets the unique ID of the geometry
  21151. */
  21152. uniqueId: number;
  21153. /**
  21154. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21155. */
  21156. delayLoadState: number;
  21157. /**
  21158. * Gets the file containing the data to load when running in delay load state
  21159. */
  21160. delayLoadingFile: Nullable<string>;
  21161. /**
  21162. * Callback called when the geometry is updated
  21163. */
  21164. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21165. private _scene;
  21166. private _engine;
  21167. private _meshes;
  21168. private _totalVertices;
  21169. /** @hidden */
  21170. _indices: IndicesArray;
  21171. /** @hidden */
  21172. _vertexBuffers: {
  21173. [key: string]: VertexBuffer;
  21174. };
  21175. private _isDisposed;
  21176. private _extend;
  21177. private _boundingBias;
  21178. /** @hidden */
  21179. _delayInfo: Array<string>;
  21180. private _indexBuffer;
  21181. private _indexBufferIsUpdatable;
  21182. /** @hidden */
  21183. _boundingInfo: Nullable<BoundingInfo>;
  21184. /** @hidden */
  21185. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21186. /** @hidden */
  21187. _softwareSkinningFrameId: number;
  21188. private _vertexArrayObjects;
  21189. private _updatable;
  21190. /** @hidden */
  21191. _positions: Nullable<Vector3[]>;
  21192. /**
  21193. * 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
  21194. */
  21195. /**
  21196. * 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
  21197. */
  21198. boundingBias: Vector2;
  21199. /**
  21200. * Static function used to attach a new empty geometry to a mesh
  21201. * @param mesh defines the mesh to attach the geometry to
  21202. * @returns the new Geometry
  21203. */
  21204. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21205. /**
  21206. * Creates a new geometry
  21207. * @param id defines the unique ID
  21208. * @param scene defines the hosting scene
  21209. * @param vertexData defines the VertexData used to get geometry data
  21210. * @param updatable defines if geometry must be updatable (false by default)
  21211. * @param mesh defines the mesh that will be associated with the geometry
  21212. */
  21213. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21214. /**
  21215. * Gets the current extend of the geometry
  21216. */
  21217. readonly extend: {
  21218. minimum: Vector3;
  21219. maximum: Vector3;
  21220. };
  21221. /**
  21222. * Gets the hosting scene
  21223. * @returns the hosting Scene
  21224. */
  21225. getScene(): Scene;
  21226. /**
  21227. * Gets the hosting engine
  21228. * @returns the hosting Engine
  21229. */
  21230. getEngine(): Engine;
  21231. /**
  21232. * Defines if the geometry is ready to use
  21233. * @returns true if the geometry is ready to be used
  21234. */
  21235. isReady(): boolean;
  21236. /**
  21237. * Gets a value indicating that the geometry should not be serialized
  21238. */
  21239. readonly doNotSerialize: boolean;
  21240. /** @hidden */
  21241. _rebuild(): void;
  21242. /**
  21243. * Affects all geometry data in one call
  21244. * @param vertexData defines the geometry data
  21245. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21246. */
  21247. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21248. /**
  21249. * Set specific vertex data
  21250. * @param kind defines the data kind (Position, normal, etc...)
  21251. * @param data defines the vertex data to use
  21252. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21253. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21254. */
  21255. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21256. /**
  21257. * Removes a specific vertex data
  21258. * @param kind defines the data kind (Position, normal, etc...)
  21259. */
  21260. removeVerticesData(kind: string): void;
  21261. /**
  21262. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21263. * @param buffer defines the vertex buffer to use
  21264. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21265. */
  21266. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21267. /**
  21268. * Update a specific vertex buffer
  21269. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21270. * It will do nothing if the buffer is not updatable
  21271. * @param kind defines the data kind (Position, normal, etc...)
  21272. * @param data defines the data to use
  21273. * @param offset defines the offset in the target buffer where to store the data
  21274. * @param useBytes set to true if the offset is in bytes
  21275. */
  21276. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21277. /**
  21278. * Update a specific vertex buffer
  21279. * This function will create a new buffer if the current one is not updatable
  21280. * @param kind defines the data kind (Position, normal, etc...)
  21281. * @param data defines the data to use
  21282. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21283. */
  21284. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21285. private _updateBoundingInfo;
  21286. /** @hidden */
  21287. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21288. /**
  21289. * Gets total number of vertices
  21290. * @returns the total number of vertices
  21291. */
  21292. getTotalVertices(): number;
  21293. /**
  21294. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21295. * @param kind defines the data kind (Position, normal, etc...)
  21296. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21297. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21298. * @returns a float array containing vertex data
  21299. */
  21300. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21301. /**
  21302. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21303. * @param kind defines the data kind (Position, normal, etc...)
  21304. * @returns true if the vertex buffer with the specified kind is updatable
  21305. */
  21306. isVertexBufferUpdatable(kind: string): boolean;
  21307. /**
  21308. * Gets a specific vertex buffer
  21309. * @param kind defines the data kind (Position, normal, etc...)
  21310. * @returns a VertexBuffer
  21311. */
  21312. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21313. /**
  21314. * Returns all vertex buffers
  21315. * @return an object holding all vertex buffers indexed by kind
  21316. */
  21317. getVertexBuffers(): Nullable<{
  21318. [key: string]: VertexBuffer;
  21319. }>;
  21320. /**
  21321. * Gets a boolean indicating if specific vertex buffer is present
  21322. * @param kind defines the data kind (Position, normal, etc...)
  21323. * @returns true if data is present
  21324. */
  21325. isVerticesDataPresent(kind: string): boolean;
  21326. /**
  21327. * Gets a list of all attached data kinds (Position, normal, etc...)
  21328. * @returns a list of string containing all kinds
  21329. */
  21330. getVerticesDataKinds(): string[];
  21331. /**
  21332. * Update index buffer
  21333. * @param indices defines the indices to store in the index buffer
  21334. * @param offset defines the offset in the target buffer where to store the data
  21335. * @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)
  21336. */
  21337. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21338. /**
  21339. * Creates a new index buffer
  21340. * @param indices defines the indices to store in the index buffer
  21341. * @param totalVertices defines the total number of vertices (could be null)
  21342. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21343. */
  21344. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21345. /**
  21346. * Return the total number of indices
  21347. * @returns the total number of indices
  21348. */
  21349. getTotalIndices(): number;
  21350. /**
  21351. * Gets the index buffer array
  21352. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21353. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21354. * @returns the index buffer array
  21355. */
  21356. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21357. /**
  21358. * Gets the index buffer
  21359. * @return the index buffer
  21360. */
  21361. getIndexBuffer(): Nullable<DataBuffer>;
  21362. /** @hidden */
  21363. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21364. /**
  21365. * Release the associated resources for a specific mesh
  21366. * @param mesh defines the source mesh
  21367. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21368. */
  21369. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21370. /**
  21371. * Apply current geometry to a given mesh
  21372. * @param mesh defines the mesh to apply geometry to
  21373. */
  21374. applyToMesh(mesh: Mesh): void;
  21375. private _updateExtend;
  21376. private _applyToMesh;
  21377. private notifyUpdate;
  21378. /**
  21379. * Load the geometry if it was flagged as delay loaded
  21380. * @param scene defines the hosting scene
  21381. * @param onLoaded defines a callback called when the geometry is loaded
  21382. */
  21383. load(scene: Scene, onLoaded?: () => void): void;
  21384. private _queueLoad;
  21385. /**
  21386. * Invert the geometry to move from a right handed system to a left handed one.
  21387. */
  21388. toLeftHanded(): void;
  21389. /** @hidden */
  21390. _resetPointsArrayCache(): void;
  21391. /** @hidden */
  21392. _generatePointsArray(): boolean;
  21393. /**
  21394. * Gets a value indicating if the geometry is disposed
  21395. * @returns true if the geometry was disposed
  21396. */
  21397. isDisposed(): boolean;
  21398. private _disposeVertexArrayObjects;
  21399. /**
  21400. * Free all associated resources
  21401. */
  21402. dispose(): void;
  21403. /**
  21404. * Clone the current geometry into a new geometry
  21405. * @param id defines the unique ID of the new geometry
  21406. * @returns a new geometry object
  21407. */
  21408. copy(id: string): Geometry;
  21409. /**
  21410. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21411. * @return a JSON representation of the current geometry data (without the vertices data)
  21412. */
  21413. serialize(): any;
  21414. private toNumberArray;
  21415. /**
  21416. * Serialize all vertices data into a JSON oject
  21417. * @returns a JSON representation of the current geometry data
  21418. */
  21419. serializeVerticeData(): any;
  21420. /**
  21421. * Extracts a clone of a mesh geometry
  21422. * @param mesh defines the source mesh
  21423. * @param id defines the unique ID of the new geometry object
  21424. * @returns the new geometry object
  21425. */
  21426. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21427. /**
  21428. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21429. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21430. * Be aware Math.random() could cause collisions, but:
  21431. * "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"
  21432. * @returns a string containing a new GUID
  21433. */
  21434. static RandomId(): string;
  21435. /** @hidden */
  21436. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21437. private static _CleanMatricesWeights;
  21438. /**
  21439. * Create a new geometry from persisted data (Using .babylon file format)
  21440. * @param parsedVertexData defines the persisted data
  21441. * @param scene defines the hosting scene
  21442. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21443. * @returns the new geometry object
  21444. */
  21445. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21446. }
  21447. }
  21448. declare module BABYLON {
  21449. /**
  21450. * Define an interface for all classes that will get and set the data on vertices
  21451. */
  21452. export interface IGetSetVerticesData {
  21453. /**
  21454. * Gets a boolean indicating if specific vertex data is present
  21455. * @param kind defines the vertex data kind to use
  21456. * @returns true is data kind is present
  21457. */
  21458. isVerticesDataPresent(kind: string): boolean;
  21459. /**
  21460. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21461. * @param kind defines the data kind (Position, normal, etc...)
  21462. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21463. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21464. * @returns a float array containing vertex data
  21465. */
  21466. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21467. /**
  21468. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21469. * @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.
  21470. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21471. * @returns the indices array or an empty array if the mesh has no geometry
  21472. */
  21473. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21474. /**
  21475. * Set specific vertex data
  21476. * @param kind defines the data kind (Position, normal, etc...)
  21477. * @param data defines the vertex data to use
  21478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21480. */
  21481. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21482. /**
  21483. * Update a specific associated vertex buffer
  21484. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21485. * - VertexBuffer.PositionKind
  21486. * - VertexBuffer.UVKind
  21487. * - VertexBuffer.UV2Kind
  21488. * - VertexBuffer.UV3Kind
  21489. * - VertexBuffer.UV4Kind
  21490. * - VertexBuffer.UV5Kind
  21491. * - VertexBuffer.UV6Kind
  21492. * - VertexBuffer.ColorKind
  21493. * - VertexBuffer.MatricesIndicesKind
  21494. * - VertexBuffer.MatricesIndicesExtraKind
  21495. * - VertexBuffer.MatricesWeightsKind
  21496. * - VertexBuffer.MatricesWeightsExtraKind
  21497. * @param data defines the data source
  21498. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21499. * @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)
  21500. */
  21501. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21502. /**
  21503. * Creates a new index buffer
  21504. * @param indices defines the indices to store in the index buffer
  21505. * @param totalVertices defines the total number of vertices (could be null)
  21506. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21507. */
  21508. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21509. }
  21510. /**
  21511. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21512. */
  21513. export class VertexData {
  21514. /**
  21515. * Mesh side orientation : usually the external or front surface
  21516. */
  21517. static readonly FRONTSIDE: number;
  21518. /**
  21519. * Mesh side orientation : usually the internal or back surface
  21520. */
  21521. static readonly BACKSIDE: number;
  21522. /**
  21523. * Mesh side orientation : both internal and external or front and back surfaces
  21524. */
  21525. static readonly DOUBLESIDE: number;
  21526. /**
  21527. * Mesh side orientation : by default, `FRONTSIDE`
  21528. */
  21529. static readonly DEFAULTSIDE: number;
  21530. /**
  21531. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21532. */
  21533. positions: Nullable<FloatArray>;
  21534. /**
  21535. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21536. */
  21537. normals: Nullable<FloatArray>;
  21538. /**
  21539. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21540. */
  21541. tangents: Nullable<FloatArray>;
  21542. /**
  21543. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21544. */
  21545. uvs: Nullable<FloatArray>;
  21546. /**
  21547. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21548. */
  21549. uvs2: Nullable<FloatArray>;
  21550. /**
  21551. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21552. */
  21553. uvs3: Nullable<FloatArray>;
  21554. /**
  21555. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21556. */
  21557. uvs4: Nullable<FloatArray>;
  21558. /**
  21559. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21560. */
  21561. uvs5: Nullable<FloatArray>;
  21562. /**
  21563. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21564. */
  21565. uvs6: Nullable<FloatArray>;
  21566. /**
  21567. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21568. */
  21569. colors: Nullable<FloatArray>;
  21570. /**
  21571. * 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).
  21572. */
  21573. matricesIndices: Nullable<FloatArray>;
  21574. /**
  21575. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21576. */
  21577. matricesWeights: Nullable<FloatArray>;
  21578. /**
  21579. * An array extending the number of possible indices
  21580. */
  21581. matricesIndicesExtra: Nullable<FloatArray>;
  21582. /**
  21583. * An array extending the number of possible weights when the number of indices is extended
  21584. */
  21585. matricesWeightsExtra: Nullable<FloatArray>;
  21586. /**
  21587. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21588. */
  21589. indices: Nullable<IndicesArray>;
  21590. /**
  21591. * Uses the passed data array to set the set the values for the specified kind of data
  21592. * @param data a linear array of floating numbers
  21593. * @param kind the type of data that is being set, eg positions, colors etc
  21594. */
  21595. set(data: FloatArray, kind: string): void;
  21596. /**
  21597. * Associates the vertexData to the passed Mesh.
  21598. * Sets it as updatable or not (default `false`)
  21599. * @param mesh the mesh the vertexData is applied to
  21600. * @param updatable when used and having the value true allows new data to update the vertexData
  21601. * @returns the VertexData
  21602. */
  21603. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21604. /**
  21605. * Associates the vertexData to the passed Geometry.
  21606. * Sets it as updatable or not (default `false`)
  21607. * @param geometry the geometry the vertexData is applied to
  21608. * @param updatable when used and having the value true allows new data to update the vertexData
  21609. * @returns VertexData
  21610. */
  21611. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21612. /**
  21613. * Updates the associated mesh
  21614. * @param mesh the mesh to be updated
  21615. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21616. * @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
  21617. * @returns VertexData
  21618. */
  21619. updateMesh(mesh: Mesh): VertexData;
  21620. /**
  21621. * Updates the associated geometry
  21622. * @param geometry the geometry to be updated
  21623. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21624. * @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
  21625. * @returns VertexData.
  21626. */
  21627. updateGeometry(geometry: Geometry): VertexData;
  21628. private _applyTo;
  21629. private _update;
  21630. /**
  21631. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21632. * @param matrix the transforming matrix
  21633. * @returns the VertexData
  21634. */
  21635. transform(matrix: Matrix): VertexData;
  21636. /**
  21637. * Merges the passed VertexData into the current one
  21638. * @param other the VertexData to be merged into the current one
  21639. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21640. * @returns the modified VertexData
  21641. */
  21642. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21643. private _mergeElement;
  21644. private _validate;
  21645. /**
  21646. * Serializes the VertexData
  21647. * @returns a serialized object
  21648. */
  21649. serialize(): any;
  21650. /**
  21651. * Extracts the vertexData from a mesh
  21652. * @param mesh the mesh from which to extract the VertexData
  21653. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21654. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21655. * @returns the object VertexData associated to the passed mesh
  21656. */
  21657. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21658. /**
  21659. * Extracts the vertexData from the geometry
  21660. * @param geometry the geometry from which to extract the VertexData
  21661. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21662. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21663. * @returns the object VertexData associated to the passed mesh
  21664. */
  21665. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21666. private static _ExtractFrom;
  21667. /**
  21668. * Creates the VertexData for a Ribbon
  21669. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21670. * * pathArray array of paths, each of which an array of successive Vector3
  21671. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21672. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21673. * * 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
  21674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21675. * * 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)
  21676. * * 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)
  21677. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21678. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21679. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21680. * @returns the VertexData of the ribbon
  21681. */
  21682. static CreateRibbon(options: {
  21683. pathArray: Vector3[][];
  21684. closeArray?: boolean;
  21685. closePath?: boolean;
  21686. offset?: number;
  21687. sideOrientation?: number;
  21688. frontUVs?: Vector4;
  21689. backUVs?: Vector4;
  21690. invertUV?: boolean;
  21691. uvs?: Vector2[];
  21692. colors?: Color4[];
  21693. }): VertexData;
  21694. /**
  21695. * Creates the VertexData for a box
  21696. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21697. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21698. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21699. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21700. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21701. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21702. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21704. * * 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)
  21705. * * 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)
  21706. * @returns the VertexData of the box
  21707. */
  21708. static CreateBox(options: {
  21709. size?: number;
  21710. width?: number;
  21711. height?: number;
  21712. depth?: number;
  21713. faceUV?: Vector4[];
  21714. faceColors?: Color4[];
  21715. sideOrientation?: number;
  21716. frontUVs?: Vector4;
  21717. backUVs?: Vector4;
  21718. }): VertexData;
  21719. /**
  21720. * Creates the VertexData for a tiled box
  21721. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21722. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21723. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21724. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21726. * @returns the VertexData of the box
  21727. */
  21728. static CreateTiledBox(options: {
  21729. pattern?: number;
  21730. width?: number;
  21731. height?: number;
  21732. depth?: number;
  21733. tileSize?: number;
  21734. tileWidth?: number;
  21735. tileHeight?: number;
  21736. alignHorizontal?: number;
  21737. alignVertical?: number;
  21738. faceUV?: Vector4[];
  21739. faceColors?: Color4[];
  21740. sideOrientation?: number;
  21741. }): VertexData;
  21742. /**
  21743. * Creates the VertexData for a tiled plane
  21744. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21745. * * pattern a limited pattern arrangement depending on the number
  21746. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21747. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21748. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21749. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21750. * * 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)
  21751. * * 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)
  21752. * @returns the VertexData of the tiled plane
  21753. */
  21754. static CreateTiledPlane(options: {
  21755. pattern?: number;
  21756. tileSize?: number;
  21757. tileWidth?: number;
  21758. tileHeight?: number;
  21759. size?: number;
  21760. width?: number;
  21761. height?: number;
  21762. alignHorizontal?: number;
  21763. alignVertical?: number;
  21764. sideOrientation?: number;
  21765. frontUVs?: Vector4;
  21766. backUVs?: Vector4;
  21767. }): VertexData;
  21768. /**
  21769. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21770. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21771. * * segments sets the number of horizontal strips optional, default 32
  21772. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21773. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21774. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21775. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21776. * * 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
  21777. * * 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
  21778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21779. * * 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)
  21780. * * 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)
  21781. * @returns the VertexData of the ellipsoid
  21782. */
  21783. static CreateSphere(options: {
  21784. segments?: number;
  21785. diameter?: number;
  21786. diameterX?: number;
  21787. diameterY?: number;
  21788. diameterZ?: number;
  21789. arc?: number;
  21790. slice?: number;
  21791. sideOrientation?: number;
  21792. frontUVs?: Vector4;
  21793. backUVs?: Vector4;
  21794. }): VertexData;
  21795. /**
  21796. * Creates the VertexData for a cylinder, cone or prism
  21797. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21798. * * height sets the height (y direction) of the cylinder, optional, default 2
  21799. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21800. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21801. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21802. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21803. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21804. * * 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
  21805. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21806. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21807. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21808. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21809. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21810. * * 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)
  21811. * * 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)
  21812. * @returns the VertexData of the cylinder, cone or prism
  21813. */
  21814. static CreateCylinder(options: {
  21815. height?: number;
  21816. diameterTop?: number;
  21817. diameterBottom?: number;
  21818. diameter?: number;
  21819. tessellation?: number;
  21820. subdivisions?: number;
  21821. arc?: number;
  21822. faceColors?: Color4[];
  21823. faceUV?: Vector4[];
  21824. hasRings?: boolean;
  21825. enclose?: boolean;
  21826. sideOrientation?: number;
  21827. frontUVs?: Vector4;
  21828. backUVs?: Vector4;
  21829. }): VertexData;
  21830. /**
  21831. * Creates the VertexData for a torus
  21832. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21833. * * diameter the diameter of the torus, optional default 1
  21834. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21835. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21836. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21837. * * 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)
  21838. * * 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)
  21839. * @returns the VertexData of the torus
  21840. */
  21841. static CreateTorus(options: {
  21842. diameter?: number;
  21843. thickness?: number;
  21844. tessellation?: number;
  21845. sideOrientation?: number;
  21846. frontUVs?: Vector4;
  21847. backUVs?: Vector4;
  21848. }): VertexData;
  21849. /**
  21850. * Creates the VertexData of the LineSystem
  21851. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21852. * - lines an array of lines, each line being an array of successive Vector3
  21853. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21854. * @returns the VertexData of the LineSystem
  21855. */
  21856. static CreateLineSystem(options: {
  21857. lines: Vector3[][];
  21858. colors?: Nullable<Color4[][]>;
  21859. }): VertexData;
  21860. /**
  21861. * Create the VertexData for a DashedLines
  21862. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21863. * - points an array successive Vector3
  21864. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21865. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21866. * - dashNb the intended total number of dashes, optional, default 200
  21867. * @returns the VertexData for the DashedLines
  21868. */
  21869. static CreateDashedLines(options: {
  21870. points: Vector3[];
  21871. dashSize?: number;
  21872. gapSize?: number;
  21873. dashNb?: number;
  21874. }): VertexData;
  21875. /**
  21876. * Creates the VertexData for a Ground
  21877. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21878. * - width the width (x direction) of the ground, optional, default 1
  21879. * - height the height (z direction) of the ground, optional, default 1
  21880. * - subdivisions the number of subdivisions per side, optional, default 1
  21881. * @returns the VertexData of the Ground
  21882. */
  21883. static CreateGround(options: {
  21884. width?: number;
  21885. height?: number;
  21886. subdivisions?: number;
  21887. subdivisionsX?: number;
  21888. subdivisionsY?: number;
  21889. }): VertexData;
  21890. /**
  21891. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21892. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21893. * * xmin the ground minimum X coordinate, optional, default -1
  21894. * * zmin the ground minimum Z coordinate, optional, default -1
  21895. * * xmax the ground maximum X coordinate, optional, default 1
  21896. * * zmax the ground maximum Z coordinate, optional, default 1
  21897. * * 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}
  21898. * * 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}
  21899. * @returns the VertexData of the TiledGround
  21900. */
  21901. static CreateTiledGround(options: {
  21902. xmin: number;
  21903. zmin: number;
  21904. xmax: number;
  21905. zmax: number;
  21906. subdivisions?: {
  21907. w: number;
  21908. h: number;
  21909. };
  21910. precision?: {
  21911. w: number;
  21912. h: number;
  21913. };
  21914. }): VertexData;
  21915. /**
  21916. * Creates the VertexData of the Ground designed from a heightmap
  21917. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21918. * * width the width (x direction) of the ground
  21919. * * height the height (z direction) of the ground
  21920. * * subdivisions the number of subdivisions per side
  21921. * * minHeight the minimum altitude on the ground, optional, default 0
  21922. * * maxHeight the maximum altitude on the ground, optional default 1
  21923. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21924. * * buffer the array holding the image color data
  21925. * * bufferWidth the width of image
  21926. * * bufferHeight the height of image
  21927. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21928. * @returns the VertexData of the Ground designed from a heightmap
  21929. */
  21930. static CreateGroundFromHeightMap(options: {
  21931. width: number;
  21932. height: number;
  21933. subdivisions: number;
  21934. minHeight: number;
  21935. maxHeight: number;
  21936. colorFilter: Color3;
  21937. buffer: Uint8Array;
  21938. bufferWidth: number;
  21939. bufferHeight: number;
  21940. alphaFilter: number;
  21941. }): VertexData;
  21942. /**
  21943. * Creates the VertexData for a Plane
  21944. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21945. * * size sets the width and height of the plane to the value of size, optional default 1
  21946. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21947. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21949. * * 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)
  21950. * * 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)
  21951. * @returns the VertexData of the box
  21952. */
  21953. static CreatePlane(options: {
  21954. size?: number;
  21955. width?: number;
  21956. height?: number;
  21957. sideOrientation?: number;
  21958. frontUVs?: Vector4;
  21959. backUVs?: Vector4;
  21960. }): VertexData;
  21961. /**
  21962. * Creates the VertexData of the Disc or regular Polygon
  21963. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21964. * * radius the radius of the disc, optional default 0.5
  21965. * * tessellation the number of polygon sides, optional, default 64
  21966. * * 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
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * * 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)
  21969. * * 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)
  21970. * @returns the VertexData of the box
  21971. */
  21972. static CreateDisc(options: {
  21973. radius?: number;
  21974. tessellation?: number;
  21975. arc?: number;
  21976. sideOrientation?: number;
  21977. frontUVs?: Vector4;
  21978. backUVs?: Vector4;
  21979. }): VertexData;
  21980. /**
  21981. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21982. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21983. * @param polygon a mesh built from polygonTriangulation.build()
  21984. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21985. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21986. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21987. * @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)
  21988. * @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)
  21989. * @returns the VertexData of the Polygon
  21990. */
  21991. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21992. /**
  21993. * Creates the VertexData of the IcoSphere
  21994. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21995. * * radius the radius of the IcoSphere, optional default 1
  21996. * * radiusX allows stretching in the x direction, optional, default radius
  21997. * * radiusY allows stretching in the y direction, optional, default radius
  21998. * * radiusZ allows stretching in the z direction, optional, default radius
  21999. * * flat when true creates a flat shaded mesh, optional, default true
  22000. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * * 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)
  22003. * * 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)
  22004. * @returns the VertexData of the IcoSphere
  22005. */
  22006. static CreateIcoSphere(options: {
  22007. radius?: number;
  22008. radiusX?: number;
  22009. radiusY?: number;
  22010. radiusZ?: number;
  22011. flat?: boolean;
  22012. subdivisions?: number;
  22013. sideOrientation?: number;
  22014. frontUVs?: Vector4;
  22015. backUVs?: Vector4;
  22016. }): VertexData;
  22017. /**
  22018. * Creates the VertexData for a Polyhedron
  22019. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22020. * * type provided types are:
  22021. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22022. * * 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)
  22023. * * size the size of the IcoSphere, optional default 1
  22024. * * sizeX allows stretching in the x direction, optional, default size
  22025. * * sizeY allows stretching in the y direction, optional, default size
  22026. * * sizeZ allows stretching in the z direction, optional, default size
  22027. * * 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
  22028. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22029. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22030. * * flat when true creates a flat shaded mesh, optional, default true
  22031. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22033. * * 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)
  22034. * * 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)
  22035. * @returns the VertexData of the Polyhedron
  22036. */
  22037. static CreatePolyhedron(options: {
  22038. type?: number;
  22039. size?: number;
  22040. sizeX?: number;
  22041. sizeY?: number;
  22042. sizeZ?: number;
  22043. custom?: any;
  22044. faceUV?: Vector4[];
  22045. faceColors?: Color4[];
  22046. flat?: boolean;
  22047. sideOrientation?: number;
  22048. frontUVs?: Vector4;
  22049. backUVs?: Vector4;
  22050. }): VertexData;
  22051. /**
  22052. * Creates the VertexData for a TorusKnot
  22053. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22054. * * radius the radius of the torus knot, optional, default 2
  22055. * * tube the thickness of the tube, optional, default 0.5
  22056. * * radialSegments the number of sides on each tube segments, optional, default 32
  22057. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22058. * * p the number of windings around the z axis, optional, default 2
  22059. * * q the number of windings around the x axis, optional, default 3
  22060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22061. * * 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)
  22062. * * 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)
  22063. * @returns the VertexData of the Torus Knot
  22064. */
  22065. static CreateTorusKnot(options: {
  22066. radius?: number;
  22067. tube?: number;
  22068. radialSegments?: number;
  22069. tubularSegments?: number;
  22070. p?: number;
  22071. q?: number;
  22072. sideOrientation?: number;
  22073. frontUVs?: Vector4;
  22074. backUVs?: Vector4;
  22075. }): VertexData;
  22076. /**
  22077. * Compute normals for given positions and indices
  22078. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22079. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22080. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22081. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22082. * * facetNormals : optional array of facet normals (vector3)
  22083. * * facetPositions : optional array of facet positions (vector3)
  22084. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22085. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22086. * * bInfo : optional bounding info, required for facetPartitioning computation
  22087. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22088. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22089. * * useRightHandedSystem: optional boolean to for right handed system computation
  22090. * * depthSort : optional boolean to enable the facet depth sort computation
  22091. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22092. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22093. */
  22094. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22095. facetNormals?: any;
  22096. facetPositions?: any;
  22097. facetPartitioning?: any;
  22098. ratio?: number;
  22099. bInfo?: any;
  22100. bbSize?: Vector3;
  22101. subDiv?: any;
  22102. useRightHandedSystem?: boolean;
  22103. depthSort?: boolean;
  22104. distanceTo?: Vector3;
  22105. depthSortedFacets?: any;
  22106. }): void;
  22107. /** @hidden */
  22108. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22109. /**
  22110. * Applies VertexData created from the imported parameters to the geometry
  22111. * @param parsedVertexData the parsed data from an imported file
  22112. * @param geometry the geometry to apply the VertexData to
  22113. */
  22114. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22115. }
  22116. }
  22117. declare module BABYLON {
  22118. /**
  22119. * Defines a target to use with MorphTargetManager
  22120. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22121. */
  22122. export class MorphTarget implements IAnimatable {
  22123. /** defines the name of the target */
  22124. name: string;
  22125. /**
  22126. * Gets or sets the list of animations
  22127. */
  22128. animations: Animation[];
  22129. private _scene;
  22130. private _positions;
  22131. private _normals;
  22132. private _tangents;
  22133. private _uvs;
  22134. private _influence;
  22135. private _uniqueId;
  22136. /**
  22137. * Observable raised when the influence changes
  22138. */
  22139. onInfluenceChanged: Observable<boolean>;
  22140. /** @hidden */
  22141. _onDataLayoutChanged: Observable<void>;
  22142. /**
  22143. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22144. */
  22145. influence: number;
  22146. /**
  22147. * Gets or sets the id of the morph Target
  22148. */
  22149. id: string;
  22150. private _animationPropertiesOverride;
  22151. /**
  22152. * Gets or sets the animation properties override
  22153. */
  22154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22155. /**
  22156. * Creates a new MorphTarget
  22157. * @param name defines the name of the target
  22158. * @param influence defines the influence to use
  22159. * @param scene defines the scene the morphtarget belongs to
  22160. */
  22161. constructor(
  22162. /** defines the name of the target */
  22163. name: string, influence?: number, scene?: Nullable<Scene>);
  22164. /**
  22165. * Gets the unique ID of this manager
  22166. */
  22167. readonly uniqueId: number;
  22168. /**
  22169. * Gets a boolean defining if the target contains position data
  22170. */
  22171. readonly hasPositions: boolean;
  22172. /**
  22173. * Gets a boolean defining if the target contains normal data
  22174. */
  22175. readonly hasNormals: boolean;
  22176. /**
  22177. * Gets a boolean defining if the target contains tangent data
  22178. */
  22179. readonly hasTangents: boolean;
  22180. /**
  22181. * Gets a boolean defining if the target contains texture coordinates data
  22182. */
  22183. readonly hasUVs: boolean;
  22184. /**
  22185. * Affects position data to this target
  22186. * @param data defines the position data to use
  22187. */
  22188. setPositions(data: Nullable<FloatArray>): void;
  22189. /**
  22190. * Gets the position data stored in this target
  22191. * @returns a FloatArray containing the position data (or null if not present)
  22192. */
  22193. getPositions(): Nullable<FloatArray>;
  22194. /**
  22195. * Affects normal data to this target
  22196. * @param data defines the normal data to use
  22197. */
  22198. setNormals(data: Nullable<FloatArray>): void;
  22199. /**
  22200. * Gets the normal data stored in this target
  22201. * @returns a FloatArray containing the normal data (or null if not present)
  22202. */
  22203. getNormals(): Nullable<FloatArray>;
  22204. /**
  22205. * Affects tangent data to this target
  22206. * @param data defines the tangent data to use
  22207. */
  22208. setTangents(data: Nullable<FloatArray>): void;
  22209. /**
  22210. * Gets the tangent data stored in this target
  22211. * @returns a FloatArray containing the tangent data (or null if not present)
  22212. */
  22213. getTangents(): Nullable<FloatArray>;
  22214. /**
  22215. * Affects texture coordinates data to this target
  22216. * @param data defines the texture coordinates data to use
  22217. */
  22218. setUVs(data: Nullable<FloatArray>): void;
  22219. /**
  22220. * Gets the texture coordinates data stored in this target
  22221. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22222. */
  22223. getUVs(): Nullable<FloatArray>;
  22224. /**
  22225. * Clone the current target
  22226. * @returns a new MorphTarget
  22227. */
  22228. clone(): MorphTarget;
  22229. /**
  22230. * Serializes the current target into a Serialization object
  22231. * @returns the serialized object
  22232. */
  22233. serialize(): any;
  22234. /**
  22235. * Returns the string "MorphTarget"
  22236. * @returns "MorphTarget"
  22237. */
  22238. getClassName(): string;
  22239. /**
  22240. * Creates a new target from serialized data
  22241. * @param serializationObject defines the serialized data to use
  22242. * @returns a new MorphTarget
  22243. */
  22244. static Parse(serializationObject: any): MorphTarget;
  22245. /**
  22246. * Creates a MorphTarget from mesh data
  22247. * @param mesh defines the source mesh
  22248. * @param name defines the name to use for the new target
  22249. * @param influence defines the influence to attach to the target
  22250. * @returns a new MorphTarget
  22251. */
  22252. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22253. }
  22254. }
  22255. declare module BABYLON {
  22256. /**
  22257. * This class is used to deform meshes using morphing between different targets
  22258. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22259. */
  22260. export class MorphTargetManager {
  22261. private _targets;
  22262. private _targetInfluenceChangedObservers;
  22263. private _targetDataLayoutChangedObservers;
  22264. private _activeTargets;
  22265. private _scene;
  22266. private _influences;
  22267. private _supportsNormals;
  22268. private _supportsTangents;
  22269. private _supportsUVs;
  22270. private _vertexCount;
  22271. private _uniqueId;
  22272. private _tempInfluences;
  22273. /**
  22274. * Gets or sets a boolean indicating if normals must be morphed
  22275. */
  22276. enableNormalMorphing: boolean;
  22277. /**
  22278. * Gets or sets a boolean indicating if tangents must be morphed
  22279. */
  22280. enableTangentMorphing: boolean;
  22281. /**
  22282. * Gets or sets a boolean indicating if UV must be morphed
  22283. */
  22284. enableUVMorphing: boolean;
  22285. /**
  22286. * Creates a new MorphTargetManager
  22287. * @param scene defines the current scene
  22288. */
  22289. constructor(scene?: Nullable<Scene>);
  22290. /**
  22291. * Gets the unique ID of this manager
  22292. */
  22293. readonly uniqueId: number;
  22294. /**
  22295. * Gets the number of vertices handled by this manager
  22296. */
  22297. readonly vertexCount: number;
  22298. /**
  22299. * Gets a boolean indicating if this manager supports morphing of normals
  22300. */
  22301. readonly supportsNormals: boolean;
  22302. /**
  22303. * Gets a boolean indicating if this manager supports morphing of tangents
  22304. */
  22305. readonly supportsTangents: boolean;
  22306. /**
  22307. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22308. */
  22309. readonly supportsUVs: boolean;
  22310. /**
  22311. * Gets the number of targets stored in this manager
  22312. */
  22313. readonly numTargets: number;
  22314. /**
  22315. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22316. */
  22317. readonly numInfluencers: number;
  22318. /**
  22319. * Gets the list of influences (one per target)
  22320. */
  22321. readonly influences: Float32Array;
  22322. /**
  22323. * Gets the active target at specified index. An active target is a target with an influence > 0
  22324. * @param index defines the index to check
  22325. * @returns the requested target
  22326. */
  22327. getActiveTarget(index: number): MorphTarget;
  22328. /**
  22329. * Gets the target at specified index
  22330. * @param index defines the index to check
  22331. * @returns the requested target
  22332. */
  22333. getTarget(index: number): MorphTarget;
  22334. /**
  22335. * Add a new target to this manager
  22336. * @param target defines the target to add
  22337. */
  22338. addTarget(target: MorphTarget): void;
  22339. /**
  22340. * Removes a target from the manager
  22341. * @param target defines the target to remove
  22342. */
  22343. removeTarget(target: MorphTarget): void;
  22344. /**
  22345. * Clone the current manager
  22346. * @returns a new MorphTargetManager
  22347. */
  22348. clone(): MorphTargetManager;
  22349. /**
  22350. * Serializes the current manager into a Serialization object
  22351. * @returns the serialized object
  22352. */
  22353. serialize(): any;
  22354. private _syncActiveTargets;
  22355. /**
  22356. * Syncrhonize the targets with all the meshes using this morph target manager
  22357. */
  22358. synchronize(): void;
  22359. /**
  22360. * Creates a new MorphTargetManager from serialized data
  22361. * @param serializationObject defines the serialized data
  22362. * @param scene defines the hosting scene
  22363. * @returns the new MorphTargetManager
  22364. */
  22365. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22366. }
  22367. }
  22368. declare module BABYLON {
  22369. /**
  22370. * Class used to represent a specific level of detail of a mesh
  22371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22372. */
  22373. export class MeshLODLevel {
  22374. /** Defines the distance where this level should start being displayed */
  22375. distance: number;
  22376. /** Defines the mesh to use to render this level */
  22377. mesh: Nullable<Mesh>;
  22378. /**
  22379. * Creates a new LOD level
  22380. * @param distance defines the distance where this level should star being displayed
  22381. * @param mesh defines the mesh to use to render this level
  22382. */
  22383. constructor(
  22384. /** Defines the distance where this level should start being displayed */
  22385. distance: number,
  22386. /** Defines the mesh to use to render this level */
  22387. mesh: Nullable<Mesh>);
  22388. }
  22389. }
  22390. declare module BABYLON {
  22391. /**
  22392. * Mesh representing the gorund
  22393. */
  22394. export class GroundMesh extends Mesh {
  22395. /** If octree should be generated */
  22396. generateOctree: boolean;
  22397. private _heightQuads;
  22398. /** @hidden */
  22399. _subdivisionsX: number;
  22400. /** @hidden */
  22401. _subdivisionsY: number;
  22402. /** @hidden */
  22403. _width: number;
  22404. /** @hidden */
  22405. _height: number;
  22406. /** @hidden */
  22407. _minX: number;
  22408. /** @hidden */
  22409. _maxX: number;
  22410. /** @hidden */
  22411. _minZ: number;
  22412. /** @hidden */
  22413. _maxZ: number;
  22414. constructor(name: string, scene: Scene);
  22415. /**
  22416. * "GroundMesh"
  22417. * @returns "GroundMesh"
  22418. */
  22419. getClassName(): string;
  22420. /**
  22421. * The minimum of x and y subdivisions
  22422. */
  22423. readonly subdivisions: number;
  22424. /**
  22425. * X subdivisions
  22426. */
  22427. readonly subdivisionsX: number;
  22428. /**
  22429. * Y subdivisions
  22430. */
  22431. readonly subdivisionsY: number;
  22432. /**
  22433. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22434. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22435. * @param chunksCount the number of subdivisions for x and y
  22436. * @param octreeBlocksSize (Default: 32)
  22437. */
  22438. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22439. /**
  22440. * Returns a height (y) value in the Worl system :
  22441. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22442. * @param x x coordinate
  22443. * @param z z coordinate
  22444. * @returns the ground y position if (x, z) are outside the ground surface.
  22445. */
  22446. getHeightAtCoordinates(x: number, z: number): number;
  22447. /**
  22448. * Returns a normalized vector (Vector3) orthogonal to the ground
  22449. * at the ground coordinates (x, z) expressed in the World system.
  22450. * @param x x coordinate
  22451. * @param z z coordinate
  22452. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22453. */
  22454. getNormalAtCoordinates(x: number, z: number): Vector3;
  22455. /**
  22456. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22457. * at the ground coordinates (x, z) expressed in the World system.
  22458. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22459. * @param x x coordinate
  22460. * @param z z coordinate
  22461. * @param ref vector to store the result
  22462. * @returns the GroundMesh.
  22463. */
  22464. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22465. /**
  22466. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22467. * if the ground has been updated.
  22468. * This can be used in the render loop.
  22469. * @returns the GroundMesh.
  22470. */
  22471. updateCoordinateHeights(): GroundMesh;
  22472. private _getFacetAt;
  22473. private _initHeightQuads;
  22474. private _computeHeightQuads;
  22475. /**
  22476. * Serializes this ground mesh
  22477. * @param serializationObject object to write serialization to
  22478. */
  22479. serialize(serializationObject: any): void;
  22480. /**
  22481. * Parses a serialized ground mesh
  22482. * @param parsedMesh the serialized mesh
  22483. * @param scene the scene to create the ground mesh in
  22484. * @returns the created ground mesh
  22485. */
  22486. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22487. }
  22488. }
  22489. declare module BABYLON {
  22490. /**
  22491. * Interface for Physics-Joint data
  22492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22493. */
  22494. export interface PhysicsJointData {
  22495. /**
  22496. * The main pivot of the joint
  22497. */
  22498. mainPivot?: Vector3;
  22499. /**
  22500. * The connected pivot of the joint
  22501. */
  22502. connectedPivot?: Vector3;
  22503. /**
  22504. * The main axis of the joint
  22505. */
  22506. mainAxis?: Vector3;
  22507. /**
  22508. * The connected axis of the joint
  22509. */
  22510. connectedAxis?: Vector3;
  22511. /**
  22512. * The collision of the joint
  22513. */
  22514. collision?: boolean;
  22515. /**
  22516. * Native Oimo/Cannon/Energy data
  22517. */
  22518. nativeParams?: any;
  22519. }
  22520. /**
  22521. * This is a holder class for the physics joint created by the physics plugin
  22522. * It holds a set of functions to control the underlying joint
  22523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22524. */
  22525. export class PhysicsJoint {
  22526. /**
  22527. * The type of the physics joint
  22528. */
  22529. type: number;
  22530. /**
  22531. * The data for the physics joint
  22532. */
  22533. jointData: PhysicsJointData;
  22534. private _physicsJoint;
  22535. protected _physicsPlugin: IPhysicsEnginePlugin;
  22536. /**
  22537. * Initializes the physics joint
  22538. * @param type The type of the physics joint
  22539. * @param jointData The data for the physics joint
  22540. */
  22541. constructor(
  22542. /**
  22543. * The type of the physics joint
  22544. */
  22545. type: number,
  22546. /**
  22547. * The data for the physics joint
  22548. */
  22549. jointData: PhysicsJointData);
  22550. /**
  22551. * Gets the physics joint
  22552. */
  22553. /**
  22554. * Sets the physics joint
  22555. */
  22556. physicsJoint: any;
  22557. /**
  22558. * Sets the physics plugin
  22559. */
  22560. physicsPlugin: IPhysicsEnginePlugin;
  22561. /**
  22562. * Execute a function that is physics-plugin specific.
  22563. * @param {Function} func the function that will be executed.
  22564. * It accepts two parameters: the physics world and the physics joint
  22565. */
  22566. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22567. /**
  22568. * Distance-Joint type
  22569. */
  22570. static DistanceJoint: number;
  22571. /**
  22572. * Hinge-Joint type
  22573. */
  22574. static HingeJoint: number;
  22575. /**
  22576. * Ball-and-Socket joint type
  22577. */
  22578. static BallAndSocketJoint: number;
  22579. /**
  22580. * Wheel-Joint type
  22581. */
  22582. static WheelJoint: number;
  22583. /**
  22584. * Slider-Joint type
  22585. */
  22586. static SliderJoint: number;
  22587. /**
  22588. * Prismatic-Joint type
  22589. */
  22590. static PrismaticJoint: number;
  22591. /**
  22592. * Universal-Joint type
  22593. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22594. */
  22595. static UniversalJoint: number;
  22596. /**
  22597. * Hinge-Joint 2 type
  22598. */
  22599. static Hinge2Joint: number;
  22600. /**
  22601. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22602. */
  22603. static PointToPointJoint: number;
  22604. /**
  22605. * Spring-Joint type
  22606. */
  22607. static SpringJoint: number;
  22608. /**
  22609. * Lock-Joint type
  22610. */
  22611. static LockJoint: number;
  22612. }
  22613. /**
  22614. * A class representing a physics distance joint
  22615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22616. */
  22617. export class DistanceJoint extends PhysicsJoint {
  22618. /**
  22619. *
  22620. * @param jointData The data for the Distance-Joint
  22621. */
  22622. constructor(jointData: DistanceJointData);
  22623. /**
  22624. * Update the predefined distance.
  22625. * @param maxDistance The maximum preferred distance
  22626. * @param minDistance The minimum preferred distance
  22627. */
  22628. updateDistance(maxDistance: number, minDistance?: number): void;
  22629. }
  22630. /**
  22631. * Represents a Motor-Enabled Joint
  22632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22633. */
  22634. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22635. /**
  22636. * Initializes the Motor-Enabled Joint
  22637. * @param type The type of the joint
  22638. * @param jointData The physica joint data for the joint
  22639. */
  22640. constructor(type: number, jointData: PhysicsJointData);
  22641. /**
  22642. * Set the motor values.
  22643. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22644. * @param force the force to apply
  22645. * @param maxForce max force for this motor.
  22646. */
  22647. setMotor(force?: number, maxForce?: number): void;
  22648. /**
  22649. * Set the motor's limits.
  22650. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22651. * @param upperLimit The upper limit of the motor
  22652. * @param lowerLimit The lower limit of the motor
  22653. */
  22654. setLimit(upperLimit: number, lowerLimit?: number): void;
  22655. }
  22656. /**
  22657. * This class represents a single physics Hinge-Joint
  22658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22659. */
  22660. export class HingeJoint extends MotorEnabledJoint {
  22661. /**
  22662. * Initializes the Hinge-Joint
  22663. * @param jointData The joint data for the Hinge-Joint
  22664. */
  22665. constructor(jointData: PhysicsJointData);
  22666. /**
  22667. * Set the motor values.
  22668. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22669. * @param {number} force the force to apply
  22670. * @param {number} maxForce max force for this motor.
  22671. */
  22672. setMotor(force?: number, maxForce?: number): void;
  22673. /**
  22674. * Set the motor's limits.
  22675. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22676. * @param upperLimit The upper limit of the motor
  22677. * @param lowerLimit The lower limit of the motor
  22678. */
  22679. setLimit(upperLimit: number, lowerLimit?: number): void;
  22680. }
  22681. /**
  22682. * This class represents a dual hinge physics joint (same as wheel joint)
  22683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22684. */
  22685. export class Hinge2Joint extends MotorEnabledJoint {
  22686. /**
  22687. * Initializes the Hinge2-Joint
  22688. * @param jointData The joint data for the Hinge2-Joint
  22689. */
  22690. constructor(jointData: PhysicsJointData);
  22691. /**
  22692. * Set the motor values.
  22693. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22694. * @param {number} targetSpeed the speed the motor is to reach
  22695. * @param {number} maxForce max force for this motor.
  22696. * @param {motorIndex} the motor's index, 0 or 1.
  22697. */
  22698. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22699. /**
  22700. * Set the motor limits.
  22701. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22702. * @param {number} upperLimit the upper limit
  22703. * @param {number} lowerLimit lower limit
  22704. * @param {motorIndex} the motor's index, 0 or 1.
  22705. */
  22706. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22707. }
  22708. /**
  22709. * Interface for a motor enabled joint
  22710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22711. */
  22712. export interface IMotorEnabledJoint {
  22713. /**
  22714. * Physics joint
  22715. */
  22716. physicsJoint: any;
  22717. /**
  22718. * Sets the motor of the motor-enabled joint
  22719. * @param force The force of the motor
  22720. * @param maxForce The maximum force of the motor
  22721. * @param motorIndex The index of the motor
  22722. */
  22723. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22724. /**
  22725. * Sets the limit of the motor
  22726. * @param upperLimit The upper limit of the motor
  22727. * @param lowerLimit The lower limit of the motor
  22728. * @param motorIndex The index of the motor
  22729. */
  22730. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22731. }
  22732. /**
  22733. * Joint data for a Distance-Joint
  22734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22735. */
  22736. export interface DistanceJointData extends PhysicsJointData {
  22737. /**
  22738. * Max distance the 2 joint objects can be apart
  22739. */
  22740. maxDistance: number;
  22741. }
  22742. /**
  22743. * Joint data from a spring joint
  22744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22745. */
  22746. export interface SpringJointData extends PhysicsJointData {
  22747. /**
  22748. * Length of the spring
  22749. */
  22750. length: number;
  22751. /**
  22752. * Stiffness of the spring
  22753. */
  22754. stiffness: number;
  22755. /**
  22756. * Damping of the spring
  22757. */
  22758. damping: number;
  22759. /** this callback will be called when applying the force to the impostors. */
  22760. forceApplicationCallback: () => void;
  22761. }
  22762. }
  22763. declare module BABYLON {
  22764. /**
  22765. * Holds the data for the raycast result
  22766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22767. */
  22768. export class PhysicsRaycastResult {
  22769. private _hasHit;
  22770. private _hitDistance;
  22771. private _hitNormalWorld;
  22772. private _hitPointWorld;
  22773. private _rayFromWorld;
  22774. private _rayToWorld;
  22775. /**
  22776. * Gets if there was a hit
  22777. */
  22778. readonly hasHit: boolean;
  22779. /**
  22780. * Gets the distance from the hit
  22781. */
  22782. readonly hitDistance: number;
  22783. /**
  22784. * Gets the hit normal/direction in the world
  22785. */
  22786. readonly hitNormalWorld: Vector3;
  22787. /**
  22788. * Gets the hit point in the world
  22789. */
  22790. readonly hitPointWorld: Vector3;
  22791. /**
  22792. * Gets the ray "start point" of the ray in the world
  22793. */
  22794. readonly rayFromWorld: Vector3;
  22795. /**
  22796. * Gets the ray "end point" of the ray in the world
  22797. */
  22798. readonly rayToWorld: Vector3;
  22799. /**
  22800. * Sets the hit data (normal & point in world space)
  22801. * @param hitNormalWorld defines the normal in world space
  22802. * @param hitPointWorld defines the point in world space
  22803. */
  22804. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22805. /**
  22806. * Sets the distance from the start point to the hit point
  22807. * @param distance
  22808. */
  22809. setHitDistance(distance: number): void;
  22810. /**
  22811. * Calculates the distance manually
  22812. */
  22813. calculateHitDistance(): void;
  22814. /**
  22815. * Resets all the values to default
  22816. * @param from The from point on world space
  22817. * @param to The to point on world space
  22818. */
  22819. reset(from?: Vector3, to?: Vector3): void;
  22820. }
  22821. /**
  22822. * Interface for the size containing width and height
  22823. */
  22824. interface IXYZ {
  22825. /**
  22826. * X
  22827. */
  22828. x: number;
  22829. /**
  22830. * Y
  22831. */
  22832. y: number;
  22833. /**
  22834. * Z
  22835. */
  22836. z: number;
  22837. }
  22838. }
  22839. declare module BABYLON {
  22840. /**
  22841. * Interface used to describe a physics joint
  22842. */
  22843. export interface PhysicsImpostorJoint {
  22844. /** Defines the main impostor to which the joint is linked */
  22845. mainImpostor: PhysicsImpostor;
  22846. /** Defines the impostor that is connected to the main impostor using this joint */
  22847. connectedImpostor: PhysicsImpostor;
  22848. /** Defines the joint itself */
  22849. joint: PhysicsJoint;
  22850. }
  22851. /** @hidden */
  22852. export interface IPhysicsEnginePlugin {
  22853. world: any;
  22854. name: string;
  22855. setGravity(gravity: Vector3): void;
  22856. setTimeStep(timeStep: number): void;
  22857. getTimeStep(): number;
  22858. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22859. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22860. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22861. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22862. removePhysicsBody(impostor: PhysicsImpostor): void;
  22863. generateJoint(joint: PhysicsImpostorJoint): void;
  22864. removeJoint(joint: PhysicsImpostorJoint): void;
  22865. isSupported(): boolean;
  22866. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22867. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22868. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22869. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22870. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22871. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22872. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22873. getBodyMass(impostor: PhysicsImpostor): number;
  22874. getBodyFriction(impostor: PhysicsImpostor): number;
  22875. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22876. getBodyRestitution(impostor: PhysicsImpostor): number;
  22877. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22878. getBodyPressure?(impostor: PhysicsImpostor): number;
  22879. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22880. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22881. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22882. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22883. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22884. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22885. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22886. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22887. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22888. sleepBody(impostor: PhysicsImpostor): void;
  22889. wakeUpBody(impostor: PhysicsImpostor): void;
  22890. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22891. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22892. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22893. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22894. getRadius(impostor: PhysicsImpostor): number;
  22895. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22896. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22897. dispose(): void;
  22898. }
  22899. /**
  22900. * Interface used to define a physics engine
  22901. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22902. */
  22903. export interface IPhysicsEngine {
  22904. /**
  22905. * Gets the gravity vector used by the simulation
  22906. */
  22907. gravity: Vector3;
  22908. /**
  22909. * Sets the gravity vector used by the simulation
  22910. * @param gravity defines the gravity vector to use
  22911. */
  22912. setGravity(gravity: Vector3): void;
  22913. /**
  22914. * Set the time step of the physics engine.
  22915. * Default is 1/60.
  22916. * To slow it down, enter 1/600 for example.
  22917. * To speed it up, 1/30
  22918. * @param newTimeStep the new timestep to apply to this world.
  22919. */
  22920. setTimeStep(newTimeStep: number): void;
  22921. /**
  22922. * Get the time step of the physics engine.
  22923. * @returns the current time step
  22924. */
  22925. getTimeStep(): number;
  22926. /**
  22927. * Release all resources
  22928. */
  22929. dispose(): void;
  22930. /**
  22931. * Gets the name of the current physics plugin
  22932. * @returns the name of the plugin
  22933. */
  22934. getPhysicsPluginName(): string;
  22935. /**
  22936. * Adding a new impostor for the impostor tracking.
  22937. * This will be done by the impostor itself.
  22938. * @param impostor the impostor to add
  22939. */
  22940. addImpostor(impostor: PhysicsImpostor): void;
  22941. /**
  22942. * Remove an impostor from the engine.
  22943. * This impostor and its mesh will not longer be updated by the physics engine.
  22944. * @param impostor the impostor to remove
  22945. */
  22946. removeImpostor(impostor: PhysicsImpostor): void;
  22947. /**
  22948. * Add a joint to the physics engine
  22949. * @param mainImpostor defines the main impostor to which the joint is added.
  22950. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22951. * @param joint defines the joint that will connect both impostors.
  22952. */
  22953. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22954. /**
  22955. * Removes a joint from the simulation
  22956. * @param mainImpostor defines the impostor used with the joint
  22957. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22958. * @param joint defines the joint to remove
  22959. */
  22960. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22961. /**
  22962. * Gets the current plugin used to run the simulation
  22963. * @returns current plugin
  22964. */
  22965. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22966. /**
  22967. * Gets the list of physic impostors
  22968. * @returns an array of PhysicsImpostor
  22969. */
  22970. getImpostors(): Array<PhysicsImpostor>;
  22971. /**
  22972. * Gets the impostor for a physics enabled object
  22973. * @param object defines the object impersonated by the impostor
  22974. * @returns the PhysicsImpostor or null if not found
  22975. */
  22976. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22977. /**
  22978. * Gets the impostor for a physics body object
  22979. * @param body defines physics body used by the impostor
  22980. * @returns the PhysicsImpostor or null if not found
  22981. */
  22982. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22983. /**
  22984. * Does a raycast in the physics world
  22985. * @param from when should the ray start?
  22986. * @param to when should the ray end?
  22987. * @returns PhysicsRaycastResult
  22988. */
  22989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22990. /**
  22991. * Called by the scene. No need to call it.
  22992. * @param delta defines the timespam between frames
  22993. */
  22994. _step(delta: number): void;
  22995. }
  22996. }
  22997. declare module BABYLON {
  22998. /**
  22999. * The interface for the physics imposter parameters
  23000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23001. */
  23002. export interface PhysicsImpostorParameters {
  23003. /**
  23004. * The mass of the physics imposter
  23005. */
  23006. mass: number;
  23007. /**
  23008. * The friction of the physics imposter
  23009. */
  23010. friction?: number;
  23011. /**
  23012. * The coefficient of restitution of the physics imposter
  23013. */
  23014. restitution?: number;
  23015. /**
  23016. * The native options of the physics imposter
  23017. */
  23018. nativeOptions?: any;
  23019. /**
  23020. * Specifies if the parent should be ignored
  23021. */
  23022. ignoreParent?: boolean;
  23023. /**
  23024. * Specifies if bi-directional transformations should be disabled
  23025. */
  23026. disableBidirectionalTransformation?: boolean;
  23027. /**
  23028. * The pressure inside the physics imposter, soft object only
  23029. */
  23030. pressure?: number;
  23031. /**
  23032. * The stiffness the physics imposter, soft object only
  23033. */
  23034. stiffness?: number;
  23035. /**
  23036. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23037. */
  23038. velocityIterations?: number;
  23039. /**
  23040. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23041. */
  23042. positionIterations?: number;
  23043. /**
  23044. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23045. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23046. * Add to fix multiple points
  23047. */
  23048. fixedPoints?: number;
  23049. /**
  23050. * The collision margin around a soft object
  23051. */
  23052. margin?: number;
  23053. /**
  23054. * The collision margin around a soft object
  23055. */
  23056. damping?: number;
  23057. /**
  23058. * The path for a rope based on an extrusion
  23059. */
  23060. path?: any;
  23061. /**
  23062. * The shape of an extrusion used for a rope based on an extrusion
  23063. */
  23064. shape?: any;
  23065. }
  23066. /**
  23067. * Interface for a physics-enabled object
  23068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23069. */
  23070. export interface IPhysicsEnabledObject {
  23071. /**
  23072. * The position of the physics-enabled object
  23073. */
  23074. position: Vector3;
  23075. /**
  23076. * The rotation of the physics-enabled object
  23077. */
  23078. rotationQuaternion: Nullable<Quaternion>;
  23079. /**
  23080. * The scale of the physics-enabled object
  23081. */
  23082. scaling: Vector3;
  23083. /**
  23084. * The rotation of the physics-enabled object
  23085. */
  23086. rotation?: Vector3;
  23087. /**
  23088. * The parent of the physics-enabled object
  23089. */
  23090. parent?: any;
  23091. /**
  23092. * The bounding info of the physics-enabled object
  23093. * @returns The bounding info of the physics-enabled object
  23094. */
  23095. getBoundingInfo(): BoundingInfo;
  23096. /**
  23097. * Computes the world matrix
  23098. * @param force Specifies if the world matrix should be computed by force
  23099. * @returns A world matrix
  23100. */
  23101. computeWorldMatrix(force: boolean): Matrix;
  23102. /**
  23103. * Gets the world matrix
  23104. * @returns A world matrix
  23105. */
  23106. getWorldMatrix?(): Matrix;
  23107. /**
  23108. * Gets the child meshes
  23109. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23110. * @returns An array of abstract meshes
  23111. */
  23112. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23113. /**
  23114. * Gets the vertex data
  23115. * @param kind The type of vertex data
  23116. * @returns A nullable array of numbers, or a float32 array
  23117. */
  23118. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23119. /**
  23120. * Gets the indices from the mesh
  23121. * @returns A nullable array of index arrays
  23122. */
  23123. getIndices?(): Nullable<IndicesArray>;
  23124. /**
  23125. * Gets the scene from the mesh
  23126. * @returns the indices array or null
  23127. */
  23128. getScene?(): Scene;
  23129. /**
  23130. * Gets the absolute position from the mesh
  23131. * @returns the absolute position
  23132. */
  23133. getAbsolutePosition(): Vector3;
  23134. /**
  23135. * Gets the absolute pivot point from the mesh
  23136. * @returns the absolute pivot point
  23137. */
  23138. getAbsolutePivotPoint(): Vector3;
  23139. /**
  23140. * Rotates the mesh
  23141. * @param axis The axis of rotation
  23142. * @param amount The amount of rotation
  23143. * @param space The space of the rotation
  23144. * @returns The rotation transform node
  23145. */
  23146. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23147. /**
  23148. * Translates the mesh
  23149. * @param axis The axis of translation
  23150. * @param distance The distance of translation
  23151. * @param space The space of the translation
  23152. * @returns The transform node
  23153. */
  23154. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23155. /**
  23156. * Sets the absolute position of the mesh
  23157. * @param absolutePosition The absolute position of the mesh
  23158. * @returns The transform node
  23159. */
  23160. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23161. /**
  23162. * Gets the class name of the mesh
  23163. * @returns The class name
  23164. */
  23165. getClassName(): string;
  23166. }
  23167. /**
  23168. * Represents a physics imposter
  23169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23170. */
  23171. export class PhysicsImpostor {
  23172. /**
  23173. * The physics-enabled object used as the physics imposter
  23174. */
  23175. object: IPhysicsEnabledObject;
  23176. /**
  23177. * The type of the physics imposter
  23178. */
  23179. type: number;
  23180. private _options;
  23181. private _scene?;
  23182. /**
  23183. * The default object size of the imposter
  23184. */
  23185. static DEFAULT_OBJECT_SIZE: Vector3;
  23186. /**
  23187. * The identity quaternion of the imposter
  23188. */
  23189. static IDENTITY_QUATERNION: Quaternion;
  23190. /** @hidden */
  23191. _pluginData: any;
  23192. private _physicsEngine;
  23193. private _physicsBody;
  23194. private _bodyUpdateRequired;
  23195. private _onBeforePhysicsStepCallbacks;
  23196. private _onAfterPhysicsStepCallbacks;
  23197. /** @hidden */
  23198. _onPhysicsCollideCallbacks: Array<{
  23199. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23200. otherImpostors: Array<PhysicsImpostor>;
  23201. }>;
  23202. private _deltaPosition;
  23203. private _deltaRotation;
  23204. private _deltaRotationConjugated;
  23205. /** @hidden */
  23206. _isFromLine: boolean;
  23207. private _parent;
  23208. private _isDisposed;
  23209. private static _tmpVecs;
  23210. private static _tmpQuat;
  23211. /**
  23212. * Specifies if the physics imposter is disposed
  23213. */
  23214. readonly isDisposed: boolean;
  23215. /**
  23216. * Gets the mass of the physics imposter
  23217. */
  23218. mass: number;
  23219. /**
  23220. * Gets the coefficient of friction
  23221. */
  23222. /**
  23223. * Sets the coefficient of friction
  23224. */
  23225. friction: number;
  23226. /**
  23227. * Gets the coefficient of restitution
  23228. */
  23229. /**
  23230. * Sets the coefficient of restitution
  23231. */
  23232. restitution: number;
  23233. /**
  23234. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23235. */
  23236. /**
  23237. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23238. */
  23239. pressure: number;
  23240. /**
  23241. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23242. */
  23243. /**
  23244. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23245. */
  23246. stiffness: number;
  23247. /**
  23248. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23249. */
  23250. /**
  23251. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23252. */
  23253. velocityIterations: number;
  23254. /**
  23255. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23256. */
  23257. /**
  23258. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23259. */
  23260. positionIterations: number;
  23261. /**
  23262. * The unique id of the physics imposter
  23263. * set by the physics engine when adding this impostor to the array
  23264. */
  23265. uniqueId: number;
  23266. /**
  23267. * @hidden
  23268. */
  23269. soft: boolean;
  23270. /**
  23271. * @hidden
  23272. */
  23273. segments: number;
  23274. private _joints;
  23275. /**
  23276. * Initializes the physics imposter
  23277. * @param object The physics-enabled object used as the physics imposter
  23278. * @param type The type of the physics imposter
  23279. * @param _options The options for the physics imposter
  23280. * @param _scene The Babylon scene
  23281. */
  23282. constructor(
  23283. /**
  23284. * The physics-enabled object used as the physics imposter
  23285. */
  23286. object: IPhysicsEnabledObject,
  23287. /**
  23288. * The type of the physics imposter
  23289. */
  23290. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23291. /**
  23292. * This function will completly initialize this impostor.
  23293. * It will create a new body - but only if this mesh has no parent.
  23294. * If it has, this impostor will not be used other than to define the impostor
  23295. * of the child mesh.
  23296. * @hidden
  23297. */
  23298. _init(): void;
  23299. private _getPhysicsParent;
  23300. /**
  23301. * Should a new body be generated.
  23302. * @returns boolean specifying if body initialization is required
  23303. */
  23304. isBodyInitRequired(): boolean;
  23305. /**
  23306. * Sets the updated scaling
  23307. * @param updated Specifies if the scaling is updated
  23308. */
  23309. setScalingUpdated(): void;
  23310. /**
  23311. * Force a regeneration of this or the parent's impostor's body.
  23312. * Use under cautious - This will remove all joints already implemented.
  23313. */
  23314. forceUpdate(): void;
  23315. /**
  23316. * Gets the body that holds this impostor. Either its own, or its parent.
  23317. */
  23318. /**
  23319. * Set the physics body. Used mainly by the physics engine/plugin
  23320. */
  23321. physicsBody: any;
  23322. /**
  23323. * Get the parent of the physics imposter
  23324. * @returns Physics imposter or null
  23325. */
  23326. /**
  23327. * Sets the parent of the physics imposter
  23328. */
  23329. parent: Nullable<PhysicsImpostor>;
  23330. /**
  23331. * Resets the update flags
  23332. */
  23333. resetUpdateFlags(): void;
  23334. /**
  23335. * Gets the object extend size
  23336. * @returns the object extend size
  23337. */
  23338. getObjectExtendSize(): Vector3;
  23339. /**
  23340. * Gets the object center
  23341. * @returns The object center
  23342. */
  23343. getObjectCenter(): Vector3;
  23344. /**
  23345. * Get a specific parametes from the options parameter
  23346. * @param paramName The object parameter name
  23347. * @returns The object parameter
  23348. */
  23349. getParam(paramName: string): any;
  23350. /**
  23351. * Sets a specific parameter in the options given to the physics plugin
  23352. * @param paramName The parameter name
  23353. * @param value The value of the parameter
  23354. */
  23355. setParam(paramName: string, value: number): void;
  23356. /**
  23357. * Specifically change the body's mass option. Won't recreate the physics body object
  23358. * @param mass The mass of the physics imposter
  23359. */
  23360. setMass(mass: number): void;
  23361. /**
  23362. * Gets the linear velocity
  23363. * @returns linear velocity or null
  23364. */
  23365. getLinearVelocity(): Nullable<Vector3>;
  23366. /**
  23367. * Sets the linear velocity
  23368. * @param velocity linear velocity or null
  23369. */
  23370. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23371. /**
  23372. * Gets the angular velocity
  23373. * @returns angular velocity or null
  23374. */
  23375. getAngularVelocity(): Nullable<Vector3>;
  23376. /**
  23377. * Sets the angular velocity
  23378. * @param velocity The velocity or null
  23379. */
  23380. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23381. /**
  23382. * Execute a function with the physics plugin native code
  23383. * Provide a function the will have two variables - the world object and the physics body object
  23384. * @param func The function to execute with the physics plugin native code
  23385. */
  23386. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23387. /**
  23388. * Register a function that will be executed before the physics world is stepping forward
  23389. * @param func The function to execute before the physics world is stepped forward
  23390. */
  23391. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23392. /**
  23393. * Unregister a function that will be executed before the physics world is stepping forward
  23394. * @param func The function to execute before the physics world is stepped forward
  23395. */
  23396. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23397. /**
  23398. * Register a function that will be executed after the physics step
  23399. * @param func The function to execute after physics step
  23400. */
  23401. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23402. /**
  23403. * Unregisters a function that will be executed after the physics step
  23404. * @param func The function to execute after physics step
  23405. */
  23406. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23407. /**
  23408. * register a function that will be executed when this impostor collides against a different body
  23409. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23410. * @param func Callback that is executed on collision
  23411. */
  23412. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23413. /**
  23414. * Unregisters the physics imposter on contact
  23415. * @param collideAgainst The physics object to collide against
  23416. * @param func Callback to execute on collision
  23417. */
  23418. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23419. private _tmpQuat;
  23420. private _tmpQuat2;
  23421. /**
  23422. * Get the parent rotation
  23423. * @returns The parent rotation
  23424. */
  23425. getParentsRotation(): Quaternion;
  23426. /**
  23427. * this function is executed by the physics engine.
  23428. */
  23429. beforeStep: () => void;
  23430. /**
  23431. * this function is executed by the physics engine
  23432. */
  23433. afterStep: () => void;
  23434. /**
  23435. * Legacy collision detection event support
  23436. */
  23437. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23438. /**
  23439. * event and body object due to cannon's event-based architecture.
  23440. */
  23441. onCollide: (e: {
  23442. body: any;
  23443. }) => void;
  23444. /**
  23445. * Apply a force
  23446. * @param force The force to apply
  23447. * @param contactPoint The contact point for the force
  23448. * @returns The physics imposter
  23449. */
  23450. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23451. /**
  23452. * Apply an impulse
  23453. * @param force The impulse force
  23454. * @param contactPoint The contact point for the impulse force
  23455. * @returns The physics imposter
  23456. */
  23457. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23458. /**
  23459. * A help function to create a joint
  23460. * @param otherImpostor A physics imposter used to create a joint
  23461. * @param jointType The type of joint
  23462. * @param jointData The data for the joint
  23463. * @returns The physics imposter
  23464. */
  23465. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23466. /**
  23467. * Add a joint to this impostor with a different impostor
  23468. * @param otherImpostor A physics imposter used to add a joint
  23469. * @param joint The joint to add
  23470. * @returns The physics imposter
  23471. */
  23472. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23473. /**
  23474. * Add an anchor to a cloth impostor
  23475. * @param otherImpostor rigid impostor to anchor to
  23476. * @param width ratio across width from 0 to 1
  23477. * @param height ratio up height from 0 to 1
  23478. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23479. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23480. * @returns impostor the soft imposter
  23481. */
  23482. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23483. /**
  23484. * Add a hook to a rope impostor
  23485. * @param otherImpostor rigid impostor to anchor to
  23486. * @param length ratio across rope from 0 to 1
  23487. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23488. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23489. * @returns impostor the rope imposter
  23490. */
  23491. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23492. /**
  23493. * Will keep this body still, in a sleep mode.
  23494. * @returns the physics imposter
  23495. */
  23496. sleep(): PhysicsImpostor;
  23497. /**
  23498. * Wake the body up.
  23499. * @returns The physics imposter
  23500. */
  23501. wakeUp(): PhysicsImpostor;
  23502. /**
  23503. * Clones the physics imposter
  23504. * @param newObject The physics imposter clones to this physics-enabled object
  23505. * @returns A nullable physics imposter
  23506. */
  23507. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23508. /**
  23509. * Disposes the physics imposter
  23510. */
  23511. dispose(): void;
  23512. /**
  23513. * Sets the delta position
  23514. * @param position The delta position amount
  23515. */
  23516. setDeltaPosition(position: Vector3): void;
  23517. /**
  23518. * Sets the delta rotation
  23519. * @param rotation The delta rotation amount
  23520. */
  23521. setDeltaRotation(rotation: Quaternion): void;
  23522. /**
  23523. * Gets the box size of the physics imposter and stores the result in the input parameter
  23524. * @param result Stores the box size
  23525. * @returns The physics imposter
  23526. */
  23527. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23528. /**
  23529. * Gets the radius of the physics imposter
  23530. * @returns Radius of the physics imposter
  23531. */
  23532. getRadius(): number;
  23533. /**
  23534. * Sync a bone with this impostor
  23535. * @param bone The bone to sync to the impostor.
  23536. * @param boneMesh The mesh that the bone is influencing.
  23537. * @param jointPivot The pivot of the joint / bone in local space.
  23538. * @param distToJoint Optional distance from the impostor to the joint.
  23539. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23540. */
  23541. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23542. /**
  23543. * Sync impostor to a bone
  23544. * @param bone The bone that the impostor will be synced to.
  23545. * @param boneMesh The mesh that the bone is influencing.
  23546. * @param jointPivot The pivot of the joint / bone in local space.
  23547. * @param distToJoint Optional distance from the impostor to the joint.
  23548. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23549. * @param boneAxis Optional vector3 axis the bone is aligned with
  23550. */
  23551. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23552. /**
  23553. * No-Imposter type
  23554. */
  23555. static NoImpostor: number;
  23556. /**
  23557. * Sphere-Imposter type
  23558. */
  23559. static SphereImpostor: number;
  23560. /**
  23561. * Box-Imposter type
  23562. */
  23563. static BoxImpostor: number;
  23564. /**
  23565. * Plane-Imposter type
  23566. */
  23567. static PlaneImpostor: number;
  23568. /**
  23569. * Mesh-imposter type
  23570. */
  23571. static MeshImpostor: number;
  23572. /**
  23573. * Capsule-Impostor type (Ammo.js plugin only)
  23574. */
  23575. static CapsuleImpostor: number;
  23576. /**
  23577. * Cylinder-Imposter type
  23578. */
  23579. static CylinderImpostor: number;
  23580. /**
  23581. * Particle-Imposter type
  23582. */
  23583. static ParticleImpostor: number;
  23584. /**
  23585. * Heightmap-Imposter type
  23586. */
  23587. static HeightmapImpostor: number;
  23588. /**
  23589. * ConvexHull-Impostor type (Ammo.js plugin only)
  23590. */
  23591. static ConvexHullImpostor: number;
  23592. /**
  23593. * Rope-Imposter type
  23594. */
  23595. static RopeImpostor: number;
  23596. /**
  23597. * Cloth-Imposter type
  23598. */
  23599. static ClothImpostor: number;
  23600. /**
  23601. * Softbody-Imposter type
  23602. */
  23603. static SoftbodyImpostor: number;
  23604. }
  23605. }
  23606. declare module BABYLON {
  23607. /**
  23608. * @hidden
  23609. **/
  23610. export class _CreationDataStorage {
  23611. closePath?: boolean;
  23612. closeArray?: boolean;
  23613. idx: number[];
  23614. dashSize: number;
  23615. gapSize: number;
  23616. path3D: Path3D;
  23617. pathArray: Vector3[][];
  23618. arc: number;
  23619. radius: number;
  23620. cap: number;
  23621. tessellation: number;
  23622. }
  23623. /**
  23624. * @hidden
  23625. **/
  23626. class _InstanceDataStorage {
  23627. visibleInstances: any;
  23628. batchCache: _InstancesBatch;
  23629. instancesBufferSize: number;
  23630. instancesBuffer: Nullable<Buffer>;
  23631. instancesData: Float32Array;
  23632. overridenInstanceCount: number;
  23633. isFrozen: boolean;
  23634. previousBatch: Nullable<_InstancesBatch>;
  23635. hardwareInstancedRendering: boolean;
  23636. sideOrientation: number;
  23637. }
  23638. /**
  23639. * @hidden
  23640. **/
  23641. export class _InstancesBatch {
  23642. mustReturn: boolean;
  23643. visibleInstances: Nullable<InstancedMesh[]>[];
  23644. renderSelf: boolean[];
  23645. hardwareInstancedRendering: boolean[];
  23646. }
  23647. /**
  23648. * Class used to represent renderable models
  23649. */
  23650. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23651. /**
  23652. * Mesh side orientation : usually the external or front surface
  23653. */
  23654. static readonly FRONTSIDE: number;
  23655. /**
  23656. * Mesh side orientation : usually the internal or back surface
  23657. */
  23658. static readonly BACKSIDE: number;
  23659. /**
  23660. * Mesh side orientation : both internal and external or front and back surfaces
  23661. */
  23662. static readonly DOUBLESIDE: number;
  23663. /**
  23664. * Mesh side orientation : by default, `FRONTSIDE`
  23665. */
  23666. static readonly DEFAULTSIDE: number;
  23667. /**
  23668. * Mesh cap setting : no cap
  23669. */
  23670. static readonly NO_CAP: number;
  23671. /**
  23672. * Mesh cap setting : one cap at the beginning of the mesh
  23673. */
  23674. static readonly CAP_START: number;
  23675. /**
  23676. * Mesh cap setting : one cap at the end of the mesh
  23677. */
  23678. static readonly CAP_END: number;
  23679. /**
  23680. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23681. */
  23682. static readonly CAP_ALL: number;
  23683. /**
  23684. * Mesh pattern setting : no flip or rotate
  23685. */
  23686. static readonly NO_FLIP: number;
  23687. /**
  23688. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23689. */
  23690. static readonly FLIP_TILE: number;
  23691. /**
  23692. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23693. */
  23694. static readonly ROTATE_TILE: number;
  23695. /**
  23696. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23697. */
  23698. static readonly FLIP_ROW: number;
  23699. /**
  23700. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23701. */
  23702. static readonly ROTATE_ROW: number;
  23703. /**
  23704. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23705. */
  23706. static readonly FLIP_N_ROTATE_TILE: number;
  23707. /**
  23708. * Mesh pattern setting : rotate pattern and rotate
  23709. */
  23710. static readonly FLIP_N_ROTATE_ROW: number;
  23711. /**
  23712. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23713. */
  23714. static readonly CENTER: number;
  23715. /**
  23716. * Mesh tile positioning : part tiles on left
  23717. */
  23718. static readonly LEFT: number;
  23719. /**
  23720. * Mesh tile positioning : part tiles on right
  23721. */
  23722. static readonly RIGHT: number;
  23723. /**
  23724. * Mesh tile positioning : part tiles on top
  23725. */
  23726. static readonly TOP: number;
  23727. /**
  23728. * Mesh tile positioning : part tiles on bottom
  23729. */
  23730. static readonly BOTTOM: number;
  23731. /**
  23732. * Gets the default side orientation.
  23733. * @param orientation the orientation to value to attempt to get
  23734. * @returns the default orientation
  23735. * @hidden
  23736. */
  23737. static _GetDefaultSideOrientation(orientation?: number): number;
  23738. private _internalMeshDataInfo;
  23739. /**
  23740. * An event triggered before rendering the mesh
  23741. */
  23742. readonly onBeforeRenderObservable: Observable<Mesh>;
  23743. /**
  23744. * An event triggered before binding the mesh
  23745. */
  23746. readonly onBeforeBindObservable: Observable<Mesh>;
  23747. /**
  23748. * An event triggered after rendering the mesh
  23749. */
  23750. readonly onAfterRenderObservable: Observable<Mesh>;
  23751. /**
  23752. * An event triggered before drawing the mesh
  23753. */
  23754. readonly onBeforeDrawObservable: Observable<Mesh>;
  23755. private _onBeforeDrawObserver;
  23756. /**
  23757. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23758. */
  23759. onBeforeDraw: () => void;
  23760. readonly hasInstances: boolean;
  23761. /**
  23762. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23763. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23764. */
  23765. delayLoadState: number;
  23766. /**
  23767. * Gets the list of instances created from this mesh
  23768. * it is not supposed to be modified manually.
  23769. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23770. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23771. */
  23772. instances: InstancedMesh[];
  23773. /**
  23774. * Gets the file containing delay loading data for this mesh
  23775. */
  23776. delayLoadingFile: string;
  23777. /** @hidden */
  23778. _binaryInfo: any;
  23779. /**
  23780. * User defined function used to change how LOD level selection is done
  23781. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23782. */
  23783. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23784. /**
  23785. * Gets or sets the morph target manager
  23786. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23787. */
  23788. morphTargetManager: Nullable<MorphTargetManager>;
  23789. /** @hidden */
  23790. _creationDataStorage: Nullable<_CreationDataStorage>;
  23791. /** @hidden */
  23792. _geometry: Nullable<Geometry>;
  23793. /** @hidden */
  23794. _delayInfo: Array<string>;
  23795. /** @hidden */
  23796. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23797. /** @hidden */
  23798. _instanceDataStorage: _InstanceDataStorage;
  23799. private _effectiveMaterial;
  23800. /** @hidden */
  23801. _shouldGenerateFlatShading: boolean;
  23802. /** @hidden */
  23803. _originalBuilderSideOrientation: number;
  23804. /**
  23805. * Use this property to change the original side orientation defined at construction time
  23806. */
  23807. overrideMaterialSideOrientation: Nullable<number>;
  23808. /**
  23809. * Gets the source mesh (the one used to clone this one from)
  23810. */
  23811. readonly source: Nullable<Mesh>;
  23812. /**
  23813. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23814. */
  23815. isUnIndexed: boolean;
  23816. /**
  23817. * @constructor
  23818. * @param name The value used by scene.getMeshByName() to do a lookup.
  23819. * @param scene The scene to add this mesh to.
  23820. * @param parent The parent of this mesh, if it has one
  23821. * @param source An optional Mesh from which geometry is shared, cloned.
  23822. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23823. * When false, achieved by calling a clone(), also passing False.
  23824. * This will make creation of children, recursive.
  23825. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23826. */
  23827. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23828. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23829. doNotInstantiate: boolean;
  23830. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23831. /**
  23832. * Gets the class name
  23833. * @returns the string "Mesh".
  23834. */
  23835. getClassName(): string;
  23836. /** @hidden */
  23837. readonly _isMesh: boolean;
  23838. /**
  23839. * Returns a description of this mesh
  23840. * @param fullDetails define if full details about this mesh must be used
  23841. * @returns a descriptive string representing this mesh
  23842. */
  23843. toString(fullDetails?: boolean): string;
  23844. /** @hidden */
  23845. _unBindEffect(): void;
  23846. /**
  23847. * Gets a boolean indicating if this mesh has LOD
  23848. */
  23849. readonly hasLODLevels: boolean;
  23850. /**
  23851. * Gets the list of MeshLODLevel associated with the current mesh
  23852. * @returns an array of MeshLODLevel
  23853. */
  23854. getLODLevels(): MeshLODLevel[];
  23855. private _sortLODLevels;
  23856. /**
  23857. * Add a mesh as LOD level triggered at the given distance.
  23858. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23859. * @param distance The distance from the center of the object to show this level
  23860. * @param mesh The mesh to be added as LOD level (can be null)
  23861. * @return This mesh (for chaining)
  23862. */
  23863. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23864. /**
  23865. * Returns the LOD level mesh at the passed distance or null if not found.
  23866. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23867. * @param distance The distance from the center of the object to show this level
  23868. * @returns a Mesh or `null`
  23869. */
  23870. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23871. /**
  23872. * Remove a mesh from the LOD array
  23873. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23874. * @param mesh defines the mesh to be removed
  23875. * @return This mesh (for chaining)
  23876. */
  23877. removeLODLevel(mesh: Mesh): Mesh;
  23878. /**
  23879. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23880. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23881. * @param camera defines the camera to use to compute distance
  23882. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23883. * @return This mesh (for chaining)
  23884. */
  23885. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23886. /**
  23887. * Gets the mesh internal Geometry object
  23888. */
  23889. readonly geometry: Nullable<Geometry>;
  23890. /**
  23891. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23892. * @returns the total number of vertices
  23893. */
  23894. getTotalVertices(): number;
  23895. /**
  23896. * Returns the content of an associated vertex buffer
  23897. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23898. * - VertexBuffer.PositionKind
  23899. * - VertexBuffer.UVKind
  23900. * - VertexBuffer.UV2Kind
  23901. * - VertexBuffer.UV3Kind
  23902. * - VertexBuffer.UV4Kind
  23903. * - VertexBuffer.UV5Kind
  23904. * - VertexBuffer.UV6Kind
  23905. * - VertexBuffer.ColorKind
  23906. * - VertexBuffer.MatricesIndicesKind
  23907. * - VertexBuffer.MatricesIndicesExtraKind
  23908. * - VertexBuffer.MatricesWeightsKind
  23909. * - VertexBuffer.MatricesWeightsExtraKind
  23910. * @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
  23911. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23912. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23913. */
  23914. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23915. /**
  23916. * Returns the mesh VertexBuffer object from the requested `kind`
  23917. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23918. * - VertexBuffer.PositionKind
  23919. * - VertexBuffer.NormalKind
  23920. * - VertexBuffer.UVKind
  23921. * - VertexBuffer.UV2Kind
  23922. * - VertexBuffer.UV3Kind
  23923. * - VertexBuffer.UV4Kind
  23924. * - VertexBuffer.UV5Kind
  23925. * - VertexBuffer.UV6Kind
  23926. * - VertexBuffer.ColorKind
  23927. * - VertexBuffer.MatricesIndicesKind
  23928. * - VertexBuffer.MatricesIndicesExtraKind
  23929. * - VertexBuffer.MatricesWeightsKind
  23930. * - VertexBuffer.MatricesWeightsExtraKind
  23931. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23932. */
  23933. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23934. /**
  23935. * Tests if a specific vertex buffer is associated with this mesh
  23936. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23937. * - VertexBuffer.PositionKind
  23938. * - VertexBuffer.NormalKind
  23939. * - VertexBuffer.UVKind
  23940. * - VertexBuffer.UV2Kind
  23941. * - VertexBuffer.UV3Kind
  23942. * - VertexBuffer.UV4Kind
  23943. * - VertexBuffer.UV5Kind
  23944. * - VertexBuffer.UV6Kind
  23945. * - VertexBuffer.ColorKind
  23946. * - VertexBuffer.MatricesIndicesKind
  23947. * - VertexBuffer.MatricesIndicesExtraKind
  23948. * - VertexBuffer.MatricesWeightsKind
  23949. * - VertexBuffer.MatricesWeightsExtraKind
  23950. * @returns a boolean
  23951. */
  23952. isVerticesDataPresent(kind: string): boolean;
  23953. /**
  23954. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23955. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23956. * - VertexBuffer.PositionKind
  23957. * - VertexBuffer.UVKind
  23958. * - VertexBuffer.UV2Kind
  23959. * - VertexBuffer.UV3Kind
  23960. * - VertexBuffer.UV4Kind
  23961. * - VertexBuffer.UV5Kind
  23962. * - VertexBuffer.UV6Kind
  23963. * - VertexBuffer.ColorKind
  23964. * - VertexBuffer.MatricesIndicesKind
  23965. * - VertexBuffer.MatricesIndicesExtraKind
  23966. * - VertexBuffer.MatricesWeightsKind
  23967. * - VertexBuffer.MatricesWeightsExtraKind
  23968. * @returns a boolean
  23969. */
  23970. isVertexBufferUpdatable(kind: string): boolean;
  23971. /**
  23972. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23973. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23974. * - VertexBuffer.PositionKind
  23975. * - VertexBuffer.NormalKind
  23976. * - VertexBuffer.UVKind
  23977. * - VertexBuffer.UV2Kind
  23978. * - VertexBuffer.UV3Kind
  23979. * - VertexBuffer.UV4Kind
  23980. * - VertexBuffer.UV5Kind
  23981. * - VertexBuffer.UV6Kind
  23982. * - VertexBuffer.ColorKind
  23983. * - VertexBuffer.MatricesIndicesKind
  23984. * - VertexBuffer.MatricesIndicesExtraKind
  23985. * - VertexBuffer.MatricesWeightsKind
  23986. * - VertexBuffer.MatricesWeightsExtraKind
  23987. * @returns an array of strings
  23988. */
  23989. getVerticesDataKinds(): string[];
  23990. /**
  23991. * Returns a positive integer : the total number of indices in this mesh geometry.
  23992. * @returns the numner of indices or zero if the mesh has no geometry.
  23993. */
  23994. getTotalIndices(): number;
  23995. /**
  23996. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23997. * @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.
  23998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23999. * @returns the indices array or an empty array if the mesh has no geometry
  24000. */
  24001. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24002. readonly isBlocked: boolean;
  24003. /**
  24004. * Determine if the current mesh is ready to be rendered
  24005. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24006. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24007. * @returns true if all associated assets are ready (material, textures, shaders)
  24008. */
  24009. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24010. /**
  24011. * 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.
  24012. */
  24013. readonly areNormalsFrozen: boolean;
  24014. /**
  24015. * 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.
  24016. * @returns the current mesh
  24017. */
  24018. freezeNormals(): Mesh;
  24019. /**
  24020. * 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
  24021. * @returns the current mesh
  24022. */
  24023. unfreezeNormals(): Mesh;
  24024. /**
  24025. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24026. */
  24027. overridenInstanceCount: number;
  24028. /** @hidden */
  24029. _preActivate(): Mesh;
  24030. /** @hidden */
  24031. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24032. /** @hidden */
  24033. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24034. /**
  24035. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24036. * This means the mesh underlying bounding box and sphere are recomputed.
  24037. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24038. * @returns the current mesh
  24039. */
  24040. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24041. /** @hidden */
  24042. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24043. /**
  24044. * This function will subdivide the mesh into multiple submeshes
  24045. * @param count defines the expected number of submeshes
  24046. */
  24047. subdivide(count: number): void;
  24048. /**
  24049. * Copy a FloatArray into a specific associated vertex buffer
  24050. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24051. * - VertexBuffer.PositionKind
  24052. * - VertexBuffer.UVKind
  24053. * - VertexBuffer.UV2Kind
  24054. * - VertexBuffer.UV3Kind
  24055. * - VertexBuffer.UV4Kind
  24056. * - VertexBuffer.UV5Kind
  24057. * - VertexBuffer.UV6Kind
  24058. * - VertexBuffer.ColorKind
  24059. * - VertexBuffer.MatricesIndicesKind
  24060. * - VertexBuffer.MatricesIndicesExtraKind
  24061. * - VertexBuffer.MatricesWeightsKind
  24062. * - VertexBuffer.MatricesWeightsExtraKind
  24063. * @param data defines the data source
  24064. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24065. * @param stride defines the data stride size (can be null)
  24066. * @returns the current mesh
  24067. */
  24068. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24069. /**
  24070. * Delete a vertex buffer associated with this mesh
  24071. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24072. * - VertexBuffer.PositionKind
  24073. * - VertexBuffer.UVKind
  24074. * - VertexBuffer.UV2Kind
  24075. * - VertexBuffer.UV3Kind
  24076. * - VertexBuffer.UV4Kind
  24077. * - VertexBuffer.UV5Kind
  24078. * - VertexBuffer.UV6Kind
  24079. * - VertexBuffer.ColorKind
  24080. * - VertexBuffer.MatricesIndicesKind
  24081. * - VertexBuffer.MatricesIndicesExtraKind
  24082. * - VertexBuffer.MatricesWeightsKind
  24083. * - VertexBuffer.MatricesWeightsExtraKind
  24084. */
  24085. removeVerticesData(kind: string): void;
  24086. /**
  24087. * Flags an associated vertex buffer as updatable
  24088. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24089. * - VertexBuffer.PositionKind
  24090. * - VertexBuffer.UVKind
  24091. * - VertexBuffer.UV2Kind
  24092. * - VertexBuffer.UV3Kind
  24093. * - VertexBuffer.UV4Kind
  24094. * - VertexBuffer.UV5Kind
  24095. * - VertexBuffer.UV6Kind
  24096. * - VertexBuffer.ColorKind
  24097. * - VertexBuffer.MatricesIndicesKind
  24098. * - VertexBuffer.MatricesIndicesExtraKind
  24099. * - VertexBuffer.MatricesWeightsKind
  24100. * - VertexBuffer.MatricesWeightsExtraKind
  24101. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24102. */
  24103. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24104. /**
  24105. * Sets the mesh global Vertex Buffer
  24106. * @param buffer defines the buffer to use
  24107. * @returns the current mesh
  24108. */
  24109. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24110. /**
  24111. * Update a specific associated vertex buffer
  24112. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24113. * - VertexBuffer.PositionKind
  24114. * - VertexBuffer.UVKind
  24115. * - VertexBuffer.UV2Kind
  24116. * - VertexBuffer.UV3Kind
  24117. * - VertexBuffer.UV4Kind
  24118. * - VertexBuffer.UV5Kind
  24119. * - VertexBuffer.UV6Kind
  24120. * - VertexBuffer.ColorKind
  24121. * - VertexBuffer.MatricesIndicesKind
  24122. * - VertexBuffer.MatricesIndicesExtraKind
  24123. * - VertexBuffer.MatricesWeightsKind
  24124. * - VertexBuffer.MatricesWeightsExtraKind
  24125. * @param data defines the data source
  24126. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24127. * @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)
  24128. * @returns the current mesh
  24129. */
  24130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24131. /**
  24132. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24133. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24134. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24135. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24136. * @returns the current mesh
  24137. */
  24138. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24139. /**
  24140. * Creates a un-shared specific occurence of the geometry for the mesh.
  24141. * @returns the current mesh
  24142. */
  24143. makeGeometryUnique(): Mesh;
  24144. /**
  24145. * Set the index buffer of this mesh
  24146. * @param indices defines the source data
  24147. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24148. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24149. * @returns the current mesh
  24150. */
  24151. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24152. /**
  24153. * Update the current index buffer
  24154. * @param indices defines the source data
  24155. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24156. * @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)
  24157. * @returns the current mesh
  24158. */
  24159. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24160. /**
  24161. * Invert the geometry to move from a right handed system to a left handed one.
  24162. * @returns the current mesh
  24163. */
  24164. toLeftHanded(): Mesh;
  24165. /** @hidden */
  24166. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24167. /** @hidden */
  24168. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24169. /**
  24170. * Registers for this mesh a javascript function called just before the rendering process
  24171. * @param func defines the function to call before rendering this mesh
  24172. * @returns the current mesh
  24173. */
  24174. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24175. /**
  24176. * Disposes a previously registered javascript function called before the rendering
  24177. * @param func defines the function to remove
  24178. * @returns the current mesh
  24179. */
  24180. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24181. /**
  24182. * Registers for this mesh a javascript function called just after the rendering is complete
  24183. * @param func defines the function to call after rendering this mesh
  24184. * @returns the current mesh
  24185. */
  24186. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24187. /**
  24188. * Disposes a previously registered javascript function called after the rendering.
  24189. * @param func defines the function to remove
  24190. * @returns the current mesh
  24191. */
  24192. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24193. /** @hidden */
  24194. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24195. /** @hidden */
  24196. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24197. /** @hidden */
  24198. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24199. /** @hidden */
  24200. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24201. /** @hidden */
  24202. _rebuild(): void;
  24203. /** @hidden */
  24204. _freeze(): void;
  24205. /** @hidden */
  24206. _unFreeze(): void;
  24207. /**
  24208. * 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
  24209. * @param subMesh defines the subMesh to render
  24210. * @param enableAlphaMode defines if alpha mode can be changed
  24211. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24212. * @returns the current mesh
  24213. */
  24214. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24215. private _onBeforeDraw;
  24216. /**
  24217. * Renormalize the mesh and patch it up if there are no weights
  24218. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24219. * However in the case of zero weights then we set just a single influence to 1.
  24220. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24221. */
  24222. cleanMatrixWeights(): void;
  24223. private normalizeSkinFourWeights;
  24224. private normalizeSkinWeightsAndExtra;
  24225. /**
  24226. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24227. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24228. * the user know there was an issue with importing the mesh
  24229. * @returns a validation object with skinned, valid and report string
  24230. */
  24231. validateSkinning(): {
  24232. skinned: boolean;
  24233. valid: boolean;
  24234. report: string;
  24235. };
  24236. /** @hidden */
  24237. _checkDelayState(): Mesh;
  24238. private _queueLoad;
  24239. /**
  24240. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24241. * A mesh is in the frustum if its bounding box intersects the frustum
  24242. * @param frustumPlanes defines the frustum to test
  24243. * @returns true if the mesh is in the frustum planes
  24244. */
  24245. isInFrustum(frustumPlanes: Plane[]): boolean;
  24246. /**
  24247. * Sets the mesh material by the material or multiMaterial `id` property
  24248. * @param id is a string identifying the material or the multiMaterial
  24249. * @returns the current mesh
  24250. */
  24251. setMaterialByID(id: string): Mesh;
  24252. /**
  24253. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24254. * @returns an array of IAnimatable
  24255. */
  24256. getAnimatables(): IAnimatable[];
  24257. /**
  24258. * Modifies the mesh geometry according to the passed transformation matrix.
  24259. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24260. * The mesh normals are modified using the same transformation.
  24261. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24262. * @param transform defines the transform matrix to use
  24263. * @see http://doc.babylonjs.com/resources/baking_transformations
  24264. * @returns the current mesh
  24265. */
  24266. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24267. /**
  24268. * Modifies the mesh geometry according to its own current World Matrix.
  24269. * The mesh World Matrix is then reset.
  24270. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24271. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24272. * @see http://doc.babylonjs.com/resources/baking_transformations
  24273. * @returns the current mesh
  24274. */
  24275. bakeCurrentTransformIntoVertices(): Mesh;
  24276. /** @hidden */
  24277. readonly _positions: Nullable<Vector3[]>;
  24278. /** @hidden */
  24279. _resetPointsArrayCache(): Mesh;
  24280. /** @hidden */
  24281. _generatePointsArray(): boolean;
  24282. /**
  24283. * Returns a new Mesh object generated from the current mesh properties.
  24284. * This method must not get confused with createInstance()
  24285. * @param name is a string, the name given to the new mesh
  24286. * @param newParent can be any Node object (default `null`)
  24287. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24288. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24289. * @returns a new mesh
  24290. */
  24291. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24292. /**
  24293. * Releases resources associated with this mesh.
  24294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24296. */
  24297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24298. /** @hidden */
  24299. _disposeInstanceSpecificData(): void;
  24300. /**
  24301. * Modifies the mesh geometry according to a displacement map.
  24302. * 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.
  24303. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24304. * @param url is a string, the URL from the image file is to be downloaded.
  24305. * @param minHeight is the lower limit of the displacement.
  24306. * @param maxHeight is the upper limit of the displacement.
  24307. * @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.
  24308. * @param uvOffset is an optional vector2 used to offset UV.
  24309. * @param uvScale is an optional vector2 used to scale UV.
  24310. * @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.
  24311. * @returns the Mesh.
  24312. */
  24313. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24314. /**
  24315. * Modifies the mesh geometry according to a displacementMap buffer.
  24316. * 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.
  24317. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24318. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24319. * @param heightMapWidth is the width of the buffer image.
  24320. * @param heightMapHeight is the height of the buffer image.
  24321. * @param minHeight is the lower limit of the displacement.
  24322. * @param maxHeight is the upper limit of the displacement.
  24323. * @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.
  24324. * @param uvOffset is an optional vector2 used to offset UV.
  24325. * @param uvScale is an optional vector2 used to scale UV.
  24326. * @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.
  24327. * @returns the Mesh.
  24328. */
  24329. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24330. /**
  24331. * Modify the mesh to get a flat shading rendering.
  24332. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24333. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24334. * @returns current mesh
  24335. */
  24336. convertToFlatShadedMesh(): Mesh;
  24337. /**
  24338. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24339. * In other words, more vertices, no more indices and a single bigger VBO.
  24340. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24341. * @returns current mesh
  24342. */
  24343. convertToUnIndexedMesh(): Mesh;
  24344. /**
  24345. * Inverses facet orientations.
  24346. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24347. * @param flipNormals will also inverts the normals
  24348. * @returns current mesh
  24349. */
  24350. flipFaces(flipNormals?: boolean): Mesh;
  24351. /**
  24352. * Increase the number of facets and hence vertices in a mesh
  24353. * Vertex normals are interpolated from existing vertex normals
  24354. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24355. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24356. */
  24357. increaseVertices(numberPerEdge: number): void;
  24358. /**
  24359. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24360. * This will undo any application of covertToFlatShadedMesh
  24361. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24362. */
  24363. forceSharedVertices(): void;
  24364. /** @hidden */
  24365. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24366. /** @hidden */
  24367. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24368. /**
  24369. * Creates a new InstancedMesh object from the mesh model.
  24370. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24371. * @param name defines the name of the new instance
  24372. * @returns a new InstancedMesh
  24373. */
  24374. createInstance(name: string): InstancedMesh;
  24375. /**
  24376. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24377. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24378. * @returns the current mesh
  24379. */
  24380. synchronizeInstances(): Mesh;
  24381. /**
  24382. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24383. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24384. * This should be used together with the simplification to avoid disappearing triangles.
  24385. * @param successCallback an optional success callback to be called after the optimization finished.
  24386. * @returns the current mesh
  24387. */
  24388. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24389. /**
  24390. * Serialize current mesh
  24391. * @param serializationObject defines the object which will receive the serialization data
  24392. */
  24393. serialize(serializationObject: any): void;
  24394. /** @hidden */
  24395. _syncGeometryWithMorphTargetManager(): void;
  24396. /** @hidden */
  24397. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24398. /**
  24399. * Returns a new Mesh object parsed from the source provided.
  24400. * @param parsedMesh is the source
  24401. * @param scene defines the hosting scene
  24402. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24403. * @returns a new Mesh
  24404. */
  24405. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24406. /**
  24407. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24408. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24409. * @param name defines the name of the mesh to create
  24410. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24411. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24412. * @param closePath creates a seam between the first and the last points of each path of the path array
  24413. * @param offset is taken in account only if the `pathArray` is containing a single path
  24414. * @param scene defines the hosting scene
  24415. * @param updatable defines if the mesh must be flagged as updatable
  24416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24417. * @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)
  24418. * @returns a new Mesh
  24419. */
  24420. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24421. /**
  24422. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24423. * @param name defines the name of the mesh to create
  24424. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24425. * @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
  24426. * @param scene defines the hosting scene
  24427. * @param updatable defines if the mesh must be flagged as updatable
  24428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24429. * @returns a new Mesh
  24430. */
  24431. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24432. /**
  24433. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24434. * @param name defines the name of the mesh to create
  24435. * @param size sets the size (float) of each box side (default 1)
  24436. * @param scene defines the hosting scene
  24437. * @param updatable defines if the mesh must be flagged as updatable
  24438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24439. * @returns a new Mesh
  24440. */
  24441. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24442. /**
  24443. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24444. * @param name defines the name of the mesh to create
  24445. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24446. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24447. * @param scene defines the hosting scene
  24448. * @param updatable defines if the mesh must be flagged as updatable
  24449. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24450. * @returns a new Mesh
  24451. */
  24452. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24453. /**
  24454. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24455. * @param name defines the name of the mesh to create
  24456. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24457. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24458. * @param scene defines the hosting scene
  24459. * @returns a new Mesh
  24460. */
  24461. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24462. /**
  24463. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24464. * @param name defines the name of the mesh to create
  24465. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24466. * @param diameterTop set the top cap diameter (floats, default 1)
  24467. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24468. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24469. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24470. * @param scene defines the hosting scene
  24471. * @param updatable defines if the mesh must be flagged as updatable
  24472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24473. * @returns a new Mesh
  24474. */
  24475. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24476. /**
  24477. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24478. * @param name defines the name of the mesh to create
  24479. * @param diameter sets the diameter size (float) of the torus (default 1)
  24480. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24481. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24482. * @param scene defines the hosting scene
  24483. * @param updatable defines if the mesh must be flagged as updatable
  24484. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24485. * @returns a new Mesh
  24486. */
  24487. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24488. /**
  24489. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24490. * @param name defines the name of the mesh to create
  24491. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24492. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24493. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24494. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24495. * @param p the number of windings on X axis (positive integers, default 2)
  24496. * @param q the number of windings on Y axis (positive integers, default 3)
  24497. * @param scene defines the hosting scene
  24498. * @param updatable defines if the mesh must be flagged as updatable
  24499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24500. * @returns a new Mesh
  24501. */
  24502. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24503. /**
  24504. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24505. * @param name defines the name of the mesh to create
  24506. * @param points is an array successive Vector3
  24507. * @param scene defines the hosting scene
  24508. * @param updatable defines if the mesh must be flagged as updatable
  24509. * @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).
  24510. * @returns a new Mesh
  24511. */
  24512. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24513. /**
  24514. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24515. * @param name defines the name of the mesh to create
  24516. * @param points is an array successive Vector3
  24517. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24518. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24519. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24520. * @param scene defines the hosting scene
  24521. * @param updatable defines if the mesh must be flagged as updatable
  24522. * @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)
  24523. * @returns a new Mesh
  24524. */
  24525. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24526. /**
  24527. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24528. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24529. * 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.
  24530. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24532. * Remember you can only change the shape positions, not their number when updating a polygon.
  24533. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24534. * @param name defines the name of the mesh to create
  24535. * @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
  24536. * @param scene defines the hosting scene
  24537. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24538. * @param updatable defines if the mesh must be flagged as updatable
  24539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24540. * @param earcutInjection can be used to inject your own earcut reference
  24541. * @returns a new Mesh
  24542. */
  24543. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24544. /**
  24545. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24546. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24547. * @param name defines the name of the mesh to create
  24548. * @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
  24549. * @param depth defines the height of extrusion
  24550. * @param scene defines the hosting scene
  24551. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24552. * @param updatable defines if the mesh must be flagged as updatable
  24553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24554. * @param earcutInjection can be used to inject your own earcut reference
  24555. * @returns a new Mesh
  24556. */
  24557. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24558. /**
  24559. * Creates an extruded shape mesh.
  24560. * 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
  24561. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24562. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24563. * @param name defines the name of the mesh to create
  24564. * @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
  24565. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24566. * @param scale is the value to scale the shape
  24567. * @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
  24568. * @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
  24569. * @param scene defines the hosting scene
  24570. * @param updatable defines if the mesh must be flagged as updatable
  24571. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24572. * @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)
  24573. * @returns a new Mesh
  24574. */
  24575. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24576. /**
  24577. * Creates an custom extruded shape mesh.
  24578. * The custom extrusion is a parametric shape.
  24579. * It has no predefined shape. Its final shape will depend on the input parameters.
  24580. * Please consider using the same method from the MeshBuilder class instead
  24581. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24582. * @param name defines the name of the mesh to create
  24583. * @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
  24584. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24585. * @param scaleFunction is a custom Javascript function called on each path point
  24586. * @param rotationFunction is a custom Javascript function called on each path point
  24587. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24588. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24589. * @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
  24590. * @param scene defines the hosting scene
  24591. * @param updatable defines if the mesh must be flagged as updatable
  24592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24593. * @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)
  24594. * @returns a new Mesh
  24595. */
  24596. 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;
  24597. /**
  24598. * Creates lathe mesh.
  24599. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24600. * Please consider using the same method from the MeshBuilder class instead
  24601. * @param name defines the name of the mesh to create
  24602. * @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
  24603. * @param radius is the radius value of the lathe
  24604. * @param tessellation is the side number of the lathe.
  24605. * @param scene defines the hosting scene
  24606. * @param updatable defines if the mesh must be flagged as updatable
  24607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24608. * @returns a new Mesh
  24609. */
  24610. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24611. /**
  24612. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24613. * @param name defines the name of the mesh to create
  24614. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24615. * @param scene defines the hosting scene
  24616. * @param updatable defines if the mesh must be flagged as updatable
  24617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24618. * @returns a new Mesh
  24619. */
  24620. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24621. /**
  24622. * Creates a ground mesh.
  24623. * Please consider using the same method from the MeshBuilder class instead
  24624. * @param name defines the name of the mesh to create
  24625. * @param width set the width of the ground
  24626. * @param height set the height of the ground
  24627. * @param subdivisions sets the number of subdivisions per side
  24628. * @param scene defines the hosting scene
  24629. * @param updatable defines if the mesh must be flagged as updatable
  24630. * @returns a new Mesh
  24631. */
  24632. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24633. /**
  24634. * Creates a tiled ground mesh.
  24635. * Please consider using the same method from the MeshBuilder class instead
  24636. * @param name defines the name of the mesh to create
  24637. * @param xmin set the ground minimum X coordinate
  24638. * @param zmin set the ground minimum Y coordinate
  24639. * @param xmax set the ground maximum X coordinate
  24640. * @param zmax set the ground maximum Z coordinate
  24641. * @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
  24642. * @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
  24643. * @param scene defines the hosting scene
  24644. * @param updatable defines if the mesh must be flagged as updatable
  24645. * @returns a new Mesh
  24646. */
  24647. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24648. w: number;
  24649. h: number;
  24650. }, precision: {
  24651. w: number;
  24652. h: number;
  24653. }, scene: Scene, updatable?: boolean): Mesh;
  24654. /**
  24655. * Creates a ground mesh from a height map.
  24656. * Please consider using the same method from the MeshBuilder class instead
  24657. * @see http://doc.babylonjs.com/babylon101/height_map
  24658. * @param name defines the name of the mesh to create
  24659. * @param url sets the URL of the height map image resource
  24660. * @param width set the ground width size
  24661. * @param height set the ground height size
  24662. * @param subdivisions sets the number of subdivision per side
  24663. * @param minHeight is the minimum altitude on the ground
  24664. * @param maxHeight is the maximum altitude on the ground
  24665. * @param scene defines the hosting scene
  24666. * @param updatable defines if the mesh must be flagged as updatable
  24667. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24668. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24669. * @returns a new Mesh
  24670. */
  24671. 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;
  24672. /**
  24673. * Creates a tube mesh.
  24674. * The tube is a parametric shape.
  24675. * It has no predefined shape. Its final shape will depend on the input parameters.
  24676. * Please consider using the same method from the MeshBuilder class instead
  24677. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24678. * @param name defines the name of the mesh to create
  24679. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24680. * @param radius sets the tube radius size
  24681. * @param tessellation is the number of sides on the tubular surface
  24682. * @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
  24683. * @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
  24684. * @param scene defines the hosting scene
  24685. * @param updatable defines if the mesh must be flagged as updatable
  24686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24687. * @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)
  24688. * @returns a new Mesh
  24689. */
  24690. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24691. (i: number, distance: number): number;
  24692. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24693. /**
  24694. * Creates a polyhedron mesh.
  24695. * Please consider using the same method from the MeshBuilder class instead.
  24696. * * 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
  24697. * * The parameter `size` (positive float, default 1) sets the polygon size
  24698. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24699. * * 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`
  24700. * * 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
  24701. * * 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)`)
  24702. * * 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
  24703. * * 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
  24704. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24705. * * 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
  24706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24707. * @param name defines the name of the mesh to create
  24708. * @param options defines the options used to create the mesh
  24709. * @param scene defines the hosting scene
  24710. * @returns a new Mesh
  24711. */
  24712. static CreatePolyhedron(name: string, options: {
  24713. type?: number;
  24714. size?: number;
  24715. sizeX?: number;
  24716. sizeY?: number;
  24717. sizeZ?: number;
  24718. custom?: any;
  24719. faceUV?: Vector4[];
  24720. faceColors?: Color4[];
  24721. updatable?: boolean;
  24722. sideOrientation?: number;
  24723. }, scene: Scene): Mesh;
  24724. /**
  24725. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24726. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24727. * * 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`)
  24728. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24729. * * 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
  24730. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24731. * * 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
  24732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24733. * @param name defines the name of the mesh
  24734. * @param options defines the options used to create the mesh
  24735. * @param scene defines the hosting scene
  24736. * @returns a new Mesh
  24737. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24738. */
  24739. static CreateIcoSphere(name: string, options: {
  24740. radius?: number;
  24741. flat?: boolean;
  24742. subdivisions?: number;
  24743. sideOrientation?: number;
  24744. updatable?: boolean;
  24745. }, scene: Scene): Mesh;
  24746. /**
  24747. * Creates a decal mesh.
  24748. * Please consider using the same method from the MeshBuilder class instead.
  24749. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24750. * @param name defines the name of the mesh
  24751. * @param sourceMesh defines the mesh receiving the decal
  24752. * @param position sets the position of the decal in world coordinates
  24753. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24754. * @param size sets the decal scaling
  24755. * @param angle sets the angle to rotate the decal
  24756. * @returns a new Mesh
  24757. */
  24758. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24759. /**
  24760. * Prepare internal position array for software CPU skinning
  24761. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24762. */
  24763. setPositionsForCPUSkinning(): Float32Array;
  24764. /**
  24765. * Prepare internal normal array for software CPU skinning
  24766. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24767. */
  24768. setNormalsForCPUSkinning(): Float32Array;
  24769. /**
  24770. * Updates the vertex buffer by applying transformation from the bones
  24771. * @param skeleton defines the skeleton to apply to current mesh
  24772. * @returns the current mesh
  24773. */
  24774. applySkeleton(skeleton: Skeleton): Mesh;
  24775. /**
  24776. * 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
  24777. * @param meshes defines the list of meshes to scan
  24778. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24779. */
  24780. static MinMax(meshes: AbstractMesh[]): {
  24781. min: Vector3;
  24782. max: Vector3;
  24783. };
  24784. /**
  24785. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24786. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24787. * @returns a vector3
  24788. */
  24789. static Center(meshesOrMinMaxVector: {
  24790. min: Vector3;
  24791. max: Vector3;
  24792. } | AbstractMesh[]): Vector3;
  24793. /**
  24794. * Merge the array of meshes into a single mesh for performance reasons.
  24795. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24796. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24797. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24798. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24799. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24800. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24801. * @returns a new mesh
  24802. */
  24803. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24804. /** @hidden */
  24805. addInstance(instance: InstancedMesh): void;
  24806. /** @hidden */
  24807. removeInstance(instance: InstancedMesh): void;
  24808. }
  24809. }
  24810. declare module BABYLON {
  24811. /**
  24812. * This is the base class of all the camera used in the application.
  24813. * @see http://doc.babylonjs.com/features/cameras
  24814. */
  24815. export class Camera extends Node {
  24816. /** @hidden */
  24817. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24818. /**
  24819. * This is the default projection mode used by the cameras.
  24820. * It helps recreating a feeling of perspective and better appreciate depth.
  24821. * This is the best way to simulate real life cameras.
  24822. */
  24823. static readonly PERSPECTIVE_CAMERA: number;
  24824. /**
  24825. * This helps creating camera with an orthographic mode.
  24826. * 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.
  24827. */
  24828. static readonly ORTHOGRAPHIC_CAMERA: number;
  24829. /**
  24830. * This is the default FOV mode for perspective cameras.
  24831. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24832. */
  24833. static readonly FOVMODE_VERTICAL_FIXED: number;
  24834. /**
  24835. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24836. */
  24837. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24838. /**
  24839. * This specifies ther is no need for a camera rig.
  24840. * Basically only one eye is rendered corresponding to the camera.
  24841. */
  24842. static readonly RIG_MODE_NONE: number;
  24843. /**
  24844. * Simulates a camera Rig with one blue eye and one red eye.
  24845. * This can be use with 3d blue and red glasses.
  24846. */
  24847. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24848. /**
  24849. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24850. */
  24851. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24852. /**
  24853. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24854. */
  24855. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24856. /**
  24857. * Defines that both eyes of the camera will be rendered over under each other.
  24858. */
  24859. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24860. /**
  24861. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24862. */
  24863. static readonly RIG_MODE_VR: number;
  24864. /**
  24865. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24866. */
  24867. static readonly RIG_MODE_WEBVR: number;
  24868. /**
  24869. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24870. */
  24871. static readonly RIG_MODE_CUSTOM: number;
  24872. /**
  24873. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24874. */
  24875. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24876. /**
  24877. * Define the input manager associated with the camera.
  24878. */
  24879. inputs: CameraInputsManager<Camera>;
  24880. /** @hidden */
  24881. _position: Vector3;
  24882. /**
  24883. * Define the current local position of the camera in the scene
  24884. */
  24885. position: Vector3;
  24886. /**
  24887. * The vector the camera should consider as up.
  24888. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24889. */
  24890. upVector: Vector3;
  24891. /**
  24892. * Define the current limit on the left side for an orthographic camera
  24893. * In scene unit
  24894. */
  24895. orthoLeft: Nullable<number>;
  24896. /**
  24897. * Define the current limit on the right side for an orthographic camera
  24898. * In scene unit
  24899. */
  24900. orthoRight: Nullable<number>;
  24901. /**
  24902. * Define the current limit on the bottom side for an orthographic camera
  24903. * In scene unit
  24904. */
  24905. orthoBottom: Nullable<number>;
  24906. /**
  24907. * Define the current limit on the top side for an orthographic camera
  24908. * In scene unit
  24909. */
  24910. orthoTop: Nullable<number>;
  24911. /**
  24912. * Field Of View is set in Radians. (default is 0.8)
  24913. */
  24914. fov: number;
  24915. /**
  24916. * Define the minimum distance the camera can see from.
  24917. * This is important to note that the depth buffer are not infinite and the closer it starts
  24918. * the more your scene might encounter depth fighting issue.
  24919. */
  24920. minZ: number;
  24921. /**
  24922. * Define the maximum distance the camera can see to.
  24923. * This is important to note that the depth buffer are not infinite and the further it end
  24924. * the more your scene might encounter depth fighting issue.
  24925. */
  24926. maxZ: number;
  24927. /**
  24928. * Define the default inertia of the camera.
  24929. * This helps giving a smooth feeling to the camera movement.
  24930. */
  24931. inertia: number;
  24932. /**
  24933. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24934. */
  24935. mode: number;
  24936. /**
  24937. * Define wether the camera is intermediate.
  24938. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24939. */
  24940. isIntermediate: boolean;
  24941. /**
  24942. * Define the viewport of the camera.
  24943. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24944. */
  24945. viewport: Viewport;
  24946. /**
  24947. * Restricts the camera to viewing objects with the same layerMask.
  24948. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24949. */
  24950. layerMask: number;
  24951. /**
  24952. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24953. */
  24954. fovMode: number;
  24955. /**
  24956. * Rig mode of the camera.
  24957. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24958. * This is normally controlled byt the camera themselves as internal use.
  24959. */
  24960. cameraRigMode: number;
  24961. /**
  24962. * Defines the distance between both "eyes" in case of a RIG
  24963. */
  24964. interaxialDistance: number;
  24965. /**
  24966. * Defines if stereoscopic rendering is done side by side or over under.
  24967. */
  24968. isStereoscopicSideBySide: boolean;
  24969. /**
  24970. * 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
  24971. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24972. * else in the scene. (Eg. security camera)
  24973. *
  24974. * 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)
  24975. */
  24976. customRenderTargets: RenderTargetTexture[];
  24977. /**
  24978. * When set, the camera will render to this render target instead of the default canvas
  24979. *
  24980. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24981. */
  24982. outputRenderTarget: Nullable<RenderTargetTexture>;
  24983. /**
  24984. * Observable triggered when the camera view matrix has changed.
  24985. */
  24986. onViewMatrixChangedObservable: Observable<Camera>;
  24987. /**
  24988. * Observable triggered when the camera Projection matrix has changed.
  24989. */
  24990. onProjectionMatrixChangedObservable: Observable<Camera>;
  24991. /**
  24992. * Observable triggered when the inputs have been processed.
  24993. */
  24994. onAfterCheckInputsObservable: Observable<Camera>;
  24995. /**
  24996. * Observable triggered when reset has been called and applied to the camera.
  24997. */
  24998. onRestoreStateObservable: Observable<Camera>;
  24999. /** @hidden */
  25000. _cameraRigParams: any;
  25001. /** @hidden */
  25002. _rigCameras: Camera[];
  25003. /** @hidden */
  25004. _rigPostProcess: Nullable<PostProcess>;
  25005. protected _webvrViewMatrix: Matrix;
  25006. /** @hidden */
  25007. _skipRendering: boolean;
  25008. /** @hidden */
  25009. _projectionMatrix: Matrix;
  25010. /** @hidden */
  25011. _postProcesses: Nullable<PostProcess>[];
  25012. /** @hidden */
  25013. _activeMeshes: SmartArray<AbstractMesh>;
  25014. protected _globalPosition: Vector3;
  25015. /** @hidden */
  25016. _computedViewMatrix: Matrix;
  25017. private _doNotComputeProjectionMatrix;
  25018. private _transformMatrix;
  25019. private _frustumPlanes;
  25020. private _refreshFrustumPlanes;
  25021. private _storedFov;
  25022. private _stateStored;
  25023. /**
  25024. * Instantiates a new camera object.
  25025. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25026. * @see http://doc.babylonjs.com/features/cameras
  25027. * @param name Defines the name of the camera in the scene
  25028. * @param position Defines the position of the camera
  25029. * @param scene Defines the scene the camera belongs too
  25030. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25031. */
  25032. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25033. /**
  25034. * Store current camera state (fov, position, etc..)
  25035. * @returns the camera
  25036. */
  25037. storeState(): Camera;
  25038. /**
  25039. * Restores the camera state values if it has been stored. You must call storeState() first
  25040. */
  25041. protected _restoreStateValues(): boolean;
  25042. /**
  25043. * Restored camera state. You must call storeState() first.
  25044. * @returns true if restored and false otherwise
  25045. */
  25046. restoreState(): boolean;
  25047. /**
  25048. * Gets the class name of the camera.
  25049. * @returns the class name
  25050. */
  25051. getClassName(): string;
  25052. /** @hidden */
  25053. readonly _isCamera: boolean;
  25054. /**
  25055. * Gets a string representation of the camera useful for debug purpose.
  25056. * @param fullDetails Defines that a more verboe level of logging is required
  25057. * @returns the string representation
  25058. */
  25059. toString(fullDetails?: boolean): string;
  25060. /**
  25061. * Gets the current world space position of the camera.
  25062. */
  25063. readonly globalPosition: Vector3;
  25064. /**
  25065. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25066. * @returns the active meshe list
  25067. */
  25068. getActiveMeshes(): SmartArray<AbstractMesh>;
  25069. /**
  25070. * Check wether a mesh is part of the current active mesh list of the camera
  25071. * @param mesh Defines the mesh to check
  25072. * @returns true if active, false otherwise
  25073. */
  25074. isActiveMesh(mesh: Mesh): boolean;
  25075. /**
  25076. * Is this camera ready to be used/rendered
  25077. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25078. * @return true if the camera is ready
  25079. */
  25080. isReady(completeCheck?: boolean): boolean;
  25081. /** @hidden */
  25082. _initCache(): void;
  25083. /** @hidden */
  25084. _updateCache(ignoreParentClass?: boolean): void;
  25085. /** @hidden */
  25086. _isSynchronized(): boolean;
  25087. /** @hidden */
  25088. _isSynchronizedViewMatrix(): boolean;
  25089. /** @hidden */
  25090. _isSynchronizedProjectionMatrix(): boolean;
  25091. /**
  25092. * Attach the input controls to a specific dom element to get the input from.
  25093. * @param element Defines the element the controls should be listened from
  25094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25095. */
  25096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25097. /**
  25098. * Detach the current controls from the specified dom element.
  25099. * @param element Defines the element to stop listening the inputs from
  25100. */
  25101. detachControl(element: HTMLElement): void;
  25102. /**
  25103. * Update the camera state according to the different inputs gathered during the frame.
  25104. */
  25105. update(): void;
  25106. /** @hidden */
  25107. _checkInputs(): void;
  25108. /** @hidden */
  25109. readonly rigCameras: Camera[];
  25110. /**
  25111. * Gets the post process used by the rig cameras
  25112. */
  25113. readonly rigPostProcess: Nullable<PostProcess>;
  25114. /**
  25115. * Internal, gets the first post proces.
  25116. * @returns the first post process to be run on this camera.
  25117. */
  25118. _getFirstPostProcess(): Nullable<PostProcess>;
  25119. private _cascadePostProcessesToRigCams;
  25120. /**
  25121. * Attach a post process to the camera.
  25122. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25123. * @param postProcess The post process to attach to the camera
  25124. * @param insertAt The position of the post process in case several of them are in use in the scene
  25125. * @returns the position the post process has been inserted at
  25126. */
  25127. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25128. /**
  25129. * Detach a post process to the camera.
  25130. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25131. * @param postProcess The post process to detach from the camera
  25132. */
  25133. detachPostProcess(postProcess: PostProcess): void;
  25134. /**
  25135. * Gets the current world matrix of the camera
  25136. */
  25137. getWorldMatrix(): Matrix;
  25138. /** @hidden */
  25139. _getViewMatrix(): Matrix;
  25140. /**
  25141. * Gets the current view matrix of the camera.
  25142. * @param force forces the camera to recompute the matrix without looking at the cached state
  25143. * @returns the view matrix
  25144. */
  25145. getViewMatrix(force?: boolean): Matrix;
  25146. /**
  25147. * Freeze the projection matrix.
  25148. * It will prevent the cache check of the camera projection compute and can speed up perf
  25149. * if no parameter of the camera are meant to change
  25150. * @param projection Defines manually a projection if necessary
  25151. */
  25152. freezeProjectionMatrix(projection?: Matrix): void;
  25153. /**
  25154. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25155. */
  25156. unfreezeProjectionMatrix(): void;
  25157. /**
  25158. * Gets the current projection matrix of the camera.
  25159. * @param force forces the camera to recompute the matrix without looking at the cached state
  25160. * @returns the projection matrix
  25161. */
  25162. getProjectionMatrix(force?: boolean): Matrix;
  25163. /**
  25164. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25165. * @returns a Matrix
  25166. */
  25167. getTransformationMatrix(): Matrix;
  25168. private _updateFrustumPlanes;
  25169. /**
  25170. * Checks if a cullable object (mesh...) is in the camera frustum
  25171. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25172. * @param target The object to check
  25173. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25174. * @returns true if the object is in frustum otherwise false
  25175. */
  25176. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25177. /**
  25178. * Checks if a cullable object (mesh...) is in the camera frustum
  25179. * Unlike isInFrustum this cheks the full bounding box
  25180. * @param target The object to check
  25181. * @returns true if the object is in frustum otherwise false
  25182. */
  25183. isCompletelyInFrustum(target: ICullable): boolean;
  25184. /**
  25185. * Gets a ray in the forward direction from the camera.
  25186. * @param length Defines the length of the ray to create
  25187. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25188. * @param origin Defines the start point of the ray which defaults to the camera position
  25189. * @returns the forward ray
  25190. */
  25191. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25192. /**
  25193. * Releases resources associated with this node.
  25194. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25195. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25196. */
  25197. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25198. /** @hidden */
  25199. _isLeftCamera: boolean;
  25200. /**
  25201. * Gets the left camera of a rig setup in case of Rigged Camera
  25202. */
  25203. readonly isLeftCamera: boolean;
  25204. /** @hidden */
  25205. _isRightCamera: boolean;
  25206. /**
  25207. * Gets the right camera of a rig setup in case of Rigged Camera
  25208. */
  25209. readonly isRightCamera: boolean;
  25210. /**
  25211. * Gets the left camera of a rig setup in case of Rigged Camera
  25212. */
  25213. readonly leftCamera: Nullable<FreeCamera>;
  25214. /**
  25215. * Gets the right camera of a rig setup in case of Rigged Camera
  25216. */
  25217. readonly rightCamera: Nullable<FreeCamera>;
  25218. /**
  25219. * Gets the left camera target of a rig setup in case of Rigged Camera
  25220. * @returns the target position
  25221. */
  25222. getLeftTarget(): Nullable<Vector3>;
  25223. /**
  25224. * Gets the right camera target of a rig setup in case of Rigged Camera
  25225. * @returns the target position
  25226. */
  25227. getRightTarget(): Nullable<Vector3>;
  25228. /**
  25229. * @hidden
  25230. */
  25231. setCameraRigMode(mode: number, rigParams: any): void;
  25232. /** @hidden */
  25233. static _setStereoscopicRigMode(camera: Camera): void;
  25234. /** @hidden */
  25235. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25236. /** @hidden */
  25237. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25238. /** @hidden */
  25239. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25240. /** @hidden */
  25241. _getVRProjectionMatrix(): Matrix;
  25242. protected _updateCameraRotationMatrix(): void;
  25243. protected _updateWebVRCameraRotationMatrix(): void;
  25244. /**
  25245. * This function MUST be overwritten by the different WebVR cameras available.
  25246. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25247. * @hidden
  25248. */
  25249. _getWebVRProjectionMatrix(): Matrix;
  25250. /**
  25251. * This function MUST be overwritten by the different WebVR cameras available.
  25252. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25253. * @hidden
  25254. */
  25255. _getWebVRViewMatrix(): Matrix;
  25256. /** @hidden */
  25257. setCameraRigParameter(name: string, value: any): void;
  25258. /**
  25259. * needs to be overridden by children so sub has required properties to be copied
  25260. * @hidden
  25261. */
  25262. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25263. /**
  25264. * May need to be overridden by children
  25265. * @hidden
  25266. */
  25267. _updateRigCameras(): void;
  25268. /** @hidden */
  25269. _setupInputs(): void;
  25270. /**
  25271. * Serialiaze the camera setup to a json represention
  25272. * @returns the JSON representation
  25273. */
  25274. serialize(): any;
  25275. /**
  25276. * Clones the current camera.
  25277. * @param name The cloned camera name
  25278. * @returns the cloned camera
  25279. */
  25280. clone(name: string): Camera;
  25281. /**
  25282. * Gets the direction of the camera relative to a given local axis.
  25283. * @param localAxis Defines the reference axis to provide a relative direction.
  25284. * @return the direction
  25285. */
  25286. getDirection(localAxis: Vector3): Vector3;
  25287. /**
  25288. * Returns the current camera absolute rotation
  25289. */
  25290. readonly absoluteRotation: Quaternion;
  25291. /**
  25292. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25293. * @param localAxis Defines the reference axis to provide a relative direction.
  25294. * @param result Defines the vector to store the result in
  25295. */
  25296. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25297. /**
  25298. * Gets a camera constructor for a given camera type
  25299. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25300. * @param name The name of the camera the result will be able to instantiate
  25301. * @param scene The scene the result will construct the camera in
  25302. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25303. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25304. * @returns a factory method to construc the camera
  25305. */
  25306. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25307. /**
  25308. * Compute the world matrix of the camera.
  25309. * @returns the camera world matrix
  25310. */
  25311. computeWorldMatrix(): Matrix;
  25312. /**
  25313. * Parse a JSON and creates the camera from the parsed information
  25314. * @param parsedCamera The JSON to parse
  25315. * @param scene The scene to instantiate the camera in
  25316. * @returns the newly constructed camera
  25317. */
  25318. static Parse(parsedCamera: any, scene: Scene): Camera;
  25319. }
  25320. }
  25321. declare module BABYLON {
  25322. /**
  25323. * Class containing static functions to help procedurally build meshes
  25324. */
  25325. export class DiscBuilder {
  25326. /**
  25327. * Creates a plane polygonal mesh. By default, this is a disc
  25328. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25329. * * 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
  25330. * * 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
  25331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25332. * * 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
  25333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25334. * @param name defines the name of the mesh
  25335. * @param options defines the options used to create the mesh
  25336. * @param scene defines the hosting scene
  25337. * @returns the plane polygonal mesh
  25338. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25339. */
  25340. static CreateDisc(name: string, options: {
  25341. radius?: number;
  25342. tessellation?: number;
  25343. arc?: number;
  25344. updatable?: boolean;
  25345. sideOrientation?: number;
  25346. frontUVs?: Vector4;
  25347. backUVs?: Vector4;
  25348. }, scene?: Nullable<Scene>): Mesh;
  25349. }
  25350. }
  25351. declare module BABYLON {
  25352. /**
  25353. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25354. *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.
  25355. * The SPS is also a particle system. It provides some methods to manage the particles.
  25356. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25357. *
  25358. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25359. */
  25360. export class SolidParticleSystem implements IDisposable {
  25361. /**
  25362. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25363. * Example : var p = SPS.particles[i];
  25364. */
  25365. particles: SolidParticle[];
  25366. /**
  25367. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25368. */
  25369. nbParticles: number;
  25370. /**
  25371. * If the particles must ever face the camera (default false). Useful for planar particles.
  25372. */
  25373. billboard: boolean;
  25374. /**
  25375. * Recompute normals when adding a shape
  25376. */
  25377. recomputeNormals: boolean;
  25378. /**
  25379. * This a counter ofr your own usage. It's not set by any SPS functions.
  25380. */
  25381. counter: number;
  25382. /**
  25383. * The SPS name. This name is also given to the underlying mesh.
  25384. */
  25385. name: string;
  25386. /**
  25387. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25388. */
  25389. mesh: Mesh;
  25390. /**
  25391. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25392. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25393. */
  25394. vars: any;
  25395. /**
  25396. * This array is populated when the SPS is set as 'pickable'.
  25397. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25398. * Each element of this array is an object `{idx: int, faceId: int}`.
  25399. * `idx` is the picked particle index in the `SPS.particles` array
  25400. * `faceId` is the picked face index counted within this particle.
  25401. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25402. */
  25403. pickedParticles: {
  25404. idx: number;
  25405. faceId: number;
  25406. }[];
  25407. /**
  25408. * This array is populated when `enableDepthSort` is set to true.
  25409. * Each element of this array is an instance of the class DepthSortedParticle.
  25410. */
  25411. depthSortedParticles: DepthSortedParticle[];
  25412. /**
  25413. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25414. * @hidden
  25415. */
  25416. _bSphereOnly: boolean;
  25417. /**
  25418. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25419. * @hidden
  25420. */
  25421. _bSphereRadiusFactor: number;
  25422. private _scene;
  25423. private _positions;
  25424. private _indices;
  25425. private _normals;
  25426. private _colors;
  25427. private _uvs;
  25428. private _indices32;
  25429. private _positions32;
  25430. private _normals32;
  25431. private _fixedNormal32;
  25432. private _colors32;
  25433. private _uvs32;
  25434. private _index;
  25435. private _updatable;
  25436. private _pickable;
  25437. private _isVisibilityBoxLocked;
  25438. private _alwaysVisible;
  25439. private _depthSort;
  25440. private _expandable;
  25441. private _shapeCounter;
  25442. private _copy;
  25443. private _color;
  25444. private _computeParticleColor;
  25445. private _computeParticleTexture;
  25446. private _computeParticleRotation;
  25447. private _computeParticleVertex;
  25448. private _computeBoundingBox;
  25449. private _depthSortParticles;
  25450. private _camera;
  25451. private _mustUnrotateFixedNormals;
  25452. private _particlesIntersect;
  25453. private _needs32Bits;
  25454. private _isNotBuilt;
  25455. /**
  25456. * Creates a SPS (Solid Particle System) object.
  25457. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25458. * @param scene (Scene) is the scene in which the SPS is added.
  25459. * @param options defines the options of the sps e.g.
  25460. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25461. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25462. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25463. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25464. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25465. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25466. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25467. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25468. */
  25469. constructor(name: string, scene: Scene, options?: {
  25470. updatable?: boolean;
  25471. isPickable?: boolean;
  25472. enableDepthSort?: boolean;
  25473. particleIntersection?: boolean;
  25474. boundingSphereOnly?: boolean;
  25475. bSphereRadiusFactor?: number;
  25476. expandable?: boolean;
  25477. });
  25478. /**
  25479. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25480. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25481. * @returns the created mesh
  25482. */
  25483. buildMesh(): Mesh;
  25484. /**
  25485. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25486. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25487. * Thus the particles generated from `digest()` have their property `position` set yet.
  25488. * @param mesh ( Mesh ) is the mesh to be digested
  25489. * @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
  25490. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25491. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25492. * @returns the current SPS
  25493. */
  25494. digest(mesh: Mesh, options?: {
  25495. facetNb?: number;
  25496. number?: number;
  25497. delta?: number;
  25498. }): SolidParticleSystem;
  25499. private _unrotateFixedNormals;
  25500. private _resetCopy;
  25501. private _meshBuilder;
  25502. private _posToShape;
  25503. private _uvsToShapeUV;
  25504. private _addParticle;
  25505. /**
  25506. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25507. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25508. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25509. * @param nb (positive integer) the number of particles to be created from this model
  25510. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25511. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25512. * @returns the number of shapes in the system
  25513. */
  25514. addShape(mesh: Mesh, nb: number, options?: {
  25515. positionFunction?: any;
  25516. vertexFunction?: any;
  25517. }): number;
  25518. private _rebuildParticle;
  25519. /**
  25520. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25521. * @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.
  25522. * @returns the SPS.
  25523. */
  25524. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25525. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25526. * Returns an array with the removed particles.
  25527. * 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.
  25528. * The SPS can't be empty so at least one particle needs to remain in place.
  25529. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25530. * @param start index of the first particle to remove
  25531. * @param end index of the last particle to remove (included)
  25532. * @returns an array populated with the removed particles
  25533. */
  25534. removeParticles(start: number, end: number): SolidParticle[];
  25535. /**
  25536. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25537. * This method calls `updateParticle()` for each particle of the SPS.
  25538. * For an animated SPS, it is usually called within the render loop.
  25539. * 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.
  25540. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25541. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25542. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25543. * @returns the SPS.
  25544. */
  25545. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25546. /**
  25547. * Disposes the SPS.
  25548. */
  25549. dispose(): void;
  25550. /**
  25551. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25552. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25553. * @returns the SPS.
  25554. */
  25555. refreshVisibleSize(): SolidParticleSystem;
  25556. /**
  25557. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25558. * @param size the size (float) of the visibility box
  25559. * note : this doesn't lock the SPS mesh bounding box.
  25560. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25561. */
  25562. setVisibilityBox(size: number): void;
  25563. /**
  25564. * Gets whether the SPS as always visible or not
  25565. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25566. */
  25567. /**
  25568. * Sets the SPS as always visible or not
  25569. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25570. */
  25571. isAlwaysVisible: boolean;
  25572. /**
  25573. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25575. */
  25576. /**
  25577. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25579. */
  25580. isVisibilityBoxLocked: boolean;
  25581. /**
  25582. * Tells to `setParticles()` to compute the particle rotations or not.
  25583. * Default value : true. The SPS is faster when it's set to false.
  25584. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25585. */
  25586. /**
  25587. * Gets if `setParticles()` computes the particle rotations or not.
  25588. * Default value : true. The SPS is faster when it's set to false.
  25589. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25590. */
  25591. computeParticleRotation: boolean;
  25592. /**
  25593. * Tells to `setParticles()` to compute the particle colors or not.
  25594. * Default value : true. The SPS is faster when it's set to false.
  25595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25596. */
  25597. /**
  25598. * Gets if `setParticles()` computes the particle colors or not.
  25599. * Default value : true. The SPS is faster when it's set to false.
  25600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25601. */
  25602. computeParticleColor: boolean;
  25603. /**
  25604. * Gets if `setParticles()` computes the particle textures or not.
  25605. * Default value : true. The SPS is faster when it's set to false.
  25606. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25607. */
  25608. computeParticleTexture: boolean;
  25609. /**
  25610. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25611. * Default value : false. The SPS is faster when it's set to false.
  25612. * Note : the particle custom vertex positions aren't stored values.
  25613. */
  25614. /**
  25615. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25616. * Default value : false. The SPS is faster when it's set to false.
  25617. * Note : the particle custom vertex positions aren't stored values.
  25618. */
  25619. computeParticleVertex: boolean;
  25620. /**
  25621. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25622. */
  25623. /**
  25624. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25625. */
  25626. computeBoundingBox: boolean;
  25627. /**
  25628. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25629. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25630. * Default : `true`
  25631. */
  25632. /**
  25633. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25634. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25635. * Default : `true`
  25636. */
  25637. depthSortParticles: boolean;
  25638. /**
  25639. * Gets if the SPS is created as expandable at construction time.
  25640. * Default : `false`
  25641. */
  25642. readonly expandable: boolean;
  25643. /**
  25644. * This function does nothing. It may be overwritten to set all the particle first values.
  25645. * The SPS doesn't call this function, you may have to call it by your own.
  25646. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25647. */
  25648. initParticles(): void;
  25649. /**
  25650. * This function does nothing. It may be overwritten to recycle a particle.
  25651. * The SPS doesn't call this function, you may have to call it by your own.
  25652. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25653. * @param particle The particle to recycle
  25654. * @returns the recycled particle
  25655. */
  25656. recycleParticle(particle: SolidParticle): SolidParticle;
  25657. /**
  25658. * Updates a particle : this function should be overwritten by the user.
  25659. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25660. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25661. * @example : just set a particle position or velocity and recycle conditions
  25662. * @param particle The particle to update
  25663. * @returns the updated particle
  25664. */
  25665. updateParticle(particle: SolidParticle): SolidParticle;
  25666. /**
  25667. * Updates a vertex of a particle : it can be overwritten by the user.
  25668. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25669. * @param particle the current particle
  25670. * @param vertex the current index of the current particle
  25671. * @param pt the index of the current vertex in the particle shape
  25672. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25673. * @example : just set a vertex particle position
  25674. * @returns the updated vertex
  25675. */
  25676. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25677. /**
  25678. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25679. * This does nothing and may be overwritten by the user.
  25680. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25681. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25682. * @param update the boolean update value actually passed to setParticles()
  25683. */
  25684. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25685. /**
  25686. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25687. * This will be passed three parameters.
  25688. * This does nothing and may be overwritten by the user.
  25689. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25690. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25691. * @param update the boolean update value actually passed to setParticles()
  25692. */
  25693. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25694. }
  25695. }
  25696. declare module BABYLON {
  25697. /**
  25698. * Represents one particle of a solid particle system.
  25699. */
  25700. export class SolidParticle {
  25701. /**
  25702. * particle global index
  25703. */
  25704. idx: number;
  25705. /**
  25706. * The color of the particle
  25707. */
  25708. color: Nullable<Color4>;
  25709. /**
  25710. * The world space position of the particle.
  25711. */
  25712. position: Vector3;
  25713. /**
  25714. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25715. */
  25716. rotation: Vector3;
  25717. /**
  25718. * The world space rotation quaternion of the particle.
  25719. */
  25720. rotationQuaternion: Nullable<Quaternion>;
  25721. /**
  25722. * The scaling of the particle.
  25723. */
  25724. scaling: Vector3;
  25725. /**
  25726. * The uvs of the particle.
  25727. */
  25728. uvs: Vector4;
  25729. /**
  25730. * The current speed of the particle.
  25731. */
  25732. velocity: Vector3;
  25733. /**
  25734. * The pivot point in the particle local space.
  25735. */
  25736. pivot: Vector3;
  25737. /**
  25738. * Must the particle be translated from its pivot point in its local space ?
  25739. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25740. * Default : false
  25741. */
  25742. translateFromPivot: boolean;
  25743. /**
  25744. * Is the particle active or not ?
  25745. */
  25746. alive: boolean;
  25747. /**
  25748. * Is the particle visible or not ?
  25749. */
  25750. isVisible: boolean;
  25751. /**
  25752. * Index of this particle in the global "positions" array (Internal use)
  25753. * @hidden
  25754. */
  25755. _pos: number;
  25756. /**
  25757. * @hidden Index of this particle in the global "indices" array (Internal use)
  25758. */
  25759. _ind: number;
  25760. /**
  25761. * @hidden ModelShape of this particle (Internal use)
  25762. */
  25763. _model: ModelShape;
  25764. /**
  25765. * ModelShape id of this particle
  25766. */
  25767. shapeId: number;
  25768. /**
  25769. * Index of the particle in its shape id
  25770. */
  25771. idxInShape: number;
  25772. /**
  25773. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25774. */
  25775. _modelBoundingInfo: BoundingInfo;
  25776. /**
  25777. * @hidden Particle BoundingInfo object (Internal use)
  25778. */
  25779. _boundingInfo: BoundingInfo;
  25780. /**
  25781. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25782. */
  25783. _sps: SolidParticleSystem;
  25784. /**
  25785. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25786. */
  25787. _stillInvisible: boolean;
  25788. /**
  25789. * @hidden Last computed particle rotation matrix
  25790. */
  25791. _rotationMatrix: number[];
  25792. /**
  25793. * Parent particle Id, if any.
  25794. * Default null.
  25795. */
  25796. parentId: Nullable<number>;
  25797. /**
  25798. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25799. * The possible values are :
  25800. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25801. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25802. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25803. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25804. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25805. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25806. * */
  25807. cullingStrategy: number;
  25808. /**
  25809. * @hidden Internal global position in the SPS.
  25810. */
  25811. _globalPosition: Vector3;
  25812. /**
  25813. * Creates a Solid Particle object.
  25814. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25815. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25816. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25817. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25818. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25819. * @param shapeId (integer) is the model shape identifier in the SPS.
  25820. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25821. * @param sps defines the sps it is associated to
  25822. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25823. */
  25824. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25825. /**
  25826. * Legacy support, changed scale to scaling
  25827. */
  25828. /**
  25829. * Legacy support, changed scale to scaling
  25830. */
  25831. scale: Vector3;
  25832. /**
  25833. * Legacy support, changed quaternion to rotationQuaternion
  25834. */
  25835. /**
  25836. * Legacy support, changed quaternion to rotationQuaternion
  25837. */
  25838. quaternion: Nullable<Quaternion>;
  25839. /**
  25840. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25841. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25842. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25843. * @returns true if it intersects
  25844. */
  25845. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25846. /**
  25847. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25848. * A particle is in the frustum if its bounding box intersects the frustum
  25849. * @param frustumPlanes defines the frustum to test
  25850. * @returns true if the particle is in the frustum planes
  25851. */
  25852. isInFrustum(frustumPlanes: Plane[]): boolean;
  25853. /**
  25854. * get the rotation matrix of the particle
  25855. * @hidden
  25856. */
  25857. getRotationMatrix(m: Matrix): void;
  25858. }
  25859. /**
  25860. * Represents the shape of the model used by one particle of a solid particle system.
  25861. * SPS internal tool, don't use it manually.
  25862. */
  25863. export class ModelShape {
  25864. /**
  25865. * The shape id
  25866. * @hidden
  25867. */
  25868. shapeID: number;
  25869. /**
  25870. * flat array of model positions (internal use)
  25871. * @hidden
  25872. */
  25873. _shape: Vector3[];
  25874. /**
  25875. * flat array of model UVs (internal use)
  25876. * @hidden
  25877. */
  25878. _shapeUV: number[];
  25879. /**
  25880. * color array of the model
  25881. * @hidden
  25882. */
  25883. _shapeColors: number[];
  25884. /**
  25885. * indices array of the model
  25886. * @hidden
  25887. */
  25888. _indices: number[];
  25889. /**
  25890. * normals array of the model
  25891. * @hidden
  25892. */
  25893. _normals: number[];
  25894. /**
  25895. * length of the shape in the model indices array (internal use)
  25896. * @hidden
  25897. */
  25898. _indicesLength: number;
  25899. /**
  25900. * Custom position function (internal use)
  25901. * @hidden
  25902. */
  25903. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25904. /**
  25905. * Custom vertex function (internal use)
  25906. * @hidden
  25907. */
  25908. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25909. /**
  25910. * 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.
  25911. * SPS internal tool, don't use it manually.
  25912. * @hidden
  25913. */
  25914. 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>);
  25915. }
  25916. /**
  25917. * Represents a Depth Sorted Particle in the solid particle system.
  25918. */
  25919. export class DepthSortedParticle {
  25920. /**
  25921. * Index of the particle in the "indices" array
  25922. */
  25923. ind: number;
  25924. /**
  25925. * Length of the particle shape in the "indices" array
  25926. */
  25927. indicesLength: number;
  25928. /**
  25929. * Squared distance from the particle to the camera
  25930. */
  25931. sqDistance: number;
  25932. }
  25933. }
  25934. declare module BABYLON {
  25935. /**
  25936. * @hidden
  25937. */
  25938. export class _MeshCollisionData {
  25939. _checkCollisions: boolean;
  25940. _collisionMask: number;
  25941. _collisionGroup: number;
  25942. _collider: Nullable<Collider>;
  25943. _oldPositionForCollisions: Vector3;
  25944. _diffPositionForCollisions: Vector3;
  25945. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25946. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25947. }
  25948. }
  25949. declare module BABYLON {
  25950. /** @hidden */
  25951. class _FacetDataStorage {
  25952. facetPositions: Vector3[];
  25953. facetNormals: Vector3[];
  25954. facetPartitioning: number[][];
  25955. facetNb: number;
  25956. partitioningSubdivisions: number;
  25957. partitioningBBoxRatio: number;
  25958. facetDataEnabled: boolean;
  25959. facetParameters: any;
  25960. bbSize: Vector3;
  25961. subDiv: {
  25962. max: number;
  25963. X: number;
  25964. Y: number;
  25965. Z: number;
  25966. };
  25967. facetDepthSort: boolean;
  25968. facetDepthSortEnabled: boolean;
  25969. depthSortedIndices: IndicesArray;
  25970. depthSortedFacets: {
  25971. ind: number;
  25972. sqDistance: number;
  25973. }[];
  25974. facetDepthSortFunction: (f1: {
  25975. ind: number;
  25976. sqDistance: number;
  25977. }, f2: {
  25978. ind: number;
  25979. sqDistance: number;
  25980. }) => number;
  25981. facetDepthSortFrom: Vector3;
  25982. facetDepthSortOrigin: Vector3;
  25983. invertedMatrix: Matrix;
  25984. }
  25985. /**
  25986. * @hidden
  25987. **/
  25988. class _InternalAbstractMeshDataInfo {
  25989. _hasVertexAlpha: boolean;
  25990. _useVertexColors: boolean;
  25991. _numBoneInfluencers: number;
  25992. _applyFog: boolean;
  25993. _receiveShadows: boolean;
  25994. _facetData: _FacetDataStorage;
  25995. _visibility: number;
  25996. _skeleton: Nullable<Skeleton>;
  25997. _layerMask: number;
  25998. _computeBonesUsingShaders: boolean;
  25999. _isActive: boolean;
  26000. _onlyForInstances: boolean;
  26001. _isActiveIntermediate: boolean;
  26002. _onlyForInstancesIntermediate: boolean;
  26003. _actAsRegularMesh: boolean;
  26004. }
  26005. /**
  26006. * Class used to store all common mesh properties
  26007. */
  26008. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26009. /** No occlusion */
  26010. static OCCLUSION_TYPE_NONE: number;
  26011. /** Occlusion set to optimisitic */
  26012. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26013. /** Occlusion set to strict */
  26014. static OCCLUSION_TYPE_STRICT: number;
  26015. /** Use an accurante occlusion algorithm */
  26016. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26017. /** Use a conservative occlusion algorithm */
  26018. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26019. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26020. * Test order :
  26021. * Is the bounding sphere outside the frustum ?
  26022. * If not, are the bounding box vertices outside the frustum ?
  26023. * It not, then the cullable object is in the frustum.
  26024. */
  26025. static readonly CULLINGSTRATEGY_STANDARD: number;
  26026. /** Culling strategy : Bounding Sphere Only.
  26027. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26028. * It's also less accurate than the standard because some not visible objects can still be selected.
  26029. * Test : is the bounding sphere outside the frustum ?
  26030. * If not, then the cullable object is in the frustum.
  26031. */
  26032. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26033. /** Culling strategy : Optimistic Inclusion.
  26034. * This in an inclusion test first, then the standard exclusion test.
  26035. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26036. * 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.
  26037. * Anyway, it's as accurate as the standard strategy.
  26038. * Test :
  26039. * Is the cullable object bounding sphere center in the frustum ?
  26040. * If not, apply the default culling strategy.
  26041. */
  26042. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26043. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26044. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26045. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26046. * 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.
  26047. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26048. * Test :
  26049. * Is the cullable object bounding sphere center in the frustum ?
  26050. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26051. */
  26052. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26053. /**
  26054. * No billboard
  26055. */
  26056. static readonly BILLBOARDMODE_NONE: number;
  26057. /** Billboard on X axis */
  26058. static readonly BILLBOARDMODE_X: number;
  26059. /** Billboard on Y axis */
  26060. static readonly BILLBOARDMODE_Y: number;
  26061. /** Billboard on Z axis */
  26062. static readonly BILLBOARDMODE_Z: number;
  26063. /** Billboard on all axes */
  26064. static readonly BILLBOARDMODE_ALL: number;
  26065. /** Billboard on using position instead of orientation */
  26066. static readonly BILLBOARDMODE_USE_POSITION: number;
  26067. /** @hidden */
  26068. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26069. /**
  26070. * The culling strategy to use to check whether the mesh must be rendered or not.
  26071. * This value can be changed at any time and will be used on the next render mesh selection.
  26072. * The possible values are :
  26073. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26074. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26075. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26076. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26077. * Please read each static variable documentation to get details about the culling process.
  26078. * */
  26079. cullingStrategy: number;
  26080. /**
  26081. * Gets the number of facets in the mesh
  26082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26083. */
  26084. readonly facetNb: number;
  26085. /**
  26086. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26088. */
  26089. partitioningSubdivisions: number;
  26090. /**
  26091. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26092. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26094. */
  26095. partitioningBBoxRatio: number;
  26096. /**
  26097. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26098. * Works only for updatable meshes.
  26099. * Doesn't work with multi-materials
  26100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26101. */
  26102. mustDepthSortFacets: boolean;
  26103. /**
  26104. * The location (Vector3) where the facet depth sort must be computed from.
  26105. * By default, the active camera position.
  26106. * Used only when facet depth sort is enabled
  26107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26108. */
  26109. facetDepthSortFrom: Vector3;
  26110. /**
  26111. * gets a boolean indicating if facetData is enabled
  26112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26113. */
  26114. readonly isFacetDataEnabled: boolean;
  26115. /** @hidden */
  26116. _updateNonUniformScalingState(value: boolean): boolean;
  26117. /**
  26118. * An event triggered when this mesh collides with another one
  26119. */
  26120. onCollideObservable: Observable<AbstractMesh>;
  26121. /** Set a function to call when this mesh collides with another one */
  26122. onCollide: () => void;
  26123. /**
  26124. * An event triggered when the collision's position changes
  26125. */
  26126. onCollisionPositionChangeObservable: Observable<Vector3>;
  26127. /** Set a function to call when the collision's position changes */
  26128. onCollisionPositionChange: () => void;
  26129. /**
  26130. * An event triggered when material is changed
  26131. */
  26132. onMaterialChangedObservable: Observable<AbstractMesh>;
  26133. /**
  26134. * Gets or sets the orientation for POV movement & rotation
  26135. */
  26136. definedFacingForward: boolean;
  26137. /** @hidden */
  26138. _occlusionQuery: Nullable<WebGLQuery>;
  26139. /** @hidden */
  26140. _renderingGroup: Nullable<RenderingGroup>;
  26141. /**
  26142. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26143. */
  26144. /**
  26145. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26146. */
  26147. visibility: number;
  26148. /** Gets or sets the alpha index used to sort transparent meshes
  26149. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26150. */
  26151. alphaIndex: number;
  26152. /**
  26153. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26154. */
  26155. isVisible: boolean;
  26156. /**
  26157. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26158. */
  26159. isPickable: boolean;
  26160. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26161. showSubMeshesBoundingBox: boolean;
  26162. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26163. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26164. */
  26165. isBlocker: boolean;
  26166. /**
  26167. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26168. */
  26169. enablePointerMoveEvents: boolean;
  26170. /**
  26171. * Specifies the rendering group id for this mesh (0 by default)
  26172. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26173. */
  26174. renderingGroupId: number;
  26175. private _material;
  26176. /** Gets or sets current material */
  26177. material: Nullable<Material>;
  26178. /**
  26179. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26180. * @see http://doc.babylonjs.com/babylon101/shadows
  26181. */
  26182. receiveShadows: boolean;
  26183. /** Defines color to use when rendering outline */
  26184. outlineColor: Color3;
  26185. /** Define width to use when rendering outline */
  26186. outlineWidth: number;
  26187. /** Defines color to use when rendering overlay */
  26188. overlayColor: Color3;
  26189. /** Defines alpha to use when rendering overlay */
  26190. overlayAlpha: number;
  26191. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26192. hasVertexAlpha: boolean;
  26193. /** 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) */
  26194. useVertexColors: boolean;
  26195. /**
  26196. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26197. */
  26198. computeBonesUsingShaders: boolean;
  26199. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26200. numBoneInfluencers: number;
  26201. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26202. applyFog: boolean;
  26203. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26204. useOctreeForRenderingSelection: boolean;
  26205. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26206. useOctreeForPicking: boolean;
  26207. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26208. useOctreeForCollisions: boolean;
  26209. /**
  26210. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26211. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26212. */
  26213. layerMask: number;
  26214. /**
  26215. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26216. */
  26217. alwaysSelectAsActiveMesh: boolean;
  26218. /**
  26219. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26220. */
  26221. doNotSyncBoundingInfo: boolean;
  26222. /**
  26223. * Gets or sets the current action manager
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26225. */
  26226. actionManager: Nullable<AbstractActionManager>;
  26227. private _meshCollisionData;
  26228. /**
  26229. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26231. */
  26232. ellipsoid: Vector3;
  26233. /**
  26234. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26236. */
  26237. ellipsoidOffset: Vector3;
  26238. /**
  26239. * Gets or sets a collision mask used to mask collisions (default is -1).
  26240. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26241. */
  26242. collisionMask: number;
  26243. /**
  26244. * Gets or sets the current collision group mask (-1 by default).
  26245. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26246. */
  26247. collisionGroup: number;
  26248. /**
  26249. * Defines edge width used when edgesRenderer is enabled
  26250. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26251. */
  26252. edgesWidth: number;
  26253. /**
  26254. * Defines edge color used when edgesRenderer is enabled
  26255. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26256. */
  26257. edgesColor: Color4;
  26258. /** @hidden */
  26259. _edgesRenderer: Nullable<IEdgesRenderer>;
  26260. /** @hidden */
  26261. _masterMesh: Nullable<AbstractMesh>;
  26262. /** @hidden */
  26263. _boundingInfo: Nullable<BoundingInfo>;
  26264. /** @hidden */
  26265. _renderId: number;
  26266. /**
  26267. * Gets or sets the list of subMeshes
  26268. * @see http://doc.babylonjs.com/how_to/multi_materials
  26269. */
  26270. subMeshes: SubMesh[];
  26271. /** @hidden */
  26272. _intersectionsInProgress: AbstractMesh[];
  26273. /** @hidden */
  26274. _unIndexed: boolean;
  26275. /** @hidden */
  26276. _lightSources: Light[];
  26277. /** Gets the list of lights affecting that mesh */
  26278. readonly lightSources: Light[];
  26279. /** @hidden */
  26280. readonly _positions: Nullable<Vector3[]>;
  26281. /** @hidden */
  26282. _waitingData: {
  26283. lods: Nullable<any>;
  26284. actions: Nullable<any>;
  26285. freezeWorldMatrix: Nullable<boolean>;
  26286. };
  26287. /** @hidden */
  26288. _bonesTransformMatrices: Nullable<Float32Array>;
  26289. /** @hidden */
  26290. _transformMatrixTexture: Nullable<RawTexture>;
  26291. /**
  26292. * Gets or sets a skeleton to apply skining transformations
  26293. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26294. */
  26295. skeleton: Nullable<Skeleton>;
  26296. /**
  26297. * An event triggered when the mesh is rebuilt.
  26298. */
  26299. onRebuildObservable: Observable<AbstractMesh>;
  26300. /**
  26301. * Creates a new AbstractMesh
  26302. * @param name defines the name of the mesh
  26303. * @param scene defines the hosting scene
  26304. */
  26305. constructor(name: string, scene?: Nullable<Scene>);
  26306. /**
  26307. * Returns the string "AbstractMesh"
  26308. * @returns "AbstractMesh"
  26309. */
  26310. getClassName(): string;
  26311. /**
  26312. * Gets a string representation of the current mesh
  26313. * @param fullDetails defines a boolean indicating if full details must be included
  26314. * @returns a string representation of the current mesh
  26315. */
  26316. toString(fullDetails?: boolean): string;
  26317. /**
  26318. * @hidden
  26319. */
  26320. protected _getEffectiveParent(): Nullable<Node>;
  26321. /** @hidden */
  26322. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26323. /** @hidden */
  26324. _rebuild(): void;
  26325. /** @hidden */
  26326. _resyncLightSources(): void;
  26327. /** @hidden */
  26328. _resyncLighSource(light: Light): void;
  26329. /** @hidden */
  26330. _unBindEffect(): void;
  26331. /** @hidden */
  26332. _removeLightSource(light: Light, dispose: boolean): void;
  26333. private _markSubMeshesAsDirty;
  26334. /** @hidden */
  26335. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26336. /** @hidden */
  26337. _markSubMeshesAsAttributesDirty(): void;
  26338. /** @hidden */
  26339. _markSubMeshesAsMiscDirty(): void;
  26340. /**
  26341. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26342. */
  26343. scaling: Vector3;
  26344. /**
  26345. * Returns true if the mesh is blocked. Implemented by child classes
  26346. */
  26347. readonly isBlocked: boolean;
  26348. /**
  26349. * Returns the mesh itself by default. Implemented by child classes
  26350. * @param camera defines the camera to use to pick the right LOD level
  26351. * @returns the currentAbstractMesh
  26352. */
  26353. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26354. /**
  26355. * Returns 0 by default. Implemented by child classes
  26356. * @returns an integer
  26357. */
  26358. getTotalVertices(): number;
  26359. /**
  26360. * Returns a positive integer : the total number of indices in this mesh geometry.
  26361. * @returns the numner of indices or zero if the mesh has no geometry.
  26362. */
  26363. getTotalIndices(): number;
  26364. /**
  26365. * Returns null by default. Implemented by child classes
  26366. * @returns null
  26367. */
  26368. getIndices(): Nullable<IndicesArray>;
  26369. /**
  26370. * Returns the array of the requested vertex data kind. Implemented by child classes
  26371. * @param kind defines the vertex data kind to use
  26372. * @returns null
  26373. */
  26374. getVerticesData(kind: string): Nullable<FloatArray>;
  26375. /**
  26376. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26377. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26378. * Note that a new underlying VertexBuffer object is created each call.
  26379. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26380. * @param kind defines vertex data kind:
  26381. * * VertexBuffer.PositionKind
  26382. * * VertexBuffer.UVKind
  26383. * * VertexBuffer.UV2Kind
  26384. * * VertexBuffer.UV3Kind
  26385. * * VertexBuffer.UV4Kind
  26386. * * VertexBuffer.UV5Kind
  26387. * * VertexBuffer.UV6Kind
  26388. * * VertexBuffer.ColorKind
  26389. * * VertexBuffer.MatricesIndicesKind
  26390. * * VertexBuffer.MatricesIndicesExtraKind
  26391. * * VertexBuffer.MatricesWeightsKind
  26392. * * VertexBuffer.MatricesWeightsExtraKind
  26393. * @param data defines the data source
  26394. * @param updatable defines if the data must be flagged as updatable (or static)
  26395. * @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
  26396. * @returns the current mesh
  26397. */
  26398. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26399. /**
  26400. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26401. * If the mesh has no geometry, it is simply returned as it is.
  26402. * @param kind defines vertex data kind:
  26403. * * VertexBuffer.PositionKind
  26404. * * VertexBuffer.UVKind
  26405. * * VertexBuffer.UV2Kind
  26406. * * VertexBuffer.UV3Kind
  26407. * * VertexBuffer.UV4Kind
  26408. * * VertexBuffer.UV5Kind
  26409. * * VertexBuffer.UV6Kind
  26410. * * VertexBuffer.ColorKind
  26411. * * VertexBuffer.MatricesIndicesKind
  26412. * * VertexBuffer.MatricesIndicesExtraKind
  26413. * * VertexBuffer.MatricesWeightsKind
  26414. * * VertexBuffer.MatricesWeightsExtraKind
  26415. * @param data defines the data source
  26416. * @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
  26417. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26418. * @returns the current mesh
  26419. */
  26420. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26421. /**
  26422. * Sets the mesh indices,
  26423. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26424. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26425. * @param totalVertices Defines the total number of vertices
  26426. * @returns the current mesh
  26427. */
  26428. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26429. /**
  26430. * Gets a boolean indicating if specific vertex data is present
  26431. * @param kind defines the vertex data kind to use
  26432. * @returns true is data kind is present
  26433. */
  26434. isVerticesDataPresent(kind: string): boolean;
  26435. /**
  26436. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26437. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26438. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26439. * @returns a BoundingInfo
  26440. */
  26441. getBoundingInfo(): BoundingInfo;
  26442. /**
  26443. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26444. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26445. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26446. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26447. * @returns the current mesh
  26448. */
  26449. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26450. /**
  26451. * Overwrite the current bounding info
  26452. * @param boundingInfo defines the new bounding info
  26453. * @returns the current mesh
  26454. */
  26455. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26456. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26457. readonly useBones: boolean;
  26458. /** @hidden */
  26459. _preActivate(): void;
  26460. /** @hidden */
  26461. _preActivateForIntermediateRendering(renderId: number): void;
  26462. /** @hidden */
  26463. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26464. /** @hidden */
  26465. _postActivate(): void;
  26466. /** @hidden */
  26467. _freeze(): void;
  26468. /** @hidden */
  26469. _unFreeze(): void;
  26470. /**
  26471. * Gets the current world matrix
  26472. * @returns a Matrix
  26473. */
  26474. getWorldMatrix(): Matrix;
  26475. /** @hidden */
  26476. _getWorldMatrixDeterminant(): number;
  26477. /**
  26478. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26479. */
  26480. readonly isAnInstance: boolean;
  26481. /**
  26482. * Gets a boolean indicating if this mesh has instances
  26483. */
  26484. readonly hasInstances: boolean;
  26485. /**
  26486. * Perform relative position change from the point of view of behind the front of the mesh.
  26487. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26488. * Supports definition of mesh facing forward or backward
  26489. * @param amountRight defines the distance on the right axis
  26490. * @param amountUp defines the distance on the up axis
  26491. * @param amountForward defines the distance on the forward axis
  26492. * @returns the current mesh
  26493. */
  26494. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26495. /**
  26496. * Calculate relative position change from the point of view of behind the front of the mesh.
  26497. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26498. * Supports definition of mesh facing forward or backward
  26499. * @param amountRight defines the distance on the right axis
  26500. * @param amountUp defines the distance on the up axis
  26501. * @param amountForward defines the distance on the forward axis
  26502. * @returns the new displacement vector
  26503. */
  26504. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26505. /**
  26506. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26507. * Supports definition of mesh facing forward or backward
  26508. * @param flipBack defines the flip
  26509. * @param twirlClockwise defines the twirl
  26510. * @param tiltRight defines the tilt
  26511. * @returns the current mesh
  26512. */
  26513. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26514. /**
  26515. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26516. * Supports definition of mesh facing forward or backward.
  26517. * @param flipBack defines the flip
  26518. * @param twirlClockwise defines the twirl
  26519. * @param tiltRight defines the tilt
  26520. * @returns the new rotation vector
  26521. */
  26522. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26523. /**
  26524. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26525. * This means the mesh underlying bounding box and sphere are recomputed.
  26526. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26527. * @returns the current mesh
  26528. */
  26529. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26530. /** @hidden */
  26531. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26532. /** @hidden */
  26533. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26534. /** @hidden */
  26535. _updateBoundingInfo(): AbstractMesh;
  26536. /** @hidden */
  26537. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26538. /** @hidden */
  26539. protected _afterComputeWorldMatrix(): void;
  26540. /** @hidden */
  26541. readonly _effectiveMesh: AbstractMesh;
  26542. /**
  26543. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26544. * A mesh is in the frustum if its bounding box intersects the frustum
  26545. * @param frustumPlanes defines the frustum to test
  26546. * @returns true if the mesh is in the frustum planes
  26547. */
  26548. isInFrustum(frustumPlanes: Plane[]): boolean;
  26549. /**
  26550. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26551. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26552. * @param frustumPlanes defines the frustum to test
  26553. * @returns true if the mesh is completely in the frustum planes
  26554. */
  26555. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26556. /**
  26557. * True if the mesh intersects another mesh or a SolidParticle object
  26558. * @param mesh defines a target mesh or SolidParticle to test
  26559. * @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)
  26560. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26561. * @returns true if there is an intersection
  26562. */
  26563. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26564. /**
  26565. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26566. * @param point defines the point to test
  26567. * @returns true if there is an intersection
  26568. */
  26569. intersectsPoint(point: Vector3): boolean;
  26570. /**
  26571. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26572. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26573. */
  26574. checkCollisions: boolean;
  26575. /**
  26576. * Gets Collider object used to compute collisions (not physics)
  26577. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26578. */
  26579. readonly collider: Nullable<Collider>;
  26580. /**
  26581. * Move the mesh using collision engine
  26582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26583. * @param displacement defines the requested displacement vector
  26584. * @returns the current mesh
  26585. */
  26586. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26587. private _onCollisionPositionChange;
  26588. /** @hidden */
  26589. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26590. /** @hidden */
  26591. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26592. /** @hidden */
  26593. _checkCollision(collider: Collider): AbstractMesh;
  26594. /** @hidden */
  26595. _generatePointsArray(): boolean;
  26596. /**
  26597. * Checks if the passed Ray intersects with the mesh
  26598. * @param ray defines the ray to use
  26599. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26601. * @returns the picking info
  26602. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26603. */
  26604. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26605. /**
  26606. * Clones the current mesh
  26607. * @param name defines the mesh name
  26608. * @param newParent defines the new mesh parent
  26609. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26610. * @returns the new mesh
  26611. */
  26612. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26613. /**
  26614. * Disposes all the submeshes of the current meshnp
  26615. * @returns the current mesh
  26616. */
  26617. releaseSubMeshes(): AbstractMesh;
  26618. /**
  26619. * Releases resources associated with this abstract mesh.
  26620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26622. */
  26623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26624. /**
  26625. * Adds the passed mesh as a child to the current mesh
  26626. * @param mesh defines the child mesh
  26627. * @returns the current mesh
  26628. */
  26629. addChild(mesh: AbstractMesh): AbstractMesh;
  26630. /**
  26631. * Removes the passed mesh from the current mesh children list
  26632. * @param mesh defines the child mesh
  26633. * @returns the current mesh
  26634. */
  26635. removeChild(mesh: AbstractMesh): AbstractMesh;
  26636. /** @hidden */
  26637. private _initFacetData;
  26638. /**
  26639. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26640. * This method can be called within the render loop.
  26641. * 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
  26642. * @returns the current mesh
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26644. */
  26645. updateFacetData(): AbstractMesh;
  26646. /**
  26647. * Returns the facetLocalNormals array.
  26648. * The normals are expressed in the mesh local spac
  26649. * @returns an array of Vector3
  26650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26651. */
  26652. getFacetLocalNormals(): Vector3[];
  26653. /**
  26654. * Returns the facetLocalPositions array.
  26655. * The facet positions are expressed in the mesh local space
  26656. * @returns an array of Vector3
  26657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26658. */
  26659. getFacetLocalPositions(): Vector3[];
  26660. /**
  26661. * Returns the facetLocalPartioning array
  26662. * @returns an array of array of numbers
  26663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26664. */
  26665. getFacetLocalPartitioning(): number[][];
  26666. /**
  26667. * Returns the i-th facet position in the world system.
  26668. * This method allocates a new Vector3 per call
  26669. * @param i defines the facet index
  26670. * @returns a new Vector3
  26671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26672. */
  26673. getFacetPosition(i: number): Vector3;
  26674. /**
  26675. * Sets the reference Vector3 with the i-th facet position in the world system
  26676. * @param i defines the facet index
  26677. * @param ref defines the target vector
  26678. * @returns the current mesh
  26679. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26680. */
  26681. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26682. /**
  26683. * Returns the i-th facet normal in the world system.
  26684. * This method allocates a new Vector3 per call
  26685. * @param i defines the facet index
  26686. * @returns a new Vector3
  26687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26688. */
  26689. getFacetNormal(i: number): Vector3;
  26690. /**
  26691. * Sets the reference Vector3 with the i-th facet normal in the world system
  26692. * @param i defines the facet index
  26693. * @param ref defines the target vector
  26694. * @returns the current mesh
  26695. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26696. */
  26697. getFacetNormalToRef(i: number, ref: Vector3): this;
  26698. /**
  26699. * 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)
  26700. * @param x defines x coordinate
  26701. * @param y defines y coordinate
  26702. * @param z defines z coordinate
  26703. * @returns the array of facet indexes
  26704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26705. */
  26706. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26707. /**
  26708. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26709. * @param projected sets as the (x,y,z) world projection on the facet
  26710. * @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
  26711. * @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
  26712. * @param x defines x coordinate
  26713. * @param y defines y coordinate
  26714. * @param z defines z coordinate
  26715. * @returns the face index if found (or null instead)
  26716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26717. */
  26718. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26719. /**
  26720. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26721. * @param projected sets as the (x,y,z) local projection on the facet
  26722. * @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
  26723. * @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
  26724. * @param x defines x coordinate
  26725. * @param y defines y coordinate
  26726. * @param z defines z coordinate
  26727. * @returns the face index if found (or null instead)
  26728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26729. */
  26730. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26731. /**
  26732. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26733. * @returns the parameters
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26735. */
  26736. getFacetDataParameters(): any;
  26737. /**
  26738. * Disables the feature FacetData and frees the related memory
  26739. * @returns the current mesh
  26740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26741. */
  26742. disableFacetData(): AbstractMesh;
  26743. /**
  26744. * Updates the AbstractMesh indices array
  26745. * @param indices defines the data source
  26746. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26747. * @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)
  26748. * @returns the current mesh
  26749. */
  26750. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26751. /**
  26752. * Creates new normals data for the mesh
  26753. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26754. * @returns the current mesh
  26755. */
  26756. createNormals(updatable: boolean): AbstractMesh;
  26757. /**
  26758. * Align the mesh with a normal
  26759. * @param normal defines the normal to use
  26760. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26761. * @returns the current mesh
  26762. */
  26763. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26764. /** @hidden */
  26765. _checkOcclusionQuery(): boolean;
  26766. /**
  26767. * Disables the mesh edge rendering mode
  26768. * @returns the currentAbstractMesh
  26769. */
  26770. disableEdgesRendering(): AbstractMesh;
  26771. /**
  26772. * Enables the edge rendering mode on the mesh.
  26773. * This mode makes the mesh edges visible
  26774. * @param epsilon defines the maximal distance between two angles to detect a face
  26775. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26776. * @returns the currentAbstractMesh
  26777. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26778. */
  26779. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26780. }
  26781. }
  26782. declare module BABYLON {
  26783. /**
  26784. * Interface used to define ActionEvent
  26785. */
  26786. export interface IActionEvent {
  26787. /** The mesh or sprite that triggered the action */
  26788. source: any;
  26789. /** The X mouse cursor position at the time of the event */
  26790. pointerX: number;
  26791. /** The Y mouse cursor position at the time of the event */
  26792. pointerY: number;
  26793. /** The mesh that is currently pointed at (can be null) */
  26794. meshUnderPointer: Nullable<AbstractMesh>;
  26795. /** the original (browser) event that triggered the ActionEvent */
  26796. sourceEvent?: any;
  26797. /** additional data for the event */
  26798. additionalData?: any;
  26799. }
  26800. /**
  26801. * ActionEvent is the event being sent when an action is triggered.
  26802. */
  26803. export class ActionEvent implements IActionEvent {
  26804. /** The mesh or sprite that triggered the action */
  26805. source: any;
  26806. /** The X mouse cursor position at the time of the event */
  26807. pointerX: number;
  26808. /** The Y mouse cursor position at the time of the event */
  26809. pointerY: number;
  26810. /** The mesh that is currently pointed at (can be null) */
  26811. meshUnderPointer: Nullable<AbstractMesh>;
  26812. /** the original (browser) event that triggered the ActionEvent */
  26813. sourceEvent?: any;
  26814. /** additional data for the event */
  26815. additionalData?: any;
  26816. /**
  26817. * Creates a new ActionEvent
  26818. * @param source The mesh or sprite that triggered the action
  26819. * @param pointerX The X mouse cursor position at the time of the event
  26820. * @param pointerY The Y mouse cursor position at the time of the event
  26821. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26822. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26823. * @param additionalData additional data for the event
  26824. */
  26825. constructor(
  26826. /** The mesh or sprite that triggered the action */
  26827. source: any,
  26828. /** The X mouse cursor position at the time of the event */
  26829. pointerX: number,
  26830. /** The Y mouse cursor position at the time of the event */
  26831. pointerY: number,
  26832. /** The mesh that is currently pointed at (can be null) */
  26833. meshUnderPointer: Nullable<AbstractMesh>,
  26834. /** the original (browser) event that triggered the ActionEvent */
  26835. sourceEvent?: any,
  26836. /** additional data for the event */
  26837. additionalData?: any);
  26838. /**
  26839. * Helper function to auto-create an ActionEvent from a source mesh.
  26840. * @param source The source mesh that triggered the event
  26841. * @param evt The original (browser) event
  26842. * @param additionalData additional data for the event
  26843. * @returns the new ActionEvent
  26844. */
  26845. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26846. /**
  26847. * Helper function to auto-create an ActionEvent from a source sprite
  26848. * @param source The source sprite that triggered the event
  26849. * @param scene Scene associated with the sprite
  26850. * @param evt The original (browser) event
  26851. * @param additionalData additional data for the event
  26852. * @returns the new ActionEvent
  26853. */
  26854. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26855. /**
  26856. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26857. * @param scene the scene where the event occurred
  26858. * @param evt The original (browser) event
  26859. * @returns the new ActionEvent
  26860. */
  26861. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26862. /**
  26863. * Helper function to auto-create an ActionEvent from a primitive
  26864. * @param prim defines the target primitive
  26865. * @param pointerPos defines the pointer position
  26866. * @param evt The original (browser) event
  26867. * @param additionalData additional data for the event
  26868. * @returns the new ActionEvent
  26869. */
  26870. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26871. }
  26872. }
  26873. declare module BABYLON {
  26874. /**
  26875. * Abstract class used to decouple action Manager from scene and meshes.
  26876. * Do not instantiate.
  26877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26878. */
  26879. export abstract class AbstractActionManager implements IDisposable {
  26880. /** Gets the list of active triggers */
  26881. static Triggers: {
  26882. [key: string]: number;
  26883. };
  26884. /** Gets the cursor to use when hovering items */
  26885. hoverCursor: string;
  26886. /** Gets the list of actions */
  26887. actions: IAction[];
  26888. /**
  26889. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26890. */
  26891. isRecursive: boolean;
  26892. /**
  26893. * Releases all associated resources
  26894. */
  26895. abstract dispose(): void;
  26896. /**
  26897. * Does this action manager has pointer triggers
  26898. */
  26899. abstract readonly hasPointerTriggers: boolean;
  26900. /**
  26901. * Does this action manager has pick triggers
  26902. */
  26903. abstract readonly hasPickTriggers: boolean;
  26904. /**
  26905. * Process a specific trigger
  26906. * @param trigger defines the trigger to process
  26907. * @param evt defines the event details to be processed
  26908. */
  26909. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26910. /**
  26911. * Does this action manager handles actions of any of the given triggers
  26912. * @param triggers defines the triggers to be tested
  26913. * @return a boolean indicating whether one (or more) of the triggers is handled
  26914. */
  26915. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26916. /**
  26917. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26918. * speed.
  26919. * @param triggerA defines the trigger to be tested
  26920. * @param triggerB defines the trigger to be tested
  26921. * @return a boolean indicating whether one (or more) of the triggers is handled
  26922. */
  26923. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26924. /**
  26925. * Does this action manager handles actions of a given trigger
  26926. * @param trigger defines the trigger to be tested
  26927. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26928. * @return whether the trigger is handled
  26929. */
  26930. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26931. /**
  26932. * Serialize this manager to a JSON object
  26933. * @param name defines the property name to store this manager
  26934. * @returns a JSON representation of this manager
  26935. */
  26936. abstract serialize(name: string): any;
  26937. /**
  26938. * Registers an action to this action manager
  26939. * @param action defines the action to be registered
  26940. * @return the action amended (prepared) after registration
  26941. */
  26942. abstract registerAction(action: IAction): Nullable<IAction>;
  26943. /**
  26944. * Unregisters an action to this action manager
  26945. * @param action defines the action to be unregistered
  26946. * @return a boolean indicating whether the action has been unregistered
  26947. */
  26948. abstract unregisterAction(action: IAction): Boolean;
  26949. /**
  26950. * Does exist one action manager with at least one trigger
  26951. **/
  26952. static readonly HasTriggers: boolean;
  26953. /**
  26954. * Does exist one action manager with at least one pick trigger
  26955. **/
  26956. static readonly HasPickTriggers: boolean;
  26957. /**
  26958. * Does exist one action manager that handles actions of a given trigger
  26959. * @param trigger defines the trigger to be tested
  26960. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26961. **/
  26962. static HasSpecificTrigger(trigger: number): boolean;
  26963. }
  26964. }
  26965. declare module BABYLON {
  26966. /**
  26967. * Defines how a node can be built from a string name.
  26968. */
  26969. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26970. /**
  26971. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26972. */
  26973. export class Node implements IBehaviorAware<Node> {
  26974. /** @hidden */
  26975. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26976. private static _NodeConstructors;
  26977. /**
  26978. * Add a new node constructor
  26979. * @param type defines the type name of the node to construct
  26980. * @param constructorFunc defines the constructor function
  26981. */
  26982. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26983. /**
  26984. * Returns a node constructor based on type name
  26985. * @param type defines the type name
  26986. * @param name defines the new node name
  26987. * @param scene defines the hosting scene
  26988. * @param options defines optional options to transmit to constructors
  26989. * @returns the new constructor or null
  26990. */
  26991. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26992. /**
  26993. * Gets or sets the name of the node
  26994. */
  26995. name: string;
  26996. /**
  26997. * Gets or sets the id of the node
  26998. */
  26999. id: string;
  27000. /**
  27001. * Gets or sets the unique id of the node
  27002. */
  27003. uniqueId: number;
  27004. /**
  27005. * Gets or sets a string used to store user defined state for the node
  27006. */
  27007. state: string;
  27008. /**
  27009. * Gets or sets an object used to store user defined information for the node
  27010. */
  27011. metadata: any;
  27012. /**
  27013. * For internal use only. Please do not use.
  27014. */
  27015. reservedDataStore: any;
  27016. /**
  27017. * List of inspectable custom properties (used by the Inspector)
  27018. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27019. */
  27020. inspectableCustomProperties: IInspectable[];
  27021. private _doNotSerialize;
  27022. /**
  27023. * Gets or sets a boolean used to define if the node must be serialized
  27024. */
  27025. doNotSerialize: boolean;
  27026. /** @hidden */
  27027. _isDisposed: boolean;
  27028. /**
  27029. * Gets a list of Animations associated with the node
  27030. */
  27031. animations: Animation[];
  27032. protected _ranges: {
  27033. [name: string]: Nullable<AnimationRange>;
  27034. };
  27035. /**
  27036. * Callback raised when the node is ready to be used
  27037. */
  27038. onReady: Nullable<(node: Node) => void>;
  27039. private _isEnabled;
  27040. private _isParentEnabled;
  27041. private _isReady;
  27042. /** @hidden */
  27043. _currentRenderId: number;
  27044. private _parentUpdateId;
  27045. /** @hidden */
  27046. _childUpdateId: number;
  27047. /** @hidden */
  27048. _waitingParentId: Nullable<string>;
  27049. /** @hidden */
  27050. _scene: Scene;
  27051. /** @hidden */
  27052. _cache: any;
  27053. private _parentNode;
  27054. private _children;
  27055. /** @hidden */
  27056. _worldMatrix: Matrix;
  27057. /** @hidden */
  27058. _worldMatrixDeterminant: number;
  27059. /** @hidden */
  27060. _worldMatrixDeterminantIsDirty: boolean;
  27061. /** @hidden */
  27062. private _sceneRootNodesIndex;
  27063. /**
  27064. * Gets a boolean indicating if the node has been disposed
  27065. * @returns true if the node was disposed
  27066. */
  27067. isDisposed(): boolean;
  27068. /**
  27069. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27070. * @see https://doc.babylonjs.com/how_to/parenting
  27071. */
  27072. parent: Nullable<Node>;
  27073. /** @hidden */
  27074. _addToSceneRootNodes(): void;
  27075. /** @hidden */
  27076. _removeFromSceneRootNodes(): void;
  27077. private _animationPropertiesOverride;
  27078. /**
  27079. * Gets or sets the animation properties override
  27080. */
  27081. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27082. /**
  27083. * Gets a string idenfifying the name of the class
  27084. * @returns "Node" string
  27085. */
  27086. getClassName(): string;
  27087. /** @hidden */
  27088. readonly _isNode: boolean;
  27089. /**
  27090. * An event triggered when the mesh is disposed
  27091. */
  27092. onDisposeObservable: Observable<Node>;
  27093. private _onDisposeObserver;
  27094. /**
  27095. * Sets a callback that will be raised when the node will be disposed
  27096. */
  27097. onDispose: () => void;
  27098. /**
  27099. * Creates a new Node
  27100. * @param name the name and id to be given to this node
  27101. * @param scene the scene this node will be added to
  27102. */
  27103. constructor(name: string, scene?: Nullable<Scene>);
  27104. /**
  27105. * Gets the scene of the node
  27106. * @returns a scene
  27107. */
  27108. getScene(): Scene;
  27109. /**
  27110. * Gets the engine of the node
  27111. * @returns a Engine
  27112. */
  27113. getEngine(): Engine;
  27114. private _behaviors;
  27115. /**
  27116. * Attach a behavior to the node
  27117. * @see http://doc.babylonjs.com/features/behaviour
  27118. * @param behavior defines the behavior to attach
  27119. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27120. * @returns the current Node
  27121. */
  27122. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27123. /**
  27124. * Remove an attached behavior
  27125. * @see http://doc.babylonjs.com/features/behaviour
  27126. * @param behavior defines the behavior to attach
  27127. * @returns the current Node
  27128. */
  27129. removeBehavior(behavior: Behavior<Node>): Node;
  27130. /**
  27131. * Gets the list of attached behaviors
  27132. * @see http://doc.babylonjs.com/features/behaviour
  27133. */
  27134. readonly behaviors: Behavior<Node>[];
  27135. /**
  27136. * Gets an attached behavior by name
  27137. * @param name defines the name of the behavior to look for
  27138. * @see http://doc.babylonjs.com/features/behaviour
  27139. * @returns null if behavior was not found else the requested behavior
  27140. */
  27141. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27142. /**
  27143. * Returns the latest update of the World matrix
  27144. * @returns a Matrix
  27145. */
  27146. getWorldMatrix(): Matrix;
  27147. /** @hidden */
  27148. _getWorldMatrixDeterminant(): number;
  27149. /**
  27150. * Returns directly the latest state of the mesh World matrix.
  27151. * A Matrix is returned.
  27152. */
  27153. readonly worldMatrixFromCache: Matrix;
  27154. /** @hidden */
  27155. _initCache(): void;
  27156. /** @hidden */
  27157. updateCache(force?: boolean): void;
  27158. /** @hidden */
  27159. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27160. /** @hidden */
  27161. _updateCache(ignoreParentClass?: boolean): void;
  27162. /** @hidden */
  27163. _isSynchronized(): boolean;
  27164. /** @hidden */
  27165. _markSyncedWithParent(): void;
  27166. /** @hidden */
  27167. isSynchronizedWithParent(): boolean;
  27168. /** @hidden */
  27169. isSynchronized(): boolean;
  27170. /**
  27171. * Is this node ready to be used/rendered
  27172. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27173. * @return true if the node is ready
  27174. */
  27175. isReady(completeCheck?: boolean): boolean;
  27176. /**
  27177. * Is this node enabled?
  27178. * 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
  27179. * @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
  27180. * @return whether this node (and its parent) is enabled
  27181. */
  27182. isEnabled(checkAncestors?: boolean): boolean;
  27183. /** @hidden */
  27184. protected _syncParentEnabledState(): void;
  27185. /**
  27186. * Set the enabled state of this node
  27187. * @param value defines the new enabled state
  27188. */
  27189. setEnabled(value: boolean): void;
  27190. /**
  27191. * Is this node a descendant of the given node?
  27192. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27193. * @param ancestor defines the parent node to inspect
  27194. * @returns a boolean indicating if this node is a descendant of the given node
  27195. */
  27196. isDescendantOf(ancestor: Node): boolean;
  27197. /** @hidden */
  27198. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27199. /**
  27200. * Will return all nodes that have this node as ascendant
  27201. * @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
  27202. * @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
  27203. * @return all children nodes of all types
  27204. */
  27205. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27206. /**
  27207. * Get all child-meshes of this node
  27208. * @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)
  27209. * @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
  27210. * @returns an array of AbstractMesh
  27211. */
  27212. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27213. /**
  27214. * Get all direct children of this node
  27215. * @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
  27216. * @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)
  27217. * @returns an array of Node
  27218. */
  27219. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27220. /** @hidden */
  27221. _setReady(state: boolean): void;
  27222. /**
  27223. * Get an animation by name
  27224. * @param name defines the name of the animation to look for
  27225. * @returns null if not found else the requested animation
  27226. */
  27227. getAnimationByName(name: string): Nullable<Animation>;
  27228. /**
  27229. * Creates an animation range for this node
  27230. * @param name defines the name of the range
  27231. * @param from defines the starting key
  27232. * @param to defines the end key
  27233. */
  27234. createAnimationRange(name: string, from: number, to: number): void;
  27235. /**
  27236. * Delete a specific animation range
  27237. * @param name defines the name of the range to delete
  27238. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27239. */
  27240. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27241. /**
  27242. * Get an animation range by name
  27243. * @param name defines the name of the animation range to look for
  27244. * @returns null if not found else the requested animation range
  27245. */
  27246. getAnimationRange(name: string): Nullable<AnimationRange>;
  27247. /**
  27248. * Gets the list of all animation ranges defined on this node
  27249. * @returns an array
  27250. */
  27251. getAnimationRanges(): Nullable<AnimationRange>[];
  27252. /**
  27253. * Will start the animation sequence
  27254. * @param name defines the range frames for animation sequence
  27255. * @param loop defines if the animation should loop (false by default)
  27256. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27257. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27258. * @returns the object created for this animation. If range does not exist, it will return null
  27259. */
  27260. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27261. /**
  27262. * Serialize animation ranges into a JSON compatible object
  27263. * @returns serialization object
  27264. */
  27265. serializeAnimationRanges(): any;
  27266. /**
  27267. * Computes the world matrix of the node
  27268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27269. * @returns the world matrix
  27270. */
  27271. computeWorldMatrix(force?: boolean): Matrix;
  27272. /**
  27273. * Releases resources associated with this node.
  27274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27276. */
  27277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27278. /**
  27279. * Parse animation range data from a serialization object and store them into a given node
  27280. * @param node defines where to store the animation ranges
  27281. * @param parsedNode defines the serialization object to read data from
  27282. * @param scene defines the hosting scene
  27283. */
  27284. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27285. /**
  27286. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27287. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27288. * @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
  27289. * @returns the new bounding vectors
  27290. */
  27291. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27292. min: Vector3;
  27293. max: Vector3;
  27294. };
  27295. }
  27296. }
  27297. declare module BABYLON {
  27298. /**
  27299. * @hidden
  27300. */
  27301. export class _IAnimationState {
  27302. key: number;
  27303. repeatCount: number;
  27304. workValue?: any;
  27305. loopMode?: number;
  27306. offsetValue?: any;
  27307. highLimitValue?: any;
  27308. }
  27309. /**
  27310. * Class used to store any kind of animation
  27311. */
  27312. export class Animation {
  27313. /**Name of the animation */
  27314. name: string;
  27315. /**Property to animate */
  27316. targetProperty: string;
  27317. /**The frames per second of the animation */
  27318. framePerSecond: number;
  27319. /**The data type of the animation */
  27320. dataType: number;
  27321. /**The loop mode of the animation */
  27322. loopMode?: number | undefined;
  27323. /**Specifies if blending should be enabled */
  27324. enableBlending?: boolean | undefined;
  27325. /**
  27326. * Use matrix interpolation instead of using direct key value when animating matrices
  27327. */
  27328. static AllowMatricesInterpolation: boolean;
  27329. /**
  27330. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27331. */
  27332. static AllowMatrixDecomposeForInterpolation: boolean;
  27333. /**
  27334. * Stores the key frames of the animation
  27335. */
  27336. private _keys;
  27337. /**
  27338. * Stores the easing function of the animation
  27339. */
  27340. private _easingFunction;
  27341. /**
  27342. * @hidden Internal use only
  27343. */
  27344. _runtimeAnimations: RuntimeAnimation[];
  27345. /**
  27346. * The set of event that will be linked to this animation
  27347. */
  27348. private _events;
  27349. /**
  27350. * Stores an array of target property paths
  27351. */
  27352. targetPropertyPath: string[];
  27353. /**
  27354. * Stores the blending speed of the animation
  27355. */
  27356. blendingSpeed: number;
  27357. /**
  27358. * Stores the animation ranges for the animation
  27359. */
  27360. private _ranges;
  27361. /**
  27362. * @hidden Internal use
  27363. */
  27364. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27365. /**
  27366. * Sets up an animation
  27367. * @param property The property to animate
  27368. * @param animationType The animation type to apply
  27369. * @param framePerSecond The frames per second of the animation
  27370. * @param easingFunction The easing function used in the animation
  27371. * @returns The created animation
  27372. */
  27373. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27374. /**
  27375. * Create and start an animation on a node
  27376. * @param name defines the name of the global animation that will be run on all nodes
  27377. * @param node defines the root node where the animation will take place
  27378. * @param targetProperty defines property to animate
  27379. * @param framePerSecond defines the number of frame per second yo use
  27380. * @param totalFrame defines the number of frames in total
  27381. * @param from defines the initial value
  27382. * @param to defines the final value
  27383. * @param loopMode defines which loop mode you want to use (off by default)
  27384. * @param easingFunction defines the easing function to use (linear by default)
  27385. * @param onAnimationEnd defines the callback to call when animation end
  27386. * @returns the animatable created for this animation
  27387. */
  27388. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27389. /**
  27390. * Create and start an animation on a node and its descendants
  27391. * @param name defines the name of the global animation that will be run on all nodes
  27392. * @param node defines the root node where the animation will take place
  27393. * @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
  27394. * @param targetProperty defines property to animate
  27395. * @param framePerSecond defines the number of frame per second to use
  27396. * @param totalFrame defines the number of frames in total
  27397. * @param from defines the initial value
  27398. * @param to defines the final value
  27399. * @param loopMode defines which loop mode you want to use (off by default)
  27400. * @param easingFunction defines the easing function to use (linear by default)
  27401. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27402. * @returns the list of animatables created for all nodes
  27403. * @example https://www.babylonjs-playground.com/#MH0VLI
  27404. */
  27405. 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[]>;
  27406. /**
  27407. * Creates a new animation, merges it with the existing animations and starts it
  27408. * @param name Name of the animation
  27409. * @param node Node which contains the scene that begins the animations
  27410. * @param targetProperty Specifies which property to animate
  27411. * @param framePerSecond The frames per second of the animation
  27412. * @param totalFrame The total number of frames
  27413. * @param from The frame at the beginning of the animation
  27414. * @param to The frame at the end of the animation
  27415. * @param loopMode Specifies the loop mode of the animation
  27416. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27417. * @param onAnimationEnd Callback to run once the animation is complete
  27418. * @returns Nullable animation
  27419. */
  27420. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27421. /**
  27422. * Transition property of an host to the target Value
  27423. * @param property The property to transition
  27424. * @param targetValue The target Value of the property
  27425. * @param host The object where the property to animate belongs
  27426. * @param scene Scene used to run the animation
  27427. * @param frameRate Framerate (in frame/s) to use
  27428. * @param transition The transition type we want to use
  27429. * @param duration The duration of the animation, in milliseconds
  27430. * @param onAnimationEnd Callback trigger at the end of the animation
  27431. * @returns Nullable animation
  27432. */
  27433. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27434. /**
  27435. * Return the array of runtime animations currently using this animation
  27436. */
  27437. readonly runtimeAnimations: RuntimeAnimation[];
  27438. /**
  27439. * Specifies if any of the runtime animations are currently running
  27440. */
  27441. readonly hasRunningRuntimeAnimations: boolean;
  27442. /**
  27443. * Initializes the animation
  27444. * @param name Name of the animation
  27445. * @param targetProperty Property to animate
  27446. * @param framePerSecond The frames per second of the animation
  27447. * @param dataType The data type of the animation
  27448. * @param loopMode The loop mode of the animation
  27449. * @param enableBlending Specifies if blending should be enabled
  27450. */
  27451. constructor(
  27452. /**Name of the animation */
  27453. name: string,
  27454. /**Property to animate */
  27455. targetProperty: string,
  27456. /**The frames per second of the animation */
  27457. framePerSecond: number,
  27458. /**The data type of the animation */
  27459. dataType: number,
  27460. /**The loop mode of the animation */
  27461. loopMode?: number | undefined,
  27462. /**Specifies if blending should be enabled */
  27463. enableBlending?: boolean | undefined);
  27464. /**
  27465. * Converts the animation to a string
  27466. * @param fullDetails support for multiple levels of logging within scene loading
  27467. * @returns String form of the animation
  27468. */
  27469. toString(fullDetails?: boolean): string;
  27470. /**
  27471. * Add an event to this animation
  27472. * @param event Event to add
  27473. */
  27474. addEvent(event: AnimationEvent): void;
  27475. /**
  27476. * Remove all events found at the given frame
  27477. * @param frame The frame to remove events from
  27478. */
  27479. removeEvents(frame: number): void;
  27480. /**
  27481. * Retrieves all the events from the animation
  27482. * @returns Events from the animation
  27483. */
  27484. getEvents(): AnimationEvent[];
  27485. /**
  27486. * Creates an animation range
  27487. * @param name Name of the animation range
  27488. * @param from Starting frame of the animation range
  27489. * @param to Ending frame of the animation
  27490. */
  27491. createRange(name: string, from: number, to: number): void;
  27492. /**
  27493. * Deletes an animation range by name
  27494. * @param name Name of the animation range to delete
  27495. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27496. */
  27497. deleteRange(name: string, deleteFrames?: boolean): void;
  27498. /**
  27499. * Gets the animation range by name, or null if not defined
  27500. * @param name Name of the animation range
  27501. * @returns Nullable animation range
  27502. */
  27503. getRange(name: string): Nullable<AnimationRange>;
  27504. /**
  27505. * Gets the key frames from the animation
  27506. * @returns The key frames of the animation
  27507. */
  27508. getKeys(): Array<IAnimationKey>;
  27509. /**
  27510. * Gets the highest frame rate of the animation
  27511. * @returns Highest frame rate of the animation
  27512. */
  27513. getHighestFrame(): number;
  27514. /**
  27515. * Gets the easing function of the animation
  27516. * @returns Easing function of the animation
  27517. */
  27518. getEasingFunction(): IEasingFunction;
  27519. /**
  27520. * Sets the easing function of the animation
  27521. * @param easingFunction A custom mathematical formula for animation
  27522. */
  27523. setEasingFunction(easingFunction: EasingFunction): void;
  27524. /**
  27525. * Interpolates a scalar linearly
  27526. * @param startValue Start value of the animation curve
  27527. * @param endValue End value of the animation curve
  27528. * @param gradient Scalar amount to interpolate
  27529. * @returns Interpolated scalar value
  27530. */
  27531. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27532. /**
  27533. * Interpolates a scalar cubically
  27534. * @param startValue Start value of the animation curve
  27535. * @param outTangent End tangent of the animation
  27536. * @param endValue End value of the animation curve
  27537. * @param inTangent Start tangent of the animation curve
  27538. * @param gradient Scalar amount to interpolate
  27539. * @returns Interpolated scalar value
  27540. */
  27541. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27542. /**
  27543. * Interpolates a quaternion using a spherical linear interpolation
  27544. * @param startValue Start value of the animation curve
  27545. * @param endValue End value of the animation curve
  27546. * @param gradient Scalar amount to interpolate
  27547. * @returns Interpolated quaternion value
  27548. */
  27549. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27550. /**
  27551. * Interpolates a quaternion cubically
  27552. * @param startValue Start value of the animation curve
  27553. * @param outTangent End tangent of the animation curve
  27554. * @param endValue End value of the animation curve
  27555. * @param inTangent Start tangent of the animation curve
  27556. * @param gradient Scalar amount to interpolate
  27557. * @returns Interpolated quaternion value
  27558. */
  27559. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27560. /**
  27561. * Interpolates a Vector3 linearl
  27562. * @param startValue Start value of the animation curve
  27563. * @param endValue End value of the animation curve
  27564. * @param gradient Scalar amount to interpolate
  27565. * @returns Interpolated scalar value
  27566. */
  27567. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27568. /**
  27569. * Interpolates a Vector3 cubically
  27570. * @param startValue Start value of the animation curve
  27571. * @param outTangent End tangent of the animation
  27572. * @param endValue End value of the animation curve
  27573. * @param inTangent Start tangent of the animation curve
  27574. * @param gradient Scalar amount to interpolate
  27575. * @returns InterpolatedVector3 value
  27576. */
  27577. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27578. /**
  27579. * Interpolates a Vector2 linearly
  27580. * @param startValue Start value of the animation curve
  27581. * @param endValue End value of the animation curve
  27582. * @param gradient Scalar amount to interpolate
  27583. * @returns Interpolated Vector2 value
  27584. */
  27585. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27586. /**
  27587. * Interpolates a Vector2 cubically
  27588. * @param startValue Start value of the animation curve
  27589. * @param outTangent End tangent of the animation
  27590. * @param endValue End value of the animation curve
  27591. * @param inTangent Start tangent of the animation curve
  27592. * @param gradient Scalar amount to interpolate
  27593. * @returns Interpolated Vector2 value
  27594. */
  27595. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27596. /**
  27597. * Interpolates a size linearly
  27598. * @param startValue Start value of the animation curve
  27599. * @param endValue End value of the animation curve
  27600. * @param gradient Scalar amount to interpolate
  27601. * @returns Interpolated Size value
  27602. */
  27603. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27604. /**
  27605. * Interpolates a Color3 linearly
  27606. * @param startValue Start value of the animation curve
  27607. * @param endValue End value of the animation curve
  27608. * @param gradient Scalar amount to interpolate
  27609. * @returns Interpolated Color3 value
  27610. */
  27611. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27612. /**
  27613. * Interpolates a Color4 linearly
  27614. * @param startValue Start value of the animation curve
  27615. * @param endValue End value of the animation curve
  27616. * @param gradient Scalar amount to interpolate
  27617. * @returns Interpolated Color3 value
  27618. */
  27619. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27620. /**
  27621. * @hidden Internal use only
  27622. */
  27623. _getKeyValue(value: any): any;
  27624. /**
  27625. * @hidden Internal use only
  27626. */
  27627. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27628. /**
  27629. * Defines the function to use to interpolate matrices
  27630. * @param startValue defines the start matrix
  27631. * @param endValue defines the end matrix
  27632. * @param gradient defines the gradient between both matrices
  27633. * @param result defines an optional target matrix where to store the interpolation
  27634. * @returns the interpolated matrix
  27635. */
  27636. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27637. /**
  27638. * Makes a copy of the animation
  27639. * @returns Cloned animation
  27640. */
  27641. clone(): Animation;
  27642. /**
  27643. * Sets the key frames of the animation
  27644. * @param values The animation key frames to set
  27645. */
  27646. setKeys(values: Array<IAnimationKey>): void;
  27647. /**
  27648. * Serializes the animation to an object
  27649. * @returns Serialized object
  27650. */
  27651. serialize(): any;
  27652. /**
  27653. * Float animation type
  27654. */
  27655. static readonly ANIMATIONTYPE_FLOAT: number;
  27656. /**
  27657. * Vector3 animation type
  27658. */
  27659. static readonly ANIMATIONTYPE_VECTOR3: number;
  27660. /**
  27661. * Quaternion animation type
  27662. */
  27663. static readonly ANIMATIONTYPE_QUATERNION: number;
  27664. /**
  27665. * Matrix animation type
  27666. */
  27667. static readonly ANIMATIONTYPE_MATRIX: number;
  27668. /**
  27669. * Color3 animation type
  27670. */
  27671. static readonly ANIMATIONTYPE_COLOR3: number;
  27672. /**
  27673. * Color3 animation type
  27674. */
  27675. static readonly ANIMATIONTYPE_COLOR4: number;
  27676. /**
  27677. * Vector2 animation type
  27678. */
  27679. static readonly ANIMATIONTYPE_VECTOR2: number;
  27680. /**
  27681. * Size animation type
  27682. */
  27683. static readonly ANIMATIONTYPE_SIZE: number;
  27684. /**
  27685. * Relative Loop Mode
  27686. */
  27687. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27688. /**
  27689. * Cycle Loop Mode
  27690. */
  27691. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27692. /**
  27693. * Constant Loop Mode
  27694. */
  27695. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27696. /** @hidden */
  27697. static _UniversalLerp(left: any, right: any, amount: number): any;
  27698. /**
  27699. * Parses an animation object and creates an animation
  27700. * @param parsedAnimation Parsed animation object
  27701. * @returns Animation object
  27702. */
  27703. static Parse(parsedAnimation: any): Animation;
  27704. /**
  27705. * Appends the serialized animations from the source animations
  27706. * @param source Source containing the animations
  27707. * @param destination Target to store the animations
  27708. */
  27709. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27710. }
  27711. }
  27712. declare module BABYLON {
  27713. /**
  27714. * Interface containing an array of animations
  27715. */
  27716. export interface IAnimatable {
  27717. /**
  27718. * Array of animations
  27719. */
  27720. animations: Nullable<Array<Animation>>;
  27721. }
  27722. }
  27723. declare module BABYLON {
  27724. /**
  27725. * This represents all the required information to add a fresnel effect on a material:
  27726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27727. */
  27728. export class FresnelParameters {
  27729. private _isEnabled;
  27730. /**
  27731. * Define if the fresnel effect is enable or not.
  27732. */
  27733. isEnabled: boolean;
  27734. /**
  27735. * Define the color used on edges (grazing angle)
  27736. */
  27737. leftColor: Color3;
  27738. /**
  27739. * Define the color used on center
  27740. */
  27741. rightColor: Color3;
  27742. /**
  27743. * Define bias applied to computed fresnel term
  27744. */
  27745. bias: number;
  27746. /**
  27747. * Defined the power exponent applied to fresnel term
  27748. */
  27749. power: number;
  27750. /**
  27751. * Clones the current fresnel and its valuues
  27752. * @returns a clone fresnel configuration
  27753. */
  27754. clone(): FresnelParameters;
  27755. /**
  27756. * Serializes the current fresnel parameters to a JSON representation.
  27757. * @return the JSON serialization
  27758. */
  27759. serialize(): any;
  27760. /**
  27761. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27762. * @param parsedFresnelParameters Define the JSON representation
  27763. * @returns the parsed parameters
  27764. */
  27765. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27766. }
  27767. }
  27768. declare module BABYLON {
  27769. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27770. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27771. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27772. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27773. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27774. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27775. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27776. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27777. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27778. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27779. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27780. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27781. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27782. /**
  27783. * Decorator used to define property that can be serialized as reference to a camera
  27784. * @param sourceName defines the name of the property to decorate
  27785. */
  27786. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27787. /**
  27788. * Class used to help serialization objects
  27789. */
  27790. export class SerializationHelper {
  27791. /** @hidden */
  27792. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27793. /** @hidden */
  27794. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27795. /** @hidden */
  27796. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27797. /** @hidden */
  27798. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27799. /**
  27800. * Appends the serialized animations from the source animations
  27801. * @param source Source containing the animations
  27802. * @param destination Target to store the animations
  27803. */
  27804. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27805. /**
  27806. * Static function used to serialized a specific entity
  27807. * @param entity defines the entity to serialize
  27808. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27809. * @returns a JSON compatible object representing the serialization of the entity
  27810. */
  27811. static Serialize<T>(entity: T, serializationObject?: any): any;
  27812. /**
  27813. * Creates a new entity from a serialization data object
  27814. * @param creationFunction defines a function used to instanciated the new entity
  27815. * @param source defines the source serialization data
  27816. * @param scene defines the hosting scene
  27817. * @param rootUrl defines the root url for resources
  27818. * @returns a new entity
  27819. */
  27820. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27821. /**
  27822. * Clones an object
  27823. * @param creationFunction defines the function used to instanciate the new object
  27824. * @param source defines the source object
  27825. * @returns the cloned object
  27826. */
  27827. static Clone<T>(creationFunction: () => T, source: T): T;
  27828. /**
  27829. * Instanciates a new object based on a source one (some data will be shared between both object)
  27830. * @param creationFunction defines the function used to instanciate the new object
  27831. * @param source defines the source object
  27832. * @returns the new object
  27833. */
  27834. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27835. }
  27836. }
  27837. declare module BABYLON {
  27838. /**
  27839. * Class used to manipulate GUIDs
  27840. */
  27841. export class GUID {
  27842. /**
  27843. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27844. * Be aware Math.random() could cause collisions, but:
  27845. * "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"
  27846. * @returns a pseudo random id
  27847. */
  27848. static RandomId(): string;
  27849. }
  27850. }
  27851. declare module BABYLON {
  27852. /**
  27853. * Base class of all the textures in babylon.
  27854. * It groups all the common properties the materials, post process, lights... might need
  27855. * in order to make a correct use of the texture.
  27856. */
  27857. export class BaseTexture implements IAnimatable {
  27858. /**
  27859. * Default anisotropic filtering level for the application.
  27860. * It is set to 4 as a good tradeoff between perf and quality.
  27861. */
  27862. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27863. /**
  27864. * Gets or sets the unique id of the texture
  27865. */
  27866. uniqueId: number;
  27867. /**
  27868. * Define the name of the texture.
  27869. */
  27870. name: string;
  27871. /**
  27872. * Gets or sets an object used to store user defined information.
  27873. */
  27874. metadata: any;
  27875. /**
  27876. * For internal use only. Please do not use.
  27877. */
  27878. reservedDataStore: any;
  27879. private _hasAlpha;
  27880. /**
  27881. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27882. */
  27883. hasAlpha: boolean;
  27884. /**
  27885. * Defines if the alpha value should be determined via the rgb values.
  27886. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27887. */
  27888. getAlphaFromRGB: boolean;
  27889. /**
  27890. * Intensity or strength of the texture.
  27891. * It is commonly used by materials to fine tune the intensity of the texture
  27892. */
  27893. level: number;
  27894. /**
  27895. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27896. * This is part of the texture as textures usually maps to one uv set.
  27897. */
  27898. coordinatesIndex: number;
  27899. private _coordinatesMode;
  27900. /**
  27901. * How a texture is mapped.
  27902. *
  27903. * | Value | Type | Description |
  27904. * | ----- | ----------------------------------- | ----------- |
  27905. * | 0 | EXPLICIT_MODE | |
  27906. * | 1 | SPHERICAL_MODE | |
  27907. * | 2 | PLANAR_MODE | |
  27908. * | 3 | CUBIC_MODE | |
  27909. * | 4 | PROJECTION_MODE | |
  27910. * | 5 | SKYBOX_MODE | |
  27911. * | 6 | INVCUBIC_MODE | |
  27912. * | 7 | EQUIRECTANGULAR_MODE | |
  27913. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27914. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27915. */
  27916. coordinatesMode: number;
  27917. /**
  27918. * | Value | Type | Description |
  27919. * | ----- | ------------------ | ----------- |
  27920. * | 0 | CLAMP_ADDRESSMODE | |
  27921. * | 1 | WRAP_ADDRESSMODE | |
  27922. * | 2 | MIRROR_ADDRESSMODE | |
  27923. */
  27924. wrapU: number;
  27925. /**
  27926. * | Value | Type | Description |
  27927. * | ----- | ------------------ | ----------- |
  27928. * | 0 | CLAMP_ADDRESSMODE | |
  27929. * | 1 | WRAP_ADDRESSMODE | |
  27930. * | 2 | MIRROR_ADDRESSMODE | |
  27931. */
  27932. wrapV: number;
  27933. /**
  27934. * | Value | Type | Description |
  27935. * | ----- | ------------------ | ----------- |
  27936. * | 0 | CLAMP_ADDRESSMODE | |
  27937. * | 1 | WRAP_ADDRESSMODE | |
  27938. * | 2 | MIRROR_ADDRESSMODE | |
  27939. */
  27940. wrapR: number;
  27941. /**
  27942. * With compliant hardware and browser (supporting anisotropic filtering)
  27943. * this defines the level of anisotropic filtering in the texture.
  27944. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27945. */
  27946. anisotropicFilteringLevel: number;
  27947. /**
  27948. * Define if the texture is a cube texture or if false a 2d texture.
  27949. */
  27950. isCube: boolean;
  27951. /**
  27952. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27953. */
  27954. is3D: boolean;
  27955. /**
  27956. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  27957. */
  27958. is2DArray: boolean;
  27959. /**
  27960. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27961. * HDR texture are usually stored in linear space.
  27962. * This only impacts the PBR and Background materials
  27963. */
  27964. gammaSpace: boolean;
  27965. /**
  27966. * Gets or sets whether or not the texture contains RGBD data.
  27967. */
  27968. isRGBD: boolean;
  27969. /**
  27970. * Is Z inverted in the texture (useful in a cube texture).
  27971. */
  27972. invertZ: boolean;
  27973. /**
  27974. * Are mip maps generated for this texture or not.
  27975. */
  27976. readonly noMipmap: boolean;
  27977. /**
  27978. * @hidden
  27979. */
  27980. lodLevelInAlpha: boolean;
  27981. /**
  27982. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27983. */
  27984. lodGenerationOffset: number;
  27985. /**
  27986. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27987. */
  27988. lodGenerationScale: number;
  27989. /**
  27990. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27991. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27992. * average roughness values.
  27993. */
  27994. linearSpecularLOD: boolean;
  27995. /**
  27996. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27997. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27998. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27999. */
  28000. irradianceTexture: Nullable<BaseTexture>;
  28001. /**
  28002. * Define if the texture is a render target.
  28003. */
  28004. isRenderTarget: boolean;
  28005. /**
  28006. * Define the unique id of the texture in the scene.
  28007. */
  28008. readonly uid: string;
  28009. /**
  28010. * Return a string representation of the texture.
  28011. * @returns the texture as a string
  28012. */
  28013. toString(): string;
  28014. /**
  28015. * Get the class name of the texture.
  28016. * @returns "BaseTexture"
  28017. */
  28018. getClassName(): string;
  28019. /**
  28020. * Define the list of animation attached to the texture.
  28021. */
  28022. animations: Animation[];
  28023. /**
  28024. * An event triggered when the texture is disposed.
  28025. */
  28026. onDisposeObservable: Observable<BaseTexture>;
  28027. private _onDisposeObserver;
  28028. /**
  28029. * Callback triggered when the texture has been disposed.
  28030. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28031. */
  28032. onDispose: () => void;
  28033. /**
  28034. * Define the current state of the loading sequence when in delayed load mode.
  28035. */
  28036. delayLoadState: number;
  28037. private _scene;
  28038. /** @hidden */
  28039. _texture: Nullable<InternalTexture>;
  28040. private _uid;
  28041. /**
  28042. * Define if the texture is preventinga material to render or not.
  28043. * If not and the texture is not ready, the engine will use a default black texture instead.
  28044. */
  28045. readonly isBlocking: boolean;
  28046. /**
  28047. * Instantiates a new BaseTexture.
  28048. * Base class of all the textures in babylon.
  28049. * It groups all the common properties the materials, post process, lights... might need
  28050. * in order to make a correct use of the texture.
  28051. * @param scene Define the scene the texture blongs to
  28052. */
  28053. constructor(scene: Nullable<Scene>);
  28054. /**
  28055. * Get the scene the texture belongs to.
  28056. * @returns the scene or null if undefined
  28057. */
  28058. getScene(): Nullable<Scene>;
  28059. /**
  28060. * Get the texture transform matrix used to offset tile the texture for istance.
  28061. * @returns the transformation matrix
  28062. */
  28063. getTextureMatrix(): Matrix;
  28064. /**
  28065. * Get the texture reflection matrix used to rotate/transform the reflection.
  28066. * @returns the reflection matrix
  28067. */
  28068. getReflectionTextureMatrix(): Matrix;
  28069. /**
  28070. * Get the underlying lower level texture from Babylon.
  28071. * @returns the insternal texture
  28072. */
  28073. getInternalTexture(): Nullable<InternalTexture>;
  28074. /**
  28075. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28076. * @returns true if ready or not blocking
  28077. */
  28078. isReadyOrNotBlocking(): boolean;
  28079. /**
  28080. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28081. * @returns true if fully ready
  28082. */
  28083. isReady(): boolean;
  28084. private _cachedSize;
  28085. /**
  28086. * Get the size of the texture.
  28087. * @returns the texture size.
  28088. */
  28089. getSize(): ISize;
  28090. /**
  28091. * Get the base size of the texture.
  28092. * It can be different from the size if the texture has been resized for POT for instance
  28093. * @returns the base size
  28094. */
  28095. getBaseSize(): ISize;
  28096. /**
  28097. * Update the sampling mode of the texture.
  28098. * Default is Trilinear mode.
  28099. *
  28100. * | Value | Type | Description |
  28101. * | ----- | ------------------ | ----------- |
  28102. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28103. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28104. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28105. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28106. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28107. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28108. * | 7 | NEAREST_LINEAR | |
  28109. * | 8 | NEAREST_NEAREST | |
  28110. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28111. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28112. * | 11 | LINEAR_LINEAR | |
  28113. * | 12 | LINEAR_NEAREST | |
  28114. *
  28115. * > _mag_: magnification filter (close to the viewer)
  28116. * > _min_: minification filter (far from the viewer)
  28117. * > _mip_: filter used between mip map levels
  28118. *@param samplingMode Define the new sampling mode of the texture
  28119. */
  28120. updateSamplingMode(samplingMode: number): void;
  28121. /**
  28122. * Scales the texture if is `canRescale()`
  28123. * @param ratio the resize factor we want to use to rescale
  28124. */
  28125. scale(ratio: number): void;
  28126. /**
  28127. * Get if the texture can rescale.
  28128. */
  28129. readonly canRescale: boolean;
  28130. /** @hidden */
  28131. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28132. /** @hidden */
  28133. _rebuild(): void;
  28134. /**
  28135. * Triggers the load sequence in delayed load mode.
  28136. */
  28137. delayLoad(): void;
  28138. /**
  28139. * Clones the texture.
  28140. * @returns the cloned texture
  28141. */
  28142. clone(): Nullable<BaseTexture>;
  28143. /**
  28144. * Get the texture underlying type (INT, FLOAT...)
  28145. */
  28146. readonly textureType: number;
  28147. /**
  28148. * Get the texture underlying format (RGB, RGBA...)
  28149. */
  28150. readonly textureFormat: number;
  28151. /**
  28152. * Indicates that textures need to be re-calculated for all materials
  28153. */
  28154. protected _markAllSubMeshesAsTexturesDirty(): void;
  28155. /**
  28156. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28157. * This will returns an RGBA array buffer containing either in values (0-255) or
  28158. * float values (0-1) depending of the underlying buffer type.
  28159. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28160. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28161. * @param buffer defines a user defined buffer to fill with data (can be null)
  28162. * @returns The Array buffer containing the pixels data.
  28163. */
  28164. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28165. /**
  28166. * Release and destroy the underlying lower level texture aka internalTexture.
  28167. */
  28168. releaseInternalTexture(): void;
  28169. /** @hidden */
  28170. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28171. /** @hidden */
  28172. readonly _lodTextureMid: Nullable<BaseTexture>;
  28173. /** @hidden */
  28174. readonly _lodTextureLow: Nullable<BaseTexture>;
  28175. /**
  28176. * Dispose the texture and release its associated resources.
  28177. */
  28178. dispose(): void;
  28179. /**
  28180. * Serialize the texture into a JSON representation that can be parsed later on.
  28181. * @returns the JSON representation of the texture
  28182. */
  28183. serialize(): any;
  28184. /**
  28185. * Helper function to be called back once a list of texture contains only ready textures.
  28186. * @param textures Define the list of textures to wait for
  28187. * @param callback Define the callback triggered once the entire list will be ready
  28188. */
  28189. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28190. }
  28191. }
  28192. declare module BABYLON {
  28193. /**
  28194. * Options to be used when creating an effect.
  28195. */
  28196. export interface IEffectCreationOptions {
  28197. /**
  28198. * Atrributes that will be used in the shader.
  28199. */
  28200. attributes: string[];
  28201. /**
  28202. * Uniform varible names that will be set in the shader.
  28203. */
  28204. uniformsNames: string[];
  28205. /**
  28206. * Uniform buffer varible names that will be set in the shader.
  28207. */
  28208. uniformBuffersNames: string[];
  28209. /**
  28210. * Sampler texture variable names that will be set in the shader.
  28211. */
  28212. samplers: string[];
  28213. /**
  28214. * Define statements that will be set in the shader.
  28215. */
  28216. defines: any;
  28217. /**
  28218. * Possible fallbacks for this effect to improve performance when needed.
  28219. */
  28220. fallbacks: Nullable<IEffectFallbacks>;
  28221. /**
  28222. * Callback that will be called when the shader is compiled.
  28223. */
  28224. onCompiled: Nullable<(effect: Effect) => void>;
  28225. /**
  28226. * Callback that will be called if an error occurs during shader compilation.
  28227. */
  28228. onError: Nullable<(effect: Effect, errors: string) => void>;
  28229. /**
  28230. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28231. */
  28232. indexParameters?: any;
  28233. /**
  28234. * Max number of lights that can be used in the shader.
  28235. */
  28236. maxSimultaneousLights?: number;
  28237. /**
  28238. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28239. */
  28240. transformFeedbackVaryings?: Nullable<string[]>;
  28241. }
  28242. /**
  28243. * Effect containing vertex and fragment shader that can be executed on an object.
  28244. */
  28245. export class Effect implements IDisposable {
  28246. /**
  28247. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28248. */
  28249. static ShadersRepository: string;
  28250. /**
  28251. * Name of the effect.
  28252. */
  28253. name: any;
  28254. /**
  28255. * String container all the define statements that should be set on the shader.
  28256. */
  28257. defines: string;
  28258. /**
  28259. * Callback that will be called when the shader is compiled.
  28260. */
  28261. onCompiled: Nullable<(effect: Effect) => void>;
  28262. /**
  28263. * Callback that will be called if an error occurs during shader compilation.
  28264. */
  28265. onError: Nullable<(effect: Effect, errors: string) => void>;
  28266. /**
  28267. * Callback that will be called when effect is bound.
  28268. */
  28269. onBind: Nullable<(effect: Effect) => void>;
  28270. /**
  28271. * Unique ID of the effect.
  28272. */
  28273. uniqueId: number;
  28274. /**
  28275. * Observable that will be called when the shader is compiled.
  28276. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28277. */
  28278. onCompileObservable: Observable<Effect>;
  28279. /**
  28280. * Observable that will be called if an error occurs during shader compilation.
  28281. */
  28282. onErrorObservable: Observable<Effect>;
  28283. /** @hidden */
  28284. _onBindObservable: Nullable<Observable<Effect>>;
  28285. /**
  28286. * Observable that will be called when effect is bound.
  28287. */
  28288. readonly onBindObservable: Observable<Effect>;
  28289. /** @hidden */
  28290. _bonesComputationForcedToCPU: boolean;
  28291. private static _uniqueIdSeed;
  28292. private _engine;
  28293. private _uniformBuffersNames;
  28294. private _uniformsNames;
  28295. private _samplerList;
  28296. private _samplers;
  28297. private _isReady;
  28298. private _compilationError;
  28299. private _allFallbacksProcessed;
  28300. private _attributesNames;
  28301. private _attributes;
  28302. private _uniforms;
  28303. /**
  28304. * Key for the effect.
  28305. * @hidden
  28306. */
  28307. _key: string;
  28308. private _indexParameters;
  28309. private _fallbacks;
  28310. private _vertexSourceCode;
  28311. private _fragmentSourceCode;
  28312. private _vertexSourceCodeOverride;
  28313. private _fragmentSourceCodeOverride;
  28314. private _transformFeedbackVaryings;
  28315. /**
  28316. * Compiled shader to webGL program.
  28317. * @hidden
  28318. */
  28319. _pipelineContext: Nullable<IPipelineContext>;
  28320. private _valueCache;
  28321. private static _baseCache;
  28322. /**
  28323. * Instantiates an effect.
  28324. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28325. * @param baseName Name of the effect.
  28326. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28327. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28328. * @param samplers List of sampler variables that will be passed to the shader.
  28329. * @param engine Engine to be used to render the effect
  28330. * @param defines Define statements to be added to the shader.
  28331. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28332. * @param onCompiled Callback that will be called when the shader is compiled.
  28333. * @param onError Callback that will be called if an error occurs during shader compilation.
  28334. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28335. */
  28336. 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);
  28337. private _useFinalCode;
  28338. /**
  28339. * Unique key for this effect
  28340. */
  28341. readonly key: string;
  28342. /**
  28343. * If the effect has been compiled and prepared.
  28344. * @returns if the effect is compiled and prepared.
  28345. */
  28346. isReady(): boolean;
  28347. private _isReadyInternal;
  28348. /**
  28349. * The engine the effect was initialized with.
  28350. * @returns the engine.
  28351. */
  28352. getEngine(): Engine;
  28353. /**
  28354. * The pipeline context for this effect
  28355. * @returns the associated pipeline context
  28356. */
  28357. getPipelineContext(): Nullable<IPipelineContext>;
  28358. /**
  28359. * The set of names of attribute variables for the shader.
  28360. * @returns An array of attribute names.
  28361. */
  28362. getAttributesNames(): string[];
  28363. /**
  28364. * Returns the attribute at the given index.
  28365. * @param index The index of the attribute.
  28366. * @returns The location of the attribute.
  28367. */
  28368. getAttributeLocation(index: number): number;
  28369. /**
  28370. * Returns the attribute based on the name of the variable.
  28371. * @param name of the attribute to look up.
  28372. * @returns the attribute location.
  28373. */
  28374. getAttributeLocationByName(name: string): number;
  28375. /**
  28376. * The number of attributes.
  28377. * @returns the numnber of attributes.
  28378. */
  28379. getAttributesCount(): number;
  28380. /**
  28381. * Gets the index of a uniform variable.
  28382. * @param uniformName of the uniform to look up.
  28383. * @returns the index.
  28384. */
  28385. getUniformIndex(uniformName: string): number;
  28386. /**
  28387. * Returns the attribute based on the name of the variable.
  28388. * @param uniformName of the uniform to look up.
  28389. * @returns the location of the uniform.
  28390. */
  28391. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28392. /**
  28393. * Returns an array of sampler variable names
  28394. * @returns The array of sampler variable neames.
  28395. */
  28396. getSamplers(): string[];
  28397. /**
  28398. * The error from the last compilation.
  28399. * @returns the error string.
  28400. */
  28401. getCompilationError(): string;
  28402. /**
  28403. * Gets a boolean indicating that all fallbacks were used during compilation
  28404. * @returns true if all fallbacks were used
  28405. */
  28406. allFallbacksProcessed(): boolean;
  28407. /**
  28408. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28409. * @param func The callback to be used.
  28410. */
  28411. executeWhenCompiled(func: (effect: Effect) => void): void;
  28412. private _checkIsReady;
  28413. private _loadShader;
  28414. /**
  28415. * Recompiles the webGL program
  28416. * @param vertexSourceCode The source code for the vertex shader.
  28417. * @param fragmentSourceCode The source code for the fragment shader.
  28418. * @param onCompiled Callback called when completed.
  28419. * @param onError Callback called on error.
  28420. * @hidden
  28421. */
  28422. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28423. /**
  28424. * Prepares the effect
  28425. * @hidden
  28426. */
  28427. _prepareEffect(): void;
  28428. private _processCompilationErrors;
  28429. /**
  28430. * Checks if the effect is supported. (Must be called after compilation)
  28431. */
  28432. readonly isSupported: boolean;
  28433. /**
  28434. * Binds a texture to the engine to be used as output of the shader.
  28435. * @param channel Name of the output variable.
  28436. * @param texture Texture to bind.
  28437. * @hidden
  28438. */
  28439. _bindTexture(channel: string, texture: InternalTexture): void;
  28440. /**
  28441. * Sets a texture on the engine to be used in the shader.
  28442. * @param channel Name of the sampler variable.
  28443. * @param texture Texture to set.
  28444. */
  28445. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28446. /**
  28447. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28448. * @param channel Name of the sampler variable.
  28449. * @param texture Texture to set.
  28450. */
  28451. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28452. /**
  28453. * Sets an array of textures on the engine to be used in the shader.
  28454. * @param channel Name of the variable.
  28455. * @param textures Textures to set.
  28456. */
  28457. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28458. /**
  28459. * 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)
  28460. * @param channel Name of the sampler variable.
  28461. * @param postProcess Post process to get the input texture from.
  28462. */
  28463. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28464. /**
  28465. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28466. * 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)
  28467. * @param channel Name of the sampler variable.
  28468. * @param postProcess Post process to get the output texture from.
  28469. */
  28470. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28471. /** @hidden */
  28472. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28473. /** @hidden */
  28474. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28475. /** @hidden */
  28476. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28477. /** @hidden */
  28478. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28479. /**
  28480. * Binds a buffer to a uniform.
  28481. * @param buffer Buffer to bind.
  28482. * @param name Name of the uniform variable to bind to.
  28483. */
  28484. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28485. /**
  28486. * Binds block to a uniform.
  28487. * @param blockName Name of the block to bind.
  28488. * @param index Index to bind.
  28489. */
  28490. bindUniformBlock(blockName: string, index: number): void;
  28491. /**
  28492. * Sets an interger value on a uniform variable.
  28493. * @param uniformName Name of the variable.
  28494. * @param value Value to be set.
  28495. * @returns this effect.
  28496. */
  28497. setInt(uniformName: string, value: number): Effect;
  28498. /**
  28499. * Sets an int array on a uniform variable.
  28500. * @param uniformName Name of the variable.
  28501. * @param array array to be set.
  28502. * @returns this effect.
  28503. */
  28504. setIntArray(uniformName: string, array: Int32Array): Effect;
  28505. /**
  28506. * 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)
  28507. * @param uniformName Name of the variable.
  28508. * @param array array to be set.
  28509. * @returns this effect.
  28510. */
  28511. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28512. /**
  28513. * 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)
  28514. * @param uniformName Name of the variable.
  28515. * @param array array to be set.
  28516. * @returns this effect.
  28517. */
  28518. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28519. /**
  28520. * 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)
  28521. * @param uniformName Name of the variable.
  28522. * @param array array to be set.
  28523. * @returns this effect.
  28524. */
  28525. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28526. /**
  28527. * Sets an float array on a uniform variable.
  28528. * @param uniformName Name of the variable.
  28529. * @param array array to be set.
  28530. * @returns this effect.
  28531. */
  28532. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28533. /**
  28534. * 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)
  28535. * @param uniformName Name of the variable.
  28536. * @param array array to be set.
  28537. * @returns this effect.
  28538. */
  28539. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28540. /**
  28541. * 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)
  28542. * @param uniformName Name of the variable.
  28543. * @param array array to be set.
  28544. * @returns this effect.
  28545. */
  28546. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28547. /**
  28548. * 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)
  28549. * @param uniformName Name of the variable.
  28550. * @param array array to be set.
  28551. * @returns this effect.
  28552. */
  28553. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28554. /**
  28555. * Sets an array on a uniform variable.
  28556. * @param uniformName Name of the variable.
  28557. * @param array array to be set.
  28558. * @returns this effect.
  28559. */
  28560. setArray(uniformName: string, array: number[]): Effect;
  28561. /**
  28562. * 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)
  28563. * @param uniformName Name of the variable.
  28564. * @param array array to be set.
  28565. * @returns this effect.
  28566. */
  28567. setArray2(uniformName: string, array: number[]): Effect;
  28568. /**
  28569. * 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)
  28570. * @param uniformName Name of the variable.
  28571. * @param array array to be set.
  28572. * @returns this effect.
  28573. */
  28574. setArray3(uniformName: string, array: number[]): Effect;
  28575. /**
  28576. * 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)
  28577. * @param uniformName Name of the variable.
  28578. * @param array array to be set.
  28579. * @returns this effect.
  28580. */
  28581. setArray4(uniformName: string, array: number[]): Effect;
  28582. /**
  28583. * Sets matrices on a uniform variable.
  28584. * @param uniformName Name of the variable.
  28585. * @param matrices matrices to be set.
  28586. * @returns this effect.
  28587. */
  28588. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28589. /**
  28590. * Sets matrix on a uniform variable.
  28591. * @param uniformName Name of the variable.
  28592. * @param matrix matrix to be set.
  28593. * @returns this effect.
  28594. */
  28595. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28596. /**
  28597. * 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)
  28598. * @param uniformName Name of the variable.
  28599. * @param matrix matrix to be set.
  28600. * @returns this effect.
  28601. */
  28602. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28603. /**
  28604. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28605. * @param uniformName Name of the variable.
  28606. * @param matrix matrix to be set.
  28607. * @returns this effect.
  28608. */
  28609. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28610. /**
  28611. * Sets a float on a uniform variable.
  28612. * @param uniformName Name of the variable.
  28613. * @param value value to be set.
  28614. * @returns this effect.
  28615. */
  28616. setFloat(uniformName: string, value: number): Effect;
  28617. /**
  28618. * Sets a boolean on a uniform variable.
  28619. * @param uniformName Name of the variable.
  28620. * @param bool value to be set.
  28621. * @returns this effect.
  28622. */
  28623. setBool(uniformName: string, bool: boolean): Effect;
  28624. /**
  28625. * Sets a Vector2 on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param vector2 vector2 to be set.
  28628. * @returns this effect.
  28629. */
  28630. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28631. /**
  28632. * Sets a float2 on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param x First float in float2.
  28635. * @param y Second float in float2.
  28636. * @returns this effect.
  28637. */
  28638. setFloat2(uniformName: string, x: number, y: number): Effect;
  28639. /**
  28640. * Sets a Vector3 on a uniform variable.
  28641. * @param uniformName Name of the variable.
  28642. * @param vector3 Value to be set.
  28643. * @returns this effect.
  28644. */
  28645. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28646. /**
  28647. * Sets a float3 on a uniform variable.
  28648. * @param uniformName Name of the variable.
  28649. * @param x First float in float3.
  28650. * @param y Second float in float3.
  28651. * @param z Third float in float3.
  28652. * @returns this effect.
  28653. */
  28654. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28655. /**
  28656. * Sets a Vector4 on a uniform variable.
  28657. * @param uniformName Name of the variable.
  28658. * @param vector4 Value to be set.
  28659. * @returns this effect.
  28660. */
  28661. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28662. /**
  28663. * Sets a float4 on a uniform variable.
  28664. * @param uniformName Name of the variable.
  28665. * @param x First float in float4.
  28666. * @param y Second float in float4.
  28667. * @param z Third float in float4.
  28668. * @param w Fourth float in float4.
  28669. * @returns this effect.
  28670. */
  28671. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28672. /**
  28673. * Sets a Color3 on a uniform variable.
  28674. * @param uniformName Name of the variable.
  28675. * @param color3 Value to be set.
  28676. * @returns this effect.
  28677. */
  28678. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28679. /**
  28680. * Sets a Color4 on a uniform variable.
  28681. * @param uniformName Name of the variable.
  28682. * @param color3 Value to be set.
  28683. * @param alpha Alpha value to be set.
  28684. * @returns this effect.
  28685. */
  28686. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28687. /**
  28688. * Sets a Color4 on a uniform variable
  28689. * @param uniformName defines the name of the variable
  28690. * @param color4 defines the value to be set
  28691. * @returns this effect.
  28692. */
  28693. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28694. /** Release all associated resources */
  28695. dispose(): void;
  28696. /**
  28697. * This function will add a new shader to the shader store
  28698. * @param name the name of the shader
  28699. * @param pixelShader optional pixel shader content
  28700. * @param vertexShader optional vertex shader content
  28701. */
  28702. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28703. /**
  28704. * Store of each shader (The can be looked up using effect.key)
  28705. */
  28706. static ShadersStore: {
  28707. [key: string]: string;
  28708. };
  28709. /**
  28710. * Store of each included file for a shader (The can be looked up using effect.key)
  28711. */
  28712. static IncludesShadersStore: {
  28713. [key: string]: string;
  28714. };
  28715. /**
  28716. * Resets the cache of effects.
  28717. */
  28718. static ResetCache(): void;
  28719. }
  28720. }
  28721. declare module BABYLON {
  28722. /**
  28723. * Interface used to describe the capabilities of the engine relatively to the current browser
  28724. */
  28725. export interface EngineCapabilities {
  28726. /** Maximum textures units per fragment shader */
  28727. maxTexturesImageUnits: number;
  28728. /** Maximum texture units per vertex shader */
  28729. maxVertexTextureImageUnits: number;
  28730. /** Maximum textures units in the entire pipeline */
  28731. maxCombinedTexturesImageUnits: number;
  28732. /** Maximum texture size */
  28733. maxTextureSize: number;
  28734. /** Maximum cube texture size */
  28735. maxCubemapTextureSize: number;
  28736. /** Maximum render texture size */
  28737. maxRenderTextureSize: number;
  28738. /** Maximum number of vertex attributes */
  28739. maxVertexAttribs: number;
  28740. /** Maximum number of varyings */
  28741. maxVaryingVectors: number;
  28742. /** Maximum number of uniforms per vertex shader */
  28743. maxVertexUniformVectors: number;
  28744. /** Maximum number of uniforms per fragment shader */
  28745. maxFragmentUniformVectors: number;
  28746. /** Defines if standard derivates (dx/dy) are supported */
  28747. standardDerivatives: boolean;
  28748. /** Defines if s3tc texture compression is supported */
  28749. s3tc?: WEBGL_compressed_texture_s3tc;
  28750. /** Defines if pvrtc texture compression is supported */
  28751. pvrtc: any;
  28752. /** Defines if etc1 texture compression is supported */
  28753. etc1: any;
  28754. /** Defines if etc2 texture compression is supported */
  28755. etc2: any;
  28756. /** Defines if astc texture compression is supported */
  28757. astc: any;
  28758. /** Defines if float textures are supported */
  28759. textureFloat: boolean;
  28760. /** Defines if vertex array objects are supported */
  28761. vertexArrayObject: boolean;
  28762. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28763. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28764. /** Gets the maximum level of anisotropy supported */
  28765. maxAnisotropy: number;
  28766. /** Defines if instancing is supported */
  28767. instancedArrays: boolean;
  28768. /** Defines if 32 bits indices are supported */
  28769. uintIndices: boolean;
  28770. /** Defines if high precision shaders are supported */
  28771. highPrecisionShaderSupported: boolean;
  28772. /** Defines if depth reading in the fragment shader is supported */
  28773. fragmentDepthSupported: boolean;
  28774. /** Defines if float texture linear filtering is supported*/
  28775. textureFloatLinearFiltering: boolean;
  28776. /** Defines if rendering to float textures is supported */
  28777. textureFloatRender: boolean;
  28778. /** Defines if half float textures are supported*/
  28779. textureHalfFloat: boolean;
  28780. /** Defines if half float texture linear filtering is supported*/
  28781. textureHalfFloatLinearFiltering: boolean;
  28782. /** Defines if rendering to half float textures is supported */
  28783. textureHalfFloatRender: boolean;
  28784. /** Defines if textureLOD shader command is supported */
  28785. textureLOD: boolean;
  28786. /** Defines if draw buffers extension is supported */
  28787. drawBuffersExtension: boolean;
  28788. /** Defines if depth textures are supported */
  28789. depthTextureExtension: boolean;
  28790. /** Defines if float color buffer are supported */
  28791. colorBufferFloat: boolean;
  28792. /** Gets disjoint timer query extension (null if not supported) */
  28793. timerQuery?: EXT_disjoint_timer_query;
  28794. /** Defines if timestamp can be used with timer query */
  28795. canUseTimestampForTimerQuery: boolean;
  28796. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28797. multiview?: any;
  28798. /** Function used to let the system compiles shaders in background */
  28799. parallelShaderCompile?: {
  28800. COMPLETION_STATUS_KHR: number;
  28801. };
  28802. /** Max number of texture samples for MSAA */
  28803. maxMSAASamples: number;
  28804. /** Defines if the blend min max extension is supported */
  28805. blendMinMax: boolean;
  28806. }
  28807. }
  28808. declare module BABYLON {
  28809. /**
  28810. * @hidden
  28811. **/
  28812. export class DepthCullingState {
  28813. private _isDepthTestDirty;
  28814. private _isDepthMaskDirty;
  28815. private _isDepthFuncDirty;
  28816. private _isCullFaceDirty;
  28817. private _isCullDirty;
  28818. private _isZOffsetDirty;
  28819. private _isFrontFaceDirty;
  28820. private _depthTest;
  28821. private _depthMask;
  28822. private _depthFunc;
  28823. private _cull;
  28824. private _cullFace;
  28825. private _zOffset;
  28826. private _frontFace;
  28827. /**
  28828. * Initializes the state.
  28829. */
  28830. constructor();
  28831. readonly isDirty: boolean;
  28832. zOffset: number;
  28833. cullFace: Nullable<number>;
  28834. cull: Nullable<boolean>;
  28835. depthFunc: Nullable<number>;
  28836. depthMask: boolean;
  28837. depthTest: boolean;
  28838. frontFace: Nullable<number>;
  28839. reset(): void;
  28840. apply(gl: WebGLRenderingContext): void;
  28841. }
  28842. }
  28843. declare module BABYLON {
  28844. /**
  28845. * @hidden
  28846. **/
  28847. export class StencilState {
  28848. /** 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 */
  28849. static readonly ALWAYS: number;
  28850. /** Passed to stencilOperation to specify that stencil value must be kept */
  28851. static readonly KEEP: number;
  28852. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28853. static readonly REPLACE: number;
  28854. private _isStencilTestDirty;
  28855. private _isStencilMaskDirty;
  28856. private _isStencilFuncDirty;
  28857. private _isStencilOpDirty;
  28858. private _stencilTest;
  28859. private _stencilMask;
  28860. private _stencilFunc;
  28861. private _stencilFuncRef;
  28862. private _stencilFuncMask;
  28863. private _stencilOpStencilFail;
  28864. private _stencilOpDepthFail;
  28865. private _stencilOpStencilDepthPass;
  28866. readonly isDirty: boolean;
  28867. stencilFunc: number;
  28868. stencilFuncRef: number;
  28869. stencilFuncMask: number;
  28870. stencilOpStencilFail: number;
  28871. stencilOpDepthFail: number;
  28872. stencilOpStencilDepthPass: number;
  28873. stencilMask: number;
  28874. stencilTest: boolean;
  28875. constructor();
  28876. reset(): void;
  28877. apply(gl: WebGLRenderingContext): void;
  28878. }
  28879. }
  28880. declare module BABYLON {
  28881. /**
  28882. * @hidden
  28883. **/
  28884. export class AlphaState {
  28885. private _isAlphaBlendDirty;
  28886. private _isBlendFunctionParametersDirty;
  28887. private _isBlendEquationParametersDirty;
  28888. private _isBlendConstantsDirty;
  28889. private _alphaBlend;
  28890. private _blendFunctionParameters;
  28891. private _blendEquationParameters;
  28892. private _blendConstants;
  28893. /**
  28894. * Initializes the state.
  28895. */
  28896. constructor();
  28897. readonly isDirty: boolean;
  28898. alphaBlend: boolean;
  28899. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28900. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28901. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28902. reset(): void;
  28903. apply(gl: WebGLRenderingContext): void;
  28904. }
  28905. }
  28906. declare module BABYLON {
  28907. /** @hidden */
  28908. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28909. attributeProcessor(attribute: string): string;
  28910. varyingProcessor(varying: string, isFragment: boolean): string;
  28911. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28912. }
  28913. }
  28914. declare module BABYLON {
  28915. /**
  28916. * Interface for attribute information associated with buffer instanciation
  28917. */
  28918. export interface InstancingAttributeInfo {
  28919. /**
  28920. * Index/offset of the attribute in the vertex shader
  28921. */
  28922. index: number;
  28923. /**
  28924. * size of the attribute, 1, 2, 3 or 4
  28925. */
  28926. attributeSize: number;
  28927. /**
  28928. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28929. * default is FLOAT
  28930. */
  28931. attributeType: number;
  28932. /**
  28933. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28934. */
  28935. normalized: boolean;
  28936. /**
  28937. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28938. */
  28939. offset: number;
  28940. /**
  28941. * Name of the GLSL attribute, for debugging purpose only
  28942. */
  28943. attributeName: string;
  28944. }
  28945. }
  28946. declare module BABYLON {
  28947. interface ThinEngine {
  28948. /**
  28949. * Update a video texture
  28950. * @param texture defines the texture to update
  28951. * @param video defines the video element to use
  28952. * @param invertY defines if data must be stored with Y axis inverted
  28953. */
  28954. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28955. }
  28956. }
  28957. declare module BABYLON {
  28958. /**
  28959. * Settings for finer control over video usage
  28960. */
  28961. export interface VideoTextureSettings {
  28962. /**
  28963. * Applies `autoplay` to video, if specified
  28964. */
  28965. autoPlay?: boolean;
  28966. /**
  28967. * Applies `loop` to video, if specified
  28968. */
  28969. loop?: boolean;
  28970. /**
  28971. * Automatically updates internal texture from video at every frame in the render loop
  28972. */
  28973. autoUpdateTexture: boolean;
  28974. /**
  28975. * Image src displayed during the video loading or until the user interacts with the video.
  28976. */
  28977. poster?: string;
  28978. }
  28979. /**
  28980. * If you want to display a video in your scene, this is the special texture for that.
  28981. * This special texture works similar to other textures, with the exception of a few parameters.
  28982. * @see https://doc.babylonjs.com/how_to/video_texture
  28983. */
  28984. export class VideoTexture extends Texture {
  28985. /**
  28986. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28987. */
  28988. readonly autoUpdateTexture: boolean;
  28989. /**
  28990. * The video instance used by the texture internally
  28991. */
  28992. readonly video: HTMLVideoElement;
  28993. private _onUserActionRequestedObservable;
  28994. /**
  28995. * Event triggerd when a dom action is required by the user to play the video.
  28996. * This happens due to recent changes in browser policies preventing video to auto start.
  28997. */
  28998. readonly onUserActionRequestedObservable: Observable<Texture>;
  28999. private _generateMipMaps;
  29000. private _engine;
  29001. private _stillImageCaptured;
  29002. private _displayingPosterTexture;
  29003. private _settings;
  29004. private _createInternalTextureOnEvent;
  29005. private _frameId;
  29006. /**
  29007. * Creates a video texture.
  29008. * If you want to display a video in your scene, this is the special texture for that.
  29009. * This special texture works similar to other textures, with the exception of a few parameters.
  29010. * @see https://doc.babylonjs.com/how_to/video_texture
  29011. * @param name optional name, will detect from video source, if not defined
  29012. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29013. * @param scene is obviously the current scene.
  29014. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29015. * @param invertY is false by default but can be used to invert video on Y axis
  29016. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29017. * @param settings allows finer control over video usage
  29018. */
  29019. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29020. private _getName;
  29021. private _getVideo;
  29022. private _createInternalTexture;
  29023. private reset;
  29024. /**
  29025. * @hidden Internal method to initiate `update`.
  29026. */
  29027. _rebuild(): void;
  29028. /**
  29029. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29030. */
  29031. update(): void;
  29032. /**
  29033. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29034. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29035. */
  29036. updateTexture(isVisible: boolean): void;
  29037. protected _updateInternalTexture: () => void;
  29038. /**
  29039. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29040. * @param url New url.
  29041. */
  29042. updateURL(url: string): void;
  29043. /**
  29044. * Dispose the texture and release its associated resources.
  29045. */
  29046. dispose(): void;
  29047. /**
  29048. * Creates a video texture straight from a stream.
  29049. * @param scene Define the scene the texture should be created in
  29050. * @param stream Define the stream the texture should be created from
  29051. * @returns The created video texture as a promise
  29052. */
  29053. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29054. /**
  29055. * Creates a video texture straight from your WebCam video feed.
  29056. * @param scene Define the scene the texture should be created in
  29057. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29058. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29059. * @returns The created video texture as a promise
  29060. */
  29061. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29062. minWidth: number;
  29063. maxWidth: number;
  29064. minHeight: number;
  29065. maxHeight: number;
  29066. deviceId: string;
  29067. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29068. /**
  29069. * Creates a video texture straight from your WebCam video feed.
  29070. * @param scene Define the scene the texture should be created in
  29071. * @param onReady Define a callback to triggered once the texture will be ready
  29072. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29073. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29074. */
  29075. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29076. minWidth: number;
  29077. maxWidth: number;
  29078. minHeight: number;
  29079. maxHeight: number;
  29080. deviceId: string;
  29081. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29082. }
  29083. }
  29084. declare module BABYLON {
  29085. /**
  29086. * Defines the interface used by objects working like Scene
  29087. * @hidden
  29088. */
  29089. interface ISceneLike {
  29090. _addPendingData(data: any): void;
  29091. _removePendingData(data: any): void;
  29092. offlineProvider: IOfflineProvider;
  29093. }
  29094. /** Interface defining initialization parameters for Engine class */
  29095. export interface EngineOptions extends WebGLContextAttributes {
  29096. /**
  29097. * Defines if the engine should no exceed a specified device ratio
  29098. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29099. */
  29100. limitDeviceRatio?: number;
  29101. /**
  29102. * Defines if webvr should be enabled automatically
  29103. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29104. */
  29105. autoEnableWebVR?: boolean;
  29106. /**
  29107. * Defines if webgl2 should be turned off even if supported
  29108. * @see http://doc.babylonjs.com/features/webgl2
  29109. */
  29110. disableWebGL2Support?: boolean;
  29111. /**
  29112. * Defines if webaudio should be initialized as well
  29113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29114. */
  29115. audioEngine?: boolean;
  29116. /**
  29117. * Defines if animations should run using a deterministic lock step
  29118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29119. */
  29120. deterministicLockstep?: boolean;
  29121. /** Defines the maximum steps to use with deterministic lock step mode */
  29122. lockstepMaxSteps?: number;
  29123. /**
  29124. * Defines that engine should ignore context lost events
  29125. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29126. */
  29127. doNotHandleContextLost?: boolean;
  29128. /**
  29129. * Defines that engine should ignore modifying touch action attribute and style
  29130. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29131. */
  29132. doNotHandleTouchAction?: boolean;
  29133. /**
  29134. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29135. */
  29136. useHighPrecisionFloats?: boolean;
  29137. }
  29138. /**
  29139. * The base engine class (root of all engines)
  29140. */
  29141. export class ThinEngine {
  29142. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29143. static ExceptionList: ({
  29144. key: string;
  29145. capture: string;
  29146. captureConstraint: number;
  29147. targets: string[];
  29148. } | {
  29149. key: string;
  29150. capture: null;
  29151. captureConstraint: null;
  29152. targets: string[];
  29153. })[];
  29154. /** @hidden */
  29155. static _TextureLoaders: IInternalTextureLoader[];
  29156. /**
  29157. * Returns the current npm package of the sdk
  29158. */
  29159. static readonly NpmPackage: string;
  29160. /**
  29161. * Returns the current version of the framework
  29162. */
  29163. static readonly Version: string;
  29164. /**
  29165. * Returns a string describing the current engine
  29166. */
  29167. readonly description: string;
  29168. /**
  29169. * Gets or sets the epsilon value used by collision engine
  29170. */
  29171. static CollisionsEpsilon: number;
  29172. /**
  29173. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29174. */
  29175. static ShadersRepository: string;
  29176. /** @hidden */
  29177. _shaderProcessor: IShaderProcessor;
  29178. /**
  29179. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29180. */
  29181. forcePOTTextures: boolean;
  29182. /**
  29183. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29184. */
  29185. isFullscreen: boolean;
  29186. /**
  29187. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29188. */
  29189. cullBackFaces: boolean;
  29190. /**
  29191. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29192. */
  29193. renderEvenInBackground: boolean;
  29194. /**
  29195. * Gets or sets a boolean indicating that cache can be kept between frames
  29196. */
  29197. preventCacheWipeBetweenFrames: boolean;
  29198. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29199. validateShaderPrograms: boolean;
  29200. /**
  29201. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29202. */
  29203. disableUniformBuffers: boolean;
  29204. /** @hidden */
  29205. _uniformBuffers: UniformBuffer[];
  29206. /**
  29207. * Gets a boolean indicating that the engine supports uniform buffers
  29208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29209. */
  29210. readonly supportsUniformBuffers: boolean;
  29211. /** @hidden */
  29212. _gl: WebGLRenderingContext;
  29213. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29214. protected _windowIsBackground: boolean;
  29215. protected _webGLVersion: number;
  29216. protected _creationOptions: EngineOptions;
  29217. protected _highPrecisionShadersAllowed: boolean;
  29218. /** @hidden */
  29219. readonly _shouldUseHighPrecisionShader: boolean;
  29220. /**
  29221. * Gets a boolean indicating that only power of 2 textures are supported
  29222. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29223. */
  29224. readonly needPOTTextures: boolean;
  29225. /** @hidden */
  29226. _badOS: boolean;
  29227. /** @hidden */
  29228. _badDesktopOS: boolean;
  29229. private _hardwareScalingLevel;
  29230. /** @hidden */
  29231. _caps: EngineCapabilities;
  29232. private _isStencilEnable;
  29233. protected _colorWrite: boolean;
  29234. private _glVersion;
  29235. private _glRenderer;
  29236. private _glVendor;
  29237. /** @hidden */
  29238. _videoTextureSupported: boolean;
  29239. protected _renderingQueueLaunched: boolean;
  29240. protected _activeRenderLoops: (() => void)[];
  29241. /**
  29242. * Observable signaled when a context lost event is raised
  29243. */
  29244. onContextLostObservable: Observable<ThinEngine>;
  29245. /**
  29246. * Observable signaled when a context restored event is raised
  29247. */
  29248. onContextRestoredObservable: Observable<ThinEngine>;
  29249. private _onContextLost;
  29250. private _onContextRestored;
  29251. protected _contextWasLost: boolean;
  29252. /** @hidden */
  29253. _doNotHandleContextLost: boolean;
  29254. /**
  29255. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29257. */
  29258. doNotHandleContextLost: boolean;
  29259. /**
  29260. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29261. */
  29262. disableVertexArrayObjects: boolean;
  29263. /** @hidden */
  29264. protected _depthCullingState: DepthCullingState;
  29265. /** @hidden */
  29266. protected _stencilState: StencilState;
  29267. /** @hidden */
  29268. protected _alphaState: AlphaState;
  29269. /** @hidden */
  29270. _internalTexturesCache: InternalTexture[];
  29271. /** @hidden */
  29272. protected _activeChannel: number;
  29273. private _currentTextureChannel;
  29274. /** @hidden */
  29275. protected _boundTexturesCache: {
  29276. [key: string]: Nullable<InternalTexture>;
  29277. };
  29278. /** @hidden */
  29279. protected _currentEffect: Nullable<Effect>;
  29280. /** @hidden */
  29281. protected _currentProgram: Nullable<WebGLProgram>;
  29282. private _compiledEffects;
  29283. private _vertexAttribArraysEnabled;
  29284. /** @hidden */
  29285. protected _cachedViewport: Nullable<IViewportLike>;
  29286. private _cachedVertexArrayObject;
  29287. /** @hidden */
  29288. protected _cachedVertexBuffers: any;
  29289. /** @hidden */
  29290. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29291. /** @hidden */
  29292. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29293. /** @hidden */
  29294. _currentRenderTarget: Nullable<InternalTexture>;
  29295. private _uintIndicesCurrentlySet;
  29296. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29297. /** @hidden */
  29298. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29299. private _currentBufferPointers;
  29300. private _currentInstanceLocations;
  29301. private _currentInstanceBuffers;
  29302. private _textureUnits;
  29303. /** @hidden */
  29304. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29305. /** @hidden */
  29306. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29307. /** @hidden */
  29308. _boundRenderFunction: any;
  29309. private _vaoRecordInProgress;
  29310. private _mustWipeVertexAttributes;
  29311. private _emptyTexture;
  29312. private _emptyCubeTexture;
  29313. private _emptyTexture3D;
  29314. private _emptyTexture2DArray;
  29315. /** @hidden */
  29316. _frameHandler: number;
  29317. private _nextFreeTextureSlots;
  29318. private _maxSimultaneousTextures;
  29319. private _activeRequests;
  29320. protected _texturesSupported: string[];
  29321. /** @hidden */
  29322. _textureFormatInUse: Nullable<string>;
  29323. protected readonly _supportsHardwareTextureRescaling: boolean;
  29324. /**
  29325. * Gets the list of texture formats supported
  29326. */
  29327. readonly texturesSupported: Array<string>;
  29328. /**
  29329. * Gets the list of texture formats in use
  29330. */
  29331. readonly textureFormatInUse: Nullable<string>;
  29332. /**
  29333. * Gets the current viewport
  29334. */
  29335. readonly currentViewport: Nullable<IViewportLike>;
  29336. /**
  29337. * Gets the default empty texture
  29338. */
  29339. readonly emptyTexture: InternalTexture;
  29340. /**
  29341. * Gets the default empty 3D texture
  29342. */
  29343. readonly emptyTexture3D: InternalTexture;
  29344. /**
  29345. * Gets the default empty 2D array texture
  29346. */
  29347. readonly emptyTexture2DArray: InternalTexture;
  29348. /**
  29349. * Gets the default empty cube texture
  29350. */
  29351. readonly emptyCubeTexture: InternalTexture;
  29352. /**
  29353. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29354. */
  29355. readonly premultipliedAlpha: boolean;
  29356. /**
  29357. * Observable event triggered before each texture is initialized
  29358. */
  29359. onBeforeTextureInitObservable: Observable<Texture>;
  29360. /**
  29361. * Creates a new engine
  29362. * @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
  29363. * @param antialias defines enable antialiasing (default: false)
  29364. * @param options defines further options to be sent to the getContext() function
  29365. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29366. */
  29367. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29368. private _rebuildInternalTextures;
  29369. private _rebuildEffects;
  29370. /**
  29371. * Gets a boolean indicating if all created effects are ready
  29372. * @returns true if all effects are ready
  29373. */
  29374. areAllEffectsReady(): boolean;
  29375. protected _rebuildBuffers(): void;
  29376. private _initGLContext;
  29377. /**
  29378. * Gets version of the current webGL context
  29379. */
  29380. readonly webGLVersion: number;
  29381. /**
  29382. * Gets a string idenfifying the name of the class
  29383. * @returns "Engine" string
  29384. */
  29385. getClassName(): string;
  29386. /**
  29387. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29388. */
  29389. readonly isStencilEnable: boolean;
  29390. /** @hidden */
  29391. _prepareWorkingCanvas(): void;
  29392. /**
  29393. * Reset the texture cache to empty state
  29394. */
  29395. resetTextureCache(): void;
  29396. /**
  29397. * Gets an object containing information about the current webGL context
  29398. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29399. */
  29400. getGlInfo(): {
  29401. vendor: string;
  29402. renderer: string;
  29403. version: string;
  29404. };
  29405. /**
  29406. * Defines the hardware scaling level.
  29407. * By default the hardware scaling level is computed from the window device ratio.
  29408. * 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.
  29409. * @param level defines the level to use
  29410. */
  29411. setHardwareScalingLevel(level: number): void;
  29412. /**
  29413. * Gets the current hardware scaling level.
  29414. * By default the hardware scaling level is computed from the window device ratio.
  29415. * 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.
  29416. * @returns a number indicating the current hardware scaling level
  29417. */
  29418. getHardwareScalingLevel(): number;
  29419. /**
  29420. * Gets the list of loaded textures
  29421. * @returns an array containing all loaded textures
  29422. */
  29423. getLoadedTexturesCache(): InternalTexture[];
  29424. /**
  29425. * Gets the object containing all engine capabilities
  29426. * @returns the EngineCapabilities object
  29427. */
  29428. getCaps(): EngineCapabilities;
  29429. /**
  29430. * stop executing a render loop function and remove it from the execution array
  29431. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29432. */
  29433. stopRenderLoop(renderFunction?: () => void): void;
  29434. /** @hidden */
  29435. _renderLoop(): void;
  29436. /**
  29437. * Gets the HTML canvas attached with the current webGL context
  29438. * @returns a HTML canvas
  29439. */
  29440. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29441. /**
  29442. * Gets host window
  29443. * @returns the host window object
  29444. */
  29445. getHostWindow(): Nullable<Window>;
  29446. /**
  29447. * Gets the current render width
  29448. * @param useScreen defines if screen size must be used (or the current render target if any)
  29449. * @returns a number defining the current render width
  29450. */
  29451. getRenderWidth(useScreen?: boolean): number;
  29452. /**
  29453. * Gets the current render height
  29454. * @param useScreen defines if screen size must be used (or the current render target if any)
  29455. * @returns a number defining the current render height
  29456. */
  29457. getRenderHeight(useScreen?: boolean): number;
  29458. /**
  29459. * Can be used to override the current requestAnimationFrame requester.
  29460. * @hidden
  29461. */
  29462. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29463. /**
  29464. * Register and execute a render loop. The engine can have more than one render function
  29465. * @param renderFunction defines the function to continuously execute
  29466. */
  29467. runRenderLoop(renderFunction: () => void): void;
  29468. /**
  29469. * Clear the current render buffer or the current render target (if any is set up)
  29470. * @param color defines the color to use
  29471. * @param backBuffer defines if the back buffer must be cleared
  29472. * @param depth defines if the depth buffer must be cleared
  29473. * @param stencil defines if the stencil buffer must be cleared
  29474. */
  29475. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29476. private _viewportCached;
  29477. /** @hidden */
  29478. _viewport(x: number, y: number, width: number, height: number): void;
  29479. /**
  29480. * Set the WebGL's viewport
  29481. * @param viewport defines the viewport element to be used
  29482. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29483. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29484. */
  29485. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29486. /**
  29487. * Begin a new frame
  29488. */
  29489. beginFrame(): void;
  29490. /**
  29491. * Enf the current frame
  29492. */
  29493. endFrame(): void;
  29494. /**
  29495. * Resize the view according to the canvas' size
  29496. */
  29497. resize(): void;
  29498. /**
  29499. * Force a specific size of the canvas
  29500. * @param width defines the new canvas' width
  29501. * @param height defines the new canvas' height
  29502. */
  29503. setSize(width: number, height: number): void;
  29504. /**
  29505. * Binds the frame buffer to the specified texture.
  29506. * @param texture The texture to render to or null for the default canvas
  29507. * @param faceIndex The face of the texture to render to in case of cube texture
  29508. * @param requiredWidth The width of the target to render to
  29509. * @param requiredHeight The height of the target to render to
  29510. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29511. * @param depthStencilTexture The depth stencil texture to use to render
  29512. * @param lodLevel defines le lod level to bind to the frame buffer
  29513. */
  29514. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29515. /** @hidden */
  29516. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29517. /**
  29518. * Unbind the current render target texture from the webGL context
  29519. * @param texture defines the render target texture to unbind
  29520. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29521. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29522. */
  29523. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29524. /**
  29525. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29526. */
  29527. flushFramebuffer(): void;
  29528. /**
  29529. * Unbind the current render target and bind the default framebuffer
  29530. */
  29531. restoreDefaultFramebuffer(): void;
  29532. /** @hidden */
  29533. protected _resetVertexBufferBinding(): void;
  29534. /**
  29535. * Creates a vertex buffer
  29536. * @param data the data for the vertex buffer
  29537. * @returns the new WebGL static buffer
  29538. */
  29539. createVertexBuffer(data: DataArray): DataBuffer;
  29540. private _createVertexBuffer;
  29541. /**
  29542. * Creates a dynamic vertex buffer
  29543. * @param data the data for the dynamic vertex buffer
  29544. * @returns the new WebGL dynamic buffer
  29545. */
  29546. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29547. protected _resetIndexBufferBinding(): void;
  29548. /**
  29549. * Creates a new index buffer
  29550. * @param indices defines the content of the index buffer
  29551. * @param updatable defines if the index buffer must be updatable
  29552. * @returns a new webGL buffer
  29553. */
  29554. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29555. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29556. /**
  29557. * Bind a webGL buffer to the webGL context
  29558. * @param buffer defines the buffer to bind
  29559. */
  29560. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29561. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29562. private bindBuffer;
  29563. /**
  29564. * update the bound buffer with the given data
  29565. * @param data defines the data to update
  29566. */
  29567. updateArrayBuffer(data: Float32Array): void;
  29568. private _vertexAttribPointer;
  29569. private _bindIndexBufferWithCache;
  29570. private _bindVertexBuffersAttributes;
  29571. /**
  29572. * Records a vertex array object
  29573. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29574. * @param vertexBuffers defines the list of vertex buffers to store
  29575. * @param indexBuffer defines the index buffer to store
  29576. * @param effect defines the effect to store
  29577. * @returns the new vertex array object
  29578. */
  29579. recordVertexArrayObject(vertexBuffers: {
  29580. [key: string]: VertexBuffer;
  29581. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29582. /**
  29583. * Bind a specific vertex array object
  29584. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29585. * @param vertexArrayObject defines the vertex array object to bind
  29586. * @param indexBuffer defines the index buffer to bind
  29587. */
  29588. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29589. /**
  29590. * Bind webGl buffers directly to the webGL context
  29591. * @param vertexBuffer defines the vertex buffer to bind
  29592. * @param indexBuffer defines the index buffer to bind
  29593. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29594. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29595. * @param effect defines the effect associated with the vertex buffer
  29596. */
  29597. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29598. private _unbindVertexArrayObject;
  29599. /**
  29600. * Bind a list of vertex buffers to the webGL context
  29601. * @param vertexBuffers defines the list of vertex buffers to bind
  29602. * @param indexBuffer defines the index buffer to bind
  29603. * @param effect defines the effect associated with the vertex buffers
  29604. */
  29605. bindBuffers(vertexBuffers: {
  29606. [key: string]: Nullable<VertexBuffer>;
  29607. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29608. /**
  29609. * Unbind all instance attributes
  29610. */
  29611. unbindInstanceAttributes(): void;
  29612. /**
  29613. * Release and free the memory of a vertex array object
  29614. * @param vao defines the vertex array object to delete
  29615. */
  29616. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29617. /** @hidden */
  29618. _releaseBuffer(buffer: DataBuffer): boolean;
  29619. protected _deleteBuffer(buffer: DataBuffer): void;
  29620. /**
  29621. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29622. * @param instancesBuffer defines the webGL buffer to update and bind
  29623. * @param data defines the data to store in the buffer
  29624. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29625. */
  29626. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29627. /**
  29628. * Apply all cached states (depth, culling, stencil and alpha)
  29629. */
  29630. applyStates(): void;
  29631. /**
  29632. * Send a draw order
  29633. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29634. * @param indexStart defines the starting index
  29635. * @param indexCount defines the number of index to draw
  29636. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29637. */
  29638. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29639. /**
  29640. * Draw a list of points
  29641. * @param verticesStart defines the index of first vertex to draw
  29642. * @param verticesCount defines the count of vertices to draw
  29643. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29644. */
  29645. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29646. /**
  29647. * Draw a list of unindexed primitives
  29648. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29649. * @param verticesStart defines the index of first vertex to draw
  29650. * @param verticesCount defines the count of vertices to draw
  29651. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29652. */
  29653. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29654. /**
  29655. * Draw a list of indexed primitives
  29656. * @param fillMode defines the primitive to use
  29657. * @param indexStart defines the starting index
  29658. * @param indexCount defines the number of index to draw
  29659. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29660. */
  29661. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29662. /**
  29663. * Draw a list of unindexed primitives
  29664. * @param fillMode defines the primitive to use
  29665. * @param verticesStart defines the index of first vertex to draw
  29666. * @param verticesCount defines the count of vertices to draw
  29667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29668. */
  29669. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29670. private _drawMode;
  29671. /** @hidden */
  29672. protected _reportDrawCall(): void;
  29673. /** @hidden */
  29674. _releaseEffect(effect: Effect): void;
  29675. /** @hidden */
  29676. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29677. /**
  29678. * Create a new effect (used to store vertex/fragment shaders)
  29679. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29680. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29681. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29682. * @param samplers defines an array of string used to represent textures
  29683. * @param defines defines the string containing the defines to use to compile the shaders
  29684. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29685. * @param onCompiled defines a function to call when the effect creation is successful
  29686. * @param onError defines a function to call when the effect creation has failed
  29687. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29688. * @returns the new Effect
  29689. */
  29690. 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;
  29691. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29692. private _compileShader;
  29693. private _compileRawShader;
  29694. /**
  29695. * Directly creates a webGL program
  29696. * @param pipelineContext defines the pipeline context to attach to
  29697. * @param vertexCode defines the vertex shader code to use
  29698. * @param fragmentCode defines the fragment shader code to use
  29699. * @param context defines the webGL context to use (if not set, the current one will be used)
  29700. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29701. * @returns the new webGL program
  29702. */
  29703. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29704. /**
  29705. * Creates a webGL program
  29706. * @param pipelineContext defines the pipeline context to attach to
  29707. * @param vertexCode defines the vertex shader code to use
  29708. * @param fragmentCode defines the fragment shader code to use
  29709. * @param defines defines the string containing the defines to use to compile the shaders
  29710. * @param context defines the webGL context to use (if not set, the current one will be used)
  29711. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29712. * @returns the new webGL program
  29713. */
  29714. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29715. /**
  29716. * Creates a new pipeline context
  29717. * @returns the new pipeline
  29718. */
  29719. createPipelineContext(): IPipelineContext;
  29720. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29721. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29722. /** @hidden */
  29723. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29724. /** @hidden */
  29725. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29726. /** @hidden */
  29727. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29728. /**
  29729. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29730. * @param pipelineContext defines the pipeline context to use
  29731. * @param uniformsNames defines the list of uniform names
  29732. * @returns an array of webGL uniform locations
  29733. */
  29734. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29735. /**
  29736. * Gets the lsit of active attributes for a given webGL program
  29737. * @param pipelineContext defines the pipeline context to use
  29738. * @param attributesNames defines the list of attribute names to get
  29739. * @returns an array of indices indicating the offset of each attribute
  29740. */
  29741. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29742. /**
  29743. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29744. * @param effect defines the effect to activate
  29745. */
  29746. enableEffect(effect: Nullable<Effect>): void;
  29747. /**
  29748. * Set the value of an uniform to a number (int)
  29749. * @param uniform defines the webGL uniform location where to store the value
  29750. * @param value defines the int number to store
  29751. */
  29752. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29753. /**
  29754. * Set the value of an uniform to an array of int32
  29755. * @param uniform defines the webGL uniform location where to store the value
  29756. * @param array defines the array of int32 to store
  29757. */
  29758. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29759. /**
  29760. * Set the value of an uniform to an array of int32 (stored as vec2)
  29761. * @param uniform defines the webGL uniform location where to store the value
  29762. * @param array defines the array of int32 to store
  29763. */
  29764. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29765. /**
  29766. * Set the value of an uniform to an array of int32 (stored as vec3)
  29767. * @param uniform defines the webGL uniform location where to store the value
  29768. * @param array defines the array of int32 to store
  29769. */
  29770. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29771. /**
  29772. * Set the value of an uniform to an array of int32 (stored as vec4)
  29773. * @param uniform defines the webGL uniform location where to store the value
  29774. * @param array defines the array of int32 to store
  29775. */
  29776. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29777. /**
  29778. * Set the value of an uniform to an array of number
  29779. * @param uniform defines the webGL uniform location where to store the value
  29780. * @param array defines the array of number to store
  29781. */
  29782. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29783. /**
  29784. * Set the value of an uniform to an array of number (stored as vec2)
  29785. * @param uniform defines the webGL uniform location where to store the value
  29786. * @param array defines the array of number to store
  29787. */
  29788. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29789. /**
  29790. * Set the value of an uniform to an array of number (stored as vec3)
  29791. * @param uniform defines the webGL uniform location where to store the value
  29792. * @param array defines the array of number to store
  29793. */
  29794. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29795. /**
  29796. * Set the value of an uniform to an array of number (stored as vec4)
  29797. * @param uniform defines the webGL uniform location where to store the value
  29798. * @param array defines the array of number to store
  29799. */
  29800. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29801. /**
  29802. * Set the value of an uniform to an array of float32 (stored as matrices)
  29803. * @param uniform defines the webGL uniform location where to store the value
  29804. * @param matrices defines the array of float32 to store
  29805. */
  29806. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29807. /**
  29808. * Set the value of an uniform to a matrix (3x3)
  29809. * @param uniform defines the webGL uniform location where to store the value
  29810. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29811. */
  29812. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29813. /**
  29814. * Set the value of an uniform to a matrix (2x2)
  29815. * @param uniform defines the webGL uniform location where to store the value
  29816. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29817. */
  29818. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29819. /**
  29820. * Set the value of an uniform to a number (float)
  29821. * @param uniform defines the webGL uniform location where to store the value
  29822. * @param value defines the float number to store
  29823. */
  29824. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29825. /**
  29826. * Set the value of an uniform to a vec2
  29827. * @param uniform defines the webGL uniform location where to store the value
  29828. * @param x defines the 1st component of the value
  29829. * @param y defines the 2nd component of the value
  29830. */
  29831. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29832. /**
  29833. * Set the value of an uniform to a vec3
  29834. * @param uniform defines the webGL uniform location where to store the value
  29835. * @param x defines the 1st component of the value
  29836. * @param y defines the 2nd component of the value
  29837. * @param z defines the 3rd component of the value
  29838. */
  29839. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29840. /**
  29841. * Set the value of an uniform to a vec4
  29842. * @param uniform defines the webGL uniform location where to store the value
  29843. * @param x defines the 1st component of the value
  29844. * @param y defines the 2nd component of the value
  29845. * @param z defines the 3rd component of the value
  29846. * @param w defines the 4th component of the value
  29847. */
  29848. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29849. /**
  29850. * Gets the depth culling state manager
  29851. */
  29852. readonly depthCullingState: DepthCullingState;
  29853. /**
  29854. * Gets the alpha state manager
  29855. */
  29856. readonly alphaState: AlphaState;
  29857. /**
  29858. * Gets the stencil state manager
  29859. */
  29860. readonly stencilState: StencilState;
  29861. /**
  29862. * Clears the list of texture accessible through engine.
  29863. * This can help preventing texture load conflict due to name collision.
  29864. */
  29865. clearInternalTexturesCache(): void;
  29866. /**
  29867. * Force the entire cache to be cleared
  29868. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29869. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29870. */
  29871. wipeCaches(bruteForce?: boolean): void;
  29872. /** @hidden */
  29873. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29874. min: number;
  29875. mag: number;
  29876. };
  29877. /** @hidden */
  29878. _createTexture(): WebGLTexture;
  29879. /**
  29880. * Usually called from Texture.ts.
  29881. * Passed information to create a WebGLTexture
  29882. * @param urlArg defines a value which contains one of the following:
  29883. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29884. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29885. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29886. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29887. * @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)
  29888. * @param scene needed for loading to the correct scene
  29889. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29890. * @param onLoad optional callback to be called upon successful completion
  29891. * @param onError optional callback to be called upon failure
  29892. * @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
  29893. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29894. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29895. * @param forcedExtension defines the extension to use to pick the right loader
  29896. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29897. * @param mimeType defines an optional mime type
  29898. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29899. */
  29900. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29901. /**
  29902. * @hidden
  29903. */
  29904. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29905. /**
  29906. * Creates a raw texture
  29907. * @param data defines the data to store in the texture
  29908. * @param width defines the width of the texture
  29909. * @param height defines the height of the texture
  29910. * @param format defines the format of the data
  29911. * @param generateMipMaps defines if the engine should generate the mip levels
  29912. * @param invertY defines if data must be stored with Y axis inverted
  29913. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29914. * @param compression defines the compression used (null by default)
  29915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29916. * @returns the raw texture inside an InternalTexture
  29917. */
  29918. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29919. /**
  29920. * Creates a new raw cube texture
  29921. * @param data defines the array of data to use to create each face
  29922. * @param size defines the size of the textures
  29923. * @param format defines the format of the data
  29924. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29925. * @param generateMipMaps defines if the engine should generate the mip levels
  29926. * @param invertY defines if data must be stored with Y axis inverted
  29927. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29928. * @param compression defines the compression used (null by default)
  29929. * @returns the cube texture as an InternalTexture
  29930. */
  29931. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29932. /**
  29933. * Creates a new raw 3D texture
  29934. * @param data defines the data used to create the texture
  29935. * @param width defines the width of the texture
  29936. * @param height defines the height of the texture
  29937. * @param depth defines the depth of the texture
  29938. * @param format defines the format of the texture
  29939. * @param generateMipMaps defines if the engine must generate mip levels
  29940. * @param invertY defines if data must be stored with Y axis inverted
  29941. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29942. * @param compression defines the compressed used (can be null)
  29943. * @param textureType defines the compressed used (can be null)
  29944. * @returns a new raw 3D texture (stored in an InternalTexture)
  29945. */
  29946. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29947. /**
  29948. * Creates a new raw 2D array texture
  29949. * @param data defines the data used to create the texture
  29950. * @param width defines the width of the texture
  29951. * @param height defines the height of the texture
  29952. * @param depth defines the number of layers of the texture
  29953. * @param format defines the format of the texture
  29954. * @param generateMipMaps defines if the engine must generate mip levels
  29955. * @param invertY defines if data must be stored with Y axis inverted
  29956. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29957. * @param compression defines the compressed used (can be null)
  29958. * @param textureType defines the compressed used (can be null)
  29959. * @returns a new raw 2D array texture (stored in an InternalTexture)
  29960. */
  29961. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29962. private _unpackFlipYCached;
  29963. /**
  29964. * In case you are sharing the context with other applications, it might
  29965. * be interested to not cache the unpack flip y state to ensure a consistent
  29966. * value would be set.
  29967. */
  29968. enableUnpackFlipYCached: boolean;
  29969. /** @hidden */
  29970. _unpackFlipY(value: boolean): void;
  29971. /** @hidden */
  29972. _getUnpackAlignement(): number;
  29973. /**
  29974. * Update the sampling mode of a given texture
  29975. * @param samplingMode defines the required sampling mode
  29976. * @param texture defines the texture to update
  29977. */
  29978. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29979. /** @hidden */
  29980. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29981. width: number;
  29982. height: number;
  29983. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29984. /** @hidden */
  29985. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29986. /** @hidden */
  29987. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29988. /** @hidden */
  29989. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29990. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29991. private _prepareWebGLTexture;
  29992. /** @hidden */
  29993. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29994. /** @hidden */
  29995. _releaseFramebufferObjects(texture: InternalTexture): void;
  29996. /** @hidden */
  29997. _releaseTexture(texture: InternalTexture): void;
  29998. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29999. protected _setProgram(program: WebGLProgram): void;
  30000. protected _boundUniforms: {
  30001. [key: number]: WebGLUniformLocation;
  30002. };
  30003. /**
  30004. * Binds an effect to the webGL context
  30005. * @param effect defines the effect to bind
  30006. */
  30007. bindSamplers(effect: Effect): void;
  30008. private _activateCurrentTexture;
  30009. /** @hidden */
  30010. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30011. /** @hidden */
  30012. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30013. /**
  30014. * Unbind all textures from the webGL context
  30015. */
  30016. unbindAllTextures(): void;
  30017. /**
  30018. * Sets a texture to the according uniform.
  30019. * @param channel The texture channel
  30020. * @param uniform The uniform to set
  30021. * @param texture The texture to apply
  30022. */
  30023. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30024. private _bindSamplerUniformToChannel;
  30025. private _getTextureWrapMode;
  30026. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30027. /**
  30028. * Sets an array of texture to the webGL context
  30029. * @param channel defines the channel where the texture array must be set
  30030. * @param uniform defines the associated uniform location
  30031. * @param textures defines the array of textures to bind
  30032. */
  30033. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30034. /** @hidden */
  30035. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30036. private _setTextureParameterFloat;
  30037. private _setTextureParameterInteger;
  30038. /**
  30039. * Unbind all vertex attributes from the webGL context
  30040. */
  30041. unbindAllAttributes(): void;
  30042. /**
  30043. * 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
  30044. */
  30045. releaseEffects(): void;
  30046. /**
  30047. * Dispose and release all associated resources
  30048. */
  30049. dispose(): void;
  30050. /**
  30051. * Attach a new callback raised when context lost event is fired
  30052. * @param callback defines the callback to call
  30053. */
  30054. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30055. /**
  30056. * Attach a new callback raised when context restored event is fired
  30057. * @param callback defines the callback to call
  30058. */
  30059. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30060. /**
  30061. * Get the current error code of the webGL context
  30062. * @returns the error code
  30063. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30064. */
  30065. getError(): number;
  30066. private _canRenderToFloatFramebuffer;
  30067. private _canRenderToHalfFloatFramebuffer;
  30068. private _canRenderToFramebuffer;
  30069. /** @hidden */
  30070. _getWebGLTextureType(type: number): number;
  30071. /** @hidden */
  30072. _getInternalFormat(format: number): number;
  30073. /** @hidden */
  30074. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30075. /** @hidden */
  30076. _getRGBAMultiSampleBufferFormat(type: number): number;
  30077. /** @hidden */
  30078. _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;
  30079. /**
  30080. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30081. * @returns true if the engine can be created
  30082. * @ignorenaming
  30083. */
  30084. static isSupported(): boolean;
  30085. /**
  30086. * Find the next highest power of two.
  30087. * @param x Number to start search from.
  30088. * @return Next highest power of two.
  30089. */
  30090. static CeilingPOT(x: number): number;
  30091. /**
  30092. * Find the next lowest power of two.
  30093. * @param x Number to start search from.
  30094. * @return Next lowest power of two.
  30095. */
  30096. static FloorPOT(x: number): number;
  30097. /**
  30098. * Find the nearest power of two.
  30099. * @param x Number to start search from.
  30100. * @return Next nearest power of two.
  30101. */
  30102. static NearestPOT(x: number): number;
  30103. /**
  30104. * Get the closest exponent of two
  30105. * @param value defines the value to approximate
  30106. * @param max defines the maximum value to return
  30107. * @param mode defines how to define the closest value
  30108. * @returns closest exponent of two of the given value
  30109. */
  30110. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30111. /**
  30112. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30113. * @param func - the function to be called
  30114. * @param requester - the object that will request the next frame. Falls back to window.
  30115. * @returns frame number
  30116. */
  30117. static QueueNewFrame(func: () => void, requester?: any): number;
  30118. }
  30119. }
  30120. declare module BABYLON {
  30121. /**
  30122. * Class representing spherical harmonics coefficients to the 3rd degree
  30123. */
  30124. export class SphericalHarmonics {
  30125. /**
  30126. * Defines whether or not the harmonics have been prescaled for rendering.
  30127. */
  30128. preScaled: boolean;
  30129. /**
  30130. * The l0,0 coefficients of the spherical harmonics
  30131. */
  30132. l00: Vector3;
  30133. /**
  30134. * The l1,-1 coefficients of the spherical harmonics
  30135. */
  30136. l1_1: Vector3;
  30137. /**
  30138. * The l1,0 coefficients of the spherical harmonics
  30139. */
  30140. l10: Vector3;
  30141. /**
  30142. * The l1,1 coefficients of the spherical harmonics
  30143. */
  30144. l11: Vector3;
  30145. /**
  30146. * The l2,-2 coefficients of the spherical harmonics
  30147. */
  30148. l2_2: Vector3;
  30149. /**
  30150. * The l2,-1 coefficients of the spherical harmonics
  30151. */
  30152. l2_1: Vector3;
  30153. /**
  30154. * The l2,0 coefficients of the spherical harmonics
  30155. */
  30156. l20: Vector3;
  30157. /**
  30158. * The l2,1 coefficients of the spherical harmonics
  30159. */
  30160. l21: Vector3;
  30161. /**
  30162. * The l2,2 coefficients of the spherical harmonics
  30163. */
  30164. l22: Vector3;
  30165. /**
  30166. * Adds a light to the spherical harmonics
  30167. * @param direction the direction of the light
  30168. * @param color the color of the light
  30169. * @param deltaSolidAngle the delta solid angle of the light
  30170. */
  30171. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30172. /**
  30173. * Scales the spherical harmonics by the given amount
  30174. * @param scale the amount to scale
  30175. */
  30176. scaleInPlace(scale: number): void;
  30177. /**
  30178. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30179. *
  30180. * ```
  30181. * E_lm = A_l * L_lm
  30182. * ```
  30183. *
  30184. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30185. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30186. * the scaling factors are given in equation 9.
  30187. */
  30188. convertIncidentRadianceToIrradiance(): void;
  30189. /**
  30190. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30191. *
  30192. * ```
  30193. * L = (1/pi) * E * rho
  30194. * ```
  30195. *
  30196. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30197. */
  30198. convertIrradianceToLambertianRadiance(): void;
  30199. /**
  30200. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30201. * required operations at run time.
  30202. *
  30203. * This is simply done by scaling back the SH with Ylm constants parameter.
  30204. * The trigonometric part being applied by the shader at run time.
  30205. */
  30206. preScaleForRendering(): void;
  30207. /**
  30208. * Constructs a spherical harmonics from an array.
  30209. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30210. * @returns the spherical harmonics
  30211. */
  30212. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30213. /**
  30214. * Gets the spherical harmonics from polynomial
  30215. * @param polynomial the spherical polynomial
  30216. * @returns the spherical harmonics
  30217. */
  30218. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30219. }
  30220. /**
  30221. * Class representing spherical polynomial coefficients to the 3rd degree
  30222. */
  30223. export class SphericalPolynomial {
  30224. private _harmonics;
  30225. /**
  30226. * The spherical harmonics used to create the polynomials.
  30227. */
  30228. readonly preScaledHarmonics: SphericalHarmonics;
  30229. /**
  30230. * The x coefficients of the spherical polynomial
  30231. */
  30232. x: Vector3;
  30233. /**
  30234. * The y coefficients of the spherical polynomial
  30235. */
  30236. y: Vector3;
  30237. /**
  30238. * The z coefficients of the spherical polynomial
  30239. */
  30240. z: Vector3;
  30241. /**
  30242. * The xx coefficients of the spherical polynomial
  30243. */
  30244. xx: Vector3;
  30245. /**
  30246. * The yy coefficients of the spherical polynomial
  30247. */
  30248. yy: Vector3;
  30249. /**
  30250. * The zz coefficients of the spherical polynomial
  30251. */
  30252. zz: Vector3;
  30253. /**
  30254. * The xy coefficients of the spherical polynomial
  30255. */
  30256. xy: Vector3;
  30257. /**
  30258. * The yz coefficients of the spherical polynomial
  30259. */
  30260. yz: Vector3;
  30261. /**
  30262. * The zx coefficients of the spherical polynomial
  30263. */
  30264. zx: Vector3;
  30265. /**
  30266. * Adds an ambient color to the spherical polynomial
  30267. * @param color the color to add
  30268. */
  30269. addAmbient(color: Color3): void;
  30270. /**
  30271. * Scales the spherical polynomial by the given amount
  30272. * @param scale the amount to scale
  30273. */
  30274. scaleInPlace(scale: number): void;
  30275. /**
  30276. * Gets the spherical polynomial from harmonics
  30277. * @param harmonics the spherical harmonics
  30278. * @returns the spherical polynomial
  30279. */
  30280. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30281. /**
  30282. * Constructs a spherical polynomial from an array.
  30283. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30284. * @returns the spherical polynomial
  30285. */
  30286. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30287. }
  30288. }
  30289. declare module BABYLON {
  30290. /**
  30291. * Defines the source of the internal texture
  30292. */
  30293. export enum InternalTextureSource {
  30294. /**
  30295. * The source of the texture data is unknown
  30296. */
  30297. Unknown = 0,
  30298. /**
  30299. * Texture data comes from an URL
  30300. */
  30301. Url = 1,
  30302. /**
  30303. * Texture data is only used for temporary storage
  30304. */
  30305. Temp = 2,
  30306. /**
  30307. * Texture data comes from raw data (ArrayBuffer)
  30308. */
  30309. Raw = 3,
  30310. /**
  30311. * Texture content is dynamic (video or dynamic texture)
  30312. */
  30313. Dynamic = 4,
  30314. /**
  30315. * Texture content is generated by rendering to it
  30316. */
  30317. RenderTarget = 5,
  30318. /**
  30319. * Texture content is part of a multi render target process
  30320. */
  30321. MultiRenderTarget = 6,
  30322. /**
  30323. * Texture data comes from a cube data file
  30324. */
  30325. Cube = 7,
  30326. /**
  30327. * Texture data comes from a raw cube data
  30328. */
  30329. CubeRaw = 8,
  30330. /**
  30331. * Texture data come from a prefiltered cube data file
  30332. */
  30333. CubePrefiltered = 9,
  30334. /**
  30335. * Texture content is raw 3D data
  30336. */
  30337. Raw3D = 10,
  30338. /**
  30339. * Texture content is raw 2D array data
  30340. */
  30341. Raw2DArray = 11,
  30342. /**
  30343. * Texture content is a depth texture
  30344. */
  30345. Depth = 12,
  30346. /**
  30347. * Texture data comes from a raw cube data encoded with RGBD
  30348. */
  30349. CubeRawRGBD = 13
  30350. }
  30351. /**
  30352. * Class used to store data associated with WebGL texture data for the engine
  30353. * This class should not be used directly
  30354. */
  30355. export class InternalTexture {
  30356. /** @hidden */
  30357. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30358. /**
  30359. * Defines if the texture is ready
  30360. */
  30361. isReady: boolean;
  30362. /**
  30363. * Defines if the texture is a cube texture
  30364. */
  30365. isCube: boolean;
  30366. /**
  30367. * Defines if the texture contains 3D data
  30368. */
  30369. is3D: boolean;
  30370. /**
  30371. * Defines if the texture contains 2D array data
  30372. */
  30373. is2DArray: boolean;
  30374. /**
  30375. * Defines if the texture contains multiview data
  30376. */
  30377. isMultiview: boolean;
  30378. /**
  30379. * Gets the URL used to load this texture
  30380. */
  30381. url: string;
  30382. /**
  30383. * Gets the sampling mode of the texture
  30384. */
  30385. samplingMode: number;
  30386. /**
  30387. * Gets a boolean indicating if the texture needs mipmaps generation
  30388. */
  30389. generateMipMaps: boolean;
  30390. /**
  30391. * Gets the number of samples used by the texture (WebGL2+ only)
  30392. */
  30393. samples: number;
  30394. /**
  30395. * Gets the type of the texture (int, float...)
  30396. */
  30397. type: number;
  30398. /**
  30399. * Gets the format of the texture (RGB, RGBA...)
  30400. */
  30401. format: number;
  30402. /**
  30403. * Observable called when the texture is loaded
  30404. */
  30405. onLoadedObservable: Observable<InternalTexture>;
  30406. /**
  30407. * Gets the width of the texture
  30408. */
  30409. width: number;
  30410. /**
  30411. * Gets the height of the texture
  30412. */
  30413. height: number;
  30414. /**
  30415. * Gets the depth of the texture
  30416. */
  30417. depth: number;
  30418. /**
  30419. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30420. */
  30421. baseWidth: number;
  30422. /**
  30423. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30424. */
  30425. baseHeight: number;
  30426. /**
  30427. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30428. */
  30429. baseDepth: number;
  30430. /**
  30431. * Gets a boolean indicating if the texture is inverted on Y axis
  30432. */
  30433. invertY: boolean;
  30434. /** @hidden */
  30435. _invertVScale: boolean;
  30436. /** @hidden */
  30437. _associatedChannel: number;
  30438. /** @hidden */
  30439. _source: InternalTextureSource;
  30440. /** @hidden */
  30441. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30442. /** @hidden */
  30443. _bufferView: Nullable<ArrayBufferView>;
  30444. /** @hidden */
  30445. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30446. /** @hidden */
  30447. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30448. /** @hidden */
  30449. _size: number;
  30450. /** @hidden */
  30451. _extension: string;
  30452. /** @hidden */
  30453. _files: Nullable<string[]>;
  30454. /** @hidden */
  30455. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30456. /** @hidden */
  30457. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30458. /** @hidden */
  30459. _framebuffer: Nullable<WebGLFramebuffer>;
  30460. /** @hidden */
  30461. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30462. /** @hidden */
  30463. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30464. /** @hidden */
  30465. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30466. /** @hidden */
  30467. _attachments: Nullable<number[]>;
  30468. /** @hidden */
  30469. _cachedCoordinatesMode: Nullable<number>;
  30470. /** @hidden */
  30471. _cachedWrapU: Nullable<number>;
  30472. /** @hidden */
  30473. _cachedWrapV: Nullable<number>;
  30474. /** @hidden */
  30475. _cachedWrapR: Nullable<number>;
  30476. /** @hidden */
  30477. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30478. /** @hidden */
  30479. _isDisabled: boolean;
  30480. /** @hidden */
  30481. _compression: Nullable<string>;
  30482. /** @hidden */
  30483. _generateStencilBuffer: boolean;
  30484. /** @hidden */
  30485. _generateDepthBuffer: boolean;
  30486. /** @hidden */
  30487. _comparisonFunction: number;
  30488. /** @hidden */
  30489. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30490. /** @hidden */
  30491. _lodGenerationScale: number;
  30492. /** @hidden */
  30493. _lodGenerationOffset: number;
  30494. /** @hidden */
  30495. _colorTextureArray: Nullable<WebGLTexture>;
  30496. /** @hidden */
  30497. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30498. /** @hidden */
  30499. _lodTextureHigh: Nullable<BaseTexture>;
  30500. /** @hidden */
  30501. _lodTextureMid: Nullable<BaseTexture>;
  30502. /** @hidden */
  30503. _lodTextureLow: Nullable<BaseTexture>;
  30504. /** @hidden */
  30505. _isRGBD: boolean;
  30506. /** @hidden */
  30507. _linearSpecularLOD: boolean;
  30508. /** @hidden */
  30509. _irradianceTexture: Nullable<BaseTexture>;
  30510. /** @hidden */
  30511. _webGLTexture: Nullable<WebGLTexture>;
  30512. /** @hidden */
  30513. _references: number;
  30514. private _engine;
  30515. /**
  30516. * Gets the Engine the texture belongs to.
  30517. * @returns The babylon engine
  30518. */
  30519. getEngine(): ThinEngine;
  30520. /**
  30521. * Gets the data source type of the texture
  30522. */
  30523. readonly source: InternalTextureSource;
  30524. /**
  30525. * Creates a new InternalTexture
  30526. * @param engine defines the engine to use
  30527. * @param source defines the type of data that will be used
  30528. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30529. */
  30530. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30531. /**
  30532. * Increments the number of references (ie. the number of Texture that point to it)
  30533. */
  30534. incrementReferences(): void;
  30535. /**
  30536. * Change the size of the texture (not the size of the content)
  30537. * @param width defines the new width
  30538. * @param height defines the new height
  30539. * @param depth defines the new depth (1 by default)
  30540. */
  30541. updateSize(width: int, height: int, depth?: int): void;
  30542. /** @hidden */
  30543. _rebuild(): void;
  30544. /** @hidden */
  30545. _swapAndDie(target: InternalTexture): void;
  30546. /**
  30547. * Dispose the current allocated resources
  30548. */
  30549. dispose(): void;
  30550. }
  30551. }
  30552. declare module BABYLON {
  30553. /**
  30554. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30556. */
  30557. export class Analyser {
  30558. /**
  30559. * Gets or sets the smoothing
  30560. * @ignorenaming
  30561. */
  30562. SMOOTHING: number;
  30563. /**
  30564. * Gets or sets the FFT table size
  30565. * @ignorenaming
  30566. */
  30567. FFT_SIZE: number;
  30568. /**
  30569. * Gets or sets the bar graph amplitude
  30570. * @ignorenaming
  30571. */
  30572. BARGRAPHAMPLITUDE: number;
  30573. /**
  30574. * Gets or sets the position of the debug canvas
  30575. * @ignorenaming
  30576. */
  30577. DEBUGCANVASPOS: {
  30578. x: number;
  30579. y: number;
  30580. };
  30581. /**
  30582. * Gets or sets the debug canvas size
  30583. * @ignorenaming
  30584. */
  30585. DEBUGCANVASSIZE: {
  30586. width: number;
  30587. height: number;
  30588. };
  30589. private _byteFreqs;
  30590. private _byteTime;
  30591. private _floatFreqs;
  30592. private _webAudioAnalyser;
  30593. private _debugCanvas;
  30594. private _debugCanvasContext;
  30595. private _scene;
  30596. private _registerFunc;
  30597. private _audioEngine;
  30598. /**
  30599. * Creates a new analyser
  30600. * @param scene defines hosting scene
  30601. */
  30602. constructor(scene: Scene);
  30603. /**
  30604. * Get the number of data values you will have to play with for the visualization
  30605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30606. * @returns a number
  30607. */
  30608. getFrequencyBinCount(): number;
  30609. /**
  30610. * Gets the current frequency data as a byte array
  30611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30612. * @returns a Uint8Array
  30613. */
  30614. getByteFrequencyData(): Uint8Array;
  30615. /**
  30616. * Gets the current waveform as a byte array
  30617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30618. * @returns a Uint8Array
  30619. */
  30620. getByteTimeDomainData(): Uint8Array;
  30621. /**
  30622. * Gets the current frequency data as a float array
  30623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30624. * @returns a Float32Array
  30625. */
  30626. getFloatFrequencyData(): Float32Array;
  30627. /**
  30628. * Renders the debug canvas
  30629. */
  30630. drawDebugCanvas(): void;
  30631. /**
  30632. * Stops rendering the debug canvas and removes it
  30633. */
  30634. stopDebugCanvas(): void;
  30635. /**
  30636. * Connects two audio nodes
  30637. * @param inputAudioNode defines first node to connect
  30638. * @param outputAudioNode defines second node to connect
  30639. */
  30640. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30641. /**
  30642. * Releases all associated resources
  30643. */
  30644. dispose(): void;
  30645. }
  30646. }
  30647. declare module BABYLON {
  30648. /**
  30649. * This represents an audio engine and it is responsible
  30650. * to play, synchronize and analyse sounds throughout the application.
  30651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30652. */
  30653. export interface IAudioEngine extends IDisposable {
  30654. /**
  30655. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30656. */
  30657. readonly canUseWebAudio: boolean;
  30658. /**
  30659. * Gets the current AudioContext if available.
  30660. */
  30661. readonly audioContext: Nullable<AudioContext>;
  30662. /**
  30663. * The master gain node defines the global audio volume of your audio engine.
  30664. */
  30665. readonly masterGain: GainNode;
  30666. /**
  30667. * Gets whether or not mp3 are supported by your browser.
  30668. */
  30669. readonly isMP3supported: boolean;
  30670. /**
  30671. * Gets whether or not ogg are supported by your browser.
  30672. */
  30673. readonly isOGGsupported: boolean;
  30674. /**
  30675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30676. * @ignoreNaming
  30677. */
  30678. WarnedWebAudioUnsupported: boolean;
  30679. /**
  30680. * Defines if the audio engine relies on a custom unlocked button.
  30681. * In this case, the embedded button will not be displayed.
  30682. */
  30683. useCustomUnlockedButton: boolean;
  30684. /**
  30685. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30686. */
  30687. readonly unlocked: boolean;
  30688. /**
  30689. * Event raised when audio has been unlocked on the browser.
  30690. */
  30691. onAudioUnlockedObservable: Observable<AudioEngine>;
  30692. /**
  30693. * Event raised when audio has been locked on the browser.
  30694. */
  30695. onAudioLockedObservable: Observable<AudioEngine>;
  30696. /**
  30697. * Flags the audio engine in Locked state.
  30698. * This happens due to new browser policies preventing audio to autoplay.
  30699. */
  30700. lock(): void;
  30701. /**
  30702. * Unlocks the audio engine once a user action has been done on the dom.
  30703. * This is helpful to resume play once browser policies have been satisfied.
  30704. */
  30705. unlock(): void;
  30706. }
  30707. /**
  30708. * This represents the default audio engine used in babylon.
  30709. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30711. */
  30712. export class AudioEngine implements IAudioEngine {
  30713. private _audioContext;
  30714. private _audioContextInitialized;
  30715. private _muteButton;
  30716. private _hostElement;
  30717. /**
  30718. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30719. */
  30720. canUseWebAudio: boolean;
  30721. /**
  30722. * The master gain node defines the global audio volume of your audio engine.
  30723. */
  30724. masterGain: GainNode;
  30725. /**
  30726. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30727. * @ignoreNaming
  30728. */
  30729. WarnedWebAudioUnsupported: boolean;
  30730. /**
  30731. * Gets whether or not mp3 are supported by your browser.
  30732. */
  30733. isMP3supported: boolean;
  30734. /**
  30735. * Gets whether or not ogg are supported by your browser.
  30736. */
  30737. isOGGsupported: boolean;
  30738. /**
  30739. * Gets whether audio has been unlocked on the device.
  30740. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30741. * a user interaction has happened.
  30742. */
  30743. unlocked: boolean;
  30744. /**
  30745. * Defines if the audio engine relies on a custom unlocked button.
  30746. * In this case, the embedded button will not be displayed.
  30747. */
  30748. useCustomUnlockedButton: boolean;
  30749. /**
  30750. * Event raised when audio has been unlocked on the browser.
  30751. */
  30752. onAudioUnlockedObservable: Observable<AudioEngine>;
  30753. /**
  30754. * Event raised when audio has been locked on the browser.
  30755. */
  30756. onAudioLockedObservable: Observable<AudioEngine>;
  30757. /**
  30758. * Gets the current AudioContext if available.
  30759. */
  30760. readonly audioContext: Nullable<AudioContext>;
  30761. private _connectedAnalyser;
  30762. /**
  30763. * Instantiates a new audio engine.
  30764. *
  30765. * There should be only one per page as some browsers restrict the number
  30766. * of audio contexts you can create.
  30767. * @param hostElement defines the host element where to display the mute icon if necessary
  30768. */
  30769. constructor(hostElement?: Nullable<HTMLElement>);
  30770. /**
  30771. * Flags the audio engine in Locked state.
  30772. * This happens due to new browser policies preventing audio to autoplay.
  30773. */
  30774. lock(): void;
  30775. /**
  30776. * Unlocks the audio engine once a user action has been done on the dom.
  30777. * This is helpful to resume play once browser policies have been satisfied.
  30778. */
  30779. unlock(): void;
  30780. private _resumeAudioContext;
  30781. private _initializeAudioContext;
  30782. private _tryToRun;
  30783. private _triggerRunningState;
  30784. private _triggerSuspendedState;
  30785. private _displayMuteButton;
  30786. private _moveButtonToTopLeft;
  30787. private _onResize;
  30788. private _hideMuteButton;
  30789. /**
  30790. * Destroy and release the resources associated with the audio ccontext.
  30791. */
  30792. dispose(): void;
  30793. /**
  30794. * Gets the global volume sets on the master gain.
  30795. * @returns the global volume if set or -1 otherwise
  30796. */
  30797. getGlobalVolume(): number;
  30798. /**
  30799. * Sets the global volume of your experience (sets on the master gain).
  30800. * @param newVolume Defines the new global volume of the application
  30801. */
  30802. setGlobalVolume(newVolume: number): void;
  30803. /**
  30804. * Connect the audio engine to an audio analyser allowing some amazing
  30805. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30807. * @param analyser The analyser to connect to the engine
  30808. */
  30809. connectToAnalyser(analyser: Analyser): void;
  30810. }
  30811. }
  30812. declare module BABYLON {
  30813. /**
  30814. * Interface used to present a loading screen while loading a scene
  30815. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30816. */
  30817. export interface ILoadingScreen {
  30818. /**
  30819. * Function called to display the loading screen
  30820. */
  30821. displayLoadingUI: () => void;
  30822. /**
  30823. * Function called to hide the loading screen
  30824. */
  30825. hideLoadingUI: () => void;
  30826. /**
  30827. * Gets or sets the color to use for the background
  30828. */
  30829. loadingUIBackgroundColor: string;
  30830. /**
  30831. * Gets or sets the text to display while loading
  30832. */
  30833. loadingUIText: string;
  30834. }
  30835. /**
  30836. * Class used for the default loading screen
  30837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30838. */
  30839. export class DefaultLoadingScreen implements ILoadingScreen {
  30840. private _renderingCanvas;
  30841. private _loadingText;
  30842. private _loadingDivBackgroundColor;
  30843. private _loadingDiv;
  30844. private _loadingTextDiv;
  30845. /** Gets or sets the logo url to use for the default loading screen */
  30846. static DefaultLogoUrl: string;
  30847. /** Gets or sets the spinner url to use for the default loading screen */
  30848. static DefaultSpinnerUrl: string;
  30849. /**
  30850. * Creates a new default loading screen
  30851. * @param _renderingCanvas defines the canvas used to render the scene
  30852. * @param _loadingText defines the default text to display
  30853. * @param _loadingDivBackgroundColor defines the default background color
  30854. */
  30855. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30856. /**
  30857. * Function called to display the loading screen
  30858. */
  30859. displayLoadingUI(): void;
  30860. /**
  30861. * Function called to hide the loading screen
  30862. */
  30863. hideLoadingUI(): void;
  30864. /**
  30865. * Gets or sets the text to display while loading
  30866. */
  30867. loadingUIText: string;
  30868. /**
  30869. * Gets or sets the color to use for the background
  30870. */
  30871. loadingUIBackgroundColor: string;
  30872. private _resizeLoadingUI;
  30873. }
  30874. }
  30875. declare module BABYLON {
  30876. /**
  30877. * Interface for any object that can request an animation frame
  30878. */
  30879. export interface ICustomAnimationFrameRequester {
  30880. /**
  30881. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30882. */
  30883. renderFunction?: Function;
  30884. /**
  30885. * Called to request the next frame to render to
  30886. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30887. */
  30888. requestAnimationFrame: Function;
  30889. /**
  30890. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30891. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30892. */
  30893. requestID?: number;
  30894. }
  30895. }
  30896. declare module BABYLON {
  30897. /**
  30898. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30899. */
  30900. export class PerformanceMonitor {
  30901. private _enabled;
  30902. private _rollingFrameTime;
  30903. private _lastFrameTimeMs;
  30904. /**
  30905. * constructor
  30906. * @param frameSampleSize The number of samples required to saturate the sliding window
  30907. */
  30908. constructor(frameSampleSize?: number);
  30909. /**
  30910. * Samples current frame
  30911. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30912. */
  30913. sampleFrame(timeMs?: number): void;
  30914. /**
  30915. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30916. */
  30917. readonly averageFrameTime: number;
  30918. /**
  30919. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30920. */
  30921. readonly averageFrameTimeVariance: number;
  30922. /**
  30923. * Returns the frame time of the most recent frame
  30924. */
  30925. readonly instantaneousFrameTime: number;
  30926. /**
  30927. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30928. */
  30929. readonly averageFPS: number;
  30930. /**
  30931. * Returns the average framerate in frames per second using the most recent frame time
  30932. */
  30933. readonly instantaneousFPS: number;
  30934. /**
  30935. * Returns true if enough samples have been taken to completely fill the sliding window
  30936. */
  30937. readonly isSaturated: boolean;
  30938. /**
  30939. * Enables contributions to the sliding window sample set
  30940. */
  30941. enable(): void;
  30942. /**
  30943. * Disables contributions to the sliding window sample set
  30944. * Samples will not be interpolated over the disabled period
  30945. */
  30946. disable(): void;
  30947. /**
  30948. * Returns true if sampling is enabled
  30949. */
  30950. readonly isEnabled: boolean;
  30951. /**
  30952. * Resets performance monitor
  30953. */
  30954. reset(): void;
  30955. }
  30956. /**
  30957. * RollingAverage
  30958. *
  30959. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30960. */
  30961. export class RollingAverage {
  30962. /**
  30963. * Current average
  30964. */
  30965. average: number;
  30966. /**
  30967. * Current variance
  30968. */
  30969. variance: number;
  30970. protected _samples: Array<number>;
  30971. protected _sampleCount: number;
  30972. protected _pos: number;
  30973. protected _m2: number;
  30974. /**
  30975. * constructor
  30976. * @param length The number of samples required to saturate the sliding window
  30977. */
  30978. constructor(length: number);
  30979. /**
  30980. * Adds a sample to the sample set
  30981. * @param v The sample value
  30982. */
  30983. add(v: number): void;
  30984. /**
  30985. * Returns previously added values or null if outside of history or outside the sliding window domain
  30986. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30987. * @return Value previously recorded with add() or null if outside of range
  30988. */
  30989. history(i: number): number;
  30990. /**
  30991. * Returns true if enough samples have been taken to completely fill the sliding window
  30992. * @return true if sample-set saturated
  30993. */
  30994. isSaturated(): boolean;
  30995. /**
  30996. * Resets the rolling average (equivalent to 0 samples taken so far)
  30997. */
  30998. reset(): void;
  30999. /**
  31000. * Wraps a value around the sample range boundaries
  31001. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31002. * @return Wrapped position in sample range
  31003. */
  31004. protected _wrapPosition(i: number): number;
  31005. }
  31006. }
  31007. declare module BABYLON {
  31008. /**
  31009. * This class is used to track a performance counter which is number based.
  31010. * The user has access to many properties which give statistics of different nature.
  31011. *
  31012. * The implementer can track two kinds of Performance Counter: time and count.
  31013. * 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.
  31014. * 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.
  31015. */
  31016. export class PerfCounter {
  31017. /**
  31018. * Gets or sets a global boolean to turn on and off all the counters
  31019. */
  31020. static Enabled: boolean;
  31021. /**
  31022. * Returns the smallest value ever
  31023. */
  31024. readonly min: number;
  31025. /**
  31026. * Returns the biggest value ever
  31027. */
  31028. readonly max: number;
  31029. /**
  31030. * Returns the average value since the performance counter is running
  31031. */
  31032. readonly average: number;
  31033. /**
  31034. * Returns the average value of the last second the counter was monitored
  31035. */
  31036. readonly lastSecAverage: number;
  31037. /**
  31038. * Returns the current value
  31039. */
  31040. readonly current: number;
  31041. /**
  31042. * Gets the accumulated total
  31043. */
  31044. readonly total: number;
  31045. /**
  31046. * Gets the total value count
  31047. */
  31048. readonly count: number;
  31049. /**
  31050. * Creates a new counter
  31051. */
  31052. constructor();
  31053. /**
  31054. * Call this method to start monitoring a new frame.
  31055. * 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.
  31056. */
  31057. fetchNewFrame(): void;
  31058. /**
  31059. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31060. * @param newCount the count value to add to the monitored count
  31061. * @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.
  31062. */
  31063. addCount(newCount: number, fetchResult: boolean): void;
  31064. /**
  31065. * Start monitoring this performance counter
  31066. */
  31067. beginMonitoring(): void;
  31068. /**
  31069. * Compute the time lapsed since the previous beginMonitoring() call.
  31070. * @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
  31071. */
  31072. endMonitoring(newFrame?: boolean): void;
  31073. private _fetchResult;
  31074. private _startMonitoringTime;
  31075. private _min;
  31076. private _max;
  31077. private _average;
  31078. private _current;
  31079. private _totalValueCount;
  31080. private _totalAccumulated;
  31081. private _lastSecAverage;
  31082. private _lastSecAccumulated;
  31083. private _lastSecTime;
  31084. private _lastSecValueCount;
  31085. }
  31086. }
  31087. declare module BABYLON {
  31088. /**
  31089. * Defines the interface used by display changed events
  31090. */
  31091. export interface IDisplayChangedEventArgs {
  31092. /** Gets the vrDisplay object (if any) */
  31093. vrDisplay: Nullable<any>;
  31094. /** Gets a boolean indicating if webVR is supported */
  31095. vrSupported: boolean;
  31096. }
  31097. /**
  31098. * Defines the interface used by objects containing a viewport (like a camera)
  31099. */
  31100. interface IViewportOwnerLike {
  31101. /**
  31102. * Gets or sets the viewport
  31103. */
  31104. viewport: IViewportLike;
  31105. }
  31106. /**
  31107. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31108. */
  31109. export class Engine extends ThinEngine {
  31110. /** Defines that alpha blending is disabled */
  31111. static readonly ALPHA_DISABLE: number;
  31112. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31113. static readonly ALPHA_ADD: number;
  31114. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31115. static readonly ALPHA_COMBINE: number;
  31116. /** Defines that alpha blending to DEST - SRC * DEST */
  31117. static readonly ALPHA_SUBTRACT: number;
  31118. /** Defines that alpha blending to SRC * DEST */
  31119. static readonly ALPHA_MULTIPLY: number;
  31120. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31121. static readonly ALPHA_MAXIMIZED: number;
  31122. /** Defines that alpha blending to SRC + DEST */
  31123. static readonly ALPHA_ONEONE: number;
  31124. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31125. static readonly ALPHA_PREMULTIPLIED: number;
  31126. /**
  31127. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31128. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31129. */
  31130. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31131. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31132. static readonly ALPHA_INTERPOLATE: number;
  31133. /**
  31134. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31135. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31136. */
  31137. static readonly ALPHA_SCREENMODE: number;
  31138. /** Defines that the ressource is not delayed*/
  31139. static readonly DELAYLOADSTATE_NONE: number;
  31140. /** Defines that the ressource was successfully delay loaded */
  31141. static readonly DELAYLOADSTATE_LOADED: number;
  31142. /** Defines that the ressource is currently delay loading */
  31143. static readonly DELAYLOADSTATE_LOADING: number;
  31144. /** Defines that the ressource is delayed and has not started loading */
  31145. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31146. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31147. static readonly NEVER: number;
  31148. /** 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 */
  31149. static readonly ALWAYS: number;
  31150. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31151. static readonly LESS: number;
  31152. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31153. static readonly EQUAL: number;
  31154. /** 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 */
  31155. static readonly LEQUAL: number;
  31156. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31157. static readonly GREATER: number;
  31158. /** 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 */
  31159. static readonly GEQUAL: number;
  31160. /** 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 */
  31161. static readonly NOTEQUAL: number;
  31162. /** Passed to stencilOperation to specify that stencil value must be kept */
  31163. static readonly KEEP: number;
  31164. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31165. static readonly REPLACE: number;
  31166. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31167. static readonly INCR: number;
  31168. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31169. static readonly DECR: number;
  31170. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31171. static readonly INVERT: number;
  31172. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31173. static readonly INCR_WRAP: number;
  31174. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31175. static readonly DECR_WRAP: number;
  31176. /** Texture is not repeating outside of 0..1 UVs */
  31177. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31178. /** Texture is repeating outside of 0..1 UVs */
  31179. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31180. /** Texture is repeating and mirrored */
  31181. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31182. /** ALPHA */
  31183. static readonly TEXTUREFORMAT_ALPHA: number;
  31184. /** LUMINANCE */
  31185. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31186. /** LUMINANCE_ALPHA */
  31187. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31188. /** RGB */
  31189. static readonly TEXTUREFORMAT_RGB: number;
  31190. /** RGBA */
  31191. static readonly TEXTUREFORMAT_RGBA: number;
  31192. /** RED */
  31193. static readonly TEXTUREFORMAT_RED: number;
  31194. /** RED (2nd reference) */
  31195. static readonly TEXTUREFORMAT_R: number;
  31196. /** RG */
  31197. static readonly TEXTUREFORMAT_RG: number;
  31198. /** RED_INTEGER */
  31199. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31200. /** RED_INTEGER (2nd reference) */
  31201. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31202. /** RG_INTEGER */
  31203. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31204. /** RGB_INTEGER */
  31205. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31206. /** RGBA_INTEGER */
  31207. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31208. /** UNSIGNED_BYTE */
  31209. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31210. /** UNSIGNED_BYTE (2nd reference) */
  31211. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31212. /** FLOAT */
  31213. static readonly TEXTURETYPE_FLOAT: number;
  31214. /** HALF_FLOAT */
  31215. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31216. /** BYTE */
  31217. static readonly TEXTURETYPE_BYTE: number;
  31218. /** SHORT */
  31219. static readonly TEXTURETYPE_SHORT: number;
  31220. /** UNSIGNED_SHORT */
  31221. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31222. /** INT */
  31223. static readonly TEXTURETYPE_INT: number;
  31224. /** UNSIGNED_INT */
  31225. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31226. /** UNSIGNED_SHORT_4_4_4_4 */
  31227. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31228. /** UNSIGNED_SHORT_5_5_5_1 */
  31229. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31230. /** UNSIGNED_SHORT_5_6_5 */
  31231. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31232. /** UNSIGNED_INT_2_10_10_10_REV */
  31233. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31234. /** UNSIGNED_INT_24_8 */
  31235. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31236. /** UNSIGNED_INT_10F_11F_11F_REV */
  31237. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31238. /** UNSIGNED_INT_5_9_9_9_REV */
  31239. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31240. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31241. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31242. /** nearest is mag = nearest and min = nearest and mip = linear */
  31243. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31244. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31245. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31246. /** Trilinear is mag = linear and min = linear and mip = linear */
  31247. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31248. /** nearest is mag = nearest and min = nearest and mip = linear */
  31249. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31250. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31251. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31252. /** Trilinear is mag = linear and min = linear and mip = linear */
  31253. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31254. /** mag = nearest and min = nearest and mip = nearest */
  31255. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31256. /** mag = nearest and min = linear and mip = nearest */
  31257. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31258. /** mag = nearest and min = linear and mip = linear */
  31259. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31260. /** mag = nearest and min = linear and mip = none */
  31261. static readonly TEXTURE_NEAREST_LINEAR: number;
  31262. /** mag = nearest and min = nearest and mip = none */
  31263. static readonly TEXTURE_NEAREST_NEAREST: number;
  31264. /** mag = linear and min = nearest and mip = nearest */
  31265. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31266. /** mag = linear and min = nearest and mip = linear */
  31267. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31268. /** mag = linear and min = linear and mip = none */
  31269. static readonly TEXTURE_LINEAR_LINEAR: number;
  31270. /** mag = linear and min = nearest and mip = none */
  31271. static readonly TEXTURE_LINEAR_NEAREST: number;
  31272. /** Explicit coordinates mode */
  31273. static readonly TEXTURE_EXPLICIT_MODE: number;
  31274. /** Spherical coordinates mode */
  31275. static readonly TEXTURE_SPHERICAL_MODE: number;
  31276. /** Planar coordinates mode */
  31277. static readonly TEXTURE_PLANAR_MODE: number;
  31278. /** Cubic coordinates mode */
  31279. static readonly TEXTURE_CUBIC_MODE: number;
  31280. /** Projection coordinates mode */
  31281. static readonly TEXTURE_PROJECTION_MODE: number;
  31282. /** Skybox coordinates mode */
  31283. static readonly TEXTURE_SKYBOX_MODE: number;
  31284. /** Inverse Cubic coordinates mode */
  31285. static readonly TEXTURE_INVCUBIC_MODE: number;
  31286. /** Equirectangular coordinates mode */
  31287. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31288. /** Equirectangular Fixed coordinates mode */
  31289. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31290. /** Equirectangular Fixed Mirrored coordinates mode */
  31291. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31292. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31293. static readonly SCALEMODE_FLOOR: number;
  31294. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31295. static readonly SCALEMODE_NEAREST: number;
  31296. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31297. static readonly SCALEMODE_CEILING: number;
  31298. /**
  31299. * Returns the current npm package of the sdk
  31300. */
  31301. static readonly NpmPackage: string;
  31302. /**
  31303. * Returns the current version of the framework
  31304. */
  31305. static readonly Version: string;
  31306. /** Gets the list of created engines */
  31307. static readonly Instances: Engine[];
  31308. /**
  31309. * Gets the latest created engine
  31310. */
  31311. static readonly LastCreatedEngine: Nullable<Engine>;
  31312. /**
  31313. * Gets the latest created scene
  31314. */
  31315. static readonly LastCreatedScene: Nullable<Scene>;
  31316. /**
  31317. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31318. * @param flag defines which part of the materials must be marked as dirty
  31319. * @param predicate defines a predicate used to filter which materials should be affected
  31320. */
  31321. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31322. /**
  31323. * Method called to create the default loading screen.
  31324. * This can be overriden in your own app.
  31325. * @param canvas The rendering canvas element
  31326. * @returns The loading screen
  31327. */
  31328. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31329. /**
  31330. * Method called to create the default rescale post process on each engine.
  31331. */
  31332. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31333. /**
  31334. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31335. **/
  31336. enableOfflineSupport: boolean;
  31337. /**
  31338. * 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)
  31339. **/
  31340. disableManifestCheck: boolean;
  31341. /**
  31342. * Gets the list of created scenes
  31343. */
  31344. scenes: Scene[];
  31345. /**
  31346. * Event raised when a new scene is created
  31347. */
  31348. onNewSceneAddedObservable: Observable<Scene>;
  31349. /**
  31350. * Gets the list of created postprocesses
  31351. */
  31352. postProcesses: PostProcess[];
  31353. /**
  31354. * Gets a boolean indicating if the pointer is currently locked
  31355. */
  31356. isPointerLock: boolean;
  31357. /**
  31358. * Observable event triggered each time the rendering canvas is resized
  31359. */
  31360. onResizeObservable: Observable<Engine>;
  31361. /**
  31362. * Observable event triggered each time the canvas loses focus
  31363. */
  31364. onCanvasBlurObservable: Observable<Engine>;
  31365. /**
  31366. * Observable event triggered each time the canvas gains focus
  31367. */
  31368. onCanvasFocusObservable: Observable<Engine>;
  31369. /**
  31370. * Observable event triggered each time the canvas receives pointerout event
  31371. */
  31372. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31373. /**
  31374. * Observable raised when the engine begins a new frame
  31375. */
  31376. onBeginFrameObservable: Observable<Engine>;
  31377. /**
  31378. * If set, will be used to request the next animation frame for the render loop
  31379. */
  31380. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31381. /**
  31382. * Observable raised when the engine ends the current frame
  31383. */
  31384. onEndFrameObservable: Observable<Engine>;
  31385. /**
  31386. * Observable raised when the engine is about to compile a shader
  31387. */
  31388. onBeforeShaderCompilationObservable: Observable<Engine>;
  31389. /**
  31390. * Observable raised when the engine has jsut compiled a shader
  31391. */
  31392. onAfterShaderCompilationObservable: Observable<Engine>;
  31393. /**
  31394. * Gets the audio engine
  31395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31396. * @ignorenaming
  31397. */
  31398. static audioEngine: IAudioEngine;
  31399. /**
  31400. * Default AudioEngine factory responsible of creating the Audio Engine.
  31401. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31402. */
  31403. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31404. /**
  31405. * Default offline support factory responsible of creating a tool used to store data locally.
  31406. * By default, this will create a Database object if the workload has been embedded.
  31407. */
  31408. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31409. private _loadingScreen;
  31410. private _pointerLockRequested;
  31411. private _dummyFramebuffer;
  31412. private _rescalePostProcess;
  31413. /** @hidden */
  31414. protected _alphaMode: number;
  31415. /** @hidden */
  31416. protected _alphaEquation: number;
  31417. private _deterministicLockstep;
  31418. private _lockstepMaxSteps;
  31419. protected readonly _supportsHardwareTextureRescaling: boolean;
  31420. private _fps;
  31421. private _deltaTime;
  31422. /** @hidden */
  31423. _drawCalls: PerfCounter;
  31424. /**
  31425. * Turn this value on if you want to pause FPS computation when in background
  31426. */
  31427. disablePerformanceMonitorInBackground: boolean;
  31428. private _performanceMonitor;
  31429. /**
  31430. * Gets the performance monitor attached to this engine
  31431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31432. */
  31433. readonly performanceMonitor: PerformanceMonitor;
  31434. private _onFocus;
  31435. private _onBlur;
  31436. private _onCanvasPointerOut;
  31437. private _onCanvasBlur;
  31438. private _onCanvasFocus;
  31439. private _onFullscreenChange;
  31440. private _onPointerLockChange;
  31441. /**
  31442. * Gets the HTML element used to attach event listeners
  31443. * @returns a HTML element
  31444. */
  31445. getInputElement(): Nullable<HTMLElement>;
  31446. /**
  31447. * Creates a new engine
  31448. * @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
  31449. * @param antialias defines enable antialiasing (default: false)
  31450. * @param options defines further options to be sent to the getContext() function
  31451. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31452. */
  31453. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31454. /**
  31455. * Gets current aspect ratio
  31456. * @param viewportOwner defines the camera to use to get the aspect ratio
  31457. * @param useScreen defines if screen size must be used (or the current render target if any)
  31458. * @returns a number defining the aspect ratio
  31459. */
  31460. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31461. /**
  31462. * Gets current screen aspect ratio
  31463. * @returns a number defining the aspect ratio
  31464. */
  31465. getScreenAspectRatio(): number;
  31466. /**
  31467. * Gets host document
  31468. * @returns the host document object
  31469. */
  31470. getHostDocument(): Document;
  31471. /**
  31472. * Gets the client rect of the HTML canvas attached with the current webGL context
  31473. * @returns a client rectanglee
  31474. */
  31475. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31476. /**
  31477. * Gets the client rect of the HTML element used for events
  31478. * @returns a client rectanglee
  31479. */
  31480. getInputElementClientRect(): Nullable<ClientRect>;
  31481. /**
  31482. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31483. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31484. * @returns true if engine is in deterministic lock step mode
  31485. */
  31486. isDeterministicLockStep(): boolean;
  31487. /**
  31488. * Gets the max steps when engine is running in deterministic lock step
  31489. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31490. * @returns the max steps
  31491. */
  31492. getLockstepMaxSteps(): number;
  31493. /**
  31494. * Force the mipmap generation for the given render target texture
  31495. * @param texture defines the render target texture to use
  31496. */
  31497. generateMipMapsForCubemap(texture: InternalTexture): void;
  31498. /** States */
  31499. /**
  31500. * Set various states to the webGL context
  31501. * @param culling defines backface culling state
  31502. * @param zOffset defines the value to apply to zOffset (0 by default)
  31503. * @param force defines if states must be applied even if cache is up to date
  31504. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31505. */
  31506. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31507. /**
  31508. * Set the z offset to apply to current rendering
  31509. * @param value defines the offset to apply
  31510. */
  31511. setZOffset(value: number): void;
  31512. /**
  31513. * Gets the current value of the zOffset
  31514. * @returns the current zOffset state
  31515. */
  31516. getZOffset(): number;
  31517. /**
  31518. * Enable or disable depth buffering
  31519. * @param enable defines the state to set
  31520. */
  31521. setDepthBuffer(enable: boolean): void;
  31522. /**
  31523. * Gets a boolean indicating if depth writing is enabled
  31524. * @returns the current depth writing state
  31525. */
  31526. getDepthWrite(): boolean;
  31527. /**
  31528. * Enable or disable depth writing
  31529. * @param enable defines the state to set
  31530. */
  31531. setDepthWrite(enable: boolean): void;
  31532. /**
  31533. * Enable or disable color writing
  31534. * @param enable defines the state to set
  31535. */
  31536. setColorWrite(enable: boolean): void;
  31537. /**
  31538. * Gets a boolean indicating if color writing is enabled
  31539. * @returns the current color writing state
  31540. */
  31541. getColorWrite(): boolean;
  31542. /**
  31543. * Sets alpha constants used by some alpha blending modes
  31544. * @param r defines the red component
  31545. * @param g defines the green component
  31546. * @param b defines the blue component
  31547. * @param a defines the alpha component
  31548. */
  31549. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31550. /**
  31551. * Sets the current alpha mode
  31552. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31553. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31554. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31555. */
  31556. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31557. /**
  31558. * Gets the current alpha mode
  31559. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31560. * @returns the current alpha mode
  31561. */
  31562. getAlphaMode(): number;
  31563. /**
  31564. * Sets the current alpha equation
  31565. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31566. */
  31567. setAlphaEquation(equation: number): void;
  31568. /**
  31569. * Gets the current alpha equation.
  31570. * @returns the current alpha equation
  31571. */
  31572. getAlphaEquation(): number;
  31573. /**
  31574. * Gets a boolean indicating if stencil buffer is enabled
  31575. * @returns the current stencil buffer state
  31576. */
  31577. getStencilBuffer(): boolean;
  31578. /**
  31579. * Enable or disable the stencil buffer
  31580. * @param enable defines if the stencil buffer must be enabled or disabled
  31581. */
  31582. setStencilBuffer(enable: boolean): void;
  31583. /**
  31584. * Gets the current stencil mask
  31585. * @returns a number defining the new stencil mask to use
  31586. */
  31587. getStencilMask(): number;
  31588. /**
  31589. * Sets the current stencil mask
  31590. * @param mask defines the new stencil mask to use
  31591. */
  31592. setStencilMask(mask: number): void;
  31593. /**
  31594. * Gets the current stencil function
  31595. * @returns a number defining the stencil function to use
  31596. */
  31597. getStencilFunction(): number;
  31598. /**
  31599. * Gets the current stencil reference value
  31600. * @returns a number defining the stencil reference value to use
  31601. */
  31602. getStencilFunctionReference(): number;
  31603. /**
  31604. * Gets the current stencil mask
  31605. * @returns a number defining the stencil mask to use
  31606. */
  31607. getStencilFunctionMask(): number;
  31608. /**
  31609. * Sets the current stencil function
  31610. * @param stencilFunc defines the new stencil function to use
  31611. */
  31612. setStencilFunction(stencilFunc: number): void;
  31613. /**
  31614. * Sets the current stencil reference
  31615. * @param reference defines the new stencil reference to use
  31616. */
  31617. setStencilFunctionReference(reference: number): void;
  31618. /**
  31619. * Sets the current stencil mask
  31620. * @param mask defines the new stencil mask to use
  31621. */
  31622. setStencilFunctionMask(mask: number): void;
  31623. /**
  31624. * Gets the current stencil operation when stencil fails
  31625. * @returns a number defining stencil operation to use when stencil fails
  31626. */
  31627. getStencilOperationFail(): number;
  31628. /**
  31629. * Gets the current stencil operation when depth fails
  31630. * @returns a number defining stencil operation to use when depth fails
  31631. */
  31632. getStencilOperationDepthFail(): number;
  31633. /**
  31634. * Gets the current stencil operation when stencil passes
  31635. * @returns a number defining stencil operation to use when stencil passes
  31636. */
  31637. getStencilOperationPass(): number;
  31638. /**
  31639. * Sets the stencil operation to use when stencil fails
  31640. * @param operation defines the stencil operation to use when stencil fails
  31641. */
  31642. setStencilOperationFail(operation: number): void;
  31643. /**
  31644. * Sets the stencil operation to use when depth fails
  31645. * @param operation defines the stencil operation to use when depth fails
  31646. */
  31647. setStencilOperationDepthFail(operation: number): void;
  31648. /**
  31649. * Sets the stencil operation to use when stencil passes
  31650. * @param operation defines the stencil operation to use when stencil passes
  31651. */
  31652. setStencilOperationPass(operation: number): void;
  31653. /**
  31654. * Sets a boolean indicating if the dithering state is enabled or disabled
  31655. * @param value defines the dithering state
  31656. */
  31657. setDitheringState(value: boolean): void;
  31658. /**
  31659. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31660. * @param value defines the rasterizer state
  31661. */
  31662. setRasterizerState(value: boolean): void;
  31663. /**
  31664. * Gets the current depth function
  31665. * @returns a number defining the depth function
  31666. */
  31667. getDepthFunction(): Nullable<number>;
  31668. /**
  31669. * Sets the current depth function
  31670. * @param depthFunc defines the function to use
  31671. */
  31672. setDepthFunction(depthFunc: number): void;
  31673. /**
  31674. * Sets the current depth function to GREATER
  31675. */
  31676. setDepthFunctionToGreater(): void;
  31677. /**
  31678. * Sets the current depth function to GEQUAL
  31679. */
  31680. setDepthFunctionToGreaterOrEqual(): void;
  31681. /**
  31682. * Sets the current depth function to LESS
  31683. */
  31684. setDepthFunctionToLess(): void;
  31685. /**
  31686. * Sets the current depth function to LEQUAL
  31687. */
  31688. setDepthFunctionToLessOrEqual(): void;
  31689. private _cachedStencilBuffer;
  31690. private _cachedStencilFunction;
  31691. private _cachedStencilMask;
  31692. private _cachedStencilOperationPass;
  31693. private _cachedStencilOperationFail;
  31694. private _cachedStencilOperationDepthFail;
  31695. private _cachedStencilReference;
  31696. /**
  31697. * Caches the the state of the stencil buffer
  31698. */
  31699. cacheStencilState(): void;
  31700. /**
  31701. * Restores the state of the stencil buffer
  31702. */
  31703. restoreStencilState(): void;
  31704. /**
  31705. * Directly set the WebGL Viewport
  31706. * @param x defines the x coordinate of the viewport (in screen space)
  31707. * @param y defines the y coordinate of the viewport (in screen space)
  31708. * @param width defines the width of the viewport (in screen space)
  31709. * @param height defines the height of the viewport (in screen space)
  31710. * @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
  31711. */
  31712. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31713. /**
  31714. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31715. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31716. * @param y defines the y-coordinate of the corner of the clear rectangle
  31717. * @param width defines the width of the clear rectangle
  31718. * @param height defines the height of the clear rectangle
  31719. * @param clearColor defines the clear color
  31720. */
  31721. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31722. /**
  31723. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31724. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31725. * @param y defines the y-coordinate of the corner of the clear rectangle
  31726. * @param width defines the width of the clear rectangle
  31727. * @param height defines the height of the clear rectangle
  31728. */
  31729. enableScissor(x: number, y: number, width: number, height: number): void;
  31730. /**
  31731. * Disable previously set scissor test rectangle
  31732. */
  31733. disableScissor(): void;
  31734. protected _reportDrawCall(): void;
  31735. /**
  31736. * Initializes a webVR display and starts listening to display change events
  31737. * The onVRDisplayChangedObservable will be notified upon these changes
  31738. * @returns The onVRDisplayChangedObservable
  31739. */
  31740. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31741. /** @hidden */
  31742. _prepareVRComponent(): void;
  31743. /** @hidden */
  31744. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31745. /** @hidden */
  31746. _submitVRFrame(): void;
  31747. /**
  31748. * Call this function to leave webVR mode
  31749. * Will do nothing if webVR is not supported or if there is no webVR device
  31750. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31751. */
  31752. disableVR(): void;
  31753. /**
  31754. * Gets a boolean indicating that the system is in VR mode and is presenting
  31755. * @returns true if VR mode is engaged
  31756. */
  31757. isVRPresenting(): boolean;
  31758. /** @hidden */
  31759. _requestVRFrame(): void;
  31760. /** @hidden */
  31761. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31762. /**
  31763. * Gets the source code of the vertex shader associated with a specific webGL program
  31764. * @param program defines the program to use
  31765. * @returns a string containing the source code of the vertex shader associated with the program
  31766. */
  31767. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31768. /**
  31769. * Gets the source code of the fragment shader associated with a specific webGL program
  31770. * @param program defines the program to use
  31771. * @returns a string containing the source code of the fragment shader associated with the program
  31772. */
  31773. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31774. /**
  31775. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31776. * @param x defines the x coordinate of the rectangle where pixels must be read
  31777. * @param y defines the y coordinate of the rectangle where pixels must be read
  31778. * @param width defines the width of the rectangle where pixels must be read
  31779. * @param height defines the height of the rectangle where pixels must be read
  31780. * @returns a Uint8Array containing RGBA colors
  31781. */
  31782. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31783. /**
  31784. * Sets a depth stencil texture from a render target to the according uniform.
  31785. * @param channel The texture channel
  31786. * @param uniform The uniform to set
  31787. * @param texture The render target texture containing the depth stencil texture to apply
  31788. */
  31789. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31790. /**
  31791. * Sets a texture to the webGL context from a postprocess
  31792. * @param channel defines the channel to use
  31793. * @param postProcess defines the source postprocess
  31794. */
  31795. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31796. /**
  31797. * Binds the output of the passed in post process to the texture channel specified
  31798. * @param channel The channel the texture should be bound to
  31799. * @param postProcess The post process which's output should be bound
  31800. */
  31801. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31802. /** @hidden */
  31803. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31804. protected _rebuildBuffers(): void;
  31805. /** @hidden */
  31806. _renderFrame(): void;
  31807. _renderLoop(): void;
  31808. /** @hidden */
  31809. _renderViews(): boolean;
  31810. /**
  31811. * Toggle full screen mode
  31812. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31813. */
  31814. switchFullscreen(requestPointerLock: boolean): void;
  31815. /**
  31816. * Enters full screen mode
  31817. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31818. */
  31819. enterFullscreen(requestPointerLock: boolean): void;
  31820. /**
  31821. * Exits full screen mode
  31822. */
  31823. exitFullscreen(): void;
  31824. /**
  31825. * Enters Pointerlock mode
  31826. */
  31827. enterPointerlock(): void;
  31828. /**
  31829. * Exits Pointerlock mode
  31830. */
  31831. exitPointerlock(): void;
  31832. /**
  31833. * Begin a new frame
  31834. */
  31835. beginFrame(): void;
  31836. /**
  31837. * Enf the current frame
  31838. */
  31839. endFrame(): void;
  31840. resize(): void;
  31841. /**
  31842. * Set the compressed texture format to use, based on the formats you have, and the formats
  31843. * supported by the hardware / browser.
  31844. *
  31845. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31846. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31847. * to API arguments needed to compressed textures. This puts the burden on the container
  31848. * generator to house the arcane code for determining these for current & future formats.
  31849. *
  31850. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31851. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31852. *
  31853. * Note: The result of this call is not taken into account when a texture is base64.
  31854. *
  31855. * @param formatsAvailable defines the list of those format families you have created
  31856. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31857. *
  31858. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31859. * @returns The extension selected.
  31860. */
  31861. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31862. /**
  31863. * Force a specific size of the canvas
  31864. * @param width defines the new canvas' width
  31865. * @param height defines the new canvas' height
  31866. */
  31867. setSize(width: number, height: number): void;
  31868. /**
  31869. * Updates a dynamic vertex buffer.
  31870. * @param vertexBuffer the vertex buffer to update
  31871. * @param data the data used to update the vertex buffer
  31872. * @param byteOffset the byte offset of the data
  31873. * @param byteLength the byte length of the data
  31874. */
  31875. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31876. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31877. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31878. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31879. _releaseTexture(texture: InternalTexture): void;
  31880. /**
  31881. * @hidden
  31882. * Rescales a texture
  31883. * @param source input texutre
  31884. * @param destination destination texture
  31885. * @param scene scene to use to render the resize
  31886. * @param internalFormat format to use when resizing
  31887. * @param onComplete callback to be called when resize has completed
  31888. */
  31889. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31890. /**
  31891. * Gets the current framerate
  31892. * @returns a number representing the framerate
  31893. */
  31894. getFps(): number;
  31895. /**
  31896. * Gets the time spent between current and previous frame
  31897. * @returns a number representing the delta time in ms
  31898. */
  31899. getDeltaTime(): number;
  31900. private _measureFps;
  31901. /** @hidden */
  31902. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  31903. /**
  31904. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31905. * @param renderTarget The render target to set the frame buffer for
  31906. */
  31907. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31908. /**
  31909. * Update a dynamic index buffer
  31910. * @param indexBuffer defines the target index buffer
  31911. * @param indices defines the data to update
  31912. * @param offset defines the offset in the target index buffer where update should start
  31913. */
  31914. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31915. /**
  31916. * Updates the sample count of a render target texture
  31917. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31918. * @param texture defines the texture to update
  31919. * @param samples defines the sample count to set
  31920. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31921. */
  31922. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31923. /**
  31924. * Updates a depth texture Comparison Mode and Function.
  31925. * If the comparison Function is equal to 0, the mode will be set to none.
  31926. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31927. * @param texture The texture to set the comparison function for
  31928. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31929. */
  31930. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31931. /**
  31932. * Creates a webGL buffer to use with instanciation
  31933. * @param capacity defines the size of the buffer
  31934. * @returns the webGL buffer
  31935. */
  31936. createInstancesBuffer(capacity: number): DataBuffer;
  31937. /**
  31938. * Delete a webGL buffer used with instanciation
  31939. * @param buffer defines the webGL buffer to delete
  31940. */
  31941. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31942. /** @hidden */
  31943. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31944. dispose(): void;
  31945. private _disableTouchAction;
  31946. /**
  31947. * Display the loading screen
  31948. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31949. */
  31950. displayLoadingUI(): void;
  31951. /**
  31952. * Hide the loading screen
  31953. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31954. */
  31955. hideLoadingUI(): void;
  31956. /**
  31957. * Gets the current loading screen object
  31958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31959. */
  31960. /**
  31961. * Sets the current loading screen object
  31962. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31963. */
  31964. loadingScreen: ILoadingScreen;
  31965. /**
  31966. * Sets the current loading screen text
  31967. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31968. */
  31969. loadingUIText: string;
  31970. /**
  31971. * Sets the current loading screen background color
  31972. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31973. */
  31974. loadingUIBackgroundColor: string;
  31975. /** Pointerlock and fullscreen */
  31976. /**
  31977. * Ask the browser to promote the current element to pointerlock mode
  31978. * @param element defines the DOM element to promote
  31979. */
  31980. static _RequestPointerlock(element: HTMLElement): void;
  31981. /**
  31982. * Asks the browser to exit pointerlock mode
  31983. */
  31984. static _ExitPointerlock(): void;
  31985. /**
  31986. * Ask the browser to promote the current element to fullscreen rendering mode
  31987. * @param element defines the DOM element to promote
  31988. */
  31989. static _RequestFullscreen(element: HTMLElement): void;
  31990. /**
  31991. * Asks the browser to exit fullscreen mode
  31992. */
  31993. static _ExitFullscreen(): void;
  31994. }
  31995. }
  31996. declare module BABYLON {
  31997. /**
  31998. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31999. * during the life time of the application.
  32000. */
  32001. export class EngineStore {
  32002. /** Gets the list of created engines */
  32003. static Instances: Engine[];
  32004. /** @hidden */
  32005. static _LastCreatedScene: Nullable<Scene>;
  32006. /**
  32007. * Gets the latest created engine
  32008. */
  32009. static readonly LastCreatedEngine: Nullable<Engine>;
  32010. /**
  32011. * Gets the latest created scene
  32012. */
  32013. static readonly LastCreatedScene: Nullable<Scene>;
  32014. /**
  32015. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32016. * @ignorenaming
  32017. */
  32018. static UseFallbackTexture: boolean;
  32019. /**
  32020. * Texture content used if a texture cannot loaded
  32021. * @ignorenaming
  32022. */
  32023. static FallbackTexture: string;
  32024. }
  32025. }
  32026. declare module BABYLON {
  32027. /**
  32028. * Helper class that provides a small promise polyfill
  32029. */
  32030. export class PromisePolyfill {
  32031. /**
  32032. * Static function used to check if the polyfill is required
  32033. * If this is the case then the function will inject the polyfill to window.Promise
  32034. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32035. */
  32036. static Apply(force?: boolean): void;
  32037. }
  32038. }
  32039. declare module BABYLON {
  32040. /**
  32041. * Interface for screenshot methods with describe argument called `size` as object with options
  32042. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32043. */
  32044. export interface IScreenshotSize {
  32045. /**
  32046. * number in pixels for canvas height
  32047. */
  32048. height?: number;
  32049. /**
  32050. * multiplier allowing render at a higher or lower resolution
  32051. * If value is defined then height and width will be ignored and taken from camera
  32052. */
  32053. precision?: number;
  32054. /**
  32055. * number in pixels for canvas width
  32056. */
  32057. width?: number;
  32058. }
  32059. }
  32060. declare module BABYLON {
  32061. interface IColor4Like {
  32062. r: float;
  32063. g: float;
  32064. b: float;
  32065. a: float;
  32066. }
  32067. /**
  32068. * Class containing a set of static utilities functions
  32069. */
  32070. export class Tools {
  32071. /**
  32072. * Gets or sets the base URL to use to load assets
  32073. */
  32074. static BaseUrl: string;
  32075. /**
  32076. * Enable/Disable Custom HTTP Request Headers globally.
  32077. * default = false
  32078. * @see CustomRequestHeaders
  32079. */
  32080. static UseCustomRequestHeaders: boolean;
  32081. /**
  32082. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32083. * i.e. when loading files, where the server/service expects an Authorization header
  32084. */
  32085. static CustomRequestHeaders: {
  32086. [key: string]: string;
  32087. };
  32088. /**
  32089. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32090. */
  32091. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32092. /**
  32093. * Default behaviour for cors in the application.
  32094. * It can be a string if the expected behavior is identical in the entire app.
  32095. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32096. */
  32097. static CorsBehavior: string | ((url: string | string[]) => string);
  32098. /**
  32099. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32100. * @ignorenaming
  32101. */
  32102. static UseFallbackTexture: boolean;
  32103. /**
  32104. * Use this object to register external classes like custom textures or material
  32105. * to allow the laoders to instantiate them
  32106. */
  32107. static RegisteredExternalClasses: {
  32108. [key: string]: Object;
  32109. };
  32110. /**
  32111. * Texture content used if a texture cannot loaded
  32112. * @ignorenaming
  32113. */
  32114. static fallbackTexture: string;
  32115. /**
  32116. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32117. * @param u defines the coordinate on X axis
  32118. * @param v defines the coordinate on Y axis
  32119. * @param width defines the width of the source data
  32120. * @param height defines the height of the source data
  32121. * @param pixels defines the source byte array
  32122. * @param color defines the output color
  32123. */
  32124. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32125. /**
  32126. * Interpolates between a and b via alpha
  32127. * @param a The lower value (returned when alpha = 0)
  32128. * @param b The upper value (returned when alpha = 1)
  32129. * @param alpha The interpolation-factor
  32130. * @return The mixed value
  32131. */
  32132. static Mix(a: number, b: number, alpha: number): number;
  32133. /**
  32134. * Tries to instantiate a new object from a given class name
  32135. * @param className defines the class name to instantiate
  32136. * @returns the new object or null if the system was not able to do the instantiation
  32137. */
  32138. static Instantiate(className: string): any;
  32139. /**
  32140. * Provides a slice function that will work even on IE
  32141. * @param data defines the array to slice
  32142. * @param start defines the start of the data (optional)
  32143. * @param end defines the end of the data (optional)
  32144. * @returns the new sliced array
  32145. */
  32146. static Slice<T>(data: T, start?: number, end?: number): T;
  32147. /**
  32148. * Polyfill for setImmediate
  32149. * @param action defines the action to execute after the current execution block
  32150. */
  32151. static SetImmediate(action: () => void): void;
  32152. /**
  32153. * Function indicating if a number is an exponent of 2
  32154. * @param value defines the value to test
  32155. * @returns true if the value is an exponent of 2
  32156. */
  32157. static IsExponentOfTwo(value: number): boolean;
  32158. private static _tmpFloatArray;
  32159. /**
  32160. * Returns the nearest 32-bit single precision float representation of a Number
  32161. * @param value A Number. If the parameter is of a different type, it will get converted
  32162. * to a number or to NaN if it cannot be converted
  32163. * @returns number
  32164. */
  32165. static FloatRound(value: number): number;
  32166. /**
  32167. * Extracts the filename from a path
  32168. * @param path defines the path to use
  32169. * @returns the filename
  32170. */
  32171. static GetFilename(path: string): string;
  32172. /**
  32173. * Extracts the "folder" part of a path (everything before the filename).
  32174. * @param uri The URI to extract the info from
  32175. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32176. * @returns The "folder" part of the path
  32177. */
  32178. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32179. /**
  32180. * Extracts text content from a DOM element hierarchy
  32181. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32182. */
  32183. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32184. /**
  32185. * Convert an angle in radians to degrees
  32186. * @param angle defines the angle to convert
  32187. * @returns the angle in degrees
  32188. */
  32189. static ToDegrees(angle: number): number;
  32190. /**
  32191. * Convert an angle in degrees to radians
  32192. * @param angle defines the angle to convert
  32193. * @returns the angle in radians
  32194. */
  32195. static ToRadians(angle: number): number;
  32196. /**
  32197. * Returns an array if obj is not an array
  32198. * @param obj defines the object to evaluate as an array
  32199. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32200. * @returns either obj directly if obj is an array or a new array containing obj
  32201. */
  32202. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32203. /**
  32204. * Gets the pointer prefix to use
  32205. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32206. */
  32207. static GetPointerPrefix(): string;
  32208. /**
  32209. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32210. * @param url define the url we are trying
  32211. * @param element define the dom element where to configure the cors policy
  32212. */
  32213. static SetCorsBehavior(url: string | string[], element: {
  32214. crossOrigin: string | null;
  32215. }): void;
  32216. /**
  32217. * Removes unwanted characters from an url
  32218. * @param url defines the url to clean
  32219. * @returns the cleaned url
  32220. */
  32221. static CleanUrl(url: string): string;
  32222. /**
  32223. * Gets or sets a function used to pre-process url before using them to load assets
  32224. */
  32225. static PreprocessUrl: (url: string) => string;
  32226. /**
  32227. * Loads an image as an HTMLImageElement.
  32228. * @param input url string, ArrayBuffer, or Blob to load
  32229. * @param onLoad callback called when the image successfully loads
  32230. * @param onError callback called when the image fails to load
  32231. * @param offlineProvider offline provider for caching
  32232. * @param mimeType optional mime type
  32233. * @returns the HTMLImageElement of the loaded image
  32234. */
  32235. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32236. /**
  32237. * Loads a file from a url
  32238. * @param url url string, ArrayBuffer, or Blob to load
  32239. * @param onSuccess callback called when the file successfully loads
  32240. * @param onProgress callback called while file is loading (if the server supports this mode)
  32241. * @param offlineProvider defines the offline provider for caching
  32242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32243. * @param onError callback called when the file fails to load
  32244. * @returns a file request object
  32245. */
  32246. 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;
  32247. /**
  32248. * Loads a file from a url
  32249. * @param url the file url to load
  32250. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32251. */
  32252. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32253. /**
  32254. * Load a script (identified by an url). When the url returns, the
  32255. * content of this file is added into a new script element, attached to the DOM (body element)
  32256. * @param scriptUrl defines the url of the script to laod
  32257. * @param onSuccess defines the callback called when the script is loaded
  32258. * @param onError defines the callback to call if an error occurs
  32259. * @param scriptId defines the id of the script element
  32260. */
  32261. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32262. /**
  32263. * Load an asynchronous script (identified by an url). When the url returns, the
  32264. * content of this file is added into a new script element, attached to the DOM (body element)
  32265. * @param scriptUrl defines the url of the script to laod
  32266. * @param scriptId defines the id of the script element
  32267. * @returns a promise request object
  32268. */
  32269. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32270. /**
  32271. * Loads a file from a blob
  32272. * @param fileToLoad defines the blob to use
  32273. * @param callback defines the callback to call when data is loaded
  32274. * @param progressCallback defines the callback to call during loading process
  32275. * @returns a file request object
  32276. */
  32277. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32278. /**
  32279. * Reads a file from a File object
  32280. * @param file defines the file to load
  32281. * @param onSuccess defines the callback to call when data is loaded
  32282. * @param onProgress defines the callback to call during loading process
  32283. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32284. * @param onError defines the callback to call when an error occurs
  32285. * @returns a file request object
  32286. */
  32287. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32288. /**
  32289. * Creates a data url from a given string content
  32290. * @param content defines the content to convert
  32291. * @returns the new data url link
  32292. */
  32293. static FileAsURL(content: string): string;
  32294. /**
  32295. * Format the given number to a specific decimal format
  32296. * @param value defines the number to format
  32297. * @param decimals defines the number of decimals to use
  32298. * @returns the formatted string
  32299. */
  32300. static Format(value: number, decimals?: number): string;
  32301. /**
  32302. * Tries to copy an object by duplicating every property
  32303. * @param source defines the source object
  32304. * @param destination defines the target object
  32305. * @param doNotCopyList defines a list of properties to avoid
  32306. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32307. */
  32308. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32309. /**
  32310. * Gets a boolean indicating if the given object has no own property
  32311. * @param obj defines the object to test
  32312. * @returns true if object has no own property
  32313. */
  32314. static IsEmpty(obj: any): boolean;
  32315. /**
  32316. * Function used to register events at window level
  32317. * @param windowElement defines the Window object to use
  32318. * @param events defines the events to register
  32319. */
  32320. static RegisterTopRootEvents(windowElement: Window, events: {
  32321. name: string;
  32322. handler: Nullable<(e: FocusEvent) => any>;
  32323. }[]): void;
  32324. /**
  32325. * Function used to unregister events from window level
  32326. * @param windowElement defines the Window object to use
  32327. * @param events defines the events to unregister
  32328. */
  32329. static UnregisterTopRootEvents(windowElement: Window, events: {
  32330. name: string;
  32331. handler: Nullable<(e: FocusEvent) => any>;
  32332. }[]): void;
  32333. /**
  32334. * @ignore
  32335. */
  32336. static _ScreenshotCanvas: HTMLCanvasElement;
  32337. /**
  32338. * Dumps the current bound framebuffer
  32339. * @param width defines the rendering width
  32340. * @param height defines the rendering height
  32341. * @param engine defines the hosting engine
  32342. * @param successCallback defines the callback triggered once the data are available
  32343. * @param mimeType defines the mime type of the result
  32344. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32345. */
  32346. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32347. /**
  32348. * Converts the canvas data to blob.
  32349. * This acts as a polyfill for browsers not supporting the to blob function.
  32350. * @param canvas Defines the canvas to extract the data from
  32351. * @param successCallback Defines the callback triggered once the data are available
  32352. * @param mimeType Defines the mime type of the result
  32353. */
  32354. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32355. /**
  32356. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32357. * @param successCallback defines the callback triggered once the data are available
  32358. * @param mimeType defines the mime type of the result
  32359. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32360. */
  32361. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32362. /**
  32363. * Downloads a blob in the browser
  32364. * @param blob defines the blob to download
  32365. * @param fileName defines the name of the downloaded file
  32366. */
  32367. static Download(blob: Blob, fileName: string): void;
  32368. /**
  32369. * Captures a screenshot of the current rendering
  32370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32371. * @param engine defines the rendering engine
  32372. * @param camera defines the source camera
  32373. * @param size This parameter can be set to a single number or to an object with the
  32374. * following (optional) properties: precision, width, height. If a single number is passed,
  32375. * it will be used for both width and height. If an object is passed, the screenshot size
  32376. * will be derived from the parameters. The precision property is a multiplier allowing
  32377. * rendering at a higher or lower resolution
  32378. * @param successCallback defines the callback receives a single parameter which contains the
  32379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32380. * src parameter of an <img> to display it
  32381. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32382. * Check your browser for supported MIME types
  32383. */
  32384. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32385. /**
  32386. * Captures a screenshot of the current rendering
  32387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32388. * @param engine defines the rendering engine
  32389. * @param camera defines the source camera
  32390. * @param size This parameter can be set to a single number or to an object with the
  32391. * following (optional) properties: precision, width, height. If a single number is passed,
  32392. * it will be used for both width and height. If an object is passed, the screenshot size
  32393. * will be derived from the parameters. The precision property is a multiplier allowing
  32394. * rendering at a higher or lower resolution
  32395. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32396. * Check your browser for supported MIME types
  32397. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32398. * to the src parameter of an <img> to display it
  32399. */
  32400. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32401. /**
  32402. * Generates an image screenshot from the specified camera.
  32403. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32404. * @param engine The engine to use for rendering
  32405. * @param camera The camera to use for rendering
  32406. * @param size This parameter can be set to a single number or to an object with the
  32407. * following (optional) properties: precision, width, height. If a single number is passed,
  32408. * it will be used for both width and height. If an object is passed, the screenshot size
  32409. * will be derived from the parameters. The precision property is a multiplier allowing
  32410. * rendering at a higher or lower resolution
  32411. * @param successCallback The callback receives a single parameter which contains the
  32412. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32413. * src parameter of an <img> to display it
  32414. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32415. * Check your browser for supported MIME types
  32416. * @param samples Texture samples (default: 1)
  32417. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32418. * @param fileName A name for for the downloaded file.
  32419. */
  32420. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32421. /**
  32422. * Generates an image screenshot from the specified camera.
  32423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32424. * @param engine The engine to use for rendering
  32425. * @param camera The camera to use for rendering
  32426. * @param size This parameter can be set to a single number or to an object with the
  32427. * following (optional) properties: precision, width, height. If a single number is passed,
  32428. * it will be used for both width and height. If an object is passed, the screenshot size
  32429. * will be derived from the parameters. The precision property is a multiplier allowing
  32430. * rendering at a higher or lower resolution
  32431. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32432. * Check your browser for supported MIME types
  32433. * @param samples Texture samples (default: 1)
  32434. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32435. * @param fileName A name for for the downloaded file.
  32436. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32437. * to the src parameter of an <img> to display it
  32438. */
  32439. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32440. /**
  32441. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32442. * Be aware Math.random() could cause collisions, but:
  32443. * "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"
  32444. * @returns a pseudo random id
  32445. */
  32446. static RandomId(): string;
  32447. /**
  32448. * Test if the given uri is a base64 string
  32449. * @param uri The uri to test
  32450. * @return True if the uri is a base64 string or false otherwise
  32451. */
  32452. static IsBase64(uri: string): boolean;
  32453. /**
  32454. * Decode the given base64 uri.
  32455. * @param uri The uri to decode
  32456. * @return The decoded base64 data.
  32457. */
  32458. static DecodeBase64(uri: string): ArrayBuffer;
  32459. /**
  32460. * Gets the absolute url.
  32461. * @param url the input url
  32462. * @return the absolute url
  32463. */
  32464. static GetAbsoluteUrl(url: string): string;
  32465. /**
  32466. * No log
  32467. */
  32468. static readonly NoneLogLevel: number;
  32469. /**
  32470. * Only message logs
  32471. */
  32472. static readonly MessageLogLevel: number;
  32473. /**
  32474. * Only warning logs
  32475. */
  32476. static readonly WarningLogLevel: number;
  32477. /**
  32478. * Only error logs
  32479. */
  32480. static readonly ErrorLogLevel: number;
  32481. /**
  32482. * All logs
  32483. */
  32484. static readonly AllLogLevel: number;
  32485. /**
  32486. * Gets a value indicating the number of loading errors
  32487. * @ignorenaming
  32488. */
  32489. static readonly errorsCount: number;
  32490. /**
  32491. * Callback called when a new log is added
  32492. */
  32493. static OnNewCacheEntry: (entry: string) => void;
  32494. /**
  32495. * Log a message to the console
  32496. * @param message defines the message to log
  32497. */
  32498. static Log(message: string): void;
  32499. /**
  32500. * Write a warning message to the console
  32501. * @param message defines the message to log
  32502. */
  32503. static Warn(message: string): void;
  32504. /**
  32505. * Write an error message to the console
  32506. * @param message defines the message to log
  32507. */
  32508. static Error(message: string): void;
  32509. /**
  32510. * Gets current log cache (list of logs)
  32511. */
  32512. static readonly LogCache: string;
  32513. /**
  32514. * Clears the log cache
  32515. */
  32516. static ClearLogCache(): void;
  32517. /**
  32518. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32519. */
  32520. static LogLevels: number;
  32521. /**
  32522. * Checks if the window object exists
  32523. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32524. */
  32525. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32526. /**
  32527. * No performance log
  32528. */
  32529. static readonly PerformanceNoneLogLevel: number;
  32530. /**
  32531. * Use user marks to log performance
  32532. */
  32533. static readonly PerformanceUserMarkLogLevel: number;
  32534. /**
  32535. * Log performance to the console
  32536. */
  32537. static readonly PerformanceConsoleLogLevel: number;
  32538. private static _performance;
  32539. /**
  32540. * Sets the current performance log level
  32541. */
  32542. static PerformanceLogLevel: number;
  32543. private static _StartPerformanceCounterDisabled;
  32544. private static _EndPerformanceCounterDisabled;
  32545. private static _StartUserMark;
  32546. private static _EndUserMark;
  32547. private static _StartPerformanceConsole;
  32548. private static _EndPerformanceConsole;
  32549. /**
  32550. * Starts a performance counter
  32551. */
  32552. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32553. /**
  32554. * Ends a specific performance coutner
  32555. */
  32556. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32557. /**
  32558. * Gets either window.performance.now() if supported or Date.now() else
  32559. */
  32560. static readonly Now: number;
  32561. /**
  32562. * This method will return the name of the class used to create the instance of the given object.
  32563. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32564. * @param object the object to get the class name from
  32565. * @param isType defines if the object is actually a type
  32566. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32567. */
  32568. static GetClassName(object: any, isType?: boolean): string;
  32569. /**
  32570. * Gets the first element of an array satisfying a given predicate
  32571. * @param array defines the array to browse
  32572. * @param predicate defines the predicate to use
  32573. * @returns null if not found or the element
  32574. */
  32575. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32576. /**
  32577. * This method will return the name of the full name of the class, including its owning module (if any).
  32578. * 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).
  32579. * @param object the object to get the class name from
  32580. * @param isType defines if the object is actually a type
  32581. * @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.
  32582. * @ignorenaming
  32583. */
  32584. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32585. /**
  32586. * Returns a promise that resolves after the given amount of time.
  32587. * @param delay Number of milliseconds to delay
  32588. * @returns Promise that resolves after the given amount of time
  32589. */
  32590. static DelayAsync(delay: number): Promise<void>;
  32591. }
  32592. /**
  32593. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32594. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32595. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32596. * @param name The name of the class, case should be preserved
  32597. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32598. */
  32599. export function className(name: string, module?: string): (target: Object) => void;
  32600. /**
  32601. * An implementation of a loop for asynchronous functions.
  32602. */
  32603. export class AsyncLoop {
  32604. /**
  32605. * Defines the number of iterations for the loop
  32606. */
  32607. iterations: number;
  32608. /**
  32609. * Defines the current index of the loop.
  32610. */
  32611. index: number;
  32612. private _done;
  32613. private _fn;
  32614. private _successCallback;
  32615. /**
  32616. * Constructor.
  32617. * @param iterations the number of iterations.
  32618. * @param func the function to run each iteration
  32619. * @param successCallback the callback that will be called upon succesful execution
  32620. * @param offset starting offset.
  32621. */
  32622. constructor(
  32623. /**
  32624. * Defines the number of iterations for the loop
  32625. */
  32626. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32627. /**
  32628. * Execute the next iteration. Must be called after the last iteration was finished.
  32629. */
  32630. executeNext(): void;
  32631. /**
  32632. * Break the loop and run the success callback.
  32633. */
  32634. breakLoop(): void;
  32635. /**
  32636. * Create and run an async loop.
  32637. * @param iterations the number of iterations.
  32638. * @param fn the function to run each iteration
  32639. * @param successCallback the callback that will be called upon succesful execution
  32640. * @param offset starting offset.
  32641. * @returns the created async loop object
  32642. */
  32643. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32644. /**
  32645. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32646. * @param iterations total number of iterations
  32647. * @param syncedIterations number of synchronous iterations in each async iteration.
  32648. * @param fn the function to call each iteration.
  32649. * @param callback a success call back that will be called when iterating stops.
  32650. * @param breakFunction a break condition (optional)
  32651. * @param timeout timeout settings for the setTimeout function. default - 0.
  32652. * @returns the created async loop object
  32653. */
  32654. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32655. }
  32656. }
  32657. declare module BABYLON {
  32658. /**
  32659. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32660. * The underlying implementation relies on an associative array to ensure the best performances.
  32661. * The value can be anything including 'null' but except 'undefined'
  32662. */
  32663. export class StringDictionary<T> {
  32664. /**
  32665. * This will clear this dictionary and copy the content from the 'source' one.
  32666. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32667. * @param source the dictionary to take the content from and copy to this dictionary
  32668. */
  32669. copyFrom(source: StringDictionary<T>): void;
  32670. /**
  32671. * Get a value based from its key
  32672. * @param key the given key to get the matching value from
  32673. * @return the value if found, otherwise undefined is returned
  32674. */
  32675. get(key: string): T | undefined;
  32676. /**
  32677. * Get a value from its key or add it if it doesn't exist.
  32678. * This method will ensure you that a given key/data will be present in the dictionary.
  32679. * @param key the given key to get the matching value from
  32680. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32681. * The factory will only be invoked if there's no data for the given key.
  32682. * @return the value corresponding to the key.
  32683. */
  32684. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32685. /**
  32686. * Get a value from its key if present in the dictionary otherwise add it
  32687. * @param key the key to get the value from
  32688. * @param val if there's no such key/value pair in the dictionary add it with this value
  32689. * @return the value corresponding to the key
  32690. */
  32691. getOrAdd(key: string, val: T): T;
  32692. /**
  32693. * Check if there's a given key in the dictionary
  32694. * @param key the key to check for
  32695. * @return true if the key is present, false otherwise
  32696. */
  32697. contains(key: string): boolean;
  32698. /**
  32699. * Add a new key and its corresponding value
  32700. * @param key the key to add
  32701. * @param value the value corresponding to the key
  32702. * @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
  32703. */
  32704. add(key: string, value: T): boolean;
  32705. /**
  32706. * Update a specific value associated to a key
  32707. * @param key defines the key to use
  32708. * @param value defines the value to store
  32709. * @returns true if the value was updated (or false if the key was not found)
  32710. */
  32711. set(key: string, value: T): boolean;
  32712. /**
  32713. * Get the element of the given key and remove it from the dictionary
  32714. * @param key defines the key to search
  32715. * @returns the value associated with the key or null if not found
  32716. */
  32717. getAndRemove(key: string): Nullable<T>;
  32718. /**
  32719. * Remove a key/value from the dictionary.
  32720. * @param key the key to remove
  32721. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32722. */
  32723. remove(key: string): boolean;
  32724. /**
  32725. * Clear the whole content of the dictionary
  32726. */
  32727. clear(): void;
  32728. /**
  32729. * Gets the current count
  32730. */
  32731. readonly count: number;
  32732. /**
  32733. * Execute a callback on each key/val of the dictionary.
  32734. * Note that you can remove any element in this dictionary in the callback implementation
  32735. * @param callback the callback to execute on a given key/value pair
  32736. */
  32737. forEach(callback: (key: string, val: T) => void): void;
  32738. /**
  32739. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32740. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32741. * Note that you can remove any element in this dictionary in the callback implementation
  32742. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32743. * @returns the first item
  32744. */
  32745. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32746. private _count;
  32747. private _data;
  32748. }
  32749. }
  32750. declare module BABYLON {
  32751. /** @hidden */
  32752. export interface ICollisionCoordinator {
  32753. createCollider(): Collider;
  32754. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32755. init(scene: Scene): void;
  32756. }
  32757. /** @hidden */
  32758. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32759. private _scene;
  32760. private _scaledPosition;
  32761. private _scaledVelocity;
  32762. private _finalPosition;
  32763. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32764. createCollider(): Collider;
  32765. init(scene: Scene): void;
  32766. private _collideWithWorld;
  32767. }
  32768. }
  32769. declare module BABYLON {
  32770. /**
  32771. * Class used to manage all inputs for the scene.
  32772. */
  32773. export class InputManager {
  32774. /** The distance in pixel that you have to move to prevent some events */
  32775. static DragMovementThreshold: number;
  32776. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32777. static LongPressDelay: number;
  32778. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32779. static DoubleClickDelay: number;
  32780. /** If you need to check double click without raising a single click at first click, enable this flag */
  32781. static ExclusiveDoubleClickMode: boolean;
  32782. private _wheelEventName;
  32783. private _onPointerMove;
  32784. private _onPointerDown;
  32785. private _onPointerUp;
  32786. private _initClickEvent;
  32787. private _initActionManager;
  32788. private _delayedSimpleClick;
  32789. private _delayedSimpleClickTimeout;
  32790. private _previousDelayedSimpleClickTimeout;
  32791. private _meshPickProceed;
  32792. private _previousButtonPressed;
  32793. private _currentPickResult;
  32794. private _previousPickResult;
  32795. private _totalPointersPressed;
  32796. private _doubleClickOccured;
  32797. private _pointerOverMesh;
  32798. private _pickedDownMesh;
  32799. private _pickedUpMesh;
  32800. private _pointerX;
  32801. private _pointerY;
  32802. private _unTranslatedPointerX;
  32803. private _unTranslatedPointerY;
  32804. private _startingPointerPosition;
  32805. private _previousStartingPointerPosition;
  32806. private _startingPointerTime;
  32807. private _previousStartingPointerTime;
  32808. private _pointerCaptures;
  32809. private _onKeyDown;
  32810. private _onKeyUp;
  32811. private _onCanvasFocusObserver;
  32812. private _onCanvasBlurObserver;
  32813. private _scene;
  32814. /**
  32815. * Creates a new InputManager
  32816. * @param scene defines the hosting scene
  32817. */
  32818. constructor(scene: Scene);
  32819. /**
  32820. * Gets the mesh that is currently under the pointer
  32821. */
  32822. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32823. /**
  32824. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32825. */
  32826. readonly unTranslatedPointer: Vector2;
  32827. /**
  32828. * Gets or sets the current on-screen X position of the pointer
  32829. */
  32830. pointerX: number;
  32831. /**
  32832. * Gets or sets the current on-screen Y position of the pointer
  32833. */
  32834. pointerY: number;
  32835. private _updatePointerPosition;
  32836. private _processPointerMove;
  32837. private _setRayOnPointerInfo;
  32838. private _checkPrePointerObservable;
  32839. /**
  32840. * Use this method to simulate a pointer move on a mesh
  32841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32844. */
  32845. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32846. /**
  32847. * Use this method to simulate a pointer down on a mesh
  32848. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32849. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32850. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32851. */
  32852. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32853. private _processPointerDown;
  32854. /** @hidden */
  32855. _isPointerSwiping(): boolean;
  32856. /**
  32857. * Use this method to simulate a pointer up on a mesh
  32858. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32859. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32860. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32861. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32862. */
  32863. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32864. private _processPointerUp;
  32865. /**
  32866. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32867. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32868. * @returns true if the pointer was captured
  32869. */
  32870. isPointerCaptured(pointerId?: number): boolean;
  32871. /**
  32872. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32873. * @param attachUp defines if you want to attach events to pointerup
  32874. * @param attachDown defines if you want to attach events to pointerdown
  32875. * @param attachMove defines if you want to attach events to pointermove
  32876. */
  32877. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32878. /**
  32879. * Detaches all event handlers
  32880. */
  32881. detachControl(): void;
  32882. /**
  32883. * Force the value of meshUnderPointer
  32884. * @param mesh defines the mesh to use
  32885. */
  32886. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32887. /**
  32888. * Gets the mesh under the pointer
  32889. * @returns a Mesh or null if no mesh is under the pointer
  32890. */
  32891. getPointerOverMesh(): Nullable<AbstractMesh>;
  32892. }
  32893. }
  32894. declare module BABYLON {
  32895. /**
  32896. * Helper class used to generate session unique ID
  32897. */
  32898. export class UniqueIdGenerator {
  32899. private static _UniqueIdCounter;
  32900. /**
  32901. * Gets an unique (relatively to the current scene) Id
  32902. */
  32903. static readonly UniqueId: number;
  32904. }
  32905. }
  32906. declare module BABYLON {
  32907. /**
  32908. * This class defines the direct association between an animation and a target
  32909. */
  32910. export class TargetedAnimation {
  32911. /**
  32912. * Animation to perform
  32913. */
  32914. animation: Animation;
  32915. /**
  32916. * Target to animate
  32917. */
  32918. target: any;
  32919. /**
  32920. * Serialize the object
  32921. * @returns the JSON object representing the current entity
  32922. */
  32923. serialize(): any;
  32924. }
  32925. /**
  32926. * Use this class to create coordinated animations on multiple targets
  32927. */
  32928. export class AnimationGroup implements IDisposable {
  32929. /** The name of the animation group */
  32930. name: string;
  32931. private _scene;
  32932. private _targetedAnimations;
  32933. private _animatables;
  32934. private _from;
  32935. private _to;
  32936. private _isStarted;
  32937. private _isPaused;
  32938. private _speedRatio;
  32939. private _loopAnimation;
  32940. /**
  32941. * Gets or sets the unique id of the node
  32942. */
  32943. uniqueId: number;
  32944. /**
  32945. * This observable will notify when one animation have ended
  32946. */
  32947. onAnimationEndObservable: Observable<TargetedAnimation>;
  32948. /**
  32949. * Observer raised when one animation loops
  32950. */
  32951. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32952. /**
  32953. * Observer raised when all animations have looped
  32954. */
  32955. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  32956. /**
  32957. * This observable will notify when all animations have ended.
  32958. */
  32959. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32960. /**
  32961. * This observable will notify when all animations have paused.
  32962. */
  32963. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32964. /**
  32965. * This observable will notify when all animations are playing.
  32966. */
  32967. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32968. /**
  32969. * Gets the first frame
  32970. */
  32971. readonly from: number;
  32972. /**
  32973. * Gets the last frame
  32974. */
  32975. readonly to: number;
  32976. /**
  32977. * Define if the animations are started
  32978. */
  32979. readonly isStarted: boolean;
  32980. /**
  32981. * Gets a value indicating that the current group is playing
  32982. */
  32983. readonly isPlaying: boolean;
  32984. /**
  32985. * Gets or sets the speed ratio to use for all animations
  32986. */
  32987. /**
  32988. * Gets or sets the speed ratio to use for all animations
  32989. */
  32990. speedRatio: number;
  32991. /**
  32992. * Gets or sets if all animations should loop or not
  32993. */
  32994. loopAnimation: boolean;
  32995. /**
  32996. * Gets the targeted animations for this animation group
  32997. */
  32998. readonly targetedAnimations: Array<TargetedAnimation>;
  32999. /**
  33000. * returning the list of animatables controlled by this animation group.
  33001. */
  33002. readonly animatables: Array<Animatable>;
  33003. /**
  33004. * Instantiates a new Animation Group.
  33005. * This helps managing several animations at once.
  33006. * @see http://doc.babylonjs.com/how_to/group
  33007. * @param name Defines the name of the group
  33008. * @param scene Defines the scene the group belongs to
  33009. */
  33010. constructor(
  33011. /** The name of the animation group */
  33012. name: string, scene?: Nullable<Scene>);
  33013. /**
  33014. * Add an animation (with its target) in the group
  33015. * @param animation defines the animation we want to add
  33016. * @param target defines the target of the animation
  33017. * @returns the TargetedAnimation object
  33018. */
  33019. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33020. /**
  33021. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33022. * It can add constant keys at begin or end
  33023. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33024. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33025. * @returns the animation group
  33026. */
  33027. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33028. private _animationLoopCount;
  33029. private _animationLoopFlags;
  33030. private _processLoop;
  33031. /**
  33032. * Start all animations on given targets
  33033. * @param loop defines if animations must loop
  33034. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33035. * @param from defines the from key (optional)
  33036. * @param to defines the to key (optional)
  33037. * @returns the current animation group
  33038. */
  33039. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33040. /**
  33041. * Pause all animations
  33042. * @returns the animation group
  33043. */
  33044. pause(): AnimationGroup;
  33045. /**
  33046. * Play all animations to initial state
  33047. * This function will start() the animations if they were not started or will restart() them if they were paused
  33048. * @param loop defines if animations must loop
  33049. * @returns the animation group
  33050. */
  33051. play(loop?: boolean): AnimationGroup;
  33052. /**
  33053. * Reset all animations to initial state
  33054. * @returns the animation group
  33055. */
  33056. reset(): AnimationGroup;
  33057. /**
  33058. * Restart animations from key 0
  33059. * @returns the animation group
  33060. */
  33061. restart(): AnimationGroup;
  33062. /**
  33063. * Stop all animations
  33064. * @returns the animation group
  33065. */
  33066. stop(): AnimationGroup;
  33067. /**
  33068. * Set animation weight for all animatables
  33069. * @param weight defines the weight to use
  33070. * @return the animationGroup
  33071. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33072. */
  33073. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33074. /**
  33075. * Synchronize and normalize all animatables with a source animatable
  33076. * @param root defines the root animatable to synchronize with
  33077. * @return the animationGroup
  33078. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33079. */
  33080. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33081. /**
  33082. * Goes to a specific frame in this animation group
  33083. * @param frame the frame number to go to
  33084. * @return the animationGroup
  33085. */
  33086. goToFrame(frame: number): AnimationGroup;
  33087. /**
  33088. * Dispose all associated resources
  33089. */
  33090. dispose(): void;
  33091. private _checkAnimationGroupEnded;
  33092. /**
  33093. * Clone the current animation group and returns a copy
  33094. * @param newName defines the name of the new group
  33095. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33096. * @returns the new aniamtion group
  33097. */
  33098. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33099. /**
  33100. * Serializes the animationGroup to an object
  33101. * @returns Serialized object
  33102. */
  33103. serialize(): any;
  33104. /**
  33105. * Returns a new AnimationGroup object parsed from the source provided.
  33106. * @param parsedAnimationGroup defines the source
  33107. * @param scene defines the scene that will receive the animationGroup
  33108. * @returns a new AnimationGroup
  33109. */
  33110. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33111. /**
  33112. * Returns the string "AnimationGroup"
  33113. * @returns "AnimationGroup"
  33114. */
  33115. getClassName(): string;
  33116. /**
  33117. * Creates a detailled string about the object
  33118. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33119. * @returns a string representing the object
  33120. */
  33121. toString(fullDetails?: boolean): string;
  33122. }
  33123. }
  33124. declare module BABYLON {
  33125. /**
  33126. * Define an interface for all classes that will hold resources
  33127. */
  33128. export interface IDisposable {
  33129. /**
  33130. * Releases all held resources
  33131. */
  33132. dispose(): void;
  33133. }
  33134. /** Interface defining initialization parameters for Scene class */
  33135. export interface SceneOptions {
  33136. /**
  33137. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33138. * It will improve performance when the number of geometries becomes important.
  33139. */
  33140. useGeometryUniqueIdsMap?: boolean;
  33141. /**
  33142. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33143. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33144. */
  33145. useMaterialMeshMap?: boolean;
  33146. /**
  33147. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33148. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33149. */
  33150. useClonedMeshhMap?: boolean;
  33151. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33152. virtual?: boolean;
  33153. }
  33154. /**
  33155. * Represents a scene to be rendered by the engine.
  33156. * @see http://doc.babylonjs.com/features/scene
  33157. */
  33158. export class Scene extends AbstractScene implements IAnimatable {
  33159. /** The fog is deactivated */
  33160. static readonly FOGMODE_NONE: number;
  33161. /** The fog density is following an exponential function */
  33162. static readonly FOGMODE_EXP: number;
  33163. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33164. static readonly FOGMODE_EXP2: number;
  33165. /** The fog density is following a linear function. */
  33166. static readonly FOGMODE_LINEAR: number;
  33167. /**
  33168. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33170. */
  33171. static MinDeltaTime: number;
  33172. /**
  33173. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33175. */
  33176. static MaxDeltaTime: number;
  33177. /**
  33178. * Factory used to create the default material.
  33179. * @param name The name of the material to create
  33180. * @param scene The scene to create the material for
  33181. * @returns The default material
  33182. */
  33183. static DefaultMaterialFactory(scene: Scene): Material;
  33184. /**
  33185. * Factory used to create the a collision coordinator.
  33186. * @returns The collision coordinator
  33187. */
  33188. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33189. /** @hidden */
  33190. _inputManager: InputManager;
  33191. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33192. cameraToUseForPointers: Nullable<Camera>;
  33193. /** @hidden */
  33194. readonly _isScene: boolean;
  33195. /**
  33196. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33197. */
  33198. autoClear: boolean;
  33199. /**
  33200. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33201. */
  33202. autoClearDepthAndStencil: boolean;
  33203. /**
  33204. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33205. */
  33206. clearColor: Color4;
  33207. /**
  33208. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33209. */
  33210. ambientColor: Color3;
  33211. /**
  33212. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33213. * It should only be one of the following (if not the default embedded one):
  33214. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33215. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33216. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33217. * The material properties need to be setup according to the type of texture in use.
  33218. */
  33219. environmentBRDFTexture: BaseTexture;
  33220. /** @hidden */
  33221. protected _environmentTexture: Nullable<BaseTexture>;
  33222. /**
  33223. * Texture used in all pbr material as the reflection texture.
  33224. * As in the majority of the scene they are the same (exception for multi room and so on),
  33225. * this is easier to reference from here than from all the materials.
  33226. */
  33227. /**
  33228. * Texture used in all pbr material as the reflection texture.
  33229. * As in the majority of the scene they are the same (exception for multi room and so on),
  33230. * this is easier to set here than in all the materials.
  33231. */
  33232. environmentTexture: Nullable<BaseTexture>;
  33233. /** @hidden */
  33234. protected _environmentIntensity: number;
  33235. /**
  33236. * Intensity of the environment in all pbr material.
  33237. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33238. * As in the majority of the scene they are the same (exception for multi room and so on),
  33239. * this is easier to reference from here than from all the materials.
  33240. */
  33241. /**
  33242. * Intensity of the environment in all pbr material.
  33243. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33244. * As in the majority of the scene they are the same (exception for multi room and so on),
  33245. * this is easier to set here than in all the materials.
  33246. */
  33247. environmentIntensity: number;
  33248. /** @hidden */
  33249. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33250. /**
  33251. * Default image processing configuration used either in the rendering
  33252. * Forward main pass or through the imageProcessingPostProcess if present.
  33253. * As in the majority of the scene they are the same (exception for multi camera),
  33254. * this is easier to reference from here than from all the materials and post process.
  33255. *
  33256. * No setter as we it is a shared configuration, you can set the values instead.
  33257. */
  33258. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33259. private _forceWireframe;
  33260. /**
  33261. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33262. */
  33263. forceWireframe: boolean;
  33264. private _forcePointsCloud;
  33265. /**
  33266. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33267. */
  33268. forcePointsCloud: boolean;
  33269. /**
  33270. * Gets or sets the active clipplane 1
  33271. */
  33272. clipPlane: Nullable<Plane>;
  33273. /**
  33274. * Gets or sets the active clipplane 2
  33275. */
  33276. clipPlane2: Nullable<Plane>;
  33277. /**
  33278. * Gets or sets the active clipplane 3
  33279. */
  33280. clipPlane3: Nullable<Plane>;
  33281. /**
  33282. * Gets or sets the active clipplane 4
  33283. */
  33284. clipPlane4: Nullable<Plane>;
  33285. /**
  33286. * Gets or sets a boolean indicating if animations are enabled
  33287. */
  33288. animationsEnabled: boolean;
  33289. private _animationPropertiesOverride;
  33290. /**
  33291. * Gets or sets the animation properties override
  33292. */
  33293. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33294. /**
  33295. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33296. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33297. */
  33298. useConstantAnimationDeltaTime: boolean;
  33299. /**
  33300. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33301. * Please note that it requires to run a ray cast through the scene on every frame
  33302. */
  33303. constantlyUpdateMeshUnderPointer: boolean;
  33304. /**
  33305. * Defines the HTML cursor to use when hovering over interactive elements
  33306. */
  33307. hoverCursor: string;
  33308. /**
  33309. * Defines the HTML default cursor to use (empty by default)
  33310. */
  33311. defaultCursor: string;
  33312. /**
  33313. * Defines wether cursors are handled by the scene.
  33314. */
  33315. doNotHandleCursors: boolean;
  33316. /**
  33317. * This is used to call preventDefault() on pointer down
  33318. * in order to block unwanted artifacts like system double clicks
  33319. */
  33320. preventDefaultOnPointerDown: boolean;
  33321. /**
  33322. * This is used to call preventDefault() on pointer up
  33323. * in order to block unwanted artifacts like system double clicks
  33324. */
  33325. preventDefaultOnPointerUp: boolean;
  33326. /**
  33327. * Gets or sets user defined metadata
  33328. */
  33329. metadata: any;
  33330. /**
  33331. * For internal use only. Please do not use.
  33332. */
  33333. reservedDataStore: any;
  33334. /**
  33335. * Gets the name of the plugin used to load this scene (null by default)
  33336. */
  33337. loadingPluginName: string;
  33338. /**
  33339. * Use this array to add regular expressions used to disable offline support for specific urls
  33340. */
  33341. disableOfflineSupportExceptionRules: RegExp[];
  33342. /**
  33343. * An event triggered when the scene is disposed.
  33344. */
  33345. onDisposeObservable: Observable<Scene>;
  33346. private _onDisposeObserver;
  33347. /** Sets a function to be executed when this scene is disposed. */
  33348. onDispose: () => void;
  33349. /**
  33350. * An event triggered before rendering the scene (right after animations and physics)
  33351. */
  33352. onBeforeRenderObservable: Observable<Scene>;
  33353. private _onBeforeRenderObserver;
  33354. /** Sets a function to be executed before rendering this scene */
  33355. beforeRender: Nullable<() => void>;
  33356. /**
  33357. * An event triggered after rendering the scene
  33358. */
  33359. onAfterRenderObservable: Observable<Scene>;
  33360. /**
  33361. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33362. */
  33363. onAfterRenderCameraObservable: Observable<Camera>;
  33364. private _onAfterRenderObserver;
  33365. /** Sets a function to be executed after rendering this scene */
  33366. afterRender: Nullable<() => void>;
  33367. /**
  33368. * An event triggered before animating the scene
  33369. */
  33370. onBeforeAnimationsObservable: Observable<Scene>;
  33371. /**
  33372. * An event triggered after animations processing
  33373. */
  33374. onAfterAnimationsObservable: Observable<Scene>;
  33375. /**
  33376. * An event triggered before draw calls are ready to be sent
  33377. */
  33378. onBeforeDrawPhaseObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered after draw calls have been sent
  33381. */
  33382. onAfterDrawPhaseObservable: Observable<Scene>;
  33383. /**
  33384. * An event triggered when the scene is ready
  33385. */
  33386. onReadyObservable: Observable<Scene>;
  33387. /**
  33388. * An event triggered before rendering a camera
  33389. */
  33390. onBeforeCameraRenderObservable: Observable<Camera>;
  33391. private _onBeforeCameraRenderObserver;
  33392. /** Sets a function to be executed before rendering a camera*/
  33393. beforeCameraRender: () => void;
  33394. /**
  33395. * An event triggered after rendering a camera
  33396. */
  33397. onAfterCameraRenderObservable: Observable<Camera>;
  33398. private _onAfterCameraRenderObserver;
  33399. /** Sets a function to be executed after rendering a camera*/
  33400. afterCameraRender: () => void;
  33401. /**
  33402. * An event triggered when active meshes evaluation is about to start
  33403. */
  33404. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33405. /**
  33406. * An event triggered when active meshes evaluation is done
  33407. */
  33408. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33409. /**
  33410. * An event triggered when particles rendering is about to start
  33411. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33412. */
  33413. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33414. /**
  33415. * An event triggered when particles rendering is done
  33416. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33417. */
  33418. onAfterParticlesRenderingObservable: Observable<Scene>;
  33419. /**
  33420. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33421. */
  33422. onDataLoadedObservable: Observable<Scene>;
  33423. /**
  33424. * An event triggered when a camera is created
  33425. */
  33426. onNewCameraAddedObservable: Observable<Camera>;
  33427. /**
  33428. * An event triggered when a camera is removed
  33429. */
  33430. onCameraRemovedObservable: Observable<Camera>;
  33431. /**
  33432. * An event triggered when a light is created
  33433. */
  33434. onNewLightAddedObservable: Observable<Light>;
  33435. /**
  33436. * An event triggered when a light is removed
  33437. */
  33438. onLightRemovedObservable: Observable<Light>;
  33439. /**
  33440. * An event triggered when a geometry is created
  33441. */
  33442. onNewGeometryAddedObservable: Observable<Geometry>;
  33443. /**
  33444. * An event triggered when a geometry is removed
  33445. */
  33446. onGeometryRemovedObservable: Observable<Geometry>;
  33447. /**
  33448. * An event triggered when a transform node is created
  33449. */
  33450. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33451. /**
  33452. * An event triggered when a transform node is removed
  33453. */
  33454. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33455. /**
  33456. * An event triggered when a mesh is created
  33457. */
  33458. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33459. /**
  33460. * An event triggered when a mesh is removed
  33461. */
  33462. onMeshRemovedObservable: Observable<AbstractMesh>;
  33463. /**
  33464. * An event triggered when a skeleton is created
  33465. */
  33466. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33467. /**
  33468. * An event triggered when a skeleton is removed
  33469. */
  33470. onSkeletonRemovedObservable: Observable<Skeleton>;
  33471. /**
  33472. * An event triggered when a material is created
  33473. */
  33474. onNewMaterialAddedObservable: Observable<Material>;
  33475. /**
  33476. * An event triggered when a material is removed
  33477. */
  33478. onMaterialRemovedObservable: Observable<Material>;
  33479. /**
  33480. * An event triggered when a texture is created
  33481. */
  33482. onNewTextureAddedObservable: Observable<BaseTexture>;
  33483. /**
  33484. * An event triggered when a texture is removed
  33485. */
  33486. onTextureRemovedObservable: Observable<BaseTexture>;
  33487. /**
  33488. * An event triggered when render targets are about to be rendered
  33489. * Can happen multiple times per frame.
  33490. */
  33491. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33492. /**
  33493. * An event triggered when render targets were rendered.
  33494. * Can happen multiple times per frame.
  33495. */
  33496. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33497. /**
  33498. * An event triggered before calculating deterministic simulation step
  33499. */
  33500. onBeforeStepObservable: Observable<Scene>;
  33501. /**
  33502. * An event triggered after calculating deterministic simulation step
  33503. */
  33504. onAfterStepObservable: Observable<Scene>;
  33505. /**
  33506. * An event triggered when the activeCamera property is updated
  33507. */
  33508. onActiveCameraChanged: Observable<Scene>;
  33509. /**
  33510. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33511. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33512. * 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)
  33513. */
  33514. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33515. /**
  33516. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33517. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33518. * 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)
  33519. */
  33520. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33521. /**
  33522. * This Observable will when a mesh has been imported into the scene.
  33523. */
  33524. onMeshImportedObservable: Observable<AbstractMesh>;
  33525. /**
  33526. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33527. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33528. */
  33529. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33530. /** @hidden */
  33531. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33532. /**
  33533. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33534. */
  33535. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33536. /**
  33537. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33538. */
  33539. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33540. /**
  33541. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33542. */
  33543. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33544. /** Callback called when a pointer move is detected */
  33545. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33546. /** Callback called when a pointer down is detected */
  33547. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33548. /** Callback called when a pointer up is detected */
  33549. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33550. /** Callback called when a pointer pick is detected */
  33551. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33552. /**
  33553. * 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).
  33554. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33555. */
  33556. onPrePointerObservable: Observable<PointerInfoPre>;
  33557. /**
  33558. * Observable event triggered each time an input event is received from the rendering canvas
  33559. */
  33560. onPointerObservable: Observable<PointerInfo>;
  33561. /**
  33562. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33563. */
  33564. readonly unTranslatedPointer: Vector2;
  33565. /**
  33566. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33567. */
  33568. static DragMovementThreshold: number;
  33569. /**
  33570. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33571. */
  33572. static LongPressDelay: number;
  33573. /**
  33574. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33575. */
  33576. static DoubleClickDelay: number;
  33577. /** If you need to check double click without raising a single click at first click, enable this flag */
  33578. static ExclusiveDoubleClickMode: boolean;
  33579. /** @hidden */
  33580. _mirroredCameraPosition: Nullable<Vector3>;
  33581. /**
  33582. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33583. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33584. */
  33585. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33586. /**
  33587. * Observable event triggered each time an keyboard event is received from the hosting window
  33588. */
  33589. onKeyboardObservable: Observable<KeyboardInfo>;
  33590. private _useRightHandedSystem;
  33591. /**
  33592. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33593. */
  33594. useRightHandedSystem: boolean;
  33595. private _timeAccumulator;
  33596. private _currentStepId;
  33597. private _currentInternalStep;
  33598. /**
  33599. * Sets the step Id used by deterministic lock step
  33600. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33601. * @param newStepId defines the step Id
  33602. */
  33603. setStepId(newStepId: number): void;
  33604. /**
  33605. * Gets the step Id used by deterministic lock step
  33606. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33607. * @returns the step Id
  33608. */
  33609. getStepId(): number;
  33610. /**
  33611. * Gets the internal step used by deterministic lock step
  33612. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33613. * @returns the internal step
  33614. */
  33615. getInternalStep(): number;
  33616. private _fogEnabled;
  33617. /**
  33618. * Gets or sets a boolean indicating if fog is enabled on this scene
  33619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33620. * (Default is true)
  33621. */
  33622. fogEnabled: boolean;
  33623. private _fogMode;
  33624. /**
  33625. * Gets or sets the fog mode to use
  33626. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33627. * | mode | value |
  33628. * | --- | --- |
  33629. * | FOGMODE_NONE | 0 |
  33630. * | FOGMODE_EXP | 1 |
  33631. * | FOGMODE_EXP2 | 2 |
  33632. * | FOGMODE_LINEAR | 3 |
  33633. */
  33634. fogMode: number;
  33635. /**
  33636. * Gets or sets the fog color to use
  33637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33638. * (Default is Color3(0.2, 0.2, 0.3))
  33639. */
  33640. fogColor: Color3;
  33641. /**
  33642. * Gets or sets the fog density to use
  33643. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33644. * (Default is 0.1)
  33645. */
  33646. fogDensity: number;
  33647. /**
  33648. * Gets or sets the fog start distance to use
  33649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33650. * (Default is 0)
  33651. */
  33652. fogStart: number;
  33653. /**
  33654. * Gets or sets the fog end distance to use
  33655. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33656. * (Default is 1000)
  33657. */
  33658. fogEnd: number;
  33659. private _shadowsEnabled;
  33660. /**
  33661. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33662. */
  33663. shadowsEnabled: boolean;
  33664. private _lightsEnabled;
  33665. /**
  33666. * Gets or sets a boolean indicating if lights are enabled on this scene
  33667. */
  33668. lightsEnabled: boolean;
  33669. /** All of the active cameras added to this scene. */
  33670. activeCameras: Camera[];
  33671. /** @hidden */
  33672. _activeCamera: Nullable<Camera>;
  33673. /** Gets or sets the current active camera */
  33674. activeCamera: Nullable<Camera>;
  33675. private _defaultMaterial;
  33676. /** The default material used on meshes when no material is affected */
  33677. /** The default material used on meshes when no material is affected */
  33678. defaultMaterial: Material;
  33679. private _texturesEnabled;
  33680. /**
  33681. * Gets or sets a boolean indicating if textures are enabled on this scene
  33682. */
  33683. texturesEnabled: boolean;
  33684. /**
  33685. * Gets or sets a boolean indicating if particles are enabled on this scene
  33686. */
  33687. particlesEnabled: boolean;
  33688. /**
  33689. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33690. */
  33691. spritesEnabled: boolean;
  33692. private _skeletonsEnabled;
  33693. /**
  33694. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33695. */
  33696. skeletonsEnabled: boolean;
  33697. /**
  33698. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33699. */
  33700. lensFlaresEnabled: boolean;
  33701. /**
  33702. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33704. */
  33705. collisionsEnabled: boolean;
  33706. private _collisionCoordinator;
  33707. /** @hidden */
  33708. readonly collisionCoordinator: ICollisionCoordinator;
  33709. /**
  33710. * Defines the gravity applied to this scene (used only for collisions)
  33711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33712. */
  33713. gravity: Vector3;
  33714. /**
  33715. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33716. */
  33717. postProcessesEnabled: boolean;
  33718. /**
  33719. * The list of postprocesses added to the scene
  33720. */
  33721. postProcesses: PostProcess[];
  33722. /**
  33723. * Gets the current postprocess manager
  33724. */
  33725. postProcessManager: PostProcessManager;
  33726. /**
  33727. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33728. */
  33729. renderTargetsEnabled: boolean;
  33730. /**
  33731. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33732. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33733. */
  33734. dumpNextRenderTargets: boolean;
  33735. /**
  33736. * The list of user defined render targets added to the scene
  33737. */
  33738. customRenderTargets: RenderTargetTexture[];
  33739. /**
  33740. * Defines if texture loading must be delayed
  33741. * If true, textures will only be loaded when they need to be rendered
  33742. */
  33743. useDelayedTextureLoading: boolean;
  33744. /**
  33745. * Gets the list of meshes imported to the scene through SceneLoader
  33746. */
  33747. importedMeshesFiles: String[];
  33748. /**
  33749. * Gets or sets a boolean indicating if probes are enabled on this scene
  33750. */
  33751. probesEnabled: boolean;
  33752. /**
  33753. * Gets or sets the current offline provider to use to store scene data
  33754. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33755. */
  33756. offlineProvider: IOfflineProvider;
  33757. /**
  33758. * Gets or sets the action manager associated with the scene
  33759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33760. */
  33761. actionManager: AbstractActionManager;
  33762. private _meshesForIntersections;
  33763. /**
  33764. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33765. */
  33766. proceduralTexturesEnabled: boolean;
  33767. private _engine;
  33768. private _totalVertices;
  33769. /** @hidden */
  33770. _activeIndices: PerfCounter;
  33771. /** @hidden */
  33772. _activeParticles: PerfCounter;
  33773. /** @hidden */
  33774. _activeBones: PerfCounter;
  33775. private _animationRatio;
  33776. /** @hidden */
  33777. _animationTimeLast: number;
  33778. /** @hidden */
  33779. _animationTime: number;
  33780. /**
  33781. * Gets or sets a general scale for animation speed
  33782. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33783. */
  33784. animationTimeScale: number;
  33785. /** @hidden */
  33786. _cachedMaterial: Nullable<Material>;
  33787. /** @hidden */
  33788. _cachedEffect: Nullable<Effect>;
  33789. /** @hidden */
  33790. _cachedVisibility: Nullable<number>;
  33791. private _renderId;
  33792. private _frameId;
  33793. private _executeWhenReadyTimeoutId;
  33794. private _intermediateRendering;
  33795. private _viewUpdateFlag;
  33796. private _projectionUpdateFlag;
  33797. /** @hidden */
  33798. _toBeDisposed: Nullable<IDisposable>[];
  33799. private _activeRequests;
  33800. /** @hidden */
  33801. _pendingData: any[];
  33802. private _isDisposed;
  33803. /**
  33804. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33805. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33806. */
  33807. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33808. private _activeMeshes;
  33809. private _processedMaterials;
  33810. private _renderTargets;
  33811. /** @hidden */
  33812. _activeParticleSystems: SmartArray<IParticleSystem>;
  33813. private _activeSkeletons;
  33814. private _softwareSkinnedMeshes;
  33815. private _renderingManager;
  33816. /** @hidden */
  33817. _activeAnimatables: Animatable[];
  33818. private _transformMatrix;
  33819. private _sceneUbo;
  33820. /** @hidden */
  33821. _viewMatrix: Matrix;
  33822. private _projectionMatrix;
  33823. /** @hidden */
  33824. _forcedViewPosition: Nullable<Vector3>;
  33825. /** @hidden */
  33826. _frustumPlanes: Plane[];
  33827. /**
  33828. * Gets the list of frustum planes (built from the active camera)
  33829. */
  33830. readonly frustumPlanes: Plane[];
  33831. /**
  33832. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33833. * This is useful if there are more lights that the maximum simulteanous authorized
  33834. */
  33835. requireLightSorting: boolean;
  33836. /** @hidden */
  33837. readonly useMaterialMeshMap: boolean;
  33838. /** @hidden */
  33839. readonly useClonedMeshhMap: boolean;
  33840. private _externalData;
  33841. private _uid;
  33842. /**
  33843. * @hidden
  33844. * Backing store of defined scene components.
  33845. */
  33846. _components: ISceneComponent[];
  33847. /**
  33848. * @hidden
  33849. * Backing store of defined scene components.
  33850. */
  33851. _serializableComponents: ISceneSerializableComponent[];
  33852. /**
  33853. * List of components to register on the next registration step.
  33854. */
  33855. private _transientComponents;
  33856. /**
  33857. * Registers the transient components if needed.
  33858. */
  33859. private _registerTransientComponents;
  33860. /**
  33861. * @hidden
  33862. * Add a component to the scene.
  33863. * Note that the ccomponent could be registered on th next frame if this is called after
  33864. * the register component stage.
  33865. * @param component Defines the component to add to the scene
  33866. */
  33867. _addComponent(component: ISceneComponent): void;
  33868. /**
  33869. * @hidden
  33870. * Gets a component from the scene.
  33871. * @param name defines the name of the component to retrieve
  33872. * @returns the component or null if not present
  33873. */
  33874. _getComponent(name: string): Nullable<ISceneComponent>;
  33875. /**
  33876. * @hidden
  33877. * Defines the actions happening before camera updates.
  33878. */
  33879. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33880. /**
  33881. * @hidden
  33882. * Defines the actions happening before clear the canvas.
  33883. */
  33884. _beforeClearStage: Stage<SimpleStageAction>;
  33885. /**
  33886. * @hidden
  33887. * Defines the actions when collecting render targets for the frame.
  33888. */
  33889. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33890. /**
  33891. * @hidden
  33892. * Defines the actions happening for one camera in the frame.
  33893. */
  33894. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33895. /**
  33896. * @hidden
  33897. * Defines the actions happening during the per mesh ready checks.
  33898. */
  33899. _isReadyForMeshStage: Stage<MeshStageAction>;
  33900. /**
  33901. * @hidden
  33902. * Defines the actions happening before evaluate active mesh checks.
  33903. */
  33904. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33905. /**
  33906. * @hidden
  33907. * Defines the actions happening during the evaluate sub mesh checks.
  33908. */
  33909. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33910. /**
  33911. * @hidden
  33912. * Defines the actions happening during the active mesh stage.
  33913. */
  33914. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33915. /**
  33916. * @hidden
  33917. * Defines the actions happening during the per camera render target step.
  33918. */
  33919. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33920. /**
  33921. * @hidden
  33922. * Defines the actions happening just before the active camera is drawing.
  33923. */
  33924. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33925. /**
  33926. * @hidden
  33927. * Defines the actions happening just before a render target is drawing.
  33928. */
  33929. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33930. /**
  33931. * @hidden
  33932. * Defines the actions happening just before a rendering group is drawing.
  33933. */
  33934. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33935. /**
  33936. * @hidden
  33937. * Defines the actions happening just before a mesh is drawing.
  33938. */
  33939. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33940. /**
  33941. * @hidden
  33942. * Defines the actions happening just after a mesh has been drawn.
  33943. */
  33944. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33945. /**
  33946. * @hidden
  33947. * Defines the actions happening just after a rendering group has been drawn.
  33948. */
  33949. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33950. /**
  33951. * @hidden
  33952. * Defines the actions happening just after the active camera has been drawn.
  33953. */
  33954. _afterCameraDrawStage: Stage<CameraStageAction>;
  33955. /**
  33956. * @hidden
  33957. * Defines the actions happening just after a render target has been drawn.
  33958. */
  33959. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33960. /**
  33961. * @hidden
  33962. * Defines the actions happening just after rendering all cameras and computing intersections.
  33963. */
  33964. _afterRenderStage: Stage<SimpleStageAction>;
  33965. /**
  33966. * @hidden
  33967. * Defines the actions happening when a pointer move event happens.
  33968. */
  33969. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33970. /**
  33971. * @hidden
  33972. * Defines the actions happening when a pointer down event happens.
  33973. */
  33974. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33975. /**
  33976. * @hidden
  33977. * Defines the actions happening when a pointer up event happens.
  33978. */
  33979. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33980. /**
  33981. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33982. */
  33983. private geometriesByUniqueId;
  33984. /**
  33985. * Creates a new Scene
  33986. * @param engine defines the engine to use to render this scene
  33987. * @param options defines the scene options
  33988. */
  33989. constructor(engine: Engine, options?: SceneOptions);
  33990. /**
  33991. * Gets a string idenfifying the name of the class
  33992. * @returns "Scene" string
  33993. */
  33994. getClassName(): string;
  33995. private _defaultMeshCandidates;
  33996. /**
  33997. * @hidden
  33998. */
  33999. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34000. private _defaultSubMeshCandidates;
  34001. /**
  34002. * @hidden
  34003. */
  34004. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34005. /**
  34006. * Sets the default candidate providers for the scene.
  34007. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34008. * and getCollidingSubMeshCandidates to their default function
  34009. */
  34010. setDefaultCandidateProviders(): void;
  34011. /**
  34012. * Gets the mesh that is currently under the pointer
  34013. */
  34014. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34015. /**
  34016. * Gets or sets the current on-screen X position of the pointer
  34017. */
  34018. pointerX: number;
  34019. /**
  34020. * Gets or sets the current on-screen Y position of the pointer
  34021. */
  34022. pointerY: number;
  34023. /**
  34024. * Gets the cached material (ie. the latest rendered one)
  34025. * @returns the cached material
  34026. */
  34027. getCachedMaterial(): Nullable<Material>;
  34028. /**
  34029. * Gets the cached effect (ie. the latest rendered one)
  34030. * @returns the cached effect
  34031. */
  34032. getCachedEffect(): Nullable<Effect>;
  34033. /**
  34034. * Gets the cached visibility state (ie. the latest rendered one)
  34035. * @returns the cached visibility state
  34036. */
  34037. getCachedVisibility(): Nullable<number>;
  34038. /**
  34039. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34040. * @param material defines the current material
  34041. * @param effect defines the current effect
  34042. * @param visibility defines the current visibility state
  34043. * @returns true if one parameter is not cached
  34044. */
  34045. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34046. /**
  34047. * Gets the engine associated with the scene
  34048. * @returns an Engine
  34049. */
  34050. getEngine(): Engine;
  34051. /**
  34052. * Gets the total number of vertices rendered per frame
  34053. * @returns the total number of vertices rendered per frame
  34054. */
  34055. getTotalVertices(): number;
  34056. /**
  34057. * Gets the performance counter for total vertices
  34058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34059. */
  34060. readonly totalVerticesPerfCounter: PerfCounter;
  34061. /**
  34062. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34063. * @returns the total number of active indices rendered per frame
  34064. */
  34065. getActiveIndices(): number;
  34066. /**
  34067. * Gets the performance counter for active indices
  34068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34069. */
  34070. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34071. /**
  34072. * Gets the total number of active particles rendered per frame
  34073. * @returns the total number of active particles rendered per frame
  34074. */
  34075. getActiveParticles(): number;
  34076. /**
  34077. * Gets the performance counter for active particles
  34078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34079. */
  34080. readonly activeParticlesPerfCounter: PerfCounter;
  34081. /**
  34082. * Gets the total number of active bones rendered per frame
  34083. * @returns the total number of active bones rendered per frame
  34084. */
  34085. getActiveBones(): number;
  34086. /**
  34087. * Gets the performance counter for active bones
  34088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34089. */
  34090. readonly activeBonesPerfCounter: PerfCounter;
  34091. /**
  34092. * Gets the array of active meshes
  34093. * @returns an array of AbstractMesh
  34094. */
  34095. getActiveMeshes(): SmartArray<AbstractMesh>;
  34096. /**
  34097. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34098. * @returns a number
  34099. */
  34100. getAnimationRatio(): number;
  34101. /**
  34102. * Gets an unique Id for the current render phase
  34103. * @returns a number
  34104. */
  34105. getRenderId(): number;
  34106. /**
  34107. * Gets an unique Id for the current frame
  34108. * @returns a number
  34109. */
  34110. getFrameId(): number;
  34111. /** Call this function if you want to manually increment the render Id*/
  34112. incrementRenderId(): void;
  34113. private _createUbo;
  34114. /**
  34115. * Use this method to simulate a pointer move on a mesh
  34116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34119. * @returns the current scene
  34120. */
  34121. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34122. /**
  34123. * Use this method to simulate a pointer down on a mesh
  34124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34127. * @returns the current scene
  34128. */
  34129. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34130. /**
  34131. * Use this method to simulate a pointer up on a mesh
  34132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34135. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34136. * @returns the current scene
  34137. */
  34138. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34139. /**
  34140. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34141. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34142. * @returns true if the pointer was captured
  34143. */
  34144. isPointerCaptured(pointerId?: number): boolean;
  34145. /**
  34146. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34147. * @param attachUp defines if you want to attach events to pointerup
  34148. * @param attachDown defines if you want to attach events to pointerdown
  34149. * @param attachMove defines if you want to attach events to pointermove
  34150. */
  34151. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34152. /** Detaches all event handlers*/
  34153. detachControl(): void;
  34154. /**
  34155. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34156. * Delay loaded resources are not taking in account
  34157. * @return true if all required resources are ready
  34158. */
  34159. isReady(): boolean;
  34160. /** Resets all cached information relative to material (including effect and visibility) */
  34161. resetCachedMaterial(): void;
  34162. /**
  34163. * Registers a function to be called before every frame render
  34164. * @param func defines the function to register
  34165. */
  34166. registerBeforeRender(func: () => void): void;
  34167. /**
  34168. * Unregisters a function called before every frame render
  34169. * @param func defines the function to unregister
  34170. */
  34171. unregisterBeforeRender(func: () => void): void;
  34172. /**
  34173. * Registers a function to be called after every frame render
  34174. * @param func defines the function to register
  34175. */
  34176. registerAfterRender(func: () => void): void;
  34177. /**
  34178. * Unregisters a function called after every frame render
  34179. * @param func defines the function to unregister
  34180. */
  34181. unregisterAfterRender(func: () => void): void;
  34182. private _executeOnceBeforeRender;
  34183. /**
  34184. * The provided function will run before render once and will be disposed afterwards.
  34185. * A timeout delay can be provided so that the function will be executed in N ms.
  34186. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34187. * @param func The function to be executed.
  34188. * @param timeout optional delay in ms
  34189. */
  34190. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34191. /** @hidden */
  34192. _addPendingData(data: any): void;
  34193. /** @hidden */
  34194. _removePendingData(data: any): void;
  34195. /**
  34196. * Returns the number of items waiting to be loaded
  34197. * @returns the number of items waiting to be loaded
  34198. */
  34199. getWaitingItemsCount(): number;
  34200. /**
  34201. * Returns a boolean indicating if the scene is still loading data
  34202. */
  34203. readonly isLoading: boolean;
  34204. /**
  34205. * Registers a function to be executed when the scene is ready
  34206. * @param {Function} func - the function to be executed
  34207. */
  34208. executeWhenReady(func: () => void): void;
  34209. /**
  34210. * Returns a promise that resolves when the scene is ready
  34211. * @returns A promise that resolves when the scene is ready
  34212. */
  34213. whenReadyAsync(): Promise<void>;
  34214. /** @hidden */
  34215. _checkIsReady(): void;
  34216. /**
  34217. * Gets all animatable attached to the scene
  34218. */
  34219. readonly animatables: Animatable[];
  34220. /**
  34221. * Resets the last animation time frame.
  34222. * Useful to override when animations start running when loading a scene for the first time.
  34223. */
  34224. resetLastAnimationTimeFrame(): void;
  34225. /**
  34226. * Gets the current view matrix
  34227. * @returns a Matrix
  34228. */
  34229. getViewMatrix(): Matrix;
  34230. /**
  34231. * Gets the current projection matrix
  34232. * @returns a Matrix
  34233. */
  34234. getProjectionMatrix(): Matrix;
  34235. /**
  34236. * Gets the current transform matrix
  34237. * @returns a Matrix made of View * Projection
  34238. */
  34239. getTransformMatrix(): Matrix;
  34240. /**
  34241. * Sets the current transform matrix
  34242. * @param viewL defines the View matrix to use
  34243. * @param projectionL defines the Projection matrix to use
  34244. * @param viewR defines the right View matrix to use (if provided)
  34245. * @param projectionR defines the right Projection matrix to use (if provided)
  34246. */
  34247. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34248. /**
  34249. * Gets the uniform buffer used to store scene data
  34250. * @returns a UniformBuffer
  34251. */
  34252. getSceneUniformBuffer(): UniformBuffer;
  34253. /**
  34254. * Gets an unique (relatively to the current scene) Id
  34255. * @returns an unique number for the scene
  34256. */
  34257. getUniqueId(): number;
  34258. /**
  34259. * Add a mesh to the list of scene's meshes
  34260. * @param newMesh defines the mesh to add
  34261. * @param recursive if all child meshes should also be added to the scene
  34262. */
  34263. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34264. /**
  34265. * Remove a mesh for the list of scene's meshes
  34266. * @param toRemove defines the mesh to remove
  34267. * @param recursive if all child meshes should also be removed from the scene
  34268. * @returns the index where the mesh was in the mesh list
  34269. */
  34270. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34271. /**
  34272. * Add a transform node to the list of scene's transform nodes
  34273. * @param newTransformNode defines the transform node to add
  34274. */
  34275. addTransformNode(newTransformNode: TransformNode): void;
  34276. /**
  34277. * Remove a transform node for the list of scene's transform nodes
  34278. * @param toRemove defines the transform node to remove
  34279. * @returns the index where the transform node was in the transform node list
  34280. */
  34281. removeTransformNode(toRemove: TransformNode): number;
  34282. /**
  34283. * Remove a skeleton for the list of scene's skeletons
  34284. * @param toRemove defines the skeleton to remove
  34285. * @returns the index where the skeleton was in the skeleton list
  34286. */
  34287. removeSkeleton(toRemove: Skeleton): number;
  34288. /**
  34289. * Remove a morph target for the list of scene's morph targets
  34290. * @param toRemove defines the morph target to remove
  34291. * @returns the index where the morph target was in the morph target list
  34292. */
  34293. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34294. /**
  34295. * Remove a light for the list of scene's lights
  34296. * @param toRemove defines the light to remove
  34297. * @returns the index where the light was in the light list
  34298. */
  34299. removeLight(toRemove: Light): number;
  34300. /**
  34301. * Remove a camera for the list of scene's cameras
  34302. * @param toRemove defines the camera to remove
  34303. * @returns the index where the camera was in the camera list
  34304. */
  34305. removeCamera(toRemove: Camera): number;
  34306. /**
  34307. * Remove a particle system for the list of scene's particle systems
  34308. * @param toRemove defines the particle system to remove
  34309. * @returns the index where the particle system was in the particle system list
  34310. */
  34311. removeParticleSystem(toRemove: IParticleSystem): number;
  34312. /**
  34313. * Remove a animation for the list of scene's animations
  34314. * @param toRemove defines the animation to remove
  34315. * @returns the index where the animation was in the animation list
  34316. */
  34317. removeAnimation(toRemove: Animation): number;
  34318. /**
  34319. * Will stop the animation of the given target
  34320. * @param target - the target
  34321. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34322. * @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)
  34323. */
  34324. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34325. /**
  34326. * Removes the given animation group from this scene.
  34327. * @param toRemove The animation group to remove
  34328. * @returns The index of the removed animation group
  34329. */
  34330. removeAnimationGroup(toRemove: AnimationGroup): number;
  34331. /**
  34332. * Removes the given multi-material from this scene.
  34333. * @param toRemove The multi-material to remove
  34334. * @returns The index of the removed multi-material
  34335. */
  34336. removeMultiMaterial(toRemove: MultiMaterial): number;
  34337. /**
  34338. * Removes the given material from this scene.
  34339. * @param toRemove The material to remove
  34340. * @returns The index of the removed material
  34341. */
  34342. removeMaterial(toRemove: Material): number;
  34343. /**
  34344. * Removes the given action manager from this scene.
  34345. * @param toRemove The action manager to remove
  34346. * @returns The index of the removed action manager
  34347. */
  34348. removeActionManager(toRemove: AbstractActionManager): number;
  34349. /**
  34350. * Removes the given texture from this scene.
  34351. * @param toRemove The texture to remove
  34352. * @returns The index of the removed texture
  34353. */
  34354. removeTexture(toRemove: BaseTexture): number;
  34355. /**
  34356. * Adds the given light to this scene
  34357. * @param newLight The light to add
  34358. */
  34359. addLight(newLight: Light): void;
  34360. /**
  34361. * Sorts the list list based on light priorities
  34362. */
  34363. sortLightsByPriority(): void;
  34364. /**
  34365. * Adds the given camera to this scene
  34366. * @param newCamera The camera to add
  34367. */
  34368. addCamera(newCamera: Camera): void;
  34369. /**
  34370. * Adds the given skeleton to this scene
  34371. * @param newSkeleton The skeleton to add
  34372. */
  34373. addSkeleton(newSkeleton: Skeleton): void;
  34374. /**
  34375. * Adds the given particle system to this scene
  34376. * @param newParticleSystem The particle system to add
  34377. */
  34378. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34379. /**
  34380. * Adds the given animation to this scene
  34381. * @param newAnimation The animation to add
  34382. */
  34383. addAnimation(newAnimation: Animation): void;
  34384. /**
  34385. * Adds the given animation group to this scene.
  34386. * @param newAnimationGroup The animation group to add
  34387. */
  34388. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34389. /**
  34390. * Adds the given multi-material to this scene
  34391. * @param newMultiMaterial The multi-material to add
  34392. */
  34393. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34394. /**
  34395. * Adds the given material to this scene
  34396. * @param newMaterial The material to add
  34397. */
  34398. addMaterial(newMaterial: Material): void;
  34399. /**
  34400. * Adds the given morph target to this scene
  34401. * @param newMorphTargetManager The morph target to add
  34402. */
  34403. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34404. /**
  34405. * Adds the given geometry to this scene
  34406. * @param newGeometry The geometry to add
  34407. */
  34408. addGeometry(newGeometry: Geometry): void;
  34409. /**
  34410. * Adds the given action manager to this scene
  34411. * @param newActionManager The action manager to add
  34412. */
  34413. addActionManager(newActionManager: AbstractActionManager): void;
  34414. /**
  34415. * Adds the given texture to this scene.
  34416. * @param newTexture The texture to add
  34417. */
  34418. addTexture(newTexture: BaseTexture): void;
  34419. /**
  34420. * Switch active camera
  34421. * @param newCamera defines the new active camera
  34422. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34423. */
  34424. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34425. /**
  34426. * sets the active camera of the scene using its ID
  34427. * @param id defines the camera's ID
  34428. * @return the new active camera or null if none found.
  34429. */
  34430. setActiveCameraByID(id: string): Nullable<Camera>;
  34431. /**
  34432. * sets the active camera of the scene using its name
  34433. * @param name defines the camera's name
  34434. * @returns the new active camera or null if none found.
  34435. */
  34436. setActiveCameraByName(name: string): Nullable<Camera>;
  34437. /**
  34438. * get an animation group using its name
  34439. * @param name defines the material's name
  34440. * @return the animation group or null if none found.
  34441. */
  34442. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34443. /**
  34444. * Get a material using its unique id
  34445. * @param uniqueId defines the material's unique id
  34446. * @return the material or null if none found.
  34447. */
  34448. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34449. /**
  34450. * get a material using its id
  34451. * @param id defines the material's ID
  34452. * @return the material or null if none found.
  34453. */
  34454. getMaterialByID(id: string): Nullable<Material>;
  34455. /**
  34456. * Gets a the last added material using a given id
  34457. * @param id defines the material's ID
  34458. * @return the last material with the given id or null if none found.
  34459. */
  34460. getLastMaterialByID(id: string): Nullable<Material>;
  34461. /**
  34462. * Gets a material using its name
  34463. * @param name defines the material's name
  34464. * @return the material or null if none found.
  34465. */
  34466. getMaterialByName(name: string): Nullable<Material>;
  34467. /**
  34468. * Get a texture using its unique id
  34469. * @param uniqueId defines the texture's unique id
  34470. * @return the texture or null if none found.
  34471. */
  34472. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34473. /**
  34474. * Gets a camera using its id
  34475. * @param id defines the id to look for
  34476. * @returns the camera or null if not found
  34477. */
  34478. getCameraByID(id: string): Nullable<Camera>;
  34479. /**
  34480. * Gets a camera using its unique id
  34481. * @param uniqueId defines the unique id to look for
  34482. * @returns the camera or null if not found
  34483. */
  34484. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34485. /**
  34486. * Gets a camera using its name
  34487. * @param name defines the camera's name
  34488. * @return the camera or null if none found.
  34489. */
  34490. getCameraByName(name: string): Nullable<Camera>;
  34491. /**
  34492. * Gets a bone using its id
  34493. * @param id defines the bone's id
  34494. * @return the bone or null if not found
  34495. */
  34496. getBoneByID(id: string): Nullable<Bone>;
  34497. /**
  34498. * Gets a bone using its id
  34499. * @param name defines the bone's name
  34500. * @return the bone or null if not found
  34501. */
  34502. getBoneByName(name: string): Nullable<Bone>;
  34503. /**
  34504. * Gets a light node using its name
  34505. * @param name defines the the light's name
  34506. * @return the light or null if none found.
  34507. */
  34508. getLightByName(name: string): Nullable<Light>;
  34509. /**
  34510. * Gets a light node using its id
  34511. * @param id defines the light's id
  34512. * @return the light or null if none found.
  34513. */
  34514. getLightByID(id: string): Nullable<Light>;
  34515. /**
  34516. * Gets a light node using its scene-generated unique ID
  34517. * @param uniqueId defines the light's unique id
  34518. * @return the light or null if none found.
  34519. */
  34520. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34521. /**
  34522. * Gets a particle system by id
  34523. * @param id defines the particle system id
  34524. * @return the corresponding system or null if none found
  34525. */
  34526. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34527. /**
  34528. * Gets a geometry using its ID
  34529. * @param id defines the geometry's id
  34530. * @return the geometry or null if none found.
  34531. */
  34532. getGeometryByID(id: string): Nullable<Geometry>;
  34533. private _getGeometryByUniqueID;
  34534. /**
  34535. * Add a new geometry to this scene
  34536. * @param geometry defines the geometry to be added to the scene.
  34537. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34538. * @return a boolean defining if the geometry was added or not
  34539. */
  34540. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34541. /**
  34542. * Removes an existing geometry
  34543. * @param geometry defines the geometry to be removed from the scene
  34544. * @return a boolean defining if the geometry was removed or not
  34545. */
  34546. removeGeometry(geometry: Geometry): boolean;
  34547. /**
  34548. * Gets the list of geometries attached to the scene
  34549. * @returns an array of Geometry
  34550. */
  34551. getGeometries(): Geometry[];
  34552. /**
  34553. * Gets the first added mesh found of a given ID
  34554. * @param id defines the id to search for
  34555. * @return the mesh found or null if not found at all
  34556. */
  34557. getMeshByID(id: string): Nullable<AbstractMesh>;
  34558. /**
  34559. * Gets a list of meshes using their id
  34560. * @param id defines the id to search for
  34561. * @returns a list of meshes
  34562. */
  34563. getMeshesByID(id: string): Array<AbstractMesh>;
  34564. /**
  34565. * Gets the first added transform node found of a given ID
  34566. * @param id defines the id to search for
  34567. * @return the found transform node or null if not found at all.
  34568. */
  34569. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34570. /**
  34571. * Gets a transform node with its auto-generated unique id
  34572. * @param uniqueId efines the unique id to search for
  34573. * @return the found transform node or null if not found at all.
  34574. */
  34575. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34576. /**
  34577. * Gets a list of transform nodes using their id
  34578. * @param id defines the id to search for
  34579. * @returns a list of transform nodes
  34580. */
  34581. getTransformNodesByID(id: string): Array<TransformNode>;
  34582. /**
  34583. * Gets a mesh with its auto-generated unique id
  34584. * @param uniqueId defines the unique id to search for
  34585. * @return the found mesh or null if not found at all.
  34586. */
  34587. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34588. /**
  34589. * Gets a the last added mesh using a given id
  34590. * @param id defines the id to search for
  34591. * @return the found mesh or null if not found at all.
  34592. */
  34593. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34594. /**
  34595. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34596. * @param id defines the id to search for
  34597. * @return the found node or null if not found at all
  34598. */
  34599. getLastEntryByID(id: string): Nullable<Node>;
  34600. /**
  34601. * Gets a node (Mesh, Camera, Light) using a given id
  34602. * @param id defines the id to search for
  34603. * @return the found node or null if not found at all
  34604. */
  34605. getNodeByID(id: string): Nullable<Node>;
  34606. /**
  34607. * Gets a node (Mesh, Camera, Light) using a given name
  34608. * @param name defines the name to search for
  34609. * @return the found node or null if not found at all.
  34610. */
  34611. getNodeByName(name: string): Nullable<Node>;
  34612. /**
  34613. * Gets a mesh using a given name
  34614. * @param name defines the name to search for
  34615. * @return the found mesh or null if not found at all.
  34616. */
  34617. getMeshByName(name: string): Nullable<AbstractMesh>;
  34618. /**
  34619. * Gets a transform node using a given name
  34620. * @param name defines the name to search for
  34621. * @return the found transform node or null if not found at all.
  34622. */
  34623. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34624. /**
  34625. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34626. * @param id defines the id to search for
  34627. * @return the found skeleton or null if not found at all.
  34628. */
  34629. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34630. /**
  34631. * Gets a skeleton using a given auto generated unique id
  34632. * @param uniqueId defines the unique id to search for
  34633. * @return the found skeleton or null if not found at all.
  34634. */
  34635. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34636. /**
  34637. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34638. * @param id defines the id to search for
  34639. * @return the found skeleton or null if not found at all.
  34640. */
  34641. getSkeletonById(id: string): Nullable<Skeleton>;
  34642. /**
  34643. * Gets a skeleton using a given name
  34644. * @param name defines the name to search for
  34645. * @return the found skeleton or null if not found at all.
  34646. */
  34647. getSkeletonByName(name: string): Nullable<Skeleton>;
  34648. /**
  34649. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34650. * @param id defines the id to search for
  34651. * @return the found morph target manager or null if not found at all.
  34652. */
  34653. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34654. /**
  34655. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34656. * @param id defines the id to search for
  34657. * @return the found morph target or null if not found at all.
  34658. */
  34659. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34660. /**
  34661. * Gets a boolean indicating if the given mesh is active
  34662. * @param mesh defines the mesh to look for
  34663. * @returns true if the mesh is in the active list
  34664. */
  34665. isActiveMesh(mesh: AbstractMesh): boolean;
  34666. /**
  34667. * Return a unique id as a string which can serve as an identifier for the scene
  34668. */
  34669. readonly uid: string;
  34670. /**
  34671. * Add an externaly attached data from its key.
  34672. * This method call will fail and return false, if such key already exists.
  34673. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34674. * @param key the unique key that identifies the data
  34675. * @param data the data object to associate to the key for this Engine instance
  34676. * @return true if no such key were already present and the data was added successfully, false otherwise
  34677. */
  34678. addExternalData<T>(key: string, data: T): boolean;
  34679. /**
  34680. * Get an externaly attached data from its key
  34681. * @param key the unique key that identifies the data
  34682. * @return the associated data, if present (can be null), or undefined if not present
  34683. */
  34684. getExternalData<T>(key: string): Nullable<T>;
  34685. /**
  34686. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34687. * @param key the unique key that identifies the data
  34688. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34689. * @return the associated data, can be null if the factory returned null.
  34690. */
  34691. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34692. /**
  34693. * Remove an externaly attached data from the Engine instance
  34694. * @param key the unique key that identifies the data
  34695. * @return true if the data was successfully removed, false if it doesn't exist
  34696. */
  34697. removeExternalData(key: string): boolean;
  34698. private _evaluateSubMesh;
  34699. /**
  34700. * Clear the processed materials smart array preventing retention point in material dispose.
  34701. */
  34702. freeProcessedMaterials(): void;
  34703. private _preventFreeActiveMeshesAndRenderingGroups;
  34704. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34705. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34706. * when disposing several meshes in a row or a hierarchy of meshes.
  34707. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34708. */
  34709. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34710. /**
  34711. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34712. */
  34713. freeActiveMeshes(): void;
  34714. /**
  34715. * Clear the info related to rendering groups preventing retention points during dispose.
  34716. */
  34717. freeRenderingGroups(): void;
  34718. /** @hidden */
  34719. _isInIntermediateRendering(): boolean;
  34720. /**
  34721. * Lambda returning the list of potentially active meshes.
  34722. */
  34723. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34724. /**
  34725. * Lambda returning the list of potentially active sub meshes.
  34726. */
  34727. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34728. /**
  34729. * Lambda returning the list of potentially intersecting sub meshes.
  34730. */
  34731. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34732. /**
  34733. * Lambda returning the list of potentially colliding sub meshes.
  34734. */
  34735. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34736. private _activeMeshesFrozen;
  34737. /**
  34738. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34739. * @returns the current scene
  34740. */
  34741. freezeActiveMeshes(): Scene;
  34742. /**
  34743. * Use this function to restart evaluating active meshes on every frame
  34744. * @returns the current scene
  34745. */
  34746. unfreezeActiveMeshes(): Scene;
  34747. private _evaluateActiveMeshes;
  34748. private _activeMesh;
  34749. /**
  34750. * Update the transform matrix to update from the current active camera
  34751. * @param force defines a boolean used to force the update even if cache is up to date
  34752. */
  34753. updateTransformMatrix(force?: boolean): void;
  34754. private _bindFrameBuffer;
  34755. /** @hidden */
  34756. _allowPostProcessClearColor: boolean;
  34757. /** @hidden */
  34758. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34759. private _processSubCameras;
  34760. private _checkIntersections;
  34761. /** @hidden */
  34762. _advancePhysicsEngineStep(step: number): void;
  34763. /**
  34764. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34765. */
  34766. getDeterministicFrameTime: () => number;
  34767. /** @hidden */
  34768. _animate(): void;
  34769. /** Execute all animations (for a frame) */
  34770. animate(): void;
  34771. /**
  34772. * Render the scene
  34773. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34774. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34775. */
  34776. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34777. /**
  34778. * Freeze all materials
  34779. * A frozen material will not be updatable but should be faster to render
  34780. */
  34781. freezeMaterials(): void;
  34782. /**
  34783. * Unfreeze all materials
  34784. * A frozen material will not be updatable but should be faster to render
  34785. */
  34786. unfreezeMaterials(): void;
  34787. /**
  34788. * Releases all held ressources
  34789. */
  34790. dispose(): void;
  34791. /**
  34792. * Gets if the scene is already disposed
  34793. */
  34794. readonly isDisposed: boolean;
  34795. /**
  34796. * Call this function to reduce memory footprint of the scene.
  34797. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34798. */
  34799. clearCachedVertexData(): void;
  34800. /**
  34801. * This function will remove the local cached buffer data from texture.
  34802. * It will save memory but will prevent the texture from being rebuilt
  34803. */
  34804. cleanCachedTextureBuffer(): void;
  34805. /**
  34806. * Get the world extend vectors with an optional filter
  34807. *
  34808. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34809. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34810. */
  34811. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34812. min: Vector3;
  34813. max: Vector3;
  34814. };
  34815. /**
  34816. * Creates a ray that can be used to pick in the scene
  34817. * @param x defines the x coordinate of the origin (on-screen)
  34818. * @param y defines the y coordinate of the origin (on-screen)
  34819. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34820. * @param camera defines the camera to use for the picking
  34821. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34822. * @returns a Ray
  34823. */
  34824. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34825. /**
  34826. * Creates a ray that can be used to pick in the scene
  34827. * @param x defines the x coordinate of the origin (on-screen)
  34828. * @param y defines the y coordinate of the origin (on-screen)
  34829. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34830. * @param result defines the ray where to store the picking ray
  34831. * @param camera defines the camera to use for the picking
  34832. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34833. * @returns the current scene
  34834. */
  34835. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34836. /**
  34837. * Creates a ray that can be used to pick in the scene
  34838. * @param x defines the x coordinate of the origin (on-screen)
  34839. * @param y defines the y coordinate of the origin (on-screen)
  34840. * @param camera defines the camera to use for the picking
  34841. * @returns a Ray
  34842. */
  34843. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34844. /**
  34845. * Creates a ray that can be used to pick in the scene
  34846. * @param x defines the x coordinate of the origin (on-screen)
  34847. * @param y defines the y coordinate of the origin (on-screen)
  34848. * @param result defines the ray where to store the picking ray
  34849. * @param camera defines the camera to use for the picking
  34850. * @returns the current scene
  34851. */
  34852. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34853. /** Launch a ray to try to pick a mesh in the scene
  34854. * @param x position on screen
  34855. * @param y position on screen
  34856. * @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
  34857. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34858. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34859. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34860. * @returns a PickingInfo
  34861. */
  34862. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34863. /** Use the given ray to pick a mesh in the scene
  34864. * @param ray The ray to use to pick meshes
  34865. * @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
  34866. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34867. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34868. * @returns a PickingInfo
  34869. */
  34870. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34871. /**
  34872. * Launch a ray to try to pick a mesh in the scene
  34873. * @param x X position on screen
  34874. * @param y Y position on screen
  34875. * @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
  34876. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34877. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34878. * @returns an array of PickingInfo
  34879. */
  34880. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34881. /**
  34882. * Launch a ray to try to pick a mesh in the scene
  34883. * @param ray Ray to use
  34884. * @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
  34885. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34886. * @returns an array of PickingInfo
  34887. */
  34888. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34889. /**
  34890. * Force the value of meshUnderPointer
  34891. * @param mesh defines the mesh to use
  34892. */
  34893. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34894. /**
  34895. * Gets the mesh under the pointer
  34896. * @returns a Mesh or null if no mesh is under the pointer
  34897. */
  34898. getPointerOverMesh(): Nullable<AbstractMesh>;
  34899. /** @hidden */
  34900. _rebuildGeometries(): void;
  34901. /** @hidden */
  34902. _rebuildTextures(): void;
  34903. private _getByTags;
  34904. /**
  34905. * Get a list of meshes by tags
  34906. * @param tagsQuery defines the tags query to use
  34907. * @param forEach defines a predicate used to filter results
  34908. * @returns an array of Mesh
  34909. */
  34910. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34911. /**
  34912. * Get a list of cameras by tags
  34913. * @param tagsQuery defines the tags query to use
  34914. * @param forEach defines a predicate used to filter results
  34915. * @returns an array of Camera
  34916. */
  34917. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34918. /**
  34919. * Get a list of lights by tags
  34920. * @param tagsQuery defines the tags query to use
  34921. * @param forEach defines a predicate used to filter results
  34922. * @returns an array of Light
  34923. */
  34924. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34925. /**
  34926. * Get a list of materials by tags
  34927. * @param tagsQuery defines the tags query to use
  34928. * @param forEach defines a predicate used to filter results
  34929. * @returns an array of Material
  34930. */
  34931. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34932. /**
  34933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34934. * This allowed control for front to back rendering or reversly depending of the special needs.
  34935. *
  34936. * @param renderingGroupId The rendering group id corresponding to its index
  34937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34940. */
  34941. 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;
  34942. /**
  34943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34944. *
  34945. * @param renderingGroupId The rendering group id corresponding to its index
  34946. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34947. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34948. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34949. */
  34950. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34951. /**
  34952. * Gets the current auto clear configuration for one rendering group of the rendering
  34953. * manager.
  34954. * @param index the rendering group index to get the information for
  34955. * @returns The auto clear setup for the requested rendering group
  34956. */
  34957. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34958. private _blockMaterialDirtyMechanism;
  34959. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34960. blockMaterialDirtyMechanism: boolean;
  34961. /**
  34962. * Will flag all materials as dirty to trigger new shader compilation
  34963. * @param flag defines the flag used to specify which material part must be marked as dirty
  34964. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34965. */
  34966. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34967. /** @hidden */
  34968. _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;
  34969. /** @hidden */
  34970. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34971. /** @hidden */
  34972. _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;
  34973. /** @hidden */
  34974. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34975. /** @hidden */
  34976. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34977. /** @hidden */
  34978. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34979. }
  34980. }
  34981. declare module BABYLON {
  34982. /**
  34983. * Set of assets to keep when moving a scene into an asset container.
  34984. */
  34985. export class KeepAssets extends AbstractScene {
  34986. }
  34987. /**
  34988. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  34989. */
  34990. export class InstantiatedEntries {
  34991. /**
  34992. * List of new root nodes (eg. nodes with no parent)
  34993. */
  34994. rootNodes: TransformNode[];
  34995. /**
  34996. * List of new skeletons
  34997. */
  34998. skeletons: Skeleton[];
  34999. /**
  35000. * List of new animation groups
  35001. */
  35002. animationGroups: AnimationGroup[];
  35003. }
  35004. /**
  35005. * Container with a set of assets that can be added or removed from a scene.
  35006. */
  35007. export class AssetContainer extends AbstractScene {
  35008. /**
  35009. * The scene the AssetContainer belongs to.
  35010. */
  35011. scene: Scene;
  35012. /**
  35013. * Instantiates an AssetContainer.
  35014. * @param scene The scene the AssetContainer belongs to.
  35015. */
  35016. constructor(scene: Scene);
  35017. /**
  35018. * Instantiate or clone all meshes and add the new ones to the scene.
  35019. * Skeletons and animation groups will all be cloned
  35020. * @param nameFunction defines an optional function used to get new names for clones
  35021. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35022. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35023. */
  35024. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35025. /**
  35026. * Adds all the assets from the container to the scene.
  35027. */
  35028. addAllToScene(): void;
  35029. /**
  35030. * Removes all the assets in the container from the scene
  35031. */
  35032. removeAllFromScene(): void;
  35033. /**
  35034. * Disposes all the assets in the container
  35035. */
  35036. dispose(): void;
  35037. private _moveAssets;
  35038. /**
  35039. * Removes all the assets contained in the scene and adds them to the container.
  35040. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35041. */
  35042. moveAllFromScene(keepAssets?: KeepAssets): void;
  35043. /**
  35044. * 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.
  35045. * @returns the root mesh
  35046. */
  35047. createRootMesh(): Mesh;
  35048. }
  35049. }
  35050. declare module BABYLON {
  35051. /**
  35052. * Defines how the parser contract is defined.
  35053. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35054. */
  35055. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35056. /**
  35057. * Defines how the individual parser contract is defined.
  35058. * These parser can parse an individual asset
  35059. */
  35060. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35061. /**
  35062. * Base class of the scene acting as a container for the different elements composing a scene.
  35063. * This class is dynamically extended by the different components of the scene increasing
  35064. * flexibility and reducing coupling
  35065. */
  35066. export abstract class AbstractScene {
  35067. /**
  35068. * Stores the list of available parsers in the application.
  35069. */
  35070. private static _BabylonFileParsers;
  35071. /**
  35072. * Stores the list of available individual parsers in the application.
  35073. */
  35074. private static _IndividualBabylonFileParsers;
  35075. /**
  35076. * Adds a parser in the list of available ones
  35077. * @param name Defines the name of the parser
  35078. * @param parser Defines the parser to add
  35079. */
  35080. static AddParser(name: string, parser: BabylonFileParser): void;
  35081. /**
  35082. * Gets a general parser from the list of avaialble ones
  35083. * @param name Defines the name of the parser
  35084. * @returns the requested parser or null
  35085. */
  35086. static GetParser(name: string): Nullable<BabylonFileParser>;
  35087. /**
  35088. * Adds n individual parser in the list of available ones
  35089. * @param name Defines the name of the parser
  35090. * @param parser Defines the parser to add
  35091. */
  35092. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35093. /**
  35094. * Gets an individual parser from the list of avaialble ones
  35095. * @param name Defines the name of the parser
  35096. * @returns the requested parser or null
  35097. */
  35098. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35099. /**
  35100. * Parser json data and populate both a scene and its associated container object
  35101. * @param jsonData Defines the data to parse
  35102. * @param scene Defines the scene to parse the data for
  35103. * @param container Defines the container attached to the parsing sequence
  35104. * @param rootUrl Defines the root url of the data
  35105. */
  35106. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35107. /**
  35108. * Gets the list of root nodes (ie. nodes with no parent)
  35109. */
  35110. rootNodes: Node[];
  35111. /** All of the cameras added to this scene
  35112. * @see http://doc.babylonjs.com/babylon101/cameras
  35113. */
  35114. cameras: Camera[];
  35115. /**
  35116. * All of the lights added to this scene
  35117. * @see http://doc.babylonjs.com/babylon101/lights
  35118. */
  35119. lights: Light[];
  35120. /**
  35121. * All of the (abstract) meshes added to this scene
  35122. */
  35123. meshes: AbstractMesh[];
  35124. /**
  35125. * The list of skeletons added to the scene
  35126. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35127. */
  35128. skeletons: Skeleton[];
  35129. /**
  35130. * All of the particle systems added to this scene
  35131. * @see http://doc.babylonjs.com/babylon101/particles
  35132. */
  35133. particleSystems: IParticleSystem[];
  35134. /**
  35135. * Gets a list of Animations associated with the scene
  35136. */
  35137. animations: Animation[];
  35138. /**
  35139. * All of the animation groups added to this scene
  35140. * @see http://doc.babylonjs.com/how_to/group
  35141. */
  35142. animationGroups: AnimationGroup[];
  35143. /**
  35144. * All of the multi-materials added to this scene
  35145. * @see http://doc.babylonjs.com/how_to/multi_materials
  35146. */
  35147. multiMaterials: MultiMaterial[];
  35148. /**
  35149. * All of the materials added to this scene
  35150. * In the context of a Scene, it is not supposed to be modified manually.
  35151. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35152. * Note also that the order of the Material within the array is not significant and might change.
  35153. * @see http://doc.babylonjs.com/babylon101/materials
  35154. */
  35155. materials: Material[];
  35156. /**
  35157. * The list of morph target managers added to the scene
  35158. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35159. */
  35160. morphTargetManagers: MorphTargetManager[];
  35161. /**
  35162. * The list of geometries used in the scene.
  35163. */
  35164. geometries: Geometry[];
  35165. /**
  35166. * All of the tranform nodes added to this scene
  35167. * In the context of a Scene, it is not supposed to be modified manually.
  35168. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35169. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35170. * @see http://doc.babylonjs.com/how_to/transformnode
  35171. */
  35172. transformNodes: TransformNode[];
  35173. /**
  35174. * ActionManagers available on the scene.
  35175. */
  35176. actionManagers: AbstractActionManager[];
  35177. /**
  35178. * Textures to keep.
  35179. */
  35180. textures: BaseTexture[];
  35181. /**
  35182. * Environment texture for the scene
  35183. */
  35184. environmentTexture: Nullable<BaseTexture>;
  35185. }
  35186. }
  35187. declare module BABYLON {
  35188. /**
  35189. * Interface used to define options for Sound class
  35190. */
  35191. export interface ISoundOptions {
  35192. /**
  35193. * Does the sound autoplay once loaded.
  35194. */
  35195. autoplay?: boolean;
  35196. /**
  35197. * Does the sound loop after it finishes playing once.
  35198. */
  35199. loop?: boolean;
  35200. /**
  35201. * Sound's volume
  35202. */
  35203. volume?: number;
  35204. /**
  35205. * Is it a spatial sound?
  35206. */
  35207. spatialSound?: boolean;
  35208. /**
  35209. * Maximum distance to hear that sound
  35210. */
  35211. maxDistance?: number;
  35212. /**
  35213. * Uses user defined attenuation function
  35214. */
  35215. useCustomAttenuation?: boolean;
  35216. /**
  35217. * Define the roll off factor of spatial sounds.
  35218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35219. */
  35220. rolloffFactor?: number;
  35221. /**
  35222. * Define the reference distance the sound should be heard perfectly.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. refDistance?: number;
  35226. /**
  35227. * Define the distance attenuation model the sound will follow.
  35228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35229. */
  35230. distanceModel?: string;
  35231. /**
  35232. * Defines the playback speed (1 by default)
  35233. */
  35234. playbackRate?: number;
  35235. /**
  35236. * Defines if the sound is from a streaming source
  35237. */
  35238. streaming?: boolean;
  35239. /**
  35240. * Defines an optional length (in seconds) inside the sound file
  35241. */
  35242. length?: number;
  35243. /**
  35244. * Defines an optional offset (in seconds) inside the sound file
  35245. */
  35246. offset?: number;
  35247. /**
  35248. * If true, URLs will not be required to state the audio file codec to use.
  35249. */
  35250. skipCodecCheck?: boolean;
  35251. }
  35252. /**
  35253. * Defines a sound that can be played in the application.
  35254. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35256. */
  35257. export class Sound {
  35258. /**
  35259. * The name of the sound in the scene.
  35260. */
  35261. name: string;
  35262. /**
  35263. * Does the sound autoplay once loaded.
  35264. */
  35265. autoplay: boolean;
  35266. /**
  35267. * Does the sound loop after it finishes playing once.
  35268. */
  35269. loop: boolean;
  35270. /**
  35271. * Does the sound use a custom attenuation curve to simulate the falloff
  35272. * happening when the source gets further away from the camera.
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35274. */
  35275. useCustomAttenuation: boolean;
  35276. /**
  35277. * The sound track id this sound belongs to.
  35278. */
  35279. soundTrackId: number;
  35280. /**
  35281. * Is this sound currently played.
  35282. */
  35283. isPlaying: boolean;
  35284. /**
  35285. * Is this sound currently paused.
  35286. */
  35287. isPaused: boolean;
  35288. /**
  35289. * Does this sound enables spatial sound.
  35290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35291. */
  35292. spatialSound: boolean;
  35293. /**
  35294. * Define the reference distance the sound should be heard perfectly.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. refDistance: number;
  35298. /**
  35299. * Define the roll off factor of spatial sounds.
  35300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35301. */
  35302. rolloffFactor: number;
  35303. /**
  35304. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35306. */
  35307. maxDistance: number;
  35308. /**
  35309. * Define the distance attenuation model the sound will follow.
  35310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35311. */
  35312. distanceModel: string;
  35313. /**
  35314. * @hidden
  35315. * Back Compat
  35316. **/
  35317. onended: () => any;
  35318. /**
  35319. * Observable event when the current playing sound finishes.
  35320. */
  35321. onEndedObservable: Observable<Sound>;
  35322. private _panningModel;
  35323. private _playbackRate;
  35324. private _streaming;
  35325. private _startTime;
  35326. private _startOffset;
  35327. private _position;
  35328. /** @hidden */
  35329. _positionInEmitterSpace: boolean;
  35330. private _localDirection;
  35331. private _volume;
  35332. private _isReadyToPlay;
  35333. private _isDirectional;
  35334. private _readyToPlayCallback;
  35335. private _audioBuffer;
  35336. private _soundSource;
  35337. private _streamingSource;
  35338. private _soundPanner;
  35339. private _soundGain;
  35340. private _inputAudioNode;
  35341. private _outputAudioNode;
  35342. private _coneInnerAngle;
  35343. private _coneOuterAngle;
  35344. private _coneOuterGain;
  35345. private _scene;
  35346. private _connectedTransformNode;
  35347. private _customAttenuationFunction;
  35348. private _registerFunc;
  35349. private _isOutputConnected;
  35350. private _htmlAudioElement;
  35351. private _urlType;
  35352. private _length?;
  35353. private _offset?;
  35354. /** @hidden */
  35355. static _SceneComponentInitialization: (scene: Scene) => void;
  35356. /**
  35357. * Create a sound and attach it to a scene
  35358. * @param name Name of your sound
  35359. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35360. * @param scene defines the scene the sound belongs to
  35361. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35362. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35363. */
  35364. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35365. /**
  35366. * Release the sound and its associated resources
  35367. */
  35368. dispose(): void;
  35369. /**
  35370. * Gets if the sounds is ready to be played or not.
  35371. * @returns true if ready, otherwise false
  35372. */
  35373. isReady(): boolean;
  35374. private _soundLoaded;
  35375. /**
  35376. * Sets the data of the sound from an audiobuffer
  35377. * @param audioBuffer The audioBuffer containing the data
  35378. */
  35379. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35380. /**
  35381. * Updates the current sounds options such as maxdistance, loop...
  35382. * @param options A JSON object containing values named as the object properties
  35383. */
  35384. updateOptions(options: ISoundOptions): void;
  35385. private _createSpatialParameters;
  35386. private _updateSpatialParameters;
  35387. /**
  35388. * Switch the panning model to HRTF:
  35389. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35391. */
  35392. switchPanningModelToHRTF(): void;
  35393. /**
  35394. * Switch the panning model to Equal Power:
  35395. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35397. */
  35398. switchPanningModelToEqualPower(): void;
  35399. private _switchPanningModel;
  35400. /**
  35401. * Connect this sound to a sound track audio node like gain...
  35402. * @param soundTrackAudioNode the sound track audio node to connect to
  35403. */
  35404. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35405. /**
  35406. * Transform this sound into a directional source
  35407. * @param coneInnerAngle Size of the inner cone in degree
  35408. * @param coneOuterAngle Size of the outer cone in degree
  35409. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35410. */
  35411. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35412. /**
  35413. * Gets or sets the inner angle for the directional cone.
  35414. */
  35415. /**
  35416. * Gets or sets the inner angle for the directional cone.
  35417. */
  35418. directionalConeInnerAngle: number;
  35419. /**
  35420. * Gets or sets the outer angle for the directional cone.
  35421. */
  35422. /**
  35423. * Gets or sets the outer angle for the directional cone.
  35424. */
  35425. directionalConeOuterAngle: number;
  35426. /**
  35427. * Sets the position of the emitter if spatial sound is enabled
  35428. * @param newPosition Defines the new posisiton
  35429. */
  35430. setPosition(newPosition: Vector3): void;
  35431. /**
  35432. * Sets the local direction of the emitter if spatial sound is enabled
  35433. * @param newLocalDirection Defines the new local direction
  35434. */
  35435. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35436. private _updateDirection;
  35437. /** @hidden */
  35438. updateDistanceFromListener(): void;
  35439. /**
  35440. * Sets a new custom attenuation function for the sound.
  35441. * @param callback Defines the function used for the attenuation
  35442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35443. */
  35444. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35445. /**
  35446. * Play the sound
  35447. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35448. * @param offset (optional) Start the sound at a specific time in seconds
  35449. * @param length (optional) Sound duration (in seconds)
  35450. */
  35451. play(time?: number, offset?: number, length?: number): void;
  35452. private _onended;
  35453. /**
  35454. * Stop the sound
  35455. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35456. */
  35457. stop(time?: number): void;
  35458. /**
  35459. * Put the sound in pause
  35460. */
  35461. pause(): void;
  35462. /**
  35463. * Sets a dedicated volume for this sounds
  35464. * @param newVolume Define the new volume of the sound
  35465. * @param time Define time for gradual change to new volume
  35466. */
  35467. setVolume(newVolume: number, time?: number): void;
  35468. /**
  35469. * Set the sound play back rate
  35470. * @param newPlaybackRate Define the playback rate the sound should be played at
  35471. */
  35472. setPlaybackRate(newPlaybackRate: number): void;
  35473. /**
  35474. * Gets the volume of the sound.
  35475. * @returns the volume of the sound
  35476. */
  35477. getVolume(): number;
  35478. /**
  35479. * Attach the sound to a dedicated mesh
  35480. * @param transformNode The transform node to connect the sound with
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35482. */
  35483. attachToMesh(transformNode: TransformNode): void;
  35484. /**
  35485. * Detach the sound from the previously attached mesh
  35486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35487. */
  35488. detachFromMesh(): void;
  35489. private _onRegisterAfterWorldMatrixUpdate;
  35490. /**
  35491. * Clone the current sound in the scene.
  35492. * @returns the new sound clone
  35493. */
  35494. clone(): Nullable<Sound>;
  35495. /**
  35496. * Gets the current underlying audio buffer containing the data
  35497. * @returns the audio buffer
  35498. */
  35499. getAudioBuffer(): Nullable<AudioBuffer>;
  35500. /**
  35501. * Serializes the Sound in a JSON representation
  35502. * @returns the JSON representation of the sound
  35503. */
  35504. serialize(): any;
  35505. /**
  35506. * Parse a JSON representation of a sound to innstantiate in a given scene
  35507. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35508. * @param scene Define the scene the new parsed sound should be created in
  35509. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35510. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35511. * @returns the newly parsed sound
  35512. */
  35513. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35514. }
  35515. }
  35516. declare module BABYLON {
  35517. /**
  35518. * This defines an action helpful to play a defined sound on a triggered action.
  35519. */
  35520. export class PlaySoundAction extends Action {
  35521. private _sound;
  35522. /**
  35523. * Instantiate the action
  35524. * @param triggerOptions defines the trigger options
  35525. * @param sound defines the sound to play
  35526. * @param condition defines the trigger related conditions
  35527. */
  35528. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35529. /** @hidden */
  35530. _prepare(): void;
  35531. /**
  35532. * Execute the action and play the sound.
  35533. */
  35534. execute(): void;
  35535. /**
  35536. * Serializes the actions and its related information.
  35537. * @param parent defines the object to serialize in
  35538. * @returns the serialized object
  35539. */
  35540. serialize(parent: any): any;
  35541. }
  35542. /**
  35543. * This defines an action helpful to stop a defined sound on a triggered action.
  35544. */
  35545. export class StopSoundAction extends Action {
  35546. private _sound;
  35547. /**
  35548. * Instantiate the action
  35549. * @param triggerOptions defines the trigger options
  35550. * @param sound defines the sound to stop
  35551. * @param condition defines the trigger related conditions
  35552. */
  35553. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35554. /** @hidden */
  35555. _prepare(): void;
  35556. /**
  35557. * Execute the action and stop the sound.
  35558. */
  35559. execute(): void;
  35560. /**
  35561. * Serializes the actions and its related information.
  35562. * @param parent defines the object to serialize in
  35563. * @returns the serialized object
  35564. */
  35565. serialize(parent: any): any;
  35566. }
  35567. }
  35568. declare module BABYLON {
  35569. /**
  35570. * This defines an action responsible to change the value of a property
  35571. * by interpolating between its current value and the newly set one once triggered.
  35572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35573. */
  35574. export class InterpolateValueAction extends Action {
  35575. /**
  35576. * Defines the path of the property where the value should be interpolated
  35577. */
  35578. propertyPath: string;
  35579. /**
  35580. * Defines the target value at the end of the interpolation.
  35581. */
  35582. value: any;
  35583. /**
  35584. * Defines the time it will take for the property to interpolate to the value.
  35585. */
  35586. duration: number;
  35587. /**
  35588. * Defines if the other scene animations should be stopped when the action has been triggered
  35589. */
  35590. stopOtherAnimations?: boolean;
  35591. /**
  35592. * Defines a callback raised once the interpolation animation has been done.
  35593. */
  35594. onInterpolationDone?: () => void;
  35595. /**
  35596. * Observable triggered once the interpolation animation has been done.
  35597. */
  35598. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35599. private _target;
  35600. private _effectiveTarget;
  35601. private _property;
  35602. /**
  35603. * Instantiate the action
  35604. * @param triggerOptions defines the trigger options
  35605. * @param target defines the object containing the value to interpolate
  35606. * @param propertyPath defines the path to the property in the target object
  35607. * @param value defines the target value at the end of the interpolation
  35608. * @param duration deines the time it will take for the property to interpolate to the value.
  35609. * @param condition defines the trigger related conditions
  35610. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35611. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35612. */
  35613. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35614. /** @hidden */
  35615. _prepare(): void;
  35616. /**
  35617. * Execute the action starts the value interpolation.
  35618. */
  35619. execute(): void;
  35620. /**
  35621. * Serializes the actions and its related information.
  35622. * @param parent defines the object to serialize in
  35623. * @returns the serialized object
  35624. */
  35625. serialize(parent: any): any;
  35626. }
  35627. }
  35628. declare module BABYLON {
  35629. /**
  35630. * Options allowed during the creation of a sound track.
  35631. */
  35632. export interface ISoundTrackOptions {
  35633. /**
  35634. * The volume the sound track should take during creation
  35635. */
  35636. volume?: number;
  35637. /**
  35638. * Define if the sound track is the main sound track of the scene
  35639. */
  35640. mainTrack?: boolean;
  35641. }
  35642. /**
  35643. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35644. * It will be also used in a future release to apply effects on a specific track.
  35645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35646. */
  35647. export class SoundTrack {
  35648. /**
  35649. * The unique identifier of the sound track in the scene.
  35650. */
  35651. id: number;
  35652. /**
  35653. * The list of sounds included in the sound track.
  35654. */
  35655. soundCollection: Array<Sound>;
  35656. private _outputAudioNode;
  35657. private _scene;
  35658. private _isMainTrack;
  35659. private _connectedAnalyser;
  35660. private _options;
  35661. private _isInitialized;
  35662. /**
  35663. * Creates a new sound track.
  35664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35665. * @param scene Define the scene the sound track belongs to
  35666. * @param options
  35667. */
  35668. constructor(scene: Scene, options?: ISoundTrackOptions);
  35669. private _initializeSoundTrackAudioGraph;
  35670. /**
  35671. * Release the sound track and its associated resources
  35672. */
  35673. dispose(): void;
  35674. /**
  35675. * Adds a sound to this sound track
  35676. * @param sound define the cound to add
  35677. * @ignoreNaming
  35678. */
  35679. AddSound(sound: Sound): void;
  35680. /**
  35681. * Removes a sound to this sound track
  35682. * @param sound define the cound to remove
  35683. * @ignoreNaming
  35684. */
  35685. RemoveSound(sound: Sound): void;
  35686. /**
  35687. * Set a global volume for the full sound track.
  35688. * @param newVolume Define the new volume of the sound track
  35689. */
  35690. setVolume(newVolume: number): void;
  35691. /**
  35692. * Switch the panning model to HRTF:
  35693. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35695. */
  35696. switchPanningModelToHRTF(): void;
  35697. /**
  35698. * Switch the panning model to Equal Power:
  35699. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35701. */
  35702. switchPanningModelToEqualPower(): void;
  35703. /**
  35704. * Connect the sound track to an audio analyser allowing some amazing
  35705. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35707. * @param analyser The analyser to connect to the engine
  35708. */
  35709. connectToAnalyser(analyser: Analyser): void;
  35710. }
  35711. }
  35712. declare module BABYLON {
  35713. interface AbstractScene {
  35714. /**
  35715. * The list of sounds used in the scene.
  35716. */
  35717. sounds: Nullable<Array<Sound>>;
  35718. }
  35719. interface Scene {
  35720. /**
  35721. * @hidden
  35722. * Backing field
  35723. */
  35724. _mainSoundTrack: SoundTrack;
  35725. /**
  35726. * The main sound track played by the scene.
  35727. * It cotains your primary collection of sounds.
  35728. */
  35729. mainSoundTrack: SoundTrack;
  35730. /**
  35731. * The list of sound tracks added to the scene
  35732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35733. */
  35734. soundTracks: Nullable<Array<SoundTrack>>;
  35735. /**
  35736. * Gets a sound using a given name
  35737. * @param name defines the name to search for
  35738. * @return the found sound or null if not found at all.
  35739. */
  35740. getSoundByName(name: string): Nullable<Sound>;
  35741. /**
  35742. * Gets or sets if audio support is enabled
  35743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35744. */
  35745. audioEnabled: boolean;
  35746. /**
  35747. * Gets or sets if audio will be output to headphones
  35748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35749. */
  35750. headphone: boolean;
  35751. /**
  35752. * Gets or sets custom audio listener position provider
  35753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35754. */
  35755. audioListenerPositionProvider: Nullable<() => Vector3>;
  35756. /**
  35757. * Gets or sets a refresh rate when using 3D audio positioning
  35758. */
  35759. audioPositioningRefreshRate: number;
  35760. }
  35761. /**
  35762. * Defines the sound scene component responsible to manage any sounds
  35763. * in a given scene.
  35764. */
  35765. export class AudioSceneComponent implements ISceneSerializableComponent {
  35766. /**
  35767. * The component name helpfull to identify the component in the list of scene components.
  35768. */
  35769. readonly name: string;
  35770. /**
  35771. * The scene the component belongs to.
  35772. */
  35773. scene: Scene;
  35774. private _audioEnabled;
  35775. /**
  35776. * Gets whether audio is enabled or not.
  35777. * Please use related enable/disable method to switch state.
  35778. */
  35779. readonly audioEnabled: boolean;
  35780. private _headphone;
  35781. /**
  35782. * Gets whether audio is outputing to headphone or not.
  35783. * Please use the according Switch methods to change output.
  35784. */
  35785. readonly headphone: boolean;
  35786. /**
  35787. * Gets or sets a refresh rate when using 3D audio positioning
  35788. */
  35789. audioPositioningRefreshRate: number;
  35790. private _audioListenerPositionProvider;
  35791. /**
  35792. * Gets the current audio listener position provider
  35793. */
  35794. /**
  35795. * Sets a custom listener position for all sounds in the scene
  35796. * By default, this is the position of the first active camera
  35797. */
  35798. audioListenerPositionProvider: Nullable<() => Vector3>;
  35799. /**
  35800. * Creates a new instance of the component for the given scene
  35801. * @param scene Defines the scene to register the component in
  35802. */
  35803. constructor(scene: Scene);
  35804. /**
  35805. * Registers the component in a given scene
  35806. */
  35807. register(): void;
  35808. /**
  35809. * Rebuilds the elements related to this component in case of
  35810. * context lost for instance.
  35811. */
  35812. rebuild(): void;
  35813. /**
  35814. * Serializes the component data to the specified json object
  35815. * @param serializationObject The object to serialize to
  35816. */
  35817. serialize(serializationObject: any): void;
  35818. /**
  35819. * Adds all the elements from the container to the scene
  35820. * @param container the container holding the elements
  35821. */
  35822. addFromContainer(container: AbstractScene): void;
  35823. /**
  35824. * Removes all the elements in the container from the scene
  35825. * @param container contains the elements to remove
  35826. * @param dispose if the removed element should be disposed (default: false)
  35827. */
  35828. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35829. /**
  35830. * Disposes the component and the associated ressources.
  35831. */
  35832. dispose(): void;
  35833. /**
  35834. * Disables audio in the associated scene.
  35835. */
  35836. disableAudio(): void;
  35837. /**
  35838. * Enables audio in the associated scene.
  35839. */
  35840. enableAudio(): void;
  35841. /**
  35842. * Switch audio to headphone output.
  35843. */
  35844. switchAudioModeForHeadphones(): void;
  35845. /**
  35846. * Switch audio to normal speakers.
  35847. */
  35848. switchAudioModeForNormalSpeakers(): void;
  35849. private _cachedCameraDirection;
  35850. private _cachedCameraPosition;
  35851. private _lastCheck;
  35852. private _afterRender;
  35853. }
  35854. }
  35855. declare module BABYLON {
  35856. /**
  35857. * Wraps one or more Sound objects and selects one with random weight for playback.
  35858. */
  35859. export class WeightedSound {
  35860. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35861. loop: boolean;
  35862. private _coneInnerAngle;
  35863. private _coneOuterAngle;
  35864. private _volume;
  35865. /** A Sound is currently playing. */
  35866. isPlaying: boolean;
  35867. /** A Sound is currently paused. */
  35868. isPaused: boolean;
  35869. private _sounds;
  35870. private _weights;
  35871. private _currentIndex?;
  35872. /**
  35873. * Creates a new WeightedSound from the list of sounds given.
  35874. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35875. * @param sounds Array of Sounds that will be selected from.
  35876. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35877. */
  35878. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35879. /**
  35880. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35881. */
  35882. /**
  35883. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35884. */
  35885. directionalConeInnerAngle: number;
  35886. /**
  35887. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35888. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35889. */
  35890. /**
  35891. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35892. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35893. */
  35894. directionalConeOuterAngle: number;
  35895. /**
  35896. * Playback volume.
  35897. */
  35898. /**
  35899. * Playback volume.
  35900. */
  35901. volume: number;
  35902. private _onended;
  35903. /**
  35904. * Suspend playback
  35905. */
  35906. pause(): void;
  35907. /**
  35908. * Stop playback
  35909. */
  35910. stop(): void;
  35911. /**
  35912. * Start playback.
  35913. * @param startOffset Position the clip head at a specific time in seconds.
  35914. */
  35915. play(startOffset?: number): void;
  35916. }
  35917. }
  35918. declare module BABYLON {
  35919. /**
  35920. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35922. */
  35923. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35924. /**
  35925. * Gets the name of the behavior.
  35926. */
  35927. readonly name: string;
  35928. /**
  35929. * The easing function used by animations
  35930. */
  35931. static EasingFunction: BackEase;
  35932. /**
  35933. * The easing mode used by animations
  35934. */
  35935. static EasingMode: number;
  35936. /**
  35937. * The duration of the animation, in milliseconds
  35938. */
  35939. transitionDuration: number;
  35940. /**
  35941. * Length of the distance animated by the transition when lower radius is reached
  35942. */
  35943. lowerRadiusTransitionRange: number;
  35944. /**
  35945. * Length of the distance animated by the transition when upper radius is reached
  35946. */
  35947. upperRadiusTransitionRange: number;
  35948. private _autoTransitionRange;
  35949. /**
  35950. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35951. */
  35952. /**
  35953. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35954. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35955. */
  35956. autoTransitionRange: boolean;
  35957. private _attachedCamera;
  35958. private _onAfterCheckInputsObserver;
  35959. private _onMeshTargetChangedObserver;
  35960. /**
  35961. * Initializes the behavior.
  35962. */
  35963. init(): void;
  35964. /**
  35965. * Attaches the behavior to its arc rotate camera.
  35966. * @param camera Defines the camera to attach the behavior to
  35967. */
  35968. attach(camera: ArcRotateCamera): void;
  35969. /**
  35970. * Detaches the behavior from its current arc rotate camera.
  35971. */
  35972. detach(): void;
  35973. private _radiusIsAnimating;
  35974. private _radiusBounceTransition;
  35975. private _animatables;
  35976. private _cachedWheelPrecision;
  35977. /**
  35978. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35979. * @param radiusLimit The limit to check against.
  35980. * @return Bool to indicate if at limit.
  35981. */
  35982. private _isRadiusAtLimit;
  35983. /**
  35984. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35985. * @param radiusDelta The delta by which to animate to. Can be negative.
  35986. */
  35987. private _applyBoundRadiusAnimation;
  35988. /**
  35989. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35990. */
  35991. protected _clearAnimationLocks(): void;
  35992. /**
  35993. * Stops and removes all animations that have been applied to the camera
  35994. */
  35995. stopAllAnimations(): void;
  35996. }
  35997. }
  35998. declare module BABYLON {
  35999. /**
  36000. * 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.
  36001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36002. */
  36003. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36004. /**
  36005. * Gets the name of the behavior.
  36006. */
  36007. readonly name: string;
  36008. private _mode;
  36009. private _radiusScale;
  36010. private _positionScale;
  36011. private _defaultElevation;
  36012. private _elevationReturnTime;
  36013. private _elevationReturnWaitTime;
  36014. private _zoomStopsAnimation;
  36015. private _framingTime;
  36016. /**
  36017. * The easing function used by animations
  36018. */
  36019. static EasingFunction: ExponentialEase;
  36020. /**
  36021. * The easing mode used by animations
  36022. */
  36023. static EasingMode: number;
  36024. /**
  36025. * Sets the current mode used by the behavior
  36026. */
  36027. /**
  36028. * Gets current mode used by the behavior.
  36029. */
  36030. mode: number;
  36031. /**
  36032. * Sets the scale applied to the radius (1 by default)
  36033. */
  36034. /**
  36035. * Gets the scale applied to the radius
  36036. */
  36037. radiusScale: number;
  36038. /**
  36039. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36040. */
  36041. /**
  36042. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36043. */
  36044. positionScale: number;
  36045. /**
  36046. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36047. * behaviour is triggered, in radians.
  36048. */
  36049. /**
  36050. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36051. * behaviour is triggered, in radians.
  36052. */
  36053. defaultElevation: number;
  36054. /**
  36055. * Sets the time (in milliseconds) taken to return to the default beta position.
  36056. * Negative value indicates camera should not return to default.
  36057. */
  36058. /**
  36059. * Gets the time (in milliseconds) taken to return to the default beta position.
  36060. * Negative value indicates camera should not return to default.
  36061. */
  36062. elevationReturnTime: number;
  36063. /**
  36064. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36065. */
  36066. /**
  36067. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36068. */
  36069. elevationReturnWaitTime: number;
  36070. /**
  36071. * Sets the flag that indicates if user zooming should stop animation.
  36072. */
  36073. /**
  36074. * Gets the flag that indicates if user zooming should stop animation.
  36075. */
  36076. zoomStopsAnimation: boolean;
  36077. /**
  36078. * Sets the transition time when framing the mesh, in milliseconds
  36079. */
  36080. /**
  36081. * Gets the transition time when framing the mesh, in milliseconds
  36082. */
  36083. framingTime: number;
  36084. /**
  36085. * Define if the behavior should automatically change the configured
  36086. * camera limits and sensibilities.
  36087. */
  36088. autoCorrectCameraLimitsAndSensibility: boolean;
  36089. private _onPrePointerObservableObserver;
  36090. private _onAfterCheckInputsObserver;
  36091. private _onMeshTargetChangedObserver;
  36092. private _attachedCamera;
  36093. private _isPointerDown;
  36094. private _lastInteractionTime;
  36095. /**
  36096. * Initializes the behavior.
  36097. */
  36098. init(): void;
  36099. /**
  36100. * Attaches the behavior to its arc rotate camera.
  36101. * @param camera Defines the camera to attach the behavior to
  36102. */
  36103. attach(camera: ArcRotateCamera): void;
  36104. /**
  36105. * Detaches the behavior from its current arc rotate camera.
  36106. */
  36107. detach(): void;
  36108. private _animatables;
  36109. private _betaIsAnimating;
  36110. private _betaTransition;
  36111. private _radiusTransition;
  36112. private _vectorTransition;
  36113. /**
  36114. * Targets the given mesh and updates zoom level accordingly.
  36115. * @param mesh The mesh to target.
  36116. * @param radius Optional. If a cached radius position already exists, overrides default.
  36117. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36118. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36119. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36120. */
  36121. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36122. /**
  36123. * Targets the given mesh with its children and updates zoom level accordingly.
  36124. * @param mesh The mesh to target.
  36125. * @param radius Optional. If a cached radius position already exists, overrides default.
  36126. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36127. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36128. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36129. */
  36130. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36131. /**
  36132. * Targets the given meshes with their children and updates zoom level accordingly.
  36133. * @param meshes The mesh to target.
  36134. * @param radius Optional. If a cached radius position already exists, overrides default.
  36135. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36138. */
  36139. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36140. /**
  36141. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36142. * @param minimumWorld Determines the smaller position of the bounding box extend
  36143. * @param maximumWorld Determines the bigger position of the bounding box extend
  36144. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36145. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36146. */
  36147. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36148. /**
  36149. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36150. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36151. * frustum width.
  36152. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36153. * to fully enclose the mesh in the viewing frustum.
  36154. */
  36155. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36156. /**
  36157. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36158. * is automatically returned to its default position (expected to be above ground plane).
  36159. */
  36160. private _maintainCameraAboveGround;
  36161. /**
  36162. * Returns the frustum slope based on the canvas ratio and camera FOV
  36163. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36164. */
  36165. private _getFrustumSlope;
  36166. /**
  36167. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36168. */
  36169. private _clearAnimationLocks;
  36170. /**
  36171. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36172. */
  36173. private _applyUserInteraction;
  36174. /**
  36175. * Stops and removes all animations that have been applied to the camera
  36176. */
  36177. stopAllAnimations(): void;
  36178. /**
  36179. * Gets a value indicating if the user is moving the camera
  36180. */
  36181. readonly isUserIsMoving: boolean;
  36182. /**
  36183. * The camera can move all the way towards the mesh.
  36184. */
  36185. static IgnoreBoundsSizeMode: number;
  36186. /**
  36187. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36188. */
  36189. static FitFrustumSidesMode: number;
  36190. }
  36191. }
  36192. declare module BABYLON {
  36193. /**
  36194. * Base class for Camera Pointer Inputs.
  36195. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36196. * for example usage.
  36197. */
  36198. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36199. /**
  36200. * Defines the camera the input is attached to.
  36201. */
  36202. abstract camera: Camera;
  36203. /**
  36204. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36205. */
  36206. protected _altKey: boolean;
  36207. protected _ctrlKey: boolean;
  36208. protected _metaKey: boolean;
  36209. protected _shiftKey: boolean;
  36210. /**
  36211. * Which mouse buttons were pressed at time of last mouse event.
  36212. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36213. */
  36214. protected _buttonsPressed: number;
  36215. /**
  36216. * Defines the buttons associated with the input to handle camera move.
  36217. */
  36218. buttons: number[];
  36219. /**
  36220. * Attach the input controls to a specific dom element to get the input from.
  36221. * @param element Defines the element the controls should be listened from
  36222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36223. */
  36224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36225. /**
  36226. * Detach the current controls from the specified dom element.
  36227. * @param element Defines the element to stop listening the inputs from
  36228. */
  36229. detachControl(element: Nullable<HTMLElement>): void;
  36230. /**
  36231. * Gets the class name of the current input.
  36232. * @returns the class name
  36233. */
  36234. getClassName(): string;
  36235. /**
  36236. * Get the friendly name associated with the input class.
  36237. * @returns the input friendly name
  36238. */
  36239. getSimpleName(): string;
  36240. /**
  36241. * Called on pointer POINTERDOUBLETAP event.
  36242. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36243. */
  36244. protected onDoubleTap(type: string): void;
  36245. /**
  36246. * Called on pointer POINTERMOVE event if only a single touch is active.
  36247. * Override this method to provide functionality.
  36248. */
  36249. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36250. /**
  36251. * Called on pointer POINTERMOVE event if multiple touches are active.
  36252. * Override this method to provide functionality.
  36253. */
  36254. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36255. /**
  36256. * Called on JS contextmenu event.
  36257. * Override this method to provide functionality.
  36258. */
  36259. protected onContextMenu(evt: PointerEvent): void;
  36260. /**
  36261. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36262. * press.
  36263. * Override this method to provide functionality.
  36264. */
  36265. protected onButtonDown(evt: PointerEvent): void;
  36266. /**
  36267. * Called each time a new POINTERUP event occurs. Ie, for each button
  36268. * release.
  36269. * Override this method to provide functionality.
  36270. */
  36271. protected onButtonUp(evt: PointerEvent): void;
  36272. /**
  36273. * Called when window becomes inactive.
  36274. * Override this method to provide functionality.
  36275. */
  36276. protected onLostFocus(): void;
  36277. private _pointerInput;
  36278. private _observer;
  36279. private _onLostFocus;
  36280. private pointA;
  36281. private pointB;
  36282. }
  36283. }
  36284. declare module BABYLON {
  36285. /**
  36286. * Manage the pointers inputs to control an arc rotate camera.
  36287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36288. */
  36289. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36290. /**
  36291. * Defines the camera the input is attached to.
  36292. */
  36293. camera: ArcRotateCamera;
  36294. /**
  36295. * Gets the class name of the current input.
  36296. * @returns the class name
  36297. */
  36298. getClassName(): string;
  36299. /**
  36300. * Defines the buttons associated with the input to handle camera move.
  36301. */
  36302. buttons: number[];
  36303. /**
  36304. * Defines the pointer angular sensibility along the X axis or how fast is
  36305. * the camera rotating.
  36306. */
  36307. angularSensibilityX: number;
  36308. /**
  36309. * Defines the pointer angular sensibility along the Y axis or how fast is
  36310. * the camera rotating.
  36311. */
  36312. angularSensibilityY: number;
  36313. /**
  36314. * Defines the pointer pinch precision or how fast is the camera zooming.
  36315. */
  36316. pinchPrecision: number;
  36317. /**
  36318. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36319. * from 0.
  36320. * It defines the percentage of current camera.radius to use as delta when
  36321. * pinch zoom is used.
  36322. */
  36323. pinchDeltaPercentage: number;
  36324. /**
  36325. * Defines the pointer panning sensibility or how fast is the camera moving.
  36326. */
  36327. panningSensibility: number;
  36328. /**
  36329. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36330. */
  36331. multiTouchPanning: boolean;
  36332. /**
  36333. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36334. * zoom (pinch) through multitouch.
  36335. */
  36336. multiTouchPanAndZoom: boolean;
  36337. /**
  36338. * Revers pinch action direction.
  36339. */
  36340. pinchInwards: boolean;
  36341. private _isPanClick;
  36342. private _twoFingerActivityCount;
  36343. private _isPinching;
  36344. /**
  36345. * Called on pointer POINTERMOVE event if only a single touch is active.
  36346. */
  36347. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36348. /**
  36349. * Called on pointer POINTERDOUBLETAP event.
  36350. */
  36351. protected onDoubleTap(type: string): void;
  36352. /**
  36353. * Called on pointer POINTERMOVE event if multiple touches are active.
  36354. */
  36355. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36356. /**
  36357. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36358. * press.
  36359. */
  36360. protected onButtonDown(evt: PointerEvent): void;
  36361. /**
  36362. * Called each time a new POINTERUP event occurs. Ie, for each button
  36363. * release.
  36364. */
  36365. protected onButtonUp(evt: PointerEvent): void;
  36366. /**
  36367. * Called when window becomes inactive.
  36368. */
  36369. protected onLostFocus(): void;
  36370. }
  36371. }
  36372. declare module BABYLON {
  36373. /**
  36374. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36376. */
  36377. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36378. /**
  36379. * Defines the camera the input is attached to.
  36380. */
  36381. camera: ArcRotateCamera;
  36382. /**
  36383. * Defines the list of key codes associated with the up action (increase alpha)
  36384. */
  36385. keysUp: number[];
  36386. /**
  36387. * Defines the list of key codes associated with the down action (decrease alpha)
  36388. */
  36389. keysDown: number[];
  36390. /**
  36391. * Defines the list of key codes associated with the left action (increase beta)
  36392. */
  36393. keysLeft: number[];
  36394. /**
  36395. * Defines the list of key codes associated with the right action (decrease beta)
  36396. */
  36397. keysRight: number[];
  36398. /**
  36399. * Defines the list of key codes associated with the reset action.
  36400. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36401. */
  36402. keysReset: number[];
  36403. /**
  36404. * Defines the panning sensibility of the inputs.
  36405. * (How fast is the camera paning)
  36406. */
  36407. panningSensibility: number;
  36408. /**
  36409. * Defines the zooming sensibility of the inputs.
  36410. * (How fast is the camera zooming)
  36411. */
  36412. zoomingSensibility: number;
  36413. /**
  36414. * Defines wether maintaining the alt key down switch the movement mode from
  36415. * orientation to zoom.
  36416. */
  36417. useAltToZoom: boolean;
  36418. /**
  36419. * Rotation speed of the camera
  36420. */
  36421. angularSpeed: number;
  36422. private _keys;
  36423. private _ctrlPressed;
  36424. private _altPressed;
  36425. private _onCanvasBlurObserver;
  36426. private _onKeyboardObserver;
  36427. private _engine;
  36428. private _scene;
  36429. /**
  36430. * Attach the input controls to a specific dom element to get the input from.
  36431. * @param element Defines the element the controls should be listened from
  36432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36433. */
  36434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36435. /**
  36436. * Detach the current controls from the specified dom element.
  36437. * @param element Defines the element to stop listening the inputs from
  36438. */
  36439. detachControl(element: Nullable<HTMLElement>): void;
  36440. /**
  36441. * Update the current camera state depending on the inputs that have been used this frame.
  36442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36443. */
  36444. checkInputs(): void;
  36445. /**
  36446. * Gets the class name of the current intput.
  36447. * @returns the class name
  36448. */
  36449. getClassName(): string;
  36450. /**
  36451. * Get the friendly name associated with the input class.
  36452. * @returns the input friendly name
  36453. */
  36454. getSimpleName(): string;
  36455. }
  36456. }
  36457. declare module BABYLON {
  36458. /**
  36459. * Manage the mouse wheel inputs to control an arc rotate camera.
  36460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36461. */
  36462. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36463. /**
  36464. * Defines the camera the input is attached to.
  36465. */
  36466. camera: ArcRotateCamera;
  36467. /**
  36468. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36469. */
  36470. wheelPrecision: number;
  36471. /**
  36472. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36473. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36474. */
  36475. wheelDeltaPercentage: number;
  36476. private _wheel;
  36477. private _observer;
  36478. private computeDeltaFromMouseWheelLegacyEvent;
  36479. /**
  36480. * Attach the input controls to a specific dom element to get the input from.
  36481. * @param element Defines the element the controls should be listened from
  36482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36483. */
  36484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36485. /**
  36486. * Detach the current controls from the specified dom element.
  36487. * @param element Defines the element to stop listening the inputs from
  36488. */
  36489. detachControl(element: Nullable<HTMLElement>): void;
  36490. /**
  36491. * Gets the class name of the current intput.
  36492. * @returns the class name
  36493. */
  36494. getClassName(): string;
  36495. /**
  36496. * Get the friendly name associated with the input class.
  36497. * @returns the input friendly name
  36498. */
  36499. getSimpleName(): string;
  36500. }
  36501. }
  36502. declare module BABYLON {
  36503. /**
  36504. * Default Inputs manager for the ArcRotateCamera.
  36505. * It groups all the default supported inputs for ease of use.
  36506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36507. */
  36508. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36509. /**
  36510. * Instantiates a new ArcRotateCameraInputsManager.
  36511. * @param camera Defines the camera the inputs belong to
  36512. */
  36513. constructor(camera: ArcRotateCamera);
  36514. /**
  36515. * Add mouse wheel input support to the input manager.
  36516. * @returns the current input manager
  36517. */
  36518. addMouseWheel(): ArcRotateCameraInputsManager;
  36519. /**
  36520. * Add pointers input support to the input manager.
  36521. * @returns the current input manager
  36522. */
  36523. addPointers(): ArcRotateCameraInputsManager;
  36524. /**
  36525. * Add keyboard input support to the input manager.
  36526. * @returns the current input manager
  36527. */
  36528. addKeyboard(): ArcRotateCameraInputsManager;
  36529. }
  36530. }
  36531. declare module BABYLON {
  36532. /**
  36533. * This represents an orbital type of camera.
  36534. *
  36535. * 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.
  36536. * 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.
  36537. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36538. */
  36539. export class ArcRotateCamera extends TargetCamera {
  36540. /**
  36541. * Defines the rotation angle of the camera along the longitudinal axis.
  36542. */
  36543. alpha: number;
  36544. /**
  36545. * Defines the rotation angle of the camera along the latitudinal axis.
  36546. */
  36547. beta: number;
  36548. /**
  36549. * Defines the radius of the camera from it s target point.
  36550. */
  36551. radius: number;
  36552. protected _target: Vector3;
  36553. protected _targetHost: Nullable<AbstractMesh>;
  36554. /**
  36555. * Defines the target point of the camera.
  36556. * The camera looks towards it form the radius distance.
  36557. */
  36558. target: Vector3;
  36559. /**
  36560. * Define the current local position of the camera in the scene
  36561. */
  36562. position: Vector3;
  36563. protected _upVector: Vector3;
  36564. protected _upToYMatrix: Matrix;
  36565. protected _YToUpMatrix: Matrix;
  36566. /**
  36567. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36568. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36569. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36570. */
  36571. upVector: Vector3;
  36572. /**
  36573. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36574. */
  36575. setMatUp(): void;
  36576. /**
  36577. * Current inertia value on the longitudinal axis.
  36578. * The bigger this number the longer it will take for the camera to stop.
  36579. */
  36580. inertialAlphaOffset: number;
  36581. /**
  36582. * Current inertia value on the latitudinal axis.
  36583. * The bigger this number the longer it will take for the camera to stop.
  36584. */
  36585. inertialBetaOffset: number;
  36586. /**
  36587. * Current inertia value on the radius axis.
  36588. * The bigger this number the longer it will take for the camera to stop.
  36589. */
  36590. inertialRadiusOffset: number;
  36591. /**
  36592. * Minimum allowed angle on the longitudinal axis.
  36593. * This can help limiting how the Camera is able to move in the scene.
  36594. */
  36595. lowerAlphaLimit: Nullable<number>;
  36596. /**
  36597. * Maximum allowed angle on the longitudinal axis.
  36598. * This can help limiting how the Camera is able to move in the scene.
  36599. */
  36600. upperAlphaLimit: Nullable<number>;
  36601. /**
  36602. * Minimum allowed angle on the latitudinal axis.
  36603. * This can help limiting how the Camera is able to move in the scene.
  36604. */
  36605. lowerBetaLimit: number;
  36606. /**
  36607. * Maximum allowed angle on the latitudinal axis.
  36608. * This can help limiting how the Camera is able to move in the scene.
  36609. */
  36610. upperBetaLimit: number;
  36611. /**
  36612. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36613. * This can help limiting how the Camera is able to move in the scene.
  36614. */
  36615. lowerRadiusLimit: Nullable<number>;
  36616. /**
  36617. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36618. * This can help limiting how the Camera is able to move in the scene.
  36619. */
  36620. upperRadiusLimit: Nullable<number>;
  36621. /**
  36622. * Defines the current inertia value used during panning of the camera along the X axis.
  36623. */
  36624. inertialPanningX: number;
  36625. /**
  36626. * Defines the current inertia value used during panning of the camera along the Y axis.
  36627. */
  36628. inertialPanningY: number;
  36629. /**
  36630. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36631. * Basically if your fingers moves away from more than this distance you will be considered
  36632. * in pinch mode.
  36633. */
  36634. pinchToPanMaxDistance: number;
  36635. /**
  36636. * Defines the maximum distance the camera can pan.
  36637. * This could help keeping the cammera always in your scene.
  36638. */
  36639. panningDistanceLimit: Nullable<number>;
  36640. /**
  36641. * Defines the target of the camera before paning.
  36642. */
  36643. panningOriginTarget: Vector3;
  36644. /**
  36645. * Defines the value of the inertia used during panning.
  36646. * 0 would mean stop inertia and one would mean no decelleration at all.
  36647. */
  36648. panningInertia: number;
  36649. /**
  36650. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36651. */
  36652. angularSensibilityX: number;
  36653. /**
  36654. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36655. */
  36656. angularSensibilityY: number;
  36657. /**
  36658. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36659. */
  36660. pinchPrecision: number;
  36661. /**
  36662. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36663. * It will be used instead of pinchDeltaPrecision if different from 0.
  36664. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36665. */
  36666. pinchDeltaPercentage: number;
  36667. /**
  36668. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36669. */
  36670. panningSensibility: number;
  36671. /**
  36672. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36673. */
  36674. keysUp: number[];
  36675. /**
  36676. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36677. */
  36678. keysDown: number[];
  36679. /**
  36680. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36681. */
  36682. keysLeft: number[];
  36683. /**
  36684. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36685. */
  36686. keysRight: number[];
  36687. /**
  36688. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36689. */
  36690. wheelPrecision: number;
  36691. /**
  36692. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36693. * It will be used instead of pinchDeltaPrecision if different from 0.
  36694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36695. */
  36696. wheelDeltaPercentage: number;
  36697. /**
  36698. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36699. */
  36700. zoomOnFactor: number;
  36701. /**
  36702. * Defines a screen offset for the camera position.
  36703. */
  36704. targetScreenOffset: Vector2;
  36705. /**
  36706. * Allows the camera to be completely reversed.
  36707. * If false the camera can not arrive upside down.
  36708. */
  36709. allowUpsideDown: boolean;
  36710. /**
  36711. * Define if double tap/click is used to restore the previously saved state of the camera.
  36712. */
  36713. useInputToRestoreState: boolean;
  36714. /** @hidden */
  36715. _viewMatrix: Matrix;
  36716. /** @hidden */
  36717. _useCtrlForPanning: boolean;
  36718. /** @hidden */
  36719. _panningMouseButton: number;
  36720. /**
  36721. * Defines the input associated to the camera.
  36722. */
  36723. inputs: ArcRotateCameraInputsManager;
  36724. /** @hidden */
  36725. _reset: () => void;
  36726. /**
  36727. * Defines the allowed panning axis.
  36728. */
  36729. panningAxis: Vector3;
  36730. protected _localDirection: Vector3;
  36731. protected _transformedDirection: Vector3;
  36732. private _bouncingBehavior;
  36733. /**
  36734. * Gets the bouncing behavior of the camera if it has been enabled.
  36735. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36736. */
  36737. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36738. /**
  36739. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36741. */
  36742. useBouncingBehavior: boolean;
  36743. private _framingBehavior;
  36744. /**
  36745. * Gets the framing behavior of the camera if it has been enabled.
  36746. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36747. */
  36748. readonly framingBehavior: Nullable<FramingBehavior>;
  36749. /**
  36750. * Defines if the framing behavior of the camera is enabled on the camera.
  36751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36752. */
  36753. useFramingBehavior: boolean;
  36754. private _autoRotationBehavior;
  36755. /**
  36756. * Gets the auto rotation behavior of the camera if it has been enabled.
  36757. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36758. */
  36759. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36760. /**
  36761. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36762. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36763. */
  36764. useAutoRotationBehavior: boolean;
  36765. /**
  36766. * Observable triggered when the mesh target has been changed on the camera.
  36767. */
  36768. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36769. /**
  36770. * Event raised when the camera is colliding with a mesh.
  36771. */
  36772. onCollide: (collidedMesh: AbstractMesh) => void;
  36773. /**
  36774. * Defines whether the camera should check collision with the objects oh the scene.
  36775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36776. */
  36777. checkCollisions: boolean;
  36778. /**
  36779. * Defines the collision radius of the camera.
  36780. * This simulates a sphere around the camera.
  36781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36782. */
  36783. collisionRadius: Vector3;
  36784. protected _collider: Collider;
  36785. protected _previousPosition: Vector3;
  36786. protected _collisionVelocity: Vector3;
  36787. protected _newPosition: Vector3;
  36788. protected _previousAlpha: number;
  36789. protected _previousBeta: number;
  36790. protected _previousRadius: number;
  36791. protected _collisionTriggered: boolean;
  36792. protected _targetBoundingCenter: Nullable<Vector3>;
  36793. private _computationVector;
  36794. /**
  36795. * Instantiates a new ArcRotateCamera in a given scene
  36796. * @param name Defines the name of the camera
  36797. * @param alpha Defines the camera rotation along the logitudinal axis
  36798. * @param beta Defines the camera rotation along the latitudinal axis
  36799. * @param radius Defines the camera distance from its target
  36800. * @param target Defines the camera target
  36801. * @param scene Defines the scene the camera belongs to
  36802. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36803. */
  36804. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36805. /** @hidden */
  36806. _initCache(): void;
  36807. /** @hidden */
  36808. _updateCache(ignoreParentClass?: boolean): void;
  36809. protected _getTargetPosition(): Vector3;
  36810. private _storedAlpha;
  36811. private _storedBeta;
  36812. private _storedRadius;
  36813. private _storedTarget;
  36814. private _storedTargetScreenOffset;
  36815. /**
  36816. * Stores the current state of the camera (alpha, beta, radius and target)
  36817. * @returns the camera itself
  36818. */
  36819. storeState(): Camera;
  36820. /**
  36821. * @hidden
  36822. * Restored camera state. You must call storeState() first
  36823. */
  36824. _restoreStateValues(): boolean;
  36825. /** @hidden */
  36826. _isSynchronizedViewMatrix(): boolean;
  36827. /**
  36828. * Attached controls to the current camera.
  36829. * @param element Defines the element the controls should be listened from
  36830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36831. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36832. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36833. */
  36834. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36835. /**
  36836. * Detach the current controls from the camera.
  36837. * The camera will stop reacting to inputs.
  36838. * @param element Defines the element to stop listening the inputs from
  36839. */
  36840. detachControl(element: HTMLElement): void;
  36841. /** @hidden */
  36842. _checkInputs(): void;
  36843. protected _checkLimits(): void;
  36844. /**
  36845. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36846. */
  36847. rebuildAnglesAndRadius(): void;
  36848. /**
  36849. * Use a position to define the current camera related information like alpha, beta and radius
  36850. * @param position Defines the position to set the camera at
  36851. */
  36852. setPosition(position: Vector3): void;
  36853. /**
  36854. * Defines the target the camera should look at.
  36855. * This will automatically adapt alpha beta and radius to fit within the new target.
  36856. * @param target Defines the new target as a Vector or a mesh
  36857. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36858. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36859. */
  36860. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36861. /** @hidden */
  36862. _getViewMatrix(): Matrix;
  36863. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36864. /**
  36865. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36866. * @param meshes Defines the mesh to zoom on
  36867. * @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)
  36868. */
  36869. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36870. /**
  36871. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36872. * The target will be changed but the radius
  36873. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36874. * @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)
  36875. */
  36876. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36877. min: Vector3;
  36878. max: Vector3;
  36879. distance: number;
  36880. }, doNotUpdateMaxZ?: boolean): void;
  36881. /**
  36882. * @override
  36883. * Override Camera.createRigCamera
  36884. */
  36885. createRigCamera(name: string, cameraIndex: number): Camera;
  36886. /**
  36887. * @hidden
  36888. * @override
  36889. * Override Camera._updateRigCameras
  36890. */
  36891. _updateRigCameras(): void;
  36892. /**
  36893. * Destroy the camera and release the current resources hold by it.
  36894. */
  36895. dispose(): void;
  36896. /**
  36897. * Gets the current object class name.
  36898. * @return the class name
  36899. */
  36900. getClassName(): string;
  36901. }
  36902. }
  36903. declare module BABYLON {
  36904. /**
  36905. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36906. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36907. */
  36908. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36909. /**
  36910. * Gets the name of the behavior.
  36911. */
  36912. readonly name: string;
  36913. private _zoomStopsAnimation;
  36914. private _idleRotationSpeed;
  36915. private _idleRotationWaitTime;
  36916. private _idleRotationSpinupTime;
  36917. /**
  36918. * Sets the flag that indicates if user zooming should stop animation.
  36919. */
  36920. /**
  36921. * Gets the flag that indicates if user zooming should stop animation.
  36922. */
  36923. zoomStopsAnimation: boolean;
  36924. /**
  36925. * Sets the default speed at which the camera rotates around the model.
  36926. */
  36927. /**
  36928. * Gets the default speed at which the camera rotates around the model.
  36929. */
  36930. idleRotationSpeed: number;
  36931. /**
  36932. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36933. */
  36934. /**
  36935. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36936. */
  36937. idleRotationWaitTime: number;
  36938. /**
  36939. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36940. */
  36941. /**
  36942. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36943. */
  36944. idleRotationSpinupTime: number;
  36945. /**
  36946. * Gets a value indicating if the camera is currently rotating because of this behavior
  36947. */
  36948. readonly rotationInProgress: boolean;
  36949. private _onPrePointerObservableObserver;
  36950. private _onAfterCheckInputsObserver;
  36951. private _attachedCamera;
  36952. private _isPointerDown;
  36953. private _lastFrameTime;
  36954. private _lastInteractionTime;
  36955. private _cameraRotationSpeed;
  36956. /**
  36957. * Initializes the behavior.
  36958. */
  36959. init(): void;
  36960. /**
  36961. * Attaches the behavior to its arc rotate camera.
  36962. * @param camera Defines the camera to attach the behavior to
  36963. */
  36964. attach(camera: ArcRotateCamera): void;
  36965. /**
  36966. * Detaches the behavior from its current arc rotate camera.
  36967. */
  36968. detach(): void;
  36969. /**
  36970. * Returns true if user is scrolling.
  36971. * @return true if user is scrolling.
  36972. */
  36973. private _userIsZooming;
  36974. private _lastFrameRadius;
  36975. private _shouldAnimationStopForInteraction;
  36976. /**
  36977. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36978. */
  36979. private _applyUserInteraction;
  36980. private _userIsMoving;
  36981. }
  36982. }
  36983. declare module BABYLON {
  36984. /**
  36985. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36986. */
  36987. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36988. private ui;
  36989. /**
  36990. * The name of the behavior
  36991. */
  36992. name: string;
  36993. /**
  36994. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36995. */
  36996. distanceAwayFromFace: number;
  36997. /**
  36998. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36999. */
  37000. distanceAwayFromBottomOfFace: number;
  37001. private _faceVectors;
  37002. private _target;
  37003. private _scene;
  37004. private _onRenderObserver;
  37005. private _tmpMatrix;
  37006. private _tmpVector;
  37007. /**
  37008. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37009. * @param ui The transform node that should be attched to the mesh
  37010. */
  37011. constructor(ui: TransformNode);
  37012. /**
  37013. * Initializes the behavior
  37014. */
  37015. init(): void;
  37016. private _closestFace;
  37017. private _zeroVector;
  37018. private _lookAtTmpMatrix;
  37019. private _lookAtToRef;
  37020. /**
  37021. * Attaches the AttachToBoxBehavior to the passed in mesh
  37022. * @param target The mesh that the specified node will be attached to
  37023. */
  37024. attach(target: Mesh): void;
  37025. /**
  37026. * Detaches the behavior from the mesh
  37027. */
  37028. detach(): void;
  37029. }
  37030. }
  37031. declare module BABYLON {
  37032. /**
  37033. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37034. */
  37035. export class FadeInOutBehavior implements Behavior<Mesh> {
  37036. /**
  37037. * Time in milliseconds to delay before fading in (Default: 0)
  37038. */
  37039. delay: number;
  37040. /**
  37041. * Time in milliseconds for the mesh to fade in (Default: 300)
  37042. */
  37043. fadeInTime: number;
  37044. private _millisecondsPerFrame;
  37045. private _hovered;
  37046. private _hoverValue;
  37047. private _ownerNode;
  37048. /**
  37049. * Instatiates the FadeInOutBehavior
  37050. */
  37051. constructor();
  37052. /**
  37053. * The name of the behavior
  37054. */
  37055. readonly name: string;
  37056. /**
  37057. * Initializes the behavior
  37058. */
  37059. init(): void;
  37060. /**
  37061. * Attaches the fade behavior on the passed in mesh
  37062. * @param ownerNode The mesh that will be faded in/out once attached
  37063. */
  37064. attach(ownerNode: Mesh): void;
  37065. /**
  37066. * Detaches the behavior from the mesh
  37067. */
  37068. detach(): void;
  37069. /**
  37070. * Triggers the mesh to begin fading in or out
  37071. * @param value if the object should fade in or out (true to fade in)
  37072. */
  37073. fadeIn(value: boolean): void;
  37074. private _update;
  37075. private _setAllVisibility;
  37076. }
  37077. }
  37078. declare module BABYLON {
  37079. /**
  37080. * Class containing a set of static utilities functions for managing Pivots
  37081. * @hidden
  37082. */
  37083. export class PivotTools {
  37084. private static _PivotCached;
  37085. private static _OldPivotPoint;
  37086. private static _PivotTranslation;
  37087. private static _PivotTmpVector;
  37088. /** @hidden */
  37089. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37090. /** @hidden */
  37091. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. /**
  37096. * Class containing static functions to help procedurally build meshes
  37097. */
  37098. export class PlaneBuilder {
  37099. /**
  37100. * Creates a plane mesh
  37101. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37102. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37103. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37105. * * 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
  37106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37107. * @param name defines the name of the mesh
  37108. * @param options defines the options used to create the mesh
  37109. * @param scene defines the hosting scene
  37110. * @returns the plane mesh
  37111. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37112. */
  37113. static CreatePlane(name: string, options: {
  37114. size?: number;
  37115. width?: number;
  37116. height?: number;
  37117. sideOrientation?: number;
  37118. frontUVs?: Vector4;
  37119. backUVs?: Vector4;
  37120. updatable?: boolean;
  37121. sourcePlane?: Plane;
  37122. }, scene?: Nullable<Scene>): Mesh;
  37123. }
  37124. }
  37125. declare module BABYLON {
  37126. /**
  37127. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37128. */
  37129. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37130. private static _AnyMouseID;
  37131. /**
  37132. * Abstract mesh the behavior is set on
  37133. */
  37134. attachedNode: AbstractMesh;
  37135. private _dragPlane;
  37136. private _scene;
  37137. private _pointerObserver;
  37138. private _beforeRenderObserver;
  37139. private static _planeScene;
  37140. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37141. /**
  37142. * 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)
  37143. */
  37144. maxDragAngle: number;
  37145. /**
  37146. * @hidden
  37147. */
  37148. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37149. /**
  37150. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37151. */
  37152. currentDraggingPointerID: number;
  37153. /**
  37154. * The last position where the pointer hit the drag plane in world space
  37155. */
  37156. lastDragPosition: Vector3;
  37157. /**
  37158. * If the behavior is currently in a dragging state
  37159. */
  37160. dragging: boolean;
  37161. /**
  37162. * 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)
  37163. */
  37164. dragDeltaRatio: number;
  37165. /**
  37166. * If the drag plane orientation should be updated during the dragging (Default: true)
  37167. */
  37168. updateDragPlane: boolean;
  37169. private _debugMode;
  37170. private _moving;
  37171. /**
  37172. * Fires each time the attached mesh is dragged with the pointer
  37173. * * delta between last drag position and current drag position in world space
  37174. * * dragDistance along the drag axis
  37175. * * dragPlaneNormal normal of the current drag plane used during the drag
  37176. * * dragPlanePoint in world space where the drag intersects the drag plane
  37177. */
  37178. onDragObservable: Observable<{
  37179. delta: Vector3;
  37180. dragPlanePoint: Vector3;
  37181. dragPlaneNormal: Vector3;
  37182. dragDistance: number;
  37183. pointerId: number;
  37184. }>;
  37185. /**
  37186. * Fires each time a drag begins (eg. mouse down on mesh)
  37187. */
  37188. onDragStartObservable: Observable<{
  37189. dragPlanePoint: Vector3;
  37190. pointerId: number;
  37191. }>;
  37192. /**
  37193. * Fires each time a drag ends (eg. mouse release after drag)
  37194. */
  37195. onDragEndObservable: Observable<{
  37196. dragPlanePoint: Vector3;
  37197. pointerId: number;
  37198. }>;
  37199. /**
  37200. * If the attached mesh should be moved when dragged
  37201. */
  37202. moveAttached: boolean;
  37203. /**
  37204. * If the drag behavior will react to drag events (Default: true)
  37205. */
  37206. enabled: boolean;
  37207. /**
  37208. * If pointer events should start and release the drag (Default: true)
  37209. */
  37210. startAndReleaseDragOnPointerEvents: boolean;
  37211. /**
  37212. * If camera controls should be detached during the drag
  37213. */
  37214. detachCameraControls: boolean;
  37215. /**
  37216. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37217. */
  37218. useObjectOrienationForDragging: boolean;
  37219. private _options;
  37220. /**
  37221. * Creates a pointer drag behavior that can be attached to a mesh
  37222. * @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)
  37223. */
  37224. constructor(options?: {
  37225. dragAxis?: Vector3;
  37226. dragPlaneNormal?: Vector3;
  37227. });
  37228. /**
  37229. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37230. */
  37231. validateDrag: (targetPosition: Vector3) => boolean;
  37232. /**
  37233. * The name of the behavior
  37234. */
  37235. readonly name: string;
  37236. /**
  37237. * Initializes the behavior
  37238. */
  37239. init(): void;
  37240. private _tmpVector;
  37241. private _alternatePickedPoint;
  37242. private _worldDragAxis;
  37243. private _targetPosition;
  37244. private _attachedElement;
  37245. /**
  37246. * Attaches the drag behavior the passed in mesh
  37247. * @param ownerNode The mesh that will be dragged around once attached
  37248. * @param predicate Predicate to use for pick filtering
  37249. */
  37250. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37251. /**
  37252. * Force relase the drag action by code.
  37253. */
  37254. releaseDrag(): void;
  37255. private _startDragRay;
  37256. private _lastPointerRay;
  37257. /**
  37258. * Simulates the start of a pointer drag event on the behavior
  37259. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37260. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37261. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37262. */
  37263. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37264. private _startDrag;
  37265. private _dragDelta;
  37266. private _moveDrag;
  37267. private _pickWithRayOnDragPlane;
  37268. private _pointA;
  37269. private _pointB;
  37270. private _pointC;
  37271. private _lineA;
  37272. private _lineB;
  37273. private _localAxis;
  37274. private _lookAt;
  37275. private _updateDragPlanePosition;
  37276. /**
  37277. * Detaches the behavior from the mesh
  37278. */
  37279. detach(): void;
  37280. }
  37281. }
  37282. declare module BABYLON {
  37283. /**
  37284. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37285. */
  37286. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37287. private _dragBehaviorA;
  37288. private _dragBehaviorB;
  37289. private _startDistance;
  37290. private _initialScale;
  37291. private _targetScale;
  37292. private _ownerNode;
  37293. private _sceneRenderObserver;
  37294. /**
  37295. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37296. */
  37297. constructor();
  37298. /**
  37299. * The name of the behavior
  37300. */
  37301. readonly name: string;
  37302. /**
  37303. * Initializes the behavior
  37304. */
  37305. init(): void;
  37306. private _getCurrentDistance;
  37307. /**
  37308. * Attaches the scale behavior the passed in mesh
  37309. * @param ownerNode The mesh that will be scaled around once attached
  37310. */
  37311. attach(ownerNode: Mesh): void;
  37312. /**
  37313. * Detaches the behavior from the mesh
  37314. */
  37315. detach(): void;
  37316. }
  37317. }
  37318. declare module BABYLON {
  37319. /**
  37320. * 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
  37321. */
  37322. export class SixDofDragBehavior implements Behavior<Mesh> {
  37323. private static _virtualScene;
  37324. private _ownerNode;
  37325. private _sceneRenderObserver;
  37326. private _scene;
  37327. private _targetPosition;
  37328. private _virtualOriginMesh;
  37329. private _virtualDragMesh;
  37330. private _pointerObserver;
  37331. private _moving;
  37332. private _startingOrientation;
  37333. /**
  37334. * 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)
  37335. */
  37336. private zDragFactor;
  37337. /**
  37338. * If the object should rotate to face the drag origin
  37339. */
  37340. rotateDraggedObject: boolean;
  37341. /**
  37342. * If the behavior is currently in a dragging state
  37343. */
  37344. dragging: boolean;
  37345. /**
  37346. * 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)
  37347. */
  37348. dragDeltaRatio: number;
  37349. /**
  37350. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37351. */
  37352. currentDraggingPointerID: number;
  37353. /**
  37354. * If camera controls should be detached during the drag
  37355. */
  37356. detachCameraControls: boolean;
  37357. /**
  37358. * Fires each time a drag starts
  37359. */
  37360. onDragStartObservable: Observable<{}>;
  37361. /**
  37362. * Fires each time a drag ends (eg. mouse release after drag)
  37363. */
  37364. onDragEndObservable: Observable<{}>;
  37365. /**
  37366. * 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
  37367. */
  37368. constructor();
  37369. /**
  37370. * The name of the behavior
  37371. */
  37372. readonly name: string;
  37373. /**
  37374. * Initializes the behavior
  37375. */
  37376. init(): void;
  37377. /**
  37378. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37379. */
  37380. private readonly _pointerCamera;
  37381. /**
  37382. * Attaches the scale behavior the passed in mesh
  37383. * @param ownerNode The mesh that will be scaled around once attached
  37384. */
  37385. attach(ownerNode: Mesh): void;
  37386. /**
  37387. * Detaches the behavior from the mesh
  37388. */
  37389. detach(): void;
  37390. }
  37391. }
  37392. declare module BABYLON {
  37393. /**
  37394. * Class used to apply inverse kinematics to bones
  37395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37396. */
  37397. export class BoneIKController {
  37398. private static _tmpVecs;
  37399. private static _tmpQuat;
  37400. private static _tmpMats;
  37401. /**
  37402. * Gets or sets the target mesh
  37403. */
  37404. targetMesh: AbstractMesh;
  37405. /** Gets or sets the mesh used as pole */
  37406. poleTargetMesh: AbstractMesh;
  37407. /**
  37408. * Gets or sets the bone used as pole
  37409. */
  37410. poleTargetBone: Nullable<Bone>;
  37411. /**
  37412. * Gets or sets the target position
  37413. */
  37414. targetPosition: Vector3;
  37415. /**
  37416. * Gets or sets the pole target position
  37417. */
  37418. poleTargetPosition: Vector3;
  37419. /**
  37420. * Gets or sets the pole target local offset
  37421. */
  37422. poleTargetLocalOffset: Vector3;
  37423. /**
  37424. * Gets or sets the pole angle
  37425. */
  37426. poleAngle: number;
  37427. /**
  37428. * Gets or sets the mesh associated with the controller
  37429. */
  37430. mesh: AbstractMesh;
  37431. /**
  37432. * 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)
  37433. */
  37434. slerpAmount: number;
  37435. private _bone1Quat;
  37436. private _bone1Mat;
  37437. private _bone2Ang;
  37438. private _bone1;
  37439. private _bone2;
  37440. private _bone1Length;
  37441. private _bone2Length;
  37442. private _maxAngle;
  37443. private _maxReach;
  37444. private _rightHandedSystem;
  37445. private _bendAxis;
  37446. private _slerping;
  37447. private _adjustRoll;
  37448. /**
  37449. * Gets or sets maximum allowed angle
  37450. */
  37451. maxAngle: number;
  37452. /**
  37453. * Creates a new BoneIKController
  37454. * @param mesh defines the mesh to control
  37455. * @param bone defines the bone to control
  37456. * @param options defines options to set up the controller
  37457. */
  37458. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37459. targetMesh?: AbstractMesh;
  37460. poleTargetMesh?: AbstractMesh;
  37461. poleTargetBone?: Bone;
  37462. poleTargetLocalOffset?: Vector3;
  37463. poleAngle?: number;
  37464. bendAxis?: Vector3;
  37465. maxAngle?: number;
  37466. slerpAmount?: number;
  37467. });
  37468. private _setMaxAngle;
  37469. /**
  37470. * Force the controller to update the bones
  37471. */
  37472. update(): void;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * Class used to make a bone look toward a point in space
  37478. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37479. */
  37480. export class BoneLookController {
  37481. private static _tmpVecs;
  37482. private static _tmpQuat;
  37483. private static _tmpMats;
  37484. /**
  37485. * The target Vector3 that the bone will look at
  37486. */
  37487. target: Vector3;
  37488. /**
  37489. * The mesh that the bone is attached to
  37490. */
  37491. mesh: AbstractMesh;
  37492. /**
  37493. * The bone that will be looking to the target
  37494. */
  37495. bone: Bone;
  37496. /**
  37497. * The up axis of the coordinate system that is used when the bone is rotated
  37498. */
  37499. upAxis: Vector3;
  37500. /**
  37501. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37502. */
  37503. upAxisSpace: Space;
  37504. /**
  37505. * Used to make an adjustment to the yaw of the bone
  37506. */
  37507. adjustYaw: number;
  37508. /**
  37509. * Used to make an adjustment to the pitch of the bone
  37510. */
  37511. adjustPitch: number;
  37512. /**
  37513. * Used to make an adjustment to the roll of the bone
  37514. */
  37515. adjustRoll: number;
  37516. /**
  37517. * 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)
  37518. */
  37519. slerpAmount: number;
  37520. private _minYaw;
  37521. private _maxYaw;
  37522. private _minPitch;
  37523. private _maxPitch;
  37524. private _minYawSin;
  37525. private _minYawCos;
  37526. private _maxYawSin;
  37527. private _maxYawCos;
  37528. private _midYawConstraint;
  37529. private _minPitchTan;
  37530. private _maxPitchTan;
  37531. private _boneQuat;
  37532. private _slerping;
  37533. private _transformYawPitch;
  37534. private _transformYawPitchInv;
  37535. private _firstFrameSkipped;
  37536. private _yawRange;
  37537. private _fowardAxis;
  37538. /**
  37539. * Gets or sets the minimum yaw angle that the bone can look to
  37540. */
  37541. minYaw: number;
  37542. /**
  37543. * Gets or sets the maximum yaw angle that the bone can look to
  37544. */
  37545. maxYaw: number;
  37546. /**
  37547. * Gets or sets the minimum pitch angle that the bone can look to
  37548. */
  37549. minPitch: number;
  37550. /**
  37551. * Gets or sets the maximum pitch angle that the bone can look to
  37552. */
  37553. maxPitch: number;
  37554. /**
  37555. * Create a BoneLookController
  37556. * @param mesh the mesh that the bone belongs to
  37557. * @param bone the bone that will be looking to the target
  37558. * @param target the target Vector3 to look at
  37559. * @param options optional settings:
  37560. * * maxYaw: the maximum angle the bone will yaw to
  37561. * * minYaw: the minimum angle the bone will yaw to
  37562. * * maxPitch: the maximum angle the bone will pitch to
  37563. * * minPitch: the minimum angle the bone will yaw to
  37564. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37565. * * upAxis: the up axis of the coordinate system
  37566. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37567. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37568. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37569. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37570. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37571. * * adjustRoll: used to make an adjustment to the roll of the bone
  37572. **/
  37573. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37574. maxYaw?: number;
  37575. minYaw?: number;
  37576. maxPitch?: number;
  37577. minPitch?: number;
  37578. slerpAmount?: number;
  37579. upAxis?: Vector3;
  37580. upAxisSpace?: Space;
  37581. yawAxis?: Vector3;
  37582. pitchAxis?: Vector3;
  37583. adjustYaw?: number;
  37584. adjustPitch?: number;
  37585. adjustRoll?: number;
  37586. });
  37587. /**
  37588. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37589. */
  37590. update(): void;
  37591. private _getAngleDiff;
  37592. private _getAngleBetween;
  37593. private _isAngleBetween;
  37594. }
  37595. }
  37596. declare module BABYLON {
  37597. /**
  37598. * Manage the gamepad inputs to control an arc rotate camera.
  37599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37600. */
  37601. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37602. /**
  37603. * Defines the camera the input is attached to.
  37604. */
  37605. camera: ArcRotateCamera;
  37606. /**
  37607. * Defines the gamepad the input is gathering event from.
  37608. */
  37609. gamepad: Nullable<Gamepad>;
  37610. /**
  37611. * Defines the gamepad rotation sensiblity.
  37612. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37613. */
  37614. gamepadRotationSensibility: number;
  37615. /**
  37616. * Defines the gamepad move sensiblity.
  37617. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37618. */
  37619. gamepadMoveSensibility: number;
  37620. private _yAxisScale;
  37621. /**
  37622. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37623. */
  37624. invertYAxis: boolean;
  37625. private _onGamepadConnectedObserver;
  37626. private _onGamepadDisconnectedObserver;
  37627. /**
  37628. * Attach the input controls to a specific dom element to get the input from.
  37629. * @param element Defines the element the controls should be listened from
  37630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37631. */
  37632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37633. /**
  37634. * Detach the current controls from the specified dom element.
  37635. * @param element Defines the element to stop listening the inputs from
  37636. */
  37637. detachControl(element: Nullable<HTMLElement>): void;
  37638. /**
  37639. * Update the current camera state depending on the inputs that have been used this frame.
  37640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37641. */
  37642. checkInputs(): void;
  37643. /**
  37644. * Gets the class name of the current intput.
  37645. * @returns the class name
  37646. */
  37647. getClassName(): string;
  37648. /**
  37649. * Get the friendly name associated with the input class.
  37650. * @returns the input friendly name
  37651. */
  37652. getSimpleName(): string;
  37653. }
  37654. }
  37655. declare module BABYLON {
  37656. interface ArcRotateCameraInputsManager {
  37657. /**
  37658. * Add orientation input support to the input manager.
  37659. * @returns the current input manager
  37660. */
  37661. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37662. }
  37663. /**
  37664. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37666. */
  37667. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37668. /**
  37669. * Defines the camera the input is attached to.
  37670. */
  37671. camera: ArcRotateCamera;
  37672. /**
  37673. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37674. */
  37675. alphaCorrection: number;
  37676. /**
  37677. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37678. */
  37679. gammaCorrection: number;
  37680. private _alpha;
  37681. private _gamma;
  37682. private _dirty;
  37683. private _deviceOrientationHandler;
  37684. /**
  37685. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37686. */
  37687. constructor();
  37688. /**
  37689. * Attach the input controls to a specific dom element to get the input from.
  37690. * @param element Defines the element the controls should be listened from
  37691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37692. */
  37693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37694. /** @hidden */
  37695. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37696. /**
  37697. * Update the current camera state depending on the inputs that have been used this frame.
  37698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37699. */
  37700. checkInputs(): void;
  37701. /**
  37702. * Detach the current controls from the specified dom element.
  37703. * @param element Defines the element to stop listening the inputs from
  37704. */
  37705. detachControl(element: Nullable<HTMLElement>): void;
  37706. /**
  37707. * Gets the class name of the current intput.
  37708. * @returns the class name
  37709. */
  37710. getClassName(): string;
  37711. /**
  37712. * Get the friendly name associated with the input class.
  37713. * @returns the input friendly name
  37714. */
  37715. getSimpleName(): string;
  37716. }
  37717. }
  37718. declare module BABYLON {
  37719. /**
  37720. * Listen to mouse events to control the camera.
  37721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37722. */
  37723. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37724. /**
  37725. * Defines the camera the input is attached to.
  37726. */
  37727. camera: FlyCamera;
  37728. /**
  37729. * Defines if touch is enabled. (Default is true.)
  37730. */
  37731. touchEnabled: boolean;
  37732. /**
  37733. * Defines the buttons associated with the input to handle camera rotation.
  37734. */
  37735. buttons: number[];
  37736. /**
  37737. * Assign buttons for Yaw control.
  37738. */
  37739. buttonsYaw: number[];
  37740. /**
  37741. * Assign buttons for Pitch control.
  37742. */
  37743. buttonsPitch: number[];
  37744. /**
  37745. * Assign buttons for Roll control.
  37746. */
  37747. buttonsRoll: number[];
  37748. /**
  37749. * Detect if any button is being pressed while mouse is moved.
  37750. * -1 = Mouse locked.
  37751. * 0 = Left button.
  37752. * 1 = Middle Button.
  37753. * 2 = Right Button.
  37754. */
  37755. activeButton: number;
  37756. /**
  37757. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37758. * Higher values reduce its sensitivity.
  37759. */
  37760. angularSensibility: number;
  37761. private _mousemoveCallback;
  37762. private _observer;
  37763. private _rollObserver;
  37764. private previousPosition;
  37765. private noPreventDefault;
  37766. private element;
  37767. /**
  37768. * Listen to mouse events to control the camera.
  37769. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37771. */
  37772. constructor(touchEnabled?: boolean);
  37773. /**
  37774. * Attach the mouse control to the HTML DOM element.
  37775. * @param element Defines the element that listens to the input events.
  37776. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37777. */
  37778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37779. /**
  37780. * Detach the current controls from the specified dom element.
  37781. * @param element Defines the element to stop listening the inputs from
  37782. */
  37783. detachControl(element: Nullable<HTMLElement>): void;
  37784. /**
  37785. * Gets the class name of the current input.
  37786. * @returns the class name.
  37787. */
  37788. getClassName(): string;
  37789. /**
  37790. * Get the friendly name associated with the input class.
  37791. * @returns the input's friendly name.
  37792. */
  37793. getSimpleName(): string;
  37794. private _pointerInput;
  37795. private _onMouseMove;
  37796. /**
  37797. * Rotate camera by mouse offset.
  37798. */
  37799. private rotateCamera;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /**
  37804. * Default Inputs manager for the FlyCamera.
  37805. * It groups all the default supported inputs for ease of use.
  37806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37807. */
  37808. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37809. /**
  37810. * Instantiates a new FlyCameraInputsManager.
  37811. * @param camera Defines the camera the inputs belong to.
  37812. */
  37813. constructor(camera: FlyCamera);
  37814. /**
  37815. * Add keyboard input support to the input manager.
  37816. * @returns the new FlyCameraKeyboardMoveInput().
  37817. */
  37818. addKeyboard(): FlyCameraInputsManager;
  37819. /**
  37820. * Add mouse input support to the input manager.
  37821. * @param touchEnabled Enable touch screen support.
  37822. * @returns the new FlyCameraMouseInput().
  37823. */
  37824. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. /**
  37829. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37830. * such as in a 3D Space Shooter or a Flight Simulator.
  37831. */
  37832. export class FlyCamera extends TargetCamera {
  37833. /**
  37834. * Define the collision ellipsoid of the camera.
  37835. * This is helpful for simulating a camera body, like a player's body.
  37836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37837. */
  37838. ellipsoid: Vector3;
  37839. /**
  37840. * Define an offset for the position of the ellipsoid around the camera.
  37841. * This can be helpful if the camera is attached away from the player's body center,
  37842. * such as at its head.
  37843. */
  37844. ellipsoidOffset: Vector3;
  37845. /**
  37846. * Enable or disable collisions of the camera with the rest of the scene objects.
  37847. */
  37848. checkCollisions: boolean;
  37849. /**
  37850. * Enable or disable gravity on the camera.
  37851. */
  37852. applyGravity: boolean;
  37853. /**
  37854. * Define the current direction the camera is moving to.
  37855. */
  37856. cameraDirection: Vector3;
  37857. /**
  37858. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37859. * This overrides and empties cameraRotation.
  37860. */
  37861. rotationQuaternion: Quaternion;
  37862. /**
  37863. * Track Roll to maintain the wanted Rolling when looking around.
  37864. */
  37865. _trackRoll: number;
  37866. /**
  37867. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37868. */
  37869. rollCorrect: number;
  37870. /**
  37871. * Mimic a banked turn, Rolling the camera when Yawing.
  37872. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37873. */
  37874. bankedTurn: boolean;
  37875. /**
  37876. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37877. */
  37878. bankedTurnLimit: number;
  37879. /**
  37880. * Value of 0 disables the banked Roll.
  37881. * Value of 1 is equal to the Yaw angle in radians.
  37882. */
  37883. bankedTurnMultiplier: number;
  37884. /**
  37885. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37886. */
  37887. inputs: FlyCameraInputsManager;
  37888. /**
  37889. * Gets the input sensibility for mouse input.
  37890. * Higher values reduce sensitivity.
  37891. */
  37892. /**
  37893. * Sets the input sensibility for a mouse input.
  37894. * Higher values reduce sensitivity.
  37895. */
  37896. angularSensibility: number;
  37897. /**
  37898. * Get the keys for camera movement forward.
  37899. */
  37900. /**
  37901. * Set the keys for camera movement forward.
  37902. */
  37903. keysForward: number[];
  37904. /**
  37905. * Get the keys for camera movement backward.
  37906. */
  37907. keysBackward: number[];
  37908. /**
  37909. * Get the keys for camera movement up.
  37910. */
  37911. /**
  37912. * Set the keys for camera movement up.
  37913. */
  37914. keysUp: number[];
  37915. /**
  37916. * Get the keys for camera movement down.
  37917. */
  37918. /**
  37919. * Set the keys for camera movement down.
  37920. */
  37921. keysDown: number[];
  37922. /**
  37923. * Get the keys for camera movement left.
  37924. */
  37925. /**
  37926. * Set the keys for camera movement left.
  37927. */
  37928. keysLeft: number[];
  37929. /**
  37930. * Set the keys for camera movement right.
  37931. */
  37932. /**
  37933. * Set the keys for camera movement right.
  37934. */
  37935. keysRight: number[];
  37936. /**
  37937. * Event raised when the camera collides with a mesh in the scene.
  37938. */
  37939. onCollide: (collidedMesh: AbstractMesh) => void;
  37940. private _collider;
  37941. private _needMoveForGravity;
  37942. private _oldPosition;
  37943. private _diffPosition;
  37944. private _newPosition;
  37945. /** @hidden */
  37946. _localDirection: Vector3;
  37947. /** @hidden */
  37948. _transformedDirection: Vector3;
  37949. /**
  37950. * Instantiates a FlyCamera.
  37951. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37952. * such as in a 3D Space Shooter or a Flight Simulator.
  37953. * @param name Define the name of the camera in the scene.
  37954. * @param position Define the starting position of the camera in the scene.
  37955. * @param scene Define the scene the camera belongs to.
  37956. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37957. */
  37958. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37959. /**
  37960. * Attach a control to the HTML DOM element.
  37961. * @param element Defines the element that listens to the input events.
  37962. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37963. */
  37964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37965. /**
  37966. * Detach a control from the HTML DOM element.
  37967. * The camera will stop reacting to that input.
  37968. * @param element Defines the element that listens to the input events.
  37969. */
  37970. detachControl(element: HTMLElement): void;
  37971. private _collisionMask;
  37972. /**
  37973. * Get the mask that the camera ignores in collision events.
  37974. */
  37975. /**
  37976. * Set the mask that the camera ignores in collision events.
  37977. */
  37978. collisionMask: number;
  37979. /** @hidden */
  37980. _collideWithWorld(displacement: Vector3): void;
  37981. /** @hidden */
  37982. private _onCollisionPositionChange;
  37983. /** @hidden */
  37984. _checkInputs(): void;
  37985. /** @hidden */
  37986. _decideIfNeedsToMove(): boolean;
  37987. /** @hidden */
  37988. _updatePosition(): void;
  37989. /**
  37990. * Restore the Roll to its target value at the rate specified.
  37991. * @param rate - Higher means slower restoring.
  37992. * @hidden
  37993. */
  37994. restoreRoll(rate: number): void;
  37995. /**
  37996. * Destroy the camera and release the current resources held by it.
  37997. */
  37998. dispose(): void;
  37999. /**
  38000. * Get the current object class name.
  38001. * @returns the class name.
  38002. */
  38003. getClassName(): string;
  38004. }
  38005. }
  38006. declare module BABYLON {
  38007. /**
  38008. * Listen to keyboard events to control the camera.
  38009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38010. */
  38011. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38012. /**
  38013. * Defines the camera the input is attached to.
  38014. */
  38015. camera: FlyCamera;
  38016. /**
  38017. * The list of keyboard keys used to control the forward move of the camera.
  38018. */
  38019. keysForward: number[];
  38020. /**
  38021. * The list of keyboard keys used to control the backward move of the camera.
  38022. */
  38023. keysBackward: number[];
  38024. /**
  38025. * The list of keyboard keys used to control the forward move of the camera.
  38026. */
  38027. keysUp: number[];
  38028. /**
  38029. * The list of keyboard keys used to control the backward move of the camera.
  38030. */
  38031. keysDown: number[];
  38032. /**
  38033. * The list of keyboard keys used to control the right strafe move of the camera.
  38034. */
  38035. keysRight: number[];
  38036. /**
  38037. * The list of keyboard keys used to control the left strafe move of the camera.
  38038. */
  38039. keysLeft: number[];
  38040. private _keys;
  38041. private _onCanvasBlurObserver;
  38042. private _onKeyboardObserver;
  38043. private _engine;
  38044. private _scene;
  38045. /**
  38046. * Attach the input controls to a specific dom element to get the input from.
  38047. * @param element Defines the element the controls should be listened from
  38048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38049. */
  38050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38051. /**
  38052. * Detach the current controls from the specified dom element.
  38053. * @param element Defines the element to stop listening the inputs from
  38054. */
  38055. detachControl(element: Nullable<HTMLElement>): void;
  38056. /**
  38057. * Gets the class name of the current intput.
  38058. * @returns the class name
  38059. */
  38060. getClassName(): string;
  38061. /** @hidden */
  38062. _onLostFocus(e: FocusEvent): void;
  38063. /**
  38064. * Get the friendly name associated with the input class.
  38065. * @returns the input friendly name
  38066. */
  38067. getSimpleName(): string;
  38068. /**
  38069. * Update the current camera state depending on the inputs that have been used this frame.
  38070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38071. */
  38072. checkInputs(): void;
  38073. }
  38074. }
  38075. declare module BABYLON {
  38076. /**
  38077. * Manage the mouse wheel inputs to control a follow camera.
  38078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38079. */
  38080. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38081. /**
  38082. * Defines the camera the input is attached to.
  38083. */
  38084. camera: FollowCamera;
  38085. /**
  38086. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38087. */
  38088. axisControlRadius: boolean;
  38089. /**
  38090. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38091. */
  38092. axisControlHeight: boolean;
  38093. /**
  38094. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38095. */
  38096. axisControlRotation: boolean;
  38097. /**
  38098. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38099. * relation to mouseWheel events.
  38100. */
  38101. wheelPrecision: number;
  38102. /**
  38103. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38104. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38105. */
  38106. wheelDeltaPercentage: number;
  38107. private _wheel;
  38108. private _observer;
  38109. /**
  38110. * Attach the input controls to a specific dom element to get the input from.
  38111. * @param element Defines the element the controls should be listened from
  38112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38113. */
  38114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38115. /**
  38116. * Detach the current controls from the specified dom element.
  38117. * @param element Defines the element to stop listening the inputs from
  38118. */
  38119. detachControl(element: Nullable<HTMLElement>): void;
  38120. /**
  38121. * Gets the class name of the current intput.
  38122. * @returns the class name
  38123. */
  38124. getClassName(): string;
  38125. /**
  38126. * Get the friendly name associated with the input class.
  38127. * @returns the input friendly name
  38128. */
  38129. getSimpleName(): string;
  38130. }
  38131. }
  38132. declare module BABYLON {
  38133. /**
  38134. * Manage the pointers inputs to control an follow camera.
  38135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38136. */
  38137. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38138. /**
  38139. * Defines the camera the input is attached to.
  38140. */
  38141. camera: FollowCamera;
  38142. /**
  38143. * Gets the class name of the current input.
  38144. * @returns the class name
  38145. */
  38146. getClassName(): string;
  38147. /**
  38148. * Defines the pointer angular sensibility along the X axis or how fast is
  38149. * the camera rotating.
  38150. * A negative number will reverse the axis direction.
  38151. */
  38152. angularSensibilityX: number;
  38153. /**
  38154. * Defines the pointer angular sensibility along the Y axis or how fast is
  38155. * the camera rotating.
  38156. * A negative number will reverse the axis direction.
  38157. */
  38158. angularSensibilityY: number;
  38159. /**
  38160. * Defines the pointer pinch precision or how fast is the camera zooming.
  38161. * A negative number will reverse the axis direction.
  38162. */
  38163. pinchPrecision: number;
  38164. /**
  38165. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38166. * from 0.
  38167. * It defines the percentage of current camera.radius to use as delta when
  38168. * pinch zoom is used.
  38169. */
  38170. pinchDeltaPercentage: number;
  38171. /**
  38172. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38173. */
  38174. axisXControlRadius: boolean;
  38175. /**
  38176. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38177. */
  38178. axisXControlHeight: boolean;
  38179. /**
  38180. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38181. */
  38182. axisXControlRotation: boolean;
  38183. /**
  38184. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38185. */
  38186. axisYControlRadius: boolean;
  38187. /**
  38188. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38189. */
  38190. axisYControlHeight: boolean;
  38191. /**
  38192. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38193. */
  38194. axisYControlRotation: boolean;
  38195. /**
  38196. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38197. */
  38198. axisPinchControlRadius: boolean;
  38199. /**
  38200. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38201. */
  38202. axisPinchControlHeight: boolean;
  38203. /**
  38204. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38205. */
  38206. axisPinchControlRotation: boolean;
  38207. /**
  38208. * Log error messages if basic misconfiguration has occurred.
  38209. */
  38210. warningEnable: boolean;
  38211. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38212. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38213. private _warningCounter;
  38214. private _warning;
  38215. }
  38216. }
  38217. declare module BABYLON {
  38218. /**
  38219. * Default Inputs manager for the FollowCamera.
  38220. * It groups all the default supported inputs for ease of use.
  38221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38222. */
  38223. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38224. /**
  38225. * Instantiates a new FollowCameraInputsManager.
  38226. * @param camera Defines the camera the inputs belong to
  38227. */
  38228. constructor(camera: FollowCamera);
  38229. /**
  38230. * Add keyboard input support to the input manager.
  38231. * @returns the current input manager
  38232. */
  38233. addKeyboard(): FollowCameraInputsManager;
  38234. /**
  38235. * Add mouse wheel input support to the input manager.
  38236. * @returns the current input manager
  38237. */
  38238. addMouseWheel(): FollowCameraInputsManager;
  38239. /**
  38240. * Add pointers input support to the input manager.
  38241. * @returns the current input manager
  38242. */
  38243. addPointers(): FollowCameraInputsManager;
  38244. /**
  38245. * Add orientation input support to the input manager.
  38246. * @returns the current input manager
  38247. */
  38248. addVRDeviceOrientation(): FollowCameraInputsManager;
  38249. }
  38250. }
  38251. declare module BABYLON {
  38252. /**
  38253. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38254. * an arc rotate version arcFollowCamera are available.
  38255. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38256. */
  38257. export class FollowCamera extends TargetCamera {
  38258. /**
  38259. * Distance the follow camera should follow an object at
  38260. */
  38261. radius: number;
  38262. /**
  38263. * Minimum allowed distance of the camera to the axis of rotation
  38264. * (The camera can not get closer).
  38265. * This can help limiting how the Camera is able to move in the scene.
  38266. */
  38267. lowerRadiusLimit: Nullable<number>;
  38268. /**
  38269. * Maximum allowed distance of the camera to the axis of rotation
  38270. * (The camera can not get further).
  38271. * This can help limiting how the Camera is able to move in the scene.
  38272. */
  38273. upperRadiusLimit: Nullable<number>;
  38274. /**
  38275. * Define a rotation offset between the camera and the object it follows
  38276. */
  38277. rotationOffset: number;
  38278. /**
  38279. * Minimum allowed angle to camera position relative to target object.
  38280. * This can help limiting how the Camera is able to move in the scene.
  38281. */
  38282. lowerRotationOffsetLimit: Nullable<number>;
  38283. /**
  38284. * Maximum allowed angle to camera position relative to target object.
  38285. * This can help limiting how the Camera is able to move in the scene.
  38286. */
  38287. upperRotationOffsetLimit: Nullable<number>;
  38288. /**
  38289. * Define a height offset between the camera and the object it follows.
  38290. * It can help following an object from the top (like a car chaing a plane)
  38291. */
  38292. heightOffset: number;
  38293. /**
  38294. * Minimum allowed height of camera position relative to target object.
  38295. * This can help limiting how the Camera is able to move in the scene.
  38296. */
  38297. lowerHeightOffsetLimit: Nullable<number>;
  38298. /**
  38299. * Maximum allowed height of camera position relative to target object.
  38300. * This can help limiting how the Camera is able to move in the scene.
  38301. */
  38302. upperHeightOffsetLimit: Nullable<number>;
  38303. /**
  38304. * Define how fast the camera can accelerate to follow it s target.
  38305. */
  38306. cameraAcceleration: number;
  38307. /**
  38308. * Define the speed limit of the camera following an object.
  38309. */
  38310. maxCameraSpeed: number;
  38311. /**
  38312. * Define the target of the camera.
  38313. */
  38314. lockedTarget: Nullable<AbstractMesh>;
  38315. /**
  38316. * Defines the input associated with the camera.
  38317. */
  38318. inputs: FollowCameraInputsManager;
  38319. /**
  38320. * Instantiates the follow camera.
  38321. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38322. * @param name Define the name of the camera in the scene
  38323. * @param position Define the position of the camera
  38324. * @param scene Define the scene the camera belong to
  38325. * @param lockedTarget Define the target of the camera
  38326. */
  38327. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38328. private _follow;
  38329. /**
  38330. * Attached controls to the current camera.
  38331. * @param element Defines the element the controls should be listened from
  38332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38333. */
  38334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38335. /**
  38336. * Detach the current controls from the camera.
  38337. * The camera will stop reacting to inputs.
  38338. * @param element Defines the element to stop listening the inputs from
  38339. */
  38340. detachControl(element: HTMLElement): void;
  38341. /** @hidden */
  38342. _checkInputs(): void;
  38343. private _checkLimits;
  38344. /**
  38345. * Gets the camera class name.
  38346. * @returns the class name
  38347. */
  38348. getClassName(): string;
  38349. }
  38350. /**
  38351. * Arc Rotate version of the follow camera.
  38352. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38354. */
  38355. export class ArcFollowCamera extends TargetCamera {
  38356. /** The longitudinal angle of the camera */
  38357. alpha: number;
  38358. /** The latitudinal angle of the camera */
  38359. beta: number;
  38360. /** The radius of the camera from its target */
  38361. radius: number;
  38362. /** Define the camera target (the messh it should follow) */
  38363. target: Nullable<AbstractMesh>;
  38364. private _cartesianCoordinates;
  38365. /**
  38366. * Instantiates a new ArcFollowCamera
  38367. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38368. * @param name Define the name of the camera
  38369. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38370. * @param beta Define the rotation angle of the camera around the elevation axis
  38371. * @param radius Define the radius of the camera from its target point
  38372. * @param target Define the target of the camera
  38373. * @param scene Define the scene the camera belongs to
  38374. */
  38375. constructor(name: string,
  38376. /** The longitudinal angle of the camera */
  38377. alpha: number,
  38378. /** The latitudinal angle of the camera */
  38379. beta: number,
  38380. /** The radius of the camera from its target */
  38381. radius: number,
  38382. /** Define the camera target (the messh it should follow) */
  38383. target: Nullable<AbstractMesh>, scene: Scene);
  38384. private _follow;
  38385. /** @hidden */
  38386. _checkInputs(): void;
  38387. /**
  38388. * Returns the class name of the object.
  38389. * It is mostly used internally for serialization purposes.
  38390. */
  38391. getClassName(): string;
  38392. }
  38393. }
  38394. declare module BABYLON {
  38395. /**
  38396. * Manage the keyboard inputs to control the movement of a follow camera.
  38397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38398. */
  38399. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38400. /**
  38401. * Defines the camera the input is attached to.
  38402. */
  38403. camera: FollowCamera;
  38404. /**
  38405. * Defines the list of key codes associated with the up action (increase heightOffset)
  38406. */
  38407. keysHeightOffsetIncr: number[];
  38408. /**
  38409. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38410. */
  38411. keysHeightOffsetDecr: number[];
  38412. /**
  38413. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38414. */
  38415. keysHeightOffsetModifierAlt: boolean;
  38416. /**
  38417. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38418. */
  38419. keysHeightOffsetModifierCtrl: boolean;
  38420. /**
  38421. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38422. */
  38423. keysHeightOffsetModifierShift: boolean;
  38424. /**
  38425. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38426. */
  38427. keysRotationOffsetIncr: number[];
  38428. /**
  38429. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38430. */
  38431. keysRotationOffsetDecr: number[];
  38432. /**
  38433. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38434. */
  38435. keysRotationOffsetModifierAlt: boolean;
  38436. /**
  38437. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38438. */
  38439. keysRotationOffsetModifierCtrl: boolean;
  38440. /**
  38441. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38442. */
  38443. keysRotationOffsetModifierShift: boolean;
  38444. /**
  38445. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38446. */
  38447. keysRadiusIncr: number[];
  38448. /**
  38449. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38450. */
  38451. keysRadiusDecr: number[];
  38452. /**
  38453. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38454. */
  38455. keysRadiusModifierAlt: boolean;
  38456. /**
  38457. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38458. */
  38459. keysRadiusModifierCtrl: boolean;
  38460. /**
  38461. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38462. */
  38463. keysRadiusModifierShift: boolean;
  38464. /**
  38465. * Defines the rate of change of heightOffset.
  38466. */
  38467. heightSensibility: number;
  38468. /**
  38469. * Defines the rate of change of rotationOffset.
  38470. */
  38471. rotationSensibility: number;
  38472. /**
  38473. * Defines the rate of change of radius.
  38474. */
  38475. radiusSensibility: number;
  38476. private _keys;
  38477. private _ctrlPressed;
  38478. private _altPressed;
  38479. private _shiftPressed;
  38480. private _onCanvasBlurObserver;
  38481. private _onKeyboardObserver;
  38482. private _engine;
  38483. private _scene;
  38484. /**
  38485. * Attach the input controls to a specific dom element to get the input from.
  38486. * @param element Defines the element the controls should be listened from
  38487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38488. */
  38489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38490. /**
  38491. * Detach the current controls from the specified dom element.
  38492. * @param element Defines the element to stop listening the inputs from
  38493. */
  38494. detachControl(element: Nullable<HTMLElement>): void;
  38495. /**
  38496. * Update the current camera state depending on the inputs that have been used this frame.
  38497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38498. */
  38499. checkInputs(): void;
  38500. /**
  38501. * Gets the class name of the current input.
  38502. * @returns the class name
  38503. */
  38504. getClassName(): string;
  38505. /**
  38506. * Get the friendly name associated with the input class.
  38507. * @returns the input friendly name
  38508. */
  38509. getSimpleName(): string;
  38510. /**
  38511. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38512. * allow modification of the heightOffset value.
  38513. */
  38514. private _modifierHeightOffset;
  38515. /**
  38516. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38517. * allow modification of the rotationOffset value.
  38518. */
  38519. private _modifierRotationOffset;
  38520. /**
  38521. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38522. * allow modification of the radius value.
  38523. */
  38524. private _modifierRadius;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. interface FreeCameraInputsManager {
  38529. /**
  38530. * @hidden
  38531. */
  38532. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38533. /**
  38534. * Add orientation input support to the input manager.
  38535. * @returns the current input manager
  38536. */
  38537. addDeviceOrientation(): FreeCameraInputsManager;
  38538. }
  38539. /**
  38540. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38541. * Screen rotation is taken into account.
  38542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38543. */
  38544. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38545. private _camera;
  38546. private _screenOrientationAngle;
  38547. private _constantTranform;
  38548. private _screenQuaternion;
  38549. private _alpha;
  38550. private _beta;
  38551. private _gamma;
  38552. /**
  38553. * Can be used to detect if a device orientation sensor is availible on a device
  38554. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38555. * @returns a promise that will resolve on orientation change
  38556. */
  38557. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38558. /**
  38559. * @hidden
  38560. */
  38561. _onDeviceOrientationChangedObservable: Observable<void>;
  38562. /**
  38563. * Instantiates a new input
  38564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38565. */
  38566. constructor();
  38567. /**
  38568. * Define the camera controlled by the input.
  38569. */
  38570. camera: FreeCamera;
  38571. /**
  38572. * Attach the input controls to a specific dom element to get the input from.
  38573. * @param element Defines the element the controls should be listened from
  38574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38577. private _orientationChanged;
  38578. private _deviceOrientation;
  38579. /**
  38580. * Detach the current controls from the specified dom element.
  38581. * @param element Defines the element to stop listening the inputs from
  38582. */
  38583. detachControl(element: Nullable<HTMLElement>): void;
  38584. /**
  38585. * Update the current camera state depending on the inputs that have been used this frame.
  38586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38587. */
  38588. checkInputs(): void;
  38589. /**
  38590. * Gets the class name of the current intput.
  38591. * @returns the class name
  38592. */
  38593. getClassName(): string;
  38594. /**
  38595. * Get the friendly name associated with the input class.
  38596. * @returns the input friendly name
  38597. */
  38598. getSimpleName(): string;
  38599. }
  38600. }
  38601. declare module BABYLON {
  38602. /**
  38603. * Manage the gamepad inputs to control a free camera.
  38604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38605. */
  38606. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38607. /**
  38608. * Define the camera the input is attached to.
  38609. */
  38610. camera: FreeCamera;
  38611. /**
  38612. * Define the Gamepad controlling the input
  38613. */
  38614. gamepad: Nullable<Gamepad>;
  38615. /**
  38616. * Defines the gamepad rotation sensiblity.
  38617. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38618. */
  38619. gamepadAngularSensibility: number;
  38620. /**
  38621. * Defines the gamepad move sensiblity.
  38622. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38623. */
  38624. gamepadMoveSensibility: number;
  38625. private _yAxisScale;
  38626. /**
  38627. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38628. */
  38629. invertYAxis: boolean;
  38630. private _onGamepadConnectedObserver;
  38631. private _onGamepadDisconnectedObserver;
  38632. private _cameraTransform;
  38633. private _deltaTransform;
  38634. private _vector3;
  38635. private _vector2;
  38636. /**
  38637. * Attach the input controls to a specific dom element to get the input from.
  38638. * @param element Defines the element the controls should be listened from
  38639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38640. */
  38641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38642. /**
  38643. * Detach the current controls from the specified dom element.
  38644. * @param element Defines the element to stop listening the inputs from
  38645. */
  38646. detachControl(element: Nullable<HTMLElement>): void;
  38647. /**
  38648. * Update the current camera state depending on the inputs that have been used this frame.
  38649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38650. */
  38651. checkInputs(): void;
  38652. /**
  38653. * Gets the class name of the current intput.
  38654. * @returns the class name
  38655. */
  38656. getClassName(): string;
  38657. /**
  38658. * Get the friendly name associated with the input class.
  38659. * @returns the input friendly name
  38660. */
  38661. getSimpleName(): string;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * Defines the potential axis of a Joystick
  38667. */
  38668. export enum JoystickAxis {
  38669. /** X axis */
  38670. X = 0,
  38671. /** Y axis */
  38672. Y = 1,
  38673. /** Z axis */
  38674. Z = 2
  38675. }
  38676. /**
  38677. * Class used to define virtual joystick (used in touch mode)
  38678. */
  38679. export class VirtualJoystick {
  38680. /**
  38681. * Gets or sets a boolean indicating that left and right values must be inverted
  38682. */
  38683. reverseLeftRight: boolean;
  38684. /**
  38685. * Gets or sets a boolean indicating that up and down values must be inverted
  38686. */
  38687. reverseUpDown: boolean;
  38688. /**
  38689. * Gets the offset value for the position (ie. the change of the position value)
  38690. */
  38691. deltaPosition: Vector3;
  38692. /**
  38693. * Gets a boolean indicating if the virtual joystick was pressed
  38694. */
  38695. pressed: boolean;
  38696. /**
  38697. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38698. */
  38699. static Canvas: Nullable<HTMLCanvasElement>;
  38700. private static _globalJoystickIndex;
  38701. private static vjCanvasContext;
  38702. private static vjCanvasWidth;
  38703. private static vjCanvasHeight;
  38704. private static halfWidth;
  38705. private _action;
  38706. private _axisTargetedByLeftAndRight;
  38707. private _axisTargetedByUpAndDown;
  38708. private _joystickSensibility;
  38709. private _inversedSensibility;
  38710. private _joystickPointerID;
  38711. private _joystickColor;
  38712. private _joystickPointerPos;
  38713. private _joystickPreviousPointerPos;
  38714. private _joystickPointerStartPos;
  38715. private _deltaJoystickVector;
  38716. private _leftJoystick;
  38717. private _touches;
  38718. private _onPointerDownHandlerRef;
  38719. private _onPointerMoveHandlerRef;
  38720. private _onPointerUpHandlerRef;
  38721. private _onResize;
  38722. /**
  38723. * Creates a new virtual joystick
  38724. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38725. */
  38726. constructor(leftJoystick?: boolean);
  38727. /**
  38728. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38729. * @param newJoystickSensibility defines the new sensibility
  38730. */
  38731. setJoystickSensibility(newJoystickSensibility: number): void;
  38732. private _onPointerDown;
  38733. private _onPointerMove;
  38734. private _onPointerUp;
  38735. /**
  38736. * Change the color of the virtual joystick
  38737. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38738. */
  38739. setJoystickColor(newColor: string): void;
  38740. /**
  38741. * Defines a callback to call when the joystick is touched
  38742. * @param action defines the callback
  38743. */
  38744. setActionOnTouch(action: () => any): void;
  38745. /**
  38746. * Defines which axis you'd like to control for left & right
  38747. * @param axis defines the axis to use
  38748. */
  38749. setAxisForLeftRight(axis: JoystickAxis): void;
  38750. /**
  38751. * Defines which axis you'd like to control for up & down
  38752. * @param axis defines the axis to use
  38753. */
  38754. setAxisForUpDown(axis: JoystickAxis): void;
  38755. private _drawVirtualJoystick;
  38756. /**
  38757. * Release internal HTML canvas
  38758. */
  38759. releaseCanvas(): void;
  38760. }
  38761. }
  38762. declare module BABYLON {
  38763. interface FreeCameraInputsManager {
  38764. /**
  38765. * Add virtual joystick input support to the input manager.
  38766. * @returns the current input manager
  38767. */
  38768. addVirtualJoystick(): FreeCameraInputsManager;
  38769. }
  38770. /**
  38771. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38773. */
  38774. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38775. /**
  38776. * Defines the camera the input is attached to.
  38777. */
  38778. camera: FreeCamera;
  38779. private _leftjoystick;
  38780. private _rightjoystick;
  38781. /**
  38782. * Gets the left stick of the virtual joystick.
  38783. * @returns The virtual Joystick
  38784. */
  38785. getLeftJoystick(): VirtualJoystick;
  38786. /**
  38787. * Gets the right stick of the virtual joystick.
  38788. * @returns The virtual Joystick
  38789. */
  38790. getRightJoystick(): VirtualJoystick;
  38791. /**
  38792. * Update the current camera state depending on the inputs that have been used this frame.
  38793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38794. */
  38795. checkInputs(): void;
  38796. /**
  38797. * Attach the input controls to a specific dom element to get the input from.
  38798. * @param element Defines the element the controls should be listened from
  38799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38800. */
  38801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38802. /**
  38803. * Detach the current controls from the specified dom element.
  38804. * @param element Defines the element to stop listening the inputs from
  38805. */
  38806. detachControl(element: Nullable<HTMLElement>): void;
  38807. /**
  38808. * Gets the class name of the current intput.
  38809. * @returns the class name
  38810. */
  38811. getClassName(): string;
  38812. /**
  38813. * Get the friendly name associated with the input class.
  38814. * @returns the input friendly name
  38815. */
  38816. getSimpleName(): string;
  38817. }
  38818. }
  38819. declare module BABYLON {
  38820. /**
  38821. * This represents a FPS type of camera controlled by touch.
  38822. * This is like a universal camera minus the Gamepad controls.
  38823. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38824. */
  38825. export class TouchCamera extends FreeCamera {
  38826. /**
  38827. * Defines the touch sensibility for rotation.
  38828. * The higher the faster.
  38829. */
  38830. touchAngularSensibility: number;
  38831. /**
  38832. * Defines the touch sensibility for move.
  38833. * The higher the faster.
  38834. */
  38835. touchMoveSensibility: number;
  38836. /**
  38837. * Instantiates a new touch camera.
  38838. * This represents a FPS type of camera controlled by touch.
  38839. * This is like a universal camera minus the Gamepad controls.
  38840. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38841. * @param name Define the name of the camera in the scene
  38842. * @param position Define the start position of the camera in the scene
  38843. * @param scene Define the scene the camera belongs to
  38844. */
  38845. constructor(name: string, position: Vector3, scene: Scene);
  38846. /**
  38847. * Gets the current object class name.
  38848. * @return the class name
  38849. */
  38850. getClassName(): string;
  38851. /** @hidden */
  38852. _setupInputs(): void;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38858. * being tilted forward or back and left or right.
  38859. */
  38860. export class DeviceOrientationCamera extends FreeCamera {
  38861. private _initialQuaternion;
  38862. private _quaternionCache;
  38863. private _tmpDragQuaternion;
  38864. private _disablePointerInputWhenUsingDeviceOrientation;
  38865. /**
  38866. * Creates a new device orientation camera
  38867. * @param name The name of the camera
  38868. * @param position The start position camera
  38869. * @param scene The scene the camera belongs to
  38870. */
  38871. constructor(name: string, position: Vector3, scene: Scene);
  38872. /**
  38873. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38874. */
  38875. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38876. private _dragFactor;
  38877. /**
  38878. * Enabled turning on the y axis when the orientation sensor is active
  38879. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38880. */
  38881. enableHorizontalDragging(dragFactor?: number): void;
  38882. /**
  38883. * Gets the current instance class name ("DeviceOrientationCamera").
  38884. * This helps avoiding instanceof at run time.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * @hidden
  38890. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38891. */
  38892. _checkInputs(): void;
  38893. /**
  38894. * Reset the camera to its default orientation on the specified axis only.
  38895. * @param axis The axis to reset
  38896. */
  38897. resetToCurrentRotation(axis?: Axis): void;
  38898. }
  38899. }
  38900. declare module BABYLON {
  38901. /**
  38902. * Defines supported buttons for XBox360 compatible gamepads
  38903. */
  38904. export enum Xbox360Button {
  38905. /** A */
  38906. A = 0,
  38907. /** B */
  38908. B = 1,
  38909. /** X */
  38910. X = 2,
  38911. /** Y */
  38912. Y = 3,
  38913. /** Start */
  38914. Start = 4,
  38915. /** Back */
  38916. Back = 5,
  38917. /** Left button */
  38918. LB = 6,
  38919. /** Right button */
  38920. RB = 7,
  38921. /** Left stick */
  38922. LeftStick = 8,
  38923. /** Right stick */
  38924. RightStick = 9
  38925. }
  38926. /** Defines values for XBox360 DPad */
  38927. export enum Xbox360Dpad {
  38928. /** Up */
  38929. Up = 0,
  38930. /** Down */
  38931. Down = 1,
  38932. /** Left */
  38933. Left = 2,
  38934. /** Right */
  38935. Right = 3
  38936. }
  38937. /**
  38938. * Defines a XBox360 gamepad
  38939. */
  38940. export class Xbox360Pad extends Gamepad {
  38941. private _leftTrigger;
  38942. private _rightTrigger;
  38943. private _onlefttriggerchanged;
  38944. private _onrighttriggerchanged;
  38945. private _onbuttondown;
  38946. private _onbuttonup;
  38947. private _ondpaddown;
  38948. private _ondpadup;
  38949. /** Observable raised when a button is pressed */
  38950. onButtonDownObservable: Observable<Xbox360Button>;
  38951. /** Observable raised when a button is released */
  38952. onButtonUpObservable: Observable<Xbox360Button>;
  38953. /** Observable raised when a pad is pressed */
  38954. onPadDownObservable: Observable<Xbox360Dpad>;
  38955. /** Observable raised when a pad is released */
  38956. onPadUpObservable: Observable<Xbox360Dpad>;
  38957. private _buttonA;
  38958. private _buttonB;
  38959. private _buttonX;
  38960. private _buttonY;
  38961. private _buttonBack;
  38962. private _buttonStart;
  38963. private _buttonLB;
  38964. private _buttonRB;
  38965. private _buttonLeftStick;
  38966. private _buttonRightStick;
  38967. private _dPadUp;
  38968. private _dPadDown;
  38969. private _dPadLeft;
  38970. private _dPadRight;
  38971. private _isXboxOnePad;
  38972. /**
  38973. * Creates a new XBox360 gamepad object
  38974. * @param id defines the id of this gamepad
  38975. * @param index defines its index
  38976. * @param gamepad defines the internal HTML gamepad object
  38977. * @param xboxOne defines if it is a XBox One gamepad
  38978. */
  38979. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38980. /**
  38981. * Defines the callback to call when left trigger is pressed
  38982. * @param callback defines the callback to use
  38983. */
  38984. onlefttriggerchanged(callback: (value: number) => void): void;
  38985. /**
  38986. * Defines the callback to call when right trigger is pressed
  38987. * @param callback defines the callback to use
  38988. */
  38989. onrighttriggerchanged(callback: (value: number) => void): void;
  38990. /**
  38991. * Gets the left trigger value
  38992. */
  38993. /**
  38994. * Sets the left trigger value
  38995. */
  38996. leftTrigger: number;
  38997. /**
  38998. * Gets the right trigger value
  38999. */
  39000. /**
  39001. * Sets the right trigger value
  39002. */
  39003. rightTrigger: number;
  39004. /**
  39005. * Defines the callback to call when a button is pressed
  39006. * @param callback defines the callback to use
  39007. */
  39008. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39009. /**
  39010. * Defines the callback to call when a button is released
  39011. * @param callback defines the callback to use
  39012. */
  39013. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39014. /**
  39015. * Defines the callback to call when a pad is pressed
  39016. * @param callback defines the callback to use
  39017. */
  39018. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39019. /**
  39020. * Defines the callback to call when a pad is released
  39021. * @param callback defines the callback to use
  39022. */
  39023. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39024. private _setButtonValue;
  39025. private _setDPadValue;
  39026. /**
  39027. * Gets the value of the `A` button
  39028. */
  39029. /**
  39030. * Sets the value of the `A` button
  39031. */
  39032. buttonA: number;
  39033. /**
  39034. * Gets the value of the `B` button
  39035. */
  39036. /**
  39037. * Sets the value of the `B` button
  39038. */
  39039. buttonB: number;
  39040. /**
  39041. * Gets the value of the `X` button
  39042. */
  39043. /**
  39044. * Sets the value of the `X` button
  39045. */
  39046. buttonX: number;
  39047. /**
  39048. * Gets the value of the `Y` button
  39049. */
  39050. /**
  39051. * Sets the value of the `Y` button
  39052. */
  39053. buttonY: number;
  39054. /**
  39055. * Gets the value of the `Start` button
  39056. */
  39057. /**
  39058. * Sets the value of the `Start` button
  39059. */
  39060. buttonStart: number;
  39061. /**
  39062. * Gets the value of the `Back` button
  39063. */
  39064. /**
  39065. * Sets the value of the `Back` button
  39066. */
  39067. buttonBack: number;
  39068. /**
  39069. * Gets the value of the `Left` button
  39070. */
  39071. /**
  39072. * Sets the value of the `Left` button
  39073. */
  39074. buttonLB: number;
  39075. /**
  39076. * Gets the value of the `Right` button
  39077. */
  39078. /**
  39079. * Sets the value of the `Right` button
  39080. */
  39081. buttonRB: number;
  39082. /**
  39083. * Gets the value of the Left joystick
  39084. */
  39085. /**
  39086. * Sets the value of the Left joystick
  39087. */
  39088. buttonLeftStick: number;
  39089. /**
  39090. * Gets the value of the Right joystick
  39091. */
  39092. /**
  39093. * Sets the value of the Right joystick
  39094. */
  39095. buttonRightStick: number;
  39096. /**
  39097. * Gets the value of D-pad up
  39098. */
  39099. /**
  39100. * Sets the value of D-pad up
  39101. */
  39102. dPadUp: number;
  39103. /**
  39104. * Gets the value of D-pad down
  39105. */
  39106. /**
  39107. * Sets the value of D-pad down
  39108. */
  39109. dPadDown: number;
  39110. /**
  39111. * Gets the value of D-pad left
  39112. */
  39113. /**
  39114. * Sets the value of D-pad left
  39115. */
  39116. dPadLeft: number;
  39117. /**
  39118. * Gets the value of D-pad right
  39119. */
  39120. /**
  39121. * Sets the value of D-pad right
  39122. */
  39123. dPadRight: number;
  39124. /**
  39125. * Force the gamepad to synchronize with device values
  39126. */
  39127. update(): void;
  39128. /**
  39129. * Disposes the gamepad
  39130. */
  39131. dispose(): void;
  39132. }
  39133. }
  39134. declare module BABYLON {
  39135. /**
  39136. * Defines supported buttons for DualShock compatible gamepads
  39137. */
  39138. export enum DualShockButton {
  39139. /** Cross */
  39140. Cross = 0,
  39141. /** Circle */
  39142. Circle = 1,
  39143. /** Square */
  39144. Square = 2,
  39145. /** Triangle */
  39146. Triangle = 3,
  39147. /** Options */
  39148. Options = 4,
  39149. /** Share */
  39150. Share = 5,
  39151. /** L1 */
  39152. L1 = 6,
  39153. /** R1 */
  39154. R1 = 7,
  39155. /** Left stick */
  39156. LeftStick = 8,
  39157. /** Right stick */
  39158. RightStick = 9
  39159. }
  39160. /** Defines values for DualShock DPad */
  39161. export enum DualShockDpad {
  39162. /** Up */
  39163. Up = 0,
  39164. /** Down */
  39165. Down = 1,
  39166. /** Left */
  39167. Left = 2,
  39168. /** Right */
  39169. Right = 3
  39170. }
  39171. /**
  39172. * Defines a DualShock gamepad
  39173. */
  39174. export class DualShockPad extends Gamepad {
  39175. private _leftTrigger;
  39176. private _rightTrigger;
  39177. private _onlefttriggerchanged;
  39178. private _onrighttriggerchanged;
  39179. private _onbuttondown;
  39180. private _onbuttonup;
  39181. private _ondpaddown;
  39182. private _ondpadup;
  39183. /** Observable raised when a button is pressed */
  39184. onButtonDownObservable: Observable<DualShockButton>;
  39185. /** Observable raised when a button is released */
  39186. onButtonUpObservable: Observable<DualShockButton>;
  39187. /** Observable raised when a pad is pressed */
  39188. onPadDownObservable: Observable<DualShockDpad>;
  39189. /** Observable raised when a pad is released */
  39190. onPadUpObservable: Observable<DualShockDpad>;
  39191. private _buttonCross;
  39192. private _buttonCircle;
  39193. private _buttonSquare;
  39194. private _buttonTriangle;
  39195. private _buttonShare;
  39196. private _buttonOptions;
  39197. private _buttonL1;
  39198. private _buttonR1;
  39199. private _buttonLeftStick;
  39200. private _buttonRightStick;
  39201. private _dPadUp;
  39202. private _dPadDown;
  39203. private _dPadLeft;
  39204. private _dPadRight;
  39205. /**
  39206. * Creates a new DualShock gamepad object
  39207. * @param id defines the id of this gamepad
  39208. * @param index defines its index
  39209. * @param gamepad defines the internal HTML gamepad object
  39210. */
  39211. constructor(id: string, index: number, gamepad: any);
  39212. /**
  39213. * Defines the callback to call when left trigger is pressed
  39214. * @param callback defines the callback to use
  39215. */
  39216. onlefttriggerchanged(callback: (value: number) => void): void;
  39217. /**
  39218. * Defines the callback to call when right trigger is pressed
  39219. * @param callback defines the callback to use
  39220. */
  39221. onrighttriggerchanged(callback: (value: number) => void): void;
  39222. /**
  39223. * Gets the left trigger value
  39224. */
  39225. /**
  39226. * Sets the left trigger value
  39227. */
  39228. leftTrigger: number;
  39229. /**
  39230. * Gets the right trigger value
  39231. */
  39232. /**
  39233. * Sets the right trigger value
  39234. */
  39235. rightTrigger: number;
  39236. /**
  39237. * Defines the callback to call when a button is pressed
  39238. * @param callback defines the callback to use
  39239. */
  39240. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39241. /**
  39242. * Defines the callback to call when a button is released
  39243. * @param callback defines the callback to use
  39244. */
  39245. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39246. /**
  39247. * Defines the callback to call when a pad is pressed
  39248. * @param callback defines the callback to use
  39249. */
  39250. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39251. /**
  39252. * Defines the callback to call when a pad is released
  39253. * @param callback defines the callback to use
  39254. */
  39255. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39256. private _setButtonValue;
  39257. private _setDPadValue;
  39258. /**
  39259. * Gets the value of the `Cross` button
  39260. */
  39261. /**
  39262. * Sets the value of the `Cross` button
  39263. */
  39264. buttonCross: number;
  39265. /**
  39266. * Gets the value of the `Circle` button
  39267. */
  39268. /**
  39269. * Sets the value of the `Circle` button
  39270. */
  39271. buttonCircle: number;
  39272. /**
  39273. * Gets the value of the `Square` button
  39274. */
  39275. /**
  39276. * Sets the value of the `Square` button
  39277. */
  39278. buttonSquare: number;
  39279. /**
  39280. * Gets the value of the `Triangle` button
  39281. */
  39282. /**
  39283. * Sets the value of the `Triangle` button
  39284. */
  39285. buttonTriangle: number;
  39286. /**
  39287. * Gets the value of the `Options` button
  39288. */
  39289. /**
  39290. * Sets the value of the `Options` button
  39291. */
  39292. buttonOptions: number;
  39293. /**
  39294. * Gets the value of the `Share` button
  39295. */
  39296. /**
  39297. * Sets the value of the `Share` button
  39298. */
  39299. buttonShare: number;
  39300. /**
  39301. * Gets the value of the `L1` button
  39302. */
  39303. /**
  39304. * Sets the value of the `L1` button
  39305. */
  39306. buttonL1: number;
  39307. /**
  39308. * Gets the value of the `R1` button
  39309. */
  39310. /**
  39311. * Sets the value of the `R1` button
  39312. */
  39313. buttonR1: number;
  39314. /**
  39315. * Gets the value of the Left joystick
  39316. */
  39317. /**
  39318. * Sets the value of the Left joystick
  39319. */
  39320. buttonLeftStick: number;
  39321. /**
  39322. * Gets the value of the Right joystick
  39323. */
  39324. /**
  39325. * Sets the value of the Right joystick
  39326. */
  39327. buttonRightStick: number;
  39328. /**
  39329. * Gets the value of D-pad up
  39330. */
  39331. /**
  39332. * Sets the value of D-pad up
  39333. */
  39334. dPadUp: number;
  39335. /**
  39336. * Gets the value of D-pad down
  39337. */
  39338. /**
  39339. * Sets the value of D-pad down
  39340. */
  39341. dPadDown: number;
  39342. /**
  39343. * Gets the value of D-pad left
  39344. */
  39345. /**
  39346. * Sets the value of D-pad left
  39347. */
  39348. dPadLeft: number;
  39349. /**
  39350. * Gets the value of D-pad right
  39351. */
  39352. /**
  39353. * Sets the value of D-pad right
  39354. */
  39355. dPadRight: number;
  39356. /**
  39357. * Force the gamepad to synchronize with device values
  39358. */
  39359. update(): void;
  39360. /**
  39361. * Disposes the gamepad
  39362. */
  39363. dispose(): void;
  39364. }
  39365. }
  39366. declare module BABYLON {
  39367. /**
  39368. * Manager for handling gamepads
  39369. */
  39370. export class GamepadManager {
  39371. private _scene?;
  39372. private _babylonGamepads;
  39373. private _oneGamepadConnected;
  39374. /** @hidden */
  39375. _isMonitoring: boolean;
  39376. private _gamepadEventSupported;
  39377. private _gamepadSupport;
  39378. /**
  39379. * observable to be triggered when the gamepad controller has been connected
  39380. */
  39381. onGamepadConnectedObservable: Observable<Gamepad>;
  39382. /**
  39383. * observable to be triggered when the gamepad controller has been disconnected
  39384. */
  39385. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39386. private _onGamepadConnectedEvent;
  39387. private _onGamepadDisconnectedEvent;
  39388. /**
  39389. * Initializes the gamepad manager
  39390. * @param _scene BabylonJS scene
  39391. */
  39392. constructor(_scene?: Scene | undefined);
  39393. /**
  39394. * The gamepads in the game pad manager
  39395. */
  39396. readonly gamepads: Gamepad[];
  39397. /**
  39398. * Get the gamepad controllers based on type
  39399. * @param type The type of gamepad controller
  39400. * @returns Nullable gamepad
  39401. */
  39402. getGamepadByType(type?: number): Nullable<Gamepad>;
  39403. /**
  39404. * Disposes the gamepad manager
  39405. */
  39406. dispose(): void;
  39407. private _addNewGamepad;
  39408. private _startMonitoringGamepads;
  39409. private _stopMonitoringGamepads;
  39410. /** @hidden */
  39411. _checkGamepadsStatus(): void;
  39412. private _updateGamepadObjects;
  39413. }
  39414. }
  39415. declare module BABYLON {
  39416. interface Scene {
  39417. /** @hidden */
  39418. _gamepadManager: Nullable<GamepadManager>;
  39419. /**
  39420. * Gets the gamepad manager associated with the scene
  39421. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39422. */
  39423. gamepadManager: GamepadManager;
  39424. }
  39425. /**
  39426. * Interface representing a free camera inputs manager
  39427. */
  39428. interface FreeCameraInputsManager {
  39429. /**
  39430. * Adds gamepad input support to the FreeCameraInputsManager.
  39431. * @returns the FreeCameraInputsManager
  39432. */
  39433. addGamepad(): FreeCameraInputsManager;
  39434. }
  39435. /**
  39436. * Interface representing an arc rotate camera inputs manager
  39437. */
  39438. interface ArcRotateCameraInputsManager {
  39439. /**
  39440. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39441. * @returns the camera inputs manager
  39442. */
  39443. addGamepad(): ArcRotateCameraInputsManager;
  39444. }
  39445. /**
  39446. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39447. */
  39448. export class GamepadSystemSceneComponent implements ISceneComponent {
  39449. /**
  39450. * The component name helpfull to identify the component in the list of scene components.
  39451. */
  39452. readonly name: string;
  39453. /**
  39454. * The scene the component belongs to.
  39455. */
  39456. scene: Scene;
  39457. /**
  39458. * Creates a new instance of the component for the given scene
  39459. * @param scene Defines the scene to register the component in
  39460. */
  39461. constructor(scene: Scene);
  39462. /**
  39463. * Registers the component in a given scene
  39464. */
  39465. register(): void;
  39466. /**
  39467. * Rebuilds the elements related to this component in case of
  39468. * context lost for instance.
  39469. */
  39470. rebuild(): void;
  39471. /**
  39472. * Disposes the component and the associated ressources
  39473. */
  39474. dispose(): void;
  39475. private _beforeCameraUpdate;
  39476. }
  39477. }
  39478. declare module BABYLON {
  39479. /**
  39480. * 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,
  39481. * which still works and will still be found in many Playgrounds.
  39482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39483. */
  39484. export class UniversalCamera extends TouchCamera {
  39485. /**
  39486. * Defines the gamepad rotation sensiblity.
  39487. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39488. */
  39489. gamepadAngularSensibility: number;
  39490. /**
  39491. * Defines the gamepad move sensiblity.
  39492. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39493. */
  39494. gamepadMoveSensibility: number;
  39495. /**
  39496. * 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,
  39497. * which still works and will still be found in many Playgrounds.
  39498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39499. * @param name Define the name of the camera in the scene
  39500. * @param position Define the start position of the camera in the scene
  39501. * @param scene Define the scene the camera belongs to
  39502. */
  39503. constructor(name: string, position: Vector3, scene: Scene);
  39504. /**
  39505. * Gets the current object class name.
  39506. * @return the class name
  39507. */
  39508. getClassName(): string;
  39509. }
  39510. }
  39511. declare module BABYLON {
  39512. /**
  39513. * This represents a FPS type of camera. This is only here for back compat purpose.
  39514. * Please use the UniversalCamera instead as both are identical.
  39515. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39516. */
  39517. export class GamepadCamera extends UniversalCamera {
  39518. /**
  39519. * Instantiates a new Gamepad Camera
  39520. * This represents a FPS type of camera. This is only here for back compat purpose.
  39521. * Please use the UniversalCamera instead as both are identical.
  39522. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39523. * @param name Define the name of the camera in the scene
  39524. * @param position Define the start position of the camera in the scene
  39525. * @param scene Define the scene the camera belongs to
  39526. */
  39527. constructor(name: string, position: Vector3, scene: Scene);
  39528. /**
  39529. * Gets the current object class name.
  39530. * @return the class name
  39531. */
  39532. getClassName(): string;
  39533. }
  39534. }
  39535. declare module BABYLON {
  39536. /** @hidden */
  39537. export var passPixelShader: {
  39538. name: string;
  39539. shader: string;
  39540. };
  39541. }
  39542. declare module BABYLON {
  39543. /** @hidden */
  39544. export var passCubePixelShader: {
  39545. name: string;
  39546. shader: string;
  39547. };
  39548. }
  39549. declare module BABYLON {
  39550. /**
  39551. * PassPostProcess which produces an output the same as it's input
  39552. */
  39553. export class PassPostProcess extends PostProcess {
  39554. /**
  39555. * Creates the PassPostProcess
  39556. * @param name The name of the effect.
  39557. * @param options The required width/height ratio to downsize to before computing the render pass.
  39558. * @param camera The camera to apply the render pass to.
  39559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39560. * @param engine The engine which the post process will be applied. (default: current engine)
  39561. * @param reusable If the post process can be reused on the same frame. (default: false)
  39562. * @param textureType The type of texture to be used when performing the post processing.
  39563. * @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)
  39564. */
  39565. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39566. }
  39567. /**
  39568. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39569. */
  39570. export class PassCubePostProcess extends PostProcess {
  39571. private _face;
  39572. /**
  39573. * Gets or sets the cube face to display.
  39574. * * 0 is +X
  39575. * * 1 is -X
  39576. * * 2 is +Y
  39577. * * 3 is -Y
  39578. * * 4 is +Z
  39579. * * 5 is -Z
  39580. */
  39581. face: number;
  39582. /**
  39583. * Creates the PassCubePostProcess
  39584. * @param name The name of the effect.
  39585. * @param options The required width/height ratio to downsize to before computing the render pass.
  39586. * @param camera The camera to apply the render pass to.
  39587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39588. * @param engine The engine which the post process will be applied. (default: current engine)
  39589. * @param reusable If the post process can be reused on the same frame. (default: false)
  39590. * @param textureType The type of texture to be used when performing the post processing.
  39591. * @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)
  39592. */
  39593. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39594. }
  39595. }
  39596. declare module BABYLON {
  39597. /** @hidden */
  39598. export var anaglyphPixelShader: {
  39599. name: string;
  39600. shader: string;
  39601. };
  39602. }
  39603. declare module BABYLON {
  39604. /**
  39605. * Postprocess used to generate anaglyphic rendering
  39606. */
  39607. export class AnaglyphPostProcess extends PostProcess {
  39608. private _passedProcess;
  39609. /**
  39610. * Creates a new AnaglyphPostProcess
  39611. * @param name defines postprocess name
  39612. * @param options defines creation options or target ratio scale
  39613. * @param rigCameras defines cameras using this postprocess
  39614. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39615. * @param engine defines hosting engine
  39616. * @param reusable defines if the postprocess will be reused multiple times per frame
  39617. */
  39618. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39619. }
  39620. }
  39621. declare module BABYLON {
  39622. /**
  39623. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39624. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39625. */
  39626. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39627. /**
  39628. * Creates a new AnaglyphArcRotateCamera
  39629. * @param name defines camera name
  39630. * @param alpha defines alpha angle (in radians)
  39631. * @param beta defines beta angle (in radians)
  39632. * @param radius defines radius
  39633. * @param target defines camera target
  39634. * @param interaxialDistance defines distance between each color axis
  39635. * @param scene defines the hosting scene
  39636. */
  39637. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39638. /**
  39639. * Gets camera class name
  39640. * @returns AnaglyphArcRotateCamera
  39641. */
  39642. getClassName(): string;
  39643. }
  39644. }
  39645. declare module BABYLON {
  39646. /**
  39647. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39648. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39649. */
  39650. export class AnaglyphFreeCamera extends FreeCamera {
  39651. /**
  39652. * Creates a new AnaglyphFreeCamera
  39653. * @param name defines camera name
  39654. * @param position defines initial position
  39655. * @param interaxialDistance defines distance between each color axis
  39656. * @param scene defines the hosting scene
  39657. */
  39658. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39659. /**
  39660. * Gets camera class name
  39661. * @returns AnaglyphFreeCamera
  39662. */
  39663. getClassName(): string;
  39664. }
  39665. }
  39666. declare module BABYLON {
  39667. /**
  39668. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39669. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39670. */
  39671. export class AnaglyphGamepadCamera extends GamepadCamera {
  39672. /**
  39673. * Creates a new AnaglyphGamepadCamera
  39674. * @param name defines camera name
  39675. * @param position defines initial position
  39676. * @param interaxialDistance defines distance between each color axis
  39677. * @param scene defines the hosting scene
  39678. */
  39679. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39680. /**
  39681. * Gets camera class name
  39682. * @returns AnaglyphGamepadCamera
  39683. */
  39684. getClassName(): string;
  39685. }
  39686. }
  39687. declare module BABYLON {
  39688. /**
  39689. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39690. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39691. */
  39692. export class AnaglyphUniversalCamera extends UniversalCamera {
  39693. /**
  39694. * Creates a new AnaglyphUniversalCamera
  39695. * @param name defines camera name
  39696. * @param position defines initial position
  39697. * @param interaxialDistance defines distance between each color axis
  39698. * @param scene defines the hosting scene
  39699. */
  39700. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39701. /**
  39702. * Gets camera class name
  39703. * @returns AnaglyphUniversalCamera
  39704. */
  39705. getClassName(): string;
  39706. }
  39707. }
  39708. declare module BABYLON {
  39709. /** @hidden */
  39710. export var stereoscopicInterlacePixelShader: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module BABYLON {
  39716. /**
  39717. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39718. */
  39719. export class StereoscopicInterlacePostProcess extends PostProcess {
  39720. private _stepSize;
  39721. private _passedProcess;
  39722. /**
  39723. * Initializes a StereoscopicInterlacePostProcess
  39724. * @param name The name of the effect.
  39725. * @param rigCameras The rig cameras to be appled to the post process
  39726. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39728. * @param engine The engine which the post process will be applied. (default: current engine)
  39729. * @param reusable If the post process can be reused on the same frame. (default: false)
  39730. */
  39731. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39732. }
  39733. }
  39734. declare module BABYLON {
  39735. /**
  39736. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39737. * @see http://doc.babylonjs.com/features/cameras
  39738. */
  39739. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39740. /**
  39741. * Creates a new StereoscopicArcRotateCamera
  39742. * @param name defines camera name
  39743. * @param alpha defines alpha angle (in radians)
  39744. * @param beta defines beta angle (in radians)
  39745. * @param radius defines radius
  39746. * @param target defines camera target
  39747. * @param interaxialDistance defines distance between each color axis
  39748. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39749. * @param scene defines the hosting scene
  39750. */
  39751. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39752. /**
  39753. * Gets camera class name
  39754. * @returns StereoscopicArcRotateCamera
  39755. */
  39756. getClassName(): string;
  39757. }
  39758. }
  39759. declare module BABYLON {
  39760. /**
  39761. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39762. * @see http://doc.babylonjs.com/features/cameras
  39763. */
  39764. export class StereoscopicFreeCamera extends FreeCamera {
  39765. /**
  39766. * Creates a new StereoscopicFreeCamera
  39767. * @param name defines camera name
  39768. * @param position defines initial position
  39769. * @param interaxialDistance defines distance between each color axis
  39770. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39771. * @param scene defines the hosting scene
  39772. */
  39773. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39774. /**
  39775. * Gets camera class name
  39776. * @returns StereoscopicFreeCamera
  39777. */
  39778. getClassName(): string;
  39779. }
  39780. }
  39781. declare module BABYLON {
  39782. /**
  39783. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39784. * @see http://doc.babylonjs.com/features/cameras
  39785. */
  39786. export class StereoscopicGamepadCamera extends GamepadCamera {
  39787. /**
  39788. * Creates a new StereoscopicGamepadCamera
  39789. * @param name defines camera name
  39790. * @param position defines initial position
  39791. * @param interaxialDistance defines distance between each color axis
  39792. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39793. * @param scene defines the hosting scene
  39794. */
  39795. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39796. /**
  39797. * Gets camera class name
  39798. * @returns StereoscopicGamepadCamera
  39799. */
  39800. getClassName(): string;
  39801. }
  39802. }
  39803. declare module BABYLON {
  39804. /**
  39805. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39806. * @see http://doc.babylonjs.com/features/cameras
  39807. */
  39808. export class StereoscopicUniversalCamera extends UniversalCamera {
  39809. /**
  39810. * Creates a new StereoscopicUniversalCamera
  39811. * @param name defines camera name
  39812. * @param position defines initial position
  39813. * @param interaxialDistance defines distance between each color axis
  39814. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39815. * @param scene defines the hosting scene
  39816. */
  39817. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39818. /**
  39819. * Gets camera class name
  39820. * @returns StereoscopicUniversalCamera
  39821. */
  39822. getClassName(): string;
  39823. }
  39824. }
  39825. declare module BABYLON {
  39826. /**
  39827. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39828. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39829. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39830. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39831. */
  39832. export class VirtualJoysticksCamera extends FreeCamera {
  39833. /**
  39834. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39835. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39836. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39837. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39838. * @param name Define the name of the camera in the scene
  39839. * @param position Define the start position of the camera in the scene
  39840. * @param scene Define the scene the camera belongs to
  39841. */
  39842. constructor(name: string, position: Vector3, scene: Scene);
  39843. /**
  39844. * Gets the current object class name.
  39845. * @return the class name
  39846. */
  39847. getClassName(): string;
  39848. }
  39849. }
  39850. declare module BABYLON {
  39851. /**
  39852. * This represents all the required metrics to create a VR camera.
  39853. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39854. */
  39855. export class VRCameraMetrics {
  39856. /**
  39857. * Define the horizontal resolution off the screen.
  39858. */
  39859. hResolution: number;
  39860. /**
  39861. * Define the vertical resolution off the screen.
  39862. */
  39863. vResolution: number;
  39864. /**
  39865. * Define the horizontal screen size.
  39866. */
  39867. hScreenSize: number;
  39868. /**
  39869. * Define the vertical screen size.
  39870. */
  39871. vScreenSize: number;
  39872. /**
  39873. * Define the vertical screen center position.
  39874. */
  39875. vScreenCenter: number;
  39876. /**
  39877. * Define the distance of the eyes to the screen.
  39878. */
  39879. eyeToScreenDistance: number;
  39880. /**
  39881. * Define the distance between both lenses
  39882. */
  39883. lensSeparationDistance: number;
  39884. /**
  39885. * Define the distance between both viewer's eyes.
  39886. */
  39887. interpupillaryDistance: number;
  39888. /**
  39889. * Define the distortion factor of the VR postprocess.
  39890. * Please, touch with care.
  39891. */
  39892. distortionK: number[];
  39893. /**
  39894. * Define the chromatic aberration correction factors for the VR post process.
  39895. */
  39896. chromaAbCorrection: number[];
  39897. /**
  39898. * Define the scale factor of the post process.
  39899. * The smaller the better but the slower.
  39900. */
  39901. postProcessScaleFactor: number;
  39902. /**
  39903. * Define an offset for the lens center.
  39904. */
  39905. lensCenterOffset: number;
  39906. /**
  39907. * Define if the current vr camera should compensate the distortion of the lense or not.
  39908. */
  39909. compensateDistortion: boolean;
  39910. /**
  39911. * Defines if multiview should be enabled when rendering (Default: false)
  39912. */
  39913. multiviewEnabled: boolean;
  39914. /**
  39915. * Gets the rendering aspect ratio based on the provided resolutions.
  39916. */
  39917. readonly aspectRatio: number;
  39918. /**
  39919. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39920. */
  39921. readonly aspectRatioFov: number;
  39922. /**
  39923. * @hidden
  39924. */
  39925. readonly leftHMatrix: Matrix;
  39926. /**
  39927. * @hidden
  39928. */
  39929. readonly rightHMatrix: Matrix;
  39930. /**
  39931. * @hidden
  39932. */
  39933. readonly leftPreViewMatrix: Matrix;
  39934. /**
  39935. * @hidden
  39936. */
  39937. readonly rightPreViewMatrix: Matrix;
  39938. /**
  39939. * Get the default VRMetrics based on the most generic setup.
  39940. * @returns the default vr metrics
  39941. */
  39942. static GetDefault(): VRCameraMetrics;
  39943. }
  39944. }
  39945. declare module BABYLON {
  39946. /** @hidden */
  39947. export var vrDistortionCorrectionPixelShader: {
  39948. name: string;
  39949. shader: string;
  39950. };
  39951. }
  39952. declare module BABYLON {
  39953. /**
  39954. * VRDistortionCorrectionPostProcess used for mobile VR
  39955. */
  39956. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39957. private _isRightEye;
  39958. private _distortionFactors;
  39959. private _postProcessScaleFactor;
  39960. private _lensCenterOffset;
  39961. private _scaleIn;
  39962. private _scaleFactor;
  39963. private _lensCenter;
  39964. /**
  39965. * Initializes the VRDistortionCorrectionPostProcess
  39966. * @param name The name of the effect.
  39967. * @param camera The camera to apply the render pass to.
  39968. * @param isRightEye If this is for the right eye distortion
  39969. * @param vrMetrics All the required metrics for the VR camera
  39970. */
  39971. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39972. }
  39973. }
  39974. declare module BABYLON {
  39975. /**
  39976. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39978. */
  39979. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39980. /**
  39981. * Creates a new VRDeviceOrientationArcRotateCamera
  39982. * @param name defines camera name
  39983. * @param alpha defines the camera rotation along the logitudinal axis
  39984. * @param beta defines the camera rotation along the latitudinal axis
  39985. * @param radius defines the camera distance from its target
  39986. * @param target defines the camera target
  39987. * @param scene defines the scene the camera belongs to
  39988. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39989. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39990. */
  39991. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39992. /**
  39993. * Gets camera class name
  39994. * @returns VRDeviceOrientationArcRotateCamera
  39995. */
  39996. getClassName(): string;
  39997. }
  39998. }
  39999. declare module BABYLON {
  40000. /**
  40001. * Camera used to simulate VR rendering (based on FreeCamera)
  40002. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40003. */
  40004. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40005. /**
  40006. * Creates a new VRDeviceOrientationFreeCamera
  40007. * @param name defines camera name
  40008. * @param position defines the start position of the camera
  40009. * @param scene defines the scene the camera belongs to
  40010. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40011. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40012. */
  40013. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40014. /**
  40015. * Gets camera class name
  40016. * @returns VRDeviceOrientationFreeCamera
  40017. */
  40018. getClassName(): string;
  40019. }
  40020. }
  40021. declare module BABYLON {
  40022. /**
  40023. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40024. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40025. */
  40026. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40027. /**
  40028. * Creates a new VRDeviceOrientationGamepadCamera
  40029. * @param name defines camera name
  40030. * @param position defines the start position of the camera
  40031. * @param scene defines the scene the camera belongs to
  40032. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40033. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40034. */
  40035. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40036. /**
  40037. * Gets camera class name
  40038. * @returns VRDeviceOrientationGamepadCamera
  40039. */
  40040. getClassName(): string;
  40041. }
  40042. }
  40043. declare module BABYLON {
  40044. /**
  40045. * Base class of materials working in push mode in babylon JS
  40046. * @hidden
  40047. */
  40048. export class PushMaterial extends Material {
  40049. protected _activeEffect: Effect;
  40050. protected _normalMatrix: Matrix;
  40051. /**
  40052. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40053. * This means that the material can keep using a previous shader while a new one is being compiled.
  40054. * This is mostly used when shader parallel compilation is supported (true by default)
  40055. */
  40056. allowShaderHotSwapping: boolean;
  40057. constructor(name: string, scene: Scene);
  40058. getEffect(): Effect;
  40059. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40060. /**
  40061. * Binds the given world matrix to the active effect
  40062. *
  40063. * @param world the matrix to bind
  40064. */
  40065. bindOnlyWorldMatrix(world: Matrix): void;
  40066. /**
  40067. * Binds the given normal matrix to the active effect
  40068. *
  40069. * @param normalMatrix the matrix to bind
  40070. */
  40071. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40072. bind(world: Matrix, mesh?: Mesh): void;
  40073. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40074. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40075. }
  40076. }
  40077. declare module BABYLON {
  40078. /**
  40079. * This groups all the flags used to control the materials channel.
  40080. */
  40081. export class MaterialFlags {
  40082. private static _DiffuseTextureEnabled;
  40083. /**
  40084. * Are diffuse textures enabled in the application.
  40085. */
  40086. static DiffuseTextureEnabled: boolean;
  40087. private static _AmbientTextureEnabled;
  40088. /**
  40089. * Are ambient textures enabled in the application.
  40090. */
  40091. static AmbientTextureEnabled: boolean;
  40092. private static _OpacityTextureEnabled;
  40093. /**
  40094. * Are opacity textures enabled in the application.
  40095. */
  40096. static OpacityTextureEnabled: boolean;
  40097. private static _ReflectionTextureEnabled;
  40098. /**
  40099. * Are reflection textures enabled in the application.
  40100. */
  40101. static ReflectionTextureEnabled: boolean;
  40102. private static _EmissiveTextureEnabled;
  40103. /**
  40104. * Are emissive textures enabled in the application.
  40105. */
  40106. static EmissiveTextureEnabled: boolean;
  40107. private static _SpecularTextureEnabled;
  40108. /**
  40109. * Are specular textures enabled in the application.
  40110. */
  40111. static SpecularTextureEnabled: boolean;
  40112. private static _BumpTextureEnabled;
  40113. /**
  40114. * Are bump textures enabled in the application.
  40115. */
  40116. static BumpTextureEnabled: boolean;
  40117. private static _LightmapTextureEnabled;
  40118. /**
  40119. * Are lightmap textures enabled in the application.
  40120. */
  40121. static LightmapTextureEnabled: boolean;
  40122. private static _RefractionTextureEnabled;
  40123. /**
  40124. * Are refraction textures enabled in the application.
  40125. */
  40126. static RefractionTextureEnabled: boolean;
  40127. private static _ColorGradingTextureEnabled;
  40128. /**
  40129. * Are color grading textures enabled in the application.
  40130. */
  40131. static ColorGradingTextureEnabled: boolean;
  40132. private static _FresnelEnabled;
  40133. /**
  40134. * Are fresnels enabled in the application.
  40135. */
  40136. static FresnelEnabled: boolean;
  40137. private static _ClearCoatTextureEnabled;
  40138. /**
  40139. * Are clear coat textures enabled in the application.
  40140. */
  40141. static ClearCoatTextureEnabled: boolean;
  40142. private static _ClearCoatBumpTextureEnabled;
  40143. /**
  40144. * Are clear coat bump textures enabled in the application.
  40145. */
  40146. static ClearCoatBumpTextureEnabled: boolean;
  40147. private static _ClearCoatTintTextureEnabled;
  40148. /**
  40149. * Are clear coat tint textures enabled in the application.
  40150. */
  40151. static ClearCoatTintTextureEnabled: boolean;
  40152. private static _SheenTextureEnabled;
  40153. /**
  40154. * Are sheen textures enabled in the application.
  40155. */
  40156. static SheenTextureEnabled: boolean;
  40157. private static _AnisotropicTextureEnabled;
  40158. /**
  40159. * Are anisotropic textures enabled in the application.
  40160. */
  40161. static AnisotropicTextureEnabled: boolean;
  40162. private static _ThicknessTextureEnabled;
  40163. /**
  40164. * Are thickness textures enabled in the application.
  40165. */
  40166. static ThicknessTextureEnabled: boolean;
  40167. }
  40168. }
  40169. declare module BABYLON {
  40170. /** @hidden */
  40171. export var defaultFragmentDeclaration: {
  40172. name: string;
  40173. shader: string;
  40174. };
  40175. }
  40176. declare module BABYLON {
  40177. /** @hidden */
  40178. export var defaultUboDeclaration: {
  40179. name: string;
  40180. shader: string;
  40181. };
  40182. }
  40183. declare module BABYLON {
  40184. /** @hidden */
  40185. export var lightFragmentDeclaration: {
  40186. name: string;
  40187. shader: string;
  40188. };
  40189. }
  40190. declare module BABYLON {
  40191. /** @hidden */
  40192. export var lightUboDeclaration: {
  40193. name: string;
  40194. shader: string;
  40195. };
  40196. }
  40197. declare module BABYLON {
  40198. /** @hidden */
  40199. export var lightsFragmentFunctions: {
  40200. name: string;
  40201. shader: string;
  40202. };
  40203. }
  40204. declare module BABYLON {
  40205. /** @hidden */
  40206. export var shadowsFragmentFunctions: {
  40207. name: string;
  40208. shader: string;
  40209. };
  40210. }
  40211. declare module BABYLON {
  40212. /** @hidden */
  40213. export var fresnelFunction: {
  40214. name: string;
  40215. shader: string;
  40216. };
  40217. }
  40218. declare module BABYLON {
  40219. /** @hidden */
  40220. export var reflectionFunction: {
  40221. name: string;
  40222. shader: string;
  40223. };
  40224. }
  40225. declare module BABYLON {
  40226. /** @hidden */
  40227. export var bumpFragmentFunctions: {
  40228. name: string;
  40229. shader: string;
  40230. };
  40231. }
  40232. declare module BABYLON {
  40233. /** @hidden */
  40234. export var logDepthDeclaration: {
  40235. name: string;
  40236. shader: string;
  40237. };
  40238. }
  40239. declare module BABYLON {
  40240. /** @hidden */
  40241. export var bumpFragment: {
  40242. name: string;
  40243. shader: string;
  40244. };
  40245. }
  40246. declare module BABYLON {
  40247. /** @hidden */
  40248. export var depthPrePass: {
  40249. name: string;
  40250. shader: string;
  40251. };
  40252. }
  40253. declare module BABYLON {
  40254. /** @hidden */
  40255. export var lightFragment: {
  40256. name: string;
  40257. shader: string;
  40258. };
  40259. }
  40260. declare module BABYLON {
  40261. /** @hidden */
  40262. export var logDepthFragment: {
  40263. name: string;
  40264. shader: string;
  40265. };
  40266. }
  40267. declare module BABYLON {
  40268. /** @hidden */
  40269. export var defaultPixelShader: {
  40270. name: string;
  40271. shader: string;
  40272. };
  40273. }
  40274. declare module BABYLON {
  40275. /** @hidden */
  40276. export var defaultVertexDeclaration: {
  40277. name: string;
  40278. shader: string;
  40279. };
  40280. }
  40281. declare module BABYLON {
  40282. /** @hidden */
  40283. export var bumpVertexDeclaration: {
  40284. name: string;
  40285. shader: string;
  40286. };
  40287. }
  40288. declare module BABYLON {
  40289. /** @hidden */
  40290. export var bumpVertex: {
  40291. name: string;
  40292. shader: string;
  40293. };
  40294. }
  40295. declare module BABYLON {
  40296. /** @hidden */
  40297. export var fogVertex: {
  40298. name: string;
  40299. shader: string;
  40300. };
  40301. }
  40302. declare module BABYLON {
  40303. /** @hidden */
  40304. export var shadowsVertex: {
  40305. name: string;
  40306. shader: string;
  40307. };
  40308. }
  40309. declare module BABYLON {
  40310. /** @hidden */
  40311. export var pointCloudVertex: {
  40312. name: string;
  40313. shader: string;
  40314. };
  40315. }
  40316. declare module BABYLON {
  40317. /** @hidden */
  40318. export var logDepthVertex: {
  40319. name: string;
  40320. shader: string;
  40321. };
  40322. }
  40323. declare module BABYLON {
  40324. /** @hidden */
  40325. export var defaultVertexShader: {
  40326. name: string;
  40327. shader: string;
  40328. };
  40329. }
  40330. declare module BABYLON {
  40331. /** @hidden */
  40332. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40333. MAINUV1: boolean;
  40334. MAINUV2: boolean;
  40335. DIFFUSE: boolean;
  40336. DIFFUSEDIRECTUV: number;
  40337. AMBIENT: boolean;
  40338. AMBIENTDIRECTUV: number;
  40339. OPACITY: boolean;
  40340. OPACITYDIRECTUV: number;
  40341. OPACITYRGB: boolean;
  40342. REFLECTION: boolean;
  40343. EMISSIVE: boolean;
  40344. EMISSIVEDIRECTUV: number;
  40345. SPECULAR: boolean;
  40346. SPECULARDIRECTUV: number;
  40347. BUMP: boolean;
  40348. BUMPDIRECTUV: number;
  40349. PARALLAX: boolean;
  40350. PARALLAXOCCLUSION: boolean;
  40351. SPECULAROVERALPHA: boolean;
  40352. CLIPPLANE: boolean;
  40353. CLIPPLANE2: boolean;
  40354. CLIPPLANE3: boolean;
  40355. CLIPPLANE4: boolean;
  40356. ALPHATEST: boolean;
  40357. DEPTHPREPASS: boolean;
  40358. ALPHAFROMDIFFUSE: boolean;
  40359. POINTSIZE: boolean;
  40360. FOG: boolean;
  40361. SPECULARTERM: boolean;
  40362. DIFFUSEFRESNEL: boolean;
  40363. OPACITYFRESNEL: boolean;
  40364. REFLECTIONFRESNEL: boolean;
  40365. REFRACTIONFRESNEL: boolean;
  40366. EMISSIVEFRESNEL: boolean;
  40367. FRESNEL: boolean;
  40368. NORMAL: boolean;
  40369. UV1: boolean;
  40370. UV2: boolean;
  40371. VERTEXCOLOR: boolean;
  40372. VERTEXALPHA: boolean;
  40373. NUM_BONE_INFLUENCERS: number;
  40374. BonesPerMesh: number;
  40375. BONETEXTURE: boolean;
  40376. INSTANCES: boolean;
  40377. GLOSSINESS: boolean;
  40378. ROUGHNESS: boolean;
  40379. EMISSIVEASILLUMINATION: boolean;
  40380. LINKEMISSIVEWITHDIFFUSE: boolean;
  40381. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40382. LIGHTMAP: boolean;
  40383. LIGHTMAPDIRECTUV: number;
  40384. OBJECTSPACE_NORMALMAP: boolean;
  40385. USELIGHTMAPASSHADOWMAP: boolean;
  40386. REFLECTIONMAP_3D: boolean;
  40387. REFLECTIONMAP_SPHERICAL: boolean;
  40388. REFLECTIONMAP_PLANAR: boolean;
  40389. REFLECTIONMAP_CUBIC: boolean;
  40390. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40391. REFLECTIONMAP_PROJECTION: boolean;
  40392. REFLECTIONMAP_SKYBOX: boolean;
  40393. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40394. REFLECTIONMAP_EXPLICIT: boolean;
  40395. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40396. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40397. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40398. INVERTCUBICMAP: boolean;
  40399. LOGARITHMICDEPTH: boolean;
  40400. REFRACTION: boolean;
  40401. REFRACTIONMAP_3D: boolean;
  40402. REFLECTIONOVERALPHA: boolean;
  40403. TWOSIDEDLIGHTING: boolean;
  40404. SHADOWFLOAT: boolean;
  40405. MORPHTARGETS: boolean;
  40406. MORPHTARGETS_NORMAL: boolean;
  40407. MORPHTARGETS_TANGENT: boolean;
  40408. MORPHTARGETS_UV: boolean;
  40409. NUM_MORPH_INFLUENCERS: number;
  40410. NONUNIFORMSCALING: boolean;
  40411. PREMULTIPLYALPHA: boolean;
  40412. IMAGEPROCESSING: boolean;
  40413. VIGNETTE: boolean;
  40414. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40415. VIGNETTEBLENDMODEOPAQUE: boolean;
  40416. TONEMAPPING: boolean;
  40417. TONEMAPPING_ACES: boolean;
  40418. CONTRAST: boolean;
  40419. COLORCURVES: boolean;
  40420. COLORGRADING: boolean;
  40421. COLORGRADING3D: boolean;
  40422. SAMPLER3DGREENDEPTH: boolean;
  40423. SAMPLER3DBGRMAP: boolean;
  40424. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40425. MULTIVIEW: boolean;
  40426. /**
  40427. * If the reflection texture on this material is in linear color space
  40428. * @hidden
  40429. */
  40430. IS_REFLECTION_LINEAR: boolean;
  40431. /**
  40432. * If the refraction texture on this material is in linear color space
  40433. * @hidden
  40434. */
  40435. IS_REFRACTION_LINEAR: boolean;
  40436. EXPOSURE: boolean;
  40437. constructor();
  40438. setReflectionMode(modeToEnable: string): void;
  40439. }
  40440. /**
  40441. * This is the default material used in Babylon. It is the best trade off between quality
  40442. * and performances.
  40443. * @see http://doc.babylonjs.com/babylon101/materials
  40444. */
  40445. export class StandardMaterial extends PushMaterial {
  40446. private _diffuseTexture;
  40447. /**
  40448. * The basic texture of the material as viewed under a light.
  40449. */
  40450. diffuseTexture: Nullable<BaseTexture>;
  40451. private _ambientTexture;
  40452. /**
  40453. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40454. */
  40455. ambientTexture: Nullable<BaseTexture>;
  40456. private _opacityTexture;
  40457. /**
  40458. * Define the transparency of the material from a texture.
  40459. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40460. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40461. */
  40462. opacityTexture: Nullable<BaseTexture>;
  40463. private _reflectionTexture;
  40464. /**
  40465. * Define the texture used to display the reflection.
  40466. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40467. */
  40468. reflectionTexture: Nullable<BaseTexture>;
  40469. private _emissiveTexture;
  40470. /**
  40471. * Define texture of the material as if self lit.
  40472. * This will be mixed in the final result even in the absence of light.
  40473. */
  40474. emissiveTexture: Nullable<BaseTexture>;
  40475. private _specularTexture;
  40476. /**
  40477. * Define how the color and intensity of the highlight given by the light in the material.
  40478. */
  40479. specularTexture: Nullable<BaseTexture>;
  40480. private _bumpTexture;
  40481. /**
  40482. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40483. * 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.
  40484. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40485. */
  40486. bumpTexture: Nullable<BaseTexture>;
  40487. private _lightmapTexture;
  40488. /**
  40489. * Complex lighting can be computationally expensive to compute at runtime.
  40490. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40491. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40492. */
  40493. lightmapTexture: Nullable<BaseTexture>;
  40494. private _refractionTexture;
  40495. /**
  40496. * Define the texture used to display the refraction.
  40497. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40498. */
  40499. refractionTexture: Nullable<BaseTexture>;
  40500. /**
  40501. * The color of the material lit by the environmental background lighting.
  40502. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40503. */
  40504. ambientColor: Color3;
  40505. /**
  40506. * The basic color of the material as viewed under a light.
  40507. */
  40508. diffuseColor: Color3;
  40509. /**
  40510. * Define how the color and intensity of the highlight given by the light in the material.
  40511. */
  40512. specularColor: Color3;
  40513. /**
  40514. * Define the color of the material as if self lit.
  40515. * This will be mixed in the final result even in the absence of light.
  40516. */
  40517. emissiveColor: Color3;
  40518. /**
  40519. * Defines how sharp are the highlights in the material.
  40520. * The bigger the value the sharper giving a more glossy feeling to the result.
  40521. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40522. */
  40523. specularPower: number;
  40524. private _useAlphaFromDiffuseTexture;
  40525. /**
  40526. * Does the transparency come from the diffuse texture alpha channel.
  40527. */
  40528. useAlphaFromDiffuseTexture: boolean;
  40529. private _useEmissiveAsIllumination;
  40530. /**
  40531. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40532. */
  40533. useEmissiveAsIllumination: boolean;
  40534. private _linkEmissiveWithDiffuse;
  40535. /**
  40536. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40537. * the emissive level when the final color is close to one.
  40538. */
  40539. linkEmissiveWithDiffuse: boolean;
  40540. private _useSpecularOverAlpha;
  40541. /**
  40542. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40543. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40544. */
  40545. useSpecularOverAlpha: boolean;
  40546. private _useReflectionOverAlpha;
  40547. /**
  40548. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40549. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40550. */
  40551. useReflectionOverAlpha: boolean;
  40552. private _disableLighting;
  40553. /**
  40554. * Does lights from the scene impacts this material.
  40555. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40556. */
  40557. disableLighting: boolean;
  40558. private _useObjectSpaceNormalMap;
  40559. /**
  40560. * Allows using an object space normal map (instead of tangent space).
  40561. */
  40562. useObjectSpaceNormalMap: boolean;
  40563. private _useParallax;
  40564. /**
  40565. * Is parallax enabled or not.
  40566. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40567. */
  40568. useParallax: boolean;
  40569. private _useParallaxOcclusion;
  40570. /**
  40571. * Is parallax occlusion enabled or not.
  40572. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40573. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40574. */
  40575. useParallaxOcclusion: boolean;
  40576. /**
  40577. * 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.
  40578. */
  40579. parallaxScaleBias: number;
  40580. private _roughness;
  40581. /**
  40582. * Helps to define how blurry the reflections should appears in the material.
  40583. */
  40584. roughness: number;
  40585. /**
  40586. * In case of refraction, define the value of the index of refraction.
  40587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40588. */
  40589. indexOfRefraction: number;
  40590. /**
  40591. * Invert the refraction texture alongside the y axis.
  40592. * It can be useful with procedural textures or probe for instance.
  40593. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40594. */
  40595. invertRefractionY: boolean;
  40596. /**
  40597. * Defines the alpha limits in alpha test mode.
  40598. */
  40599. alphaCutOff: number;
  40600. private _useLightmapAsShadowmap;
  40601. /**
  40602. * In case of light mapping, define whether the map contains light or shadow informations.
  40603. */
  40604. useLightmapAsShadowmap: boolean;
  40605. private _diffuseFresnelParameters;
  40606. /**
  40607. * Define the diffuse fresnel parameters of the material.
  40608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40609. */
  40610. diffuseFresnelParameters: FresnelParameters;
  40611. private _opacityFresnelParameters;
  40612. /**
  40613. * Define the opacity fresnel parameters of the material.
  40614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40615. */
  40616. opacityFresnelParameters: FresnelParameters;
  40617. private _reflectionFresnelParameters;
  40618. /**
  40619. * Define the reflection fresnel parameters of the material.
  40620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40621. */
  40622. reflectionFresnelParameters: FresnelParameters;
  40623. private _refractionFresnelParameters;
  40624. /**
  40625. * Define the refraction fresnel parameters of the material.
  40626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40627. */
  40628. refractionFresnelParameters: FresnelParameters;
  40629. private _emissiveFresnelParameters;
  40630. /**
  40631. * Define the emissive fresnel parameters of the material.
  40632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40633. */
  40634. emissiveFresnelParameters: FresnelParameters;
  40635. private _useReflectionFresnelFromSpecular;
  40636. /**
  40637. * If true automatically deducts the fresnels values from the material specularity.
  40638. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40639. */
  40640. useReflectionFresnelFromSpecular: boolean;
  40641. private _useGlossinessFromSpecularMapAlpha;
  40642. /**
  40643. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40644. */
  40645. useGlossinessFromSpecularMapAlpha: boolean;
  40646. private _maxSimultaneousLights;
  40647. /**
  40648. * Defines the maximum number of lights that can be used in the material
  40649. */
  40650. maxSimultaneousLights: number;
  40651. private _invertNormalMapX;
  40652. /**
  40653. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40654. */
  40655. invertNormalMapX: boolean;
  40656. private _invertNormalMapY;
  40657. /**
  40658. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40659. */
  40660. invertNormalMapY: boolean;
  40661. private _twoSidedLighting;
  40662. /**
  40663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40664. */
  40665. twoSidedLighting: boolean;
  40666. /**
  40667. * Default configuration related to image processing available in the standard Material.
  40668. */
  40669. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40670. /**
  40671. * Gets the image processing configuration used either in this material.
  40672. */
  40673. /**
  40674. * Sets the Default image processing configuration used either in the this material.
  40675. *
  40676. * If sets to null, the scene one is in use.
  40677. */
  40678. imageProcessingConfiguration: ImageProcessingConfiguration;
  40679. /**
  40680. * Keep track of the image processing observer to allow dispose and replace.
  40681. */
  40682. private _imageProcessingObserver;
  40683. /**
  40684. * Attaches a new image processing configuration to the Standard Material.
  40685. * @param configuration
  40686. */
  40687. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40688. /**
  40689. * Gets wether the color curves effect is enabled.
  40690. */
  40691. /**
  40692. * Sets wether the color curves effect is enabled.
  40693. */
  40694. cameraColorCurvesEnabled: boolean;
  40695. /**
  40696. * Gets wether the color grading effect is enabled.
  40697. */
  40698. /**
  40699. * Gets wether the color grading effect is enabled.
  40700. */
  40701. cameraColorGradingEnabled: boolean;
  40702. /**
  40703. * Gets wether tonemapping is enabled or not.
  40704. */
  40705. /**
  40706. * Sets wether tonemapping is enabled or not
  40707. */
  40708. cameraToneMappingEnabled: boolean;
  40709. /**
  40710. * The camera exposure used on this material.
  40711. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40712. * This corresponds to a photographic exposure.
  40713. */
  40714. /**
  40715. * The camera exposure used on this material.
  40716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40717. * This corresponds to a photographic exposure.
  40718. */
  40719. cameraExposure: number;
  40720. /**
  40721. * Gets The camera contrast used on this material.
  40722. */
  40723. /**
  40724. * Sets The camera contrast used on this material.
  40725. */
  40726. cameraContrast: number;
  40727. /**
  40728. * Gets the Color Grading 2D Lookup Texture.
  40729. */
  40730. /**
  40731. * Sets the Color Grading 2D Lookup Texture.
  40732. */
  40733. cameraColorGradingTexture: Nullable<BaseTexture>;
  40734. /**
  40735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40737. * 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;
  40738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40739. */
  40740. /**
  40741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40743. * 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;
  40744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40745. */
  40746. cameraColorCurves: Nullable<ColorCurves>;
  40747. /**
  40748. * Custom callback helping to override the default shader used in the material.
  40749. */
  40750. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40751. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40752. protected _worldViewProjectionMatrix: Matrix;
  40753. protected _globalAmbientColor: Color3;
  40754. protected _useLogarithmicDepth: boolean;
  40755. protected _rebuildInParallel: boolean;
  40756. /**
  40757. * Instantiates a new standard material.
  40758. * This is the default material used in Babylon. It is the best trade off between quality
  40759. * and performances.
  40760. * @see http://doc.babylonjs.com/babylon101/materials
  40761. * @param name Define the name of the material in the scene
  40762. * @param scene Define the scene the material belong to
  40763. */
  40764. constructor(name: string, scene: Scene);
  40765. /**
  40766. * Gets a boolean indicating that current material needs to register RTT
  40767. */
  40768. readonly hasRenderTargetTextures: boolean;
  40769. /**
  40770. * Gets the current class name of the material e.g. "StandardMaterial"
  40771. * Mainly use in serialization.
  40772. * @returns the class name
  40773. */
  40774. getClassName(): string;
  40775. /**
  40776. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40777. * You can try switching to logarithmic depth.
  40778. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40779. */
  40780. useLogarithmicDepth: boolean;
  40781. /**
  40782. * Specifies if the material will require alpha blending
  40783. * @returns a boolean specifying if alpha blending is needed
  40784. */
  40785. needAlphaBlending(): boolean;
  40786. /**
  40787. * Specifies if this material should be rendered in alpha test mode
  40788. * @returns a boolean specifying if an alpha test is needed.
  40789. */
  40790. needAlphaTesting(): boolean;
  40791. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40792. /**
  40793. * Get the texture used for alpha test purpose.
  40794. * @returns the diffuse texture in case of the standard material.
  40795. */
  40796. getAlphaTestTexture(): Nullable<BaseTexture>;
  40797. /**
  40798. * Get if the submesh is ready to be used and all its information available.
  40799. * Child classes can use it to update shaders
  40800. * @param mesh defines the mesh to check
  40801. * @param subMesh defines which submesh to check
  40802. * @param useInstances specifies that instances should be used
  40803. * @returns a boolean indicating that the submesh is ready or not
  40804. */
  40805. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40806. /**
  40807. * Builds the material UBO layouts.
  40808. * Used internally during the effect preparation.
  40809. */
  40810. buildUniformLayout(): void;
  40811. /**
  40812. * Unbinds the material from the mesh
  40813. */
  40814. unbind(): void;
  40815. /**
  40816. * Binds the submesh to this material by preparing the effect and shader to draw
  40817. * @param world defines the world transformation matrix
  40818. * @param mesh defines the mesh containing the submesh
  40819. * @param subMesh defines the submesh to bind the material to
  40820. */
  40821. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40822. /**
  40823. * Get the list of animatables in the material.
  40824. * @returns the list of animatables object used in the material
  40825. */
  40826. getAnimatables(): IAnimatable[];
  40827. /**
  40828. * Gets the active textures from the material
  40829. * @returns an array of textures
  40830. */
  40831. getActiveTextures(): BaseTexture[];
  40832. /**
  40833. * Specifies if the material uses a texture
  40834. * @param texture defines the texture to check against the material
  40835. * @returns a boolean specifying if the material uses the texture
  40836. */
  40837. hasTexture(texture: BaseTexture): boolean;
  40838. /**
  40839. * Disposes the material
  40840. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40841. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40842. */
  40843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40844. /**
  40845. * Makes a duplicate of the material, and gives it a new name
  40846. * @param name defines the new name for the duplicated material
  40847. * @returns the cloned material
  40848. */
  40849. clone(name: string): StandardMaterial;
  40850. /**
  40851. * Serializes this material in a JSON representation
  40852. * @returns the serialized material object
  40853. */
  40854. serialize(): any;
  40855. /**
  40856. * Creates a standard material from parsed material data
  40857. * @param source defines the JSON representation of the material
  40858. * @param scene defines the hosting scene
  40859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40860. * @returns a new standard material
  40861. */
  40862. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40863. /**
  40864. * Are diffuse textures enabled in the application.
  40865. */
  40866. static DiffuseTextureEnabled: boolean;
  40867. /**
  40868. * Are ambient textures enabled in the application.
  40869. */
  40870. static AmbientTextureEnabled: boolean;
  40871. /**
  40872. * Are opacity textures enabled in the application.
  40873. */
  40874. static OpacityTextureEnabled: boolean;
  40875. /**
  40876. * Are reflection textures enabled in the application.
  40877. */
  40878. static ReflectionTextureEnabled: boolean;
  40879. /**
  40880. * Are emissive textures enabled in the application.
  40881. */
  40882. static EmissiveTextureEnabled: boolean;
  40883. /**
  40884. * Are specular textures enabled in the application.
  40885. */
  40886. static SpecularTextureEnabled: boolean;
  40887. /**
  40888. * Are bump textures enabled in the application.
  40889. */
  40890. static BumpTextureEnabled: boolean;
  40891. /**
  40892. * Are lightmap textures enabled in the application.
  40893. */
  40894. static LightmapTextureEnabled: boolean;
  40895. /**
  40896. * Are refraction textures enabled in the application.
  40897. */
  40898. static RefractionTextureEnabled: boolean;
  40899. /**
  40900. * Are color grading textures enabled in the application.
  40901. */
  40902. static ColorGradingTextureEnabled: boolean;
  40903. /**
  40904. * Are fresnels enabled in the application.
  40905. */
  40906. static FresnelEnabled: boolean;
  40907. }
  40908. }
  40909. declare module BABYLON {
  40910. /** @hidden */
  40911. export var imageProcessingPixelShader: {
  40912. name: string;
  40913. shader: string;
  40914. };
  40915. }
  40916. declare module BABYLON {
  40917. /**
  40918. * ImageProcessingPostProcess
  40919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40920. */
  40921. export class ImageProcessingPostProcess extends PostProcess {
  40922. /**
  40923. * Default configuration related to image processing available in the PBR Material.
  40924. */
  40925. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40926. /**
  40927. * Gets the image processing configuration used either in this material.
  40928. */
  40929. /**
  40930. * Sets the Default image processing configuration used either in the this material.
  40931. *
  40932. * If sets to null, the scene one is in use.
  40933. */
  40934. imageProcessingConfiguration: ImageProcessingConfiguration;
  40935. /**
  40936. * Keep track of the image processing observer to allow dispose and replace.
  40937. */
  40938. private _imageProcessingObserver;
  40939. /**
  40940. * Attaches a new image processing configuration to the PBR Material.
  40941. * @param configuration
  40942. */
  40943. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40944. /**
  40945. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40946. */
  40947. /**
  40948. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40949. */
  40950. colorCurves: Nullable<ColorCurves>;
  40951. /**
  40952. * Gets wether the color curves effect is enabled.
  40953. */
  40954. /**
  40955. * Sets wether the color curves effect is enabled.
  40956. */
  40957. colorCurvesEnabled: boolean;
  40958. /**
  40959. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40960. */
  40961. /**
  40962. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40963. */
  40964. colorGradingTexture: Nullable<BaseTexture>;
  40965. /**
  40966. * Gets wether the color grading effect is enabled.
  40967. */
  40968. /**
  40969. * Gets wether the color grading effect is enabled.
  40970. */
  40971. colorGradingEnabled: boolean;
  40972. /**
  40973. * Gets exposure used in the effect.
  40974. */
  40975. /**
  40976. * Sets exposure used in the effect.
  40977. */
  40978. exposure: number;
  40979. /**
  40980. * Gets wether tonemapping is enabled or not.
  40981. */
  40982. /**
  40983. * Sets wether tonemapping is enabled or not
  40984. */
  40985. toneMappingEnabled: boolean;
  40986. /**
  40987. * Gets the type of tone mapping effect.
  40988. */
  40989. /**
  40990. * Sets the type of tone mapping effect.
  40991. */
  40992. toneMappingType: number;
  40993. /**
  40994. * Gets contrast used in the effect.
  40995. */
  40996. /**
  40997. * Sets contrast used in the effect.
  40998. */
  40999. contrast: number;
  41000. /**
  41001. * Gets Vignette stretch size.
  41002. */
  41003. /**
  41004. * Sets Vignette stretch size.
  41005. */
  41006. vignetteStretch: number;
  41007. /**
  41008. * Gets Vignette centre X Offset.
  41009. */
  41010. /**
  41011. * Sets Vignette centre X Offset.
  41012. */
  41013. vignetteCentreX: number;
  41014. /**
  41015. * Gets Vignette centre Y Offset.
  41016. */
  41017. /**
  41018. * Sets Vignette centre Y Offset.
  41019. */
  41020. vignetteCentreY: number;
  41021. /**
  41022. * Gets Vignette weight or intensity of the vignette effect.
  41023. */
  41024. /**
  41025. * Sets Vignette weight or intensity of the vignette effect.
  41026. */
  41027. vignetteWeight: number;
  41028. /**
  41029. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41030. * if vignetteEnabled is set to true.
  41031. */
  41032. /**
  41033. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41034. * if vignetteEnabled is set to true.
  41035. */
  41036. vignetteColor: Color4;
  41037. /**
  41038. * Gets Camera field of view used by the Vignette effect.
  41039. */
  41040. /**
  41041. * Sets Camera field of view used by the Vignette effect.
  41042. */
  41043. vignetteCameraFov: number;
  41044. /**
  41045. * Gets the vignette blend mode allowing different kind of effect.
  41046. */
  41047. /**
  41048. * Sets the vignette blend mode allowing different kind of effect.
  41049. */
  41050. vignetteBlendMode: number;
  41051. /**
  41052. * Gets wether the vignette effect is enabled.
  41053. */
  41054. /**
  41055. * Sets wether the vignette effect is enabled.
  41056. */
  41057. vignetteEnabled: boolean;
  41058. private _fromLinearSpace;
  41059. /**
  41060. * Gets wether the input of the processing is in Gamma or Linear Space.
  41061. */
  41062. /**
  41063. * Sets wether the input of the processing is in Gamma or Linear Space.
  41064. */
  41065. fromLinearSpace: boolean;
  41066. /**
  41067. * Defines cache preventing GC.
  41068. */
  41069. private _defines;
  41070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41071. /**
  41072. * "ImageProcessingPostProcess"
  41073. * @returns "ImageProcessingPostProcess"
  41074. */
  41075. getClassName(): string;
  41076. protected _updateParameters(): void;
  41077. dispose(camera?: Camera): void;
  41078. }
  41079. }
  41080. declare module BABYLON {
  41081. /**
  41082. * Class containing static functions to help procedurally build meshes
  41083. */
  41084. export class GroundBuilder {
  41085. /**
  41086. * Creates a ground mesh
  41087. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41088. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41090. * @param name defines the name of the mesh
  41091. * @param options defines the options used to create the mesh
  41092. * @param scene defines the hosting scene
  41093. * @returns the ground mesh
  41094. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41095. */
  41096. static CreateGround(name: string, options: {
  41097. width?: number;
  41098. height?: number;
  41099. subdivisions?: number;
  41100. subdivisionsX?: number;
  41101. subdivisionsY?: number;
  41102. updatable?: boolean;
  41103. }, scene: any): Mesh;
  41104. /**
  41105. * Creates a tiled ground mesh
  41106. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41107. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41108. * * 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
  41109. * * 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
  41110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41111. * @param name defines the name of the mesh
  41112. * @param options defines the options used to create the mesh
  41113. * @param scene defines the hosting scene
  41114. * @returns the tiled ground mesh
  41115. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41116. */
  41117. static CreateTiledGround(name: string, options: {
  41118. xmin: number;
  41119. zmin: number;
  41120. xmax: number;
  41121. zmax: number;
  41122. subdivisions?: {
  41123. w: number;
  41124. h: number;
  41125. };
  41126. precision?: {
  41127. w: number;
  41128. h: number;
  41129. };
  41130. updatable?: boolean;
  41131. }, scene?: Nullable<Scene>): Mesh;
  41132. /**
  41133. * Creates a ground mesh from a height map
  41134. * * The parameter `url` sets the URL of the height map image resource.
  41135. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41136. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41137. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41138. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41139. * * 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.
  41140. * * 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).
  41141. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41143. * @param name defines the name of the mesh
  41144. * @param url defines the url to the height map
  41145. * @param options defines the options used to create the mesh
  41146. * @param scene defines the hosting scene
  41147. * @returns the ground mesh
  41148. * @see https://doc.babylonjs.com/babylon101/height_map
  41149. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41150. */
  41151. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41152. width?: number;
  41153. height?: number;
  41154. subdivisions?: number;
  41155. minHeight?: number;
  41156. maxHeight?: number;
  41157. colorFilter?: Color3;
  41158. alphaFilter?: number;
  41159. updatable?: boolean;
  41160. onReady?: (mesh: GroundMesh) => void;
  41161. }, scene?: Nullable<Scene>): GroundMesh;
  41162. }
  41163. }
  41164. declare module BABYLON {
  41165. /**
  41166. * Class containing static functions to help procedurally build meshes
  41167. */
  41168. export class TorusBuilder {
  41169. /**
  41170. * Creates a torus mesh
  41171. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41172. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41173. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41175. * * 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
  41176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41177. * @param name defines the name of the mesh
  41178. * @param options defines the options used to create the mesh
  41179. * @param scene defines the hosting scene
  41180. * @returns the torus mesh
  41181. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41182. */
  41183. static CreateTorus(name: string, options: {
  41184. diameter?: number;
  41185. thickness?: number;
  41186. tessellation?: number;
  41187. updatable?: boolean;
  41188. sideOrientation?: number;
  41189. frontUVs?: Vector4;
  41190. backUVs?: Vector4;
  41191. }, scene: any): Mesh;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * Class containing static functions to help procedurally build meshes
  41197. */
  41198. export class CylinderBuilder {
  41199. /**
  41200. * Creates a cylinder or a cone mesh
  41201. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41202. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41203. * * 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.
  41204. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41205. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41206. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41207. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41208. * * 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).
  41209. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41210. * * 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).
  41211. * * 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
  41212. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41213. * * 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
  41214. * * 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.
  41215. * * If `enclose` is false, a ring surface is one element.
  41216. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41217. * * 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
  41218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41219. * * 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
  41220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41221. * @param name defines the name of the mesh
  41222. * @param options defines the options used to create the mesh
  41223. * @param scene defines the hosting scene
  41224. * @returns the cylinder mesh
  41225. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41226. */
  41227. static CreateCylinder(name: string, options: {
  41228. height?: number;
  41229. diameterTop?: number;
  41230. diameterBottom?: number;
  41231. diameter?: number;
  41232. tessellation?: number;
  41233. subdivisions?: number;
  41234. arc?: number;
  41235. faceColors?: Color4[];
  41236. faceUV?: Vector4[];
  41237. updatable?: boolean;
  41238. hasRings?: boolean;
  41239. enclose?: boolean;
  41240. cap?: number;
  41241. sideOrientation?: number;
  41242. frontUVs?: Vector4;
  41243. backUVs?: Vector4;
  41244. }, scene: any): Mesh;
  41245. }
  41246. }
  41247. declare module BABYLON {
  41248. /**
  41249. * Options to modify the vr teleportation behavior.
  41250. */
  41251. export interface VRTeleportationOptions {
  41252. /**
  41253. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41254. */
  41255. floorMeshName?: string;
  41256. /**
  41257. * A list of meshes to be used as the teleportation floor. (default: empty)
  41258. */
  41259. floorMeshes?: Mesh[];
  41260. }
  41261. /**
  41262. * Options to modify the vr experience helper's behavior.
  41263. */
  41264. export interface VRExperienceHelperOptions extends WebVROptions {
  41265. /**
  41266. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41267. */
  41268. createDeviceOrientationCamera?: boolean;
  41269. /**
  41270. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41271. */
  41272. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41273. /**
  41274. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41275. */
  41276. laserToggle?: boolean;
  41277. /**
  41278. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41279. */
  41280. floorMeshes?: Mesh[];
  41281. /**
  41282. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41283. */
  41284. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41285. }
  41286. /**
  41287. * Event containing information after VR has been entered
  41288. */
  41289. export class OnAfterEnteringVRObservableEvent {
  41290. /**
  41291. * If entering vr was successful
  41292. */
  41293. success: boolean;
  41294. }
  41295. /**
  41296. * Helps to quickly add VR support to an existing scene.
  41297. * See http://doc.babylonjs.com/how_to/webvr_helper
  41298. */
  41299. export class VRExperienceHelper {
  41300. /** Options to modify the vr experience helper's behavior. */
  41301. webVROptions: VRExperienceHelperOptions;
  41302. private _scene;
  41303. private _position;
  41304. private _btnVR;
  41305. private _btnVRDisplayed;
  41306. private _webVRsupported;
  41307. private _webVRready;
  41308. private _webVRrequesting;
  41309. private _webVRpresenting;
  41310. private _hasEnteredVR;
  41311. private _fullscreenVRpresenting;
  41312. private _inputElement;
  41313. private _webVRCamera;
  41314. private _vrDeviceOrientationCamera;
  41315. private _deviceOrientationCamera;
  41316. private _existingCamera;
  41317. private _onKeyDown;
  41318. private _onVrDisplayPresentChange;
  41319. private _onVRDisplayChanged;
  41320. private _onVRRequestPresentStart;
  41321. private _onVRRequestPresentComplete;
  41322. /**
  41323. * 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)
  41324. */
  41325. enableGazeEvenWhenNoPointerLock: boolean;
  41326. /**
  41327. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41328. */
  41329. exitVROnDoubleTap: boolean;
  41330. /**
  41331. * Observable raised right before entering VR.
  41332. */
  41333. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41334. /**
  41335. * Observable raised when entering VR has completed.
  41336. */
  41337. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41338. /**
  41339. * Observable raised when exiting VR.
  41340. */
  41341. onExitingVRObservable: Observable<VRExperienceHelper>;
  41342. /**
  41343. * Observable raised when controller mesh is loaded.
  41344. */
  41345. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41346. /** Return this.onEnteringVRObservable
  41347. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41348. */
  41349. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41350. /** Return this.onExitingVRObservable
  41351. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41352. */
  41353. readonly onExitingVR: Observable<VRExperienceHelper>;
  41354. /** Return this.onControllerMeshLoadedObservable
  41355. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41356. */
  41357. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41358. private _rayLength;
  41359. private _useCustomVRButton;
  41360. private _teleportationRequested;
  41361. private _teleportActive;
  41362. private _floorMeshName;
  41363. private _floorMeshesCollection;
  41364. private _rotationAllowed;
  41365. private _teleportBackwardsVector;
  41366. private _teleportationTarget;
  41367. private _isDefaultTeleportationTarget;
  41368. private _postProcessMove;
  41369. private _teleportationFillColor;
  41370. private _teleportationBorderColor;
  41371. private _rotationAngle;
  41372. private _haloCenter;
  41373. private _cameraGazer;
  41374. private _padSensibilityUp;
  41375. private _padSensibilityDown;
  41376. private _leftController;
  41377. private _rightController;
  41378. /**
  41379. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41380. */
  41381. onNewMeshSelected: Observable<AbstractMesh>;
  41382. /**
  41383. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41384. * This observable will provide the mesh and the controller used to select the mesh
  41385. */
  41386. onMeshSelectedWithController: Observable<{
  41387. mesh: AbstractMesh;
  41388. controller: WebVRController;
  41389. }>;
  41390. /**
  41391. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41392. */
  41393. onNewMeshPicked: Observable<PickingInfo>;
  41394. private _circleEase;
  41395. /**
  41396. * Observable raised before camera teleportation
  41397. */
  41398. onBeforeCameraTeleport: Observable<Vector3>;
  41399. /**
  41400. * Observable raised after camera teleportation
  41401. */
  41402. onAfterCameraTeleport: Observable<Vector3>;
  41403. /**
  41404. * Observable raised when current selected mesh gets unselected
  41405. */
  41406. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41407. private _raySelectionPredicate;
  41408. /**
  41409. * To be optionaly changed by user to define custom ray selection
  41410. */
  41411. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41412. /**
  41413. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41414. */
  41415. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41416. /**
  41417. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41418. */
  41419. teleportationEnabled: boolean;
  41420. private _defaultHeight;
  41421. private _teleportationInitialized;
  41422. private _interactionsEnabled;
  41423. private _interactionsRequested;
  41424. private _displayGaze;
  41425. private _displayLaserPointer;
  41426. /**
  41427. * The mesh used to display where the user is going to teleport.
  41428. */
  41429. /**
  41430. * Sets the mesh to be used to display where the user is going to teleport.
  41431. */
  41432. teleportationTarget: Mesh;
  41433. /**
  41434. * 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
  41435. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41436. * See http://doc.babylonjs.com/resources/baking_transformations
  41437. */
  41438. gazeTrackerMesh: Mesh;
  41439. /**
  41440. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41441. */
  41442. updateGazeTrackerScale: boolean;
  41443. /**
  41444. * If the gaze trackers color should be updated when selecting meshes
  41445. */
  41446. updateGazeTrackerColor: boolean;
  41447. /**
  41448. * If the controller laser color should be updated when selecting meshes
  41449. */
  41450. updateControllerLaserColor: boolean;
  41451. /**
  41452. * The gaze tracking mesh corresponding to the left controller
  41453. */
  41454. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41455. /**
  41456. * The gaze tracking mesh corresponding to the right controller
  41457. */
  41458. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41459. /**
  41460. * If the ray of the gaze should be displayed.
  41461. */
  41462. /**
  41463. * Sets if the ray of the gaze should be displayed.
  41464. */
  41465. displayGaze: boolean;
  41466. /**
  41467. * If the ray of the LaserPointer should be displayed.
  41468. */
  41469. /**
  41470. * Sets if the ray of the LaserPointer should be displayed.
  41471. */
  41472. displayLaserPointer: boolean;
  41473. /**
  41474. * The deviceOrientationCamera used as the camera when not in VR.
  41475. */
  41476. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41477. /**
  41478. * Based on the current WebVR support, returns the current VR camera used.
  41479. */
  41480. readonly currentVRCamera: Nullable<Camera>;
  41481. /**
  41482. * The webVRCamera which is used when in VR.
  41483. */
  41484. readonly webVRCamera: WebVRFreeCamera;
  41485. /**
  41486. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41487. */
  41488. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41489. /**
  41490. * The html button that is used to trigger entering into VR.
  41491. */
  41492. readonly vrButton: Nullable<HTMLButtonElement>;
  41493. private readonly _teleportationRequestInitiated;
  41494. /**
  41495. * Defines wether or not Pointer lock should be requested when switching to
  41496. * full screen.
  41497. */
  41498. requestPointerLockOnFullScreen: boolean;
  41499. /**
  41500. * Instantiates a VRExperienceHelper.
  41501. * Helps to quickly add VR support to an existing scene.
  41502. * @param scene The scene the VRExperienceHelper belongs to.
  41503. * @param webVROptions Options to modify the vr experience helper's behavior.
  41504. */
  41505. constructor(scene: Scene,
  41506. /** Options to modify the vr experience helper's behavior. */
  41507. webVROptions?: VRExperienceHelperOptions);
  41508. private _onDefaultMeshLoaded;
  41509. private _onResize;
  41510. private _onFullscreenChange;
  41511. /**
  41512. * Gets a value indicating if we are currently in VR mode.
  41513. */
  41514. readonly isInVRMode: boolean;
  41515. private onVrDisplayPresentChange;
  41516. private onVRDisplayChanged;
  41517. private moveButtonToBottomRight;
  41518. private displayVRButton;
  41519. private updateButtonVisibility;
  41520. private _cachedAngularSensibility;
  41521. /**
  41522. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41523. * Otherwise, will use the fullscreen API.
  41524. */
  41525. enterVR(): void;
  41526. /**
  41527. * Attempt to exit VR, or fullscreen.
  41528. */
  41529. exitVR(): void;
  41530. /**
  41531. * The position of the vr experience helper.
  41532. */
  41533. /**
  41534. * Sets the position of the vr experience helper.
  41535. */
  41536. position: Vector3;
  41537. /**
  41538. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41539. */
  41540. enableInteractions(): void;
  41541. private readonly _noControllerIsActive;
  41542. private beforeRender;
  41543. private _isTeleportationFloor;
  41544. /**
  41545. * Adds a floor mesh to be used for teleportation.
  41546. * @param floorMesh the mesh to be used for teleportation.
  41547. */
  41548. addFloorMesh(floorMesh: Mesh): void;
  41549. /**
  41550. * Removes a floor mesh from being used for teleportation.
  41551. * @param floorMesh the mesh to be removed.
  41552. */
  41553. removeFloorMesh(floorMesh: Mesh): void;
  41554. /**
  41555. * Enables interactions and teleportation using the VR controllers and gaze.
  41556. * @param vrTeleportationOptions options to modify teleportation behavior.
  41557. */
  41558. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41559. private _onNewGamepadConnected;
  41560. private _tryEnableInteractionOnController;
  41561. private _onNewGamepadDisconnected;
  41562. private _enableInteractionOnController;
  41563. private _checkTeleportWithRay;
  41564. private _checkRotate;
  41565. private _checkTeleportBackwards;
  41566. private _enableTeleportationOnController;
  41567. private _createTeleportationCircles;
  41568. private _displayTeleportationTarget;
  41569. private _hideTeleportationTarget;
  41570. private _rotateCamera;
  41571. private _moveTeleportationSelectorTo;
  41572. private _workingVector;
  41573. private _workingQuaternion;
  41574. private _workingMatrix;
  41575. /**
  41576. * Teleports the users feet to the desired location
  41577. * @param location The location where the user's feet should be placed
  41578. */
  41579. teleportCamera(location: Vector3): void;
  41580. private _convertNormalToDirectionOfRay;
  41581. private _castRayAndSelectObject;
  41582. private _notifySelectedMeshUnselected;
  41583. /**
  41584. * Sets the color of the laser ray from the vr controllers.
  41585. * @param color new color for the ray.
  41586. */
  41587. changeLaserColor(color: Color3): void;
  41588. /**
  41589. * Sets the color of the ray from the vr headsets gaze.
  41590. * @param color new color for the ray.
  41591. */
  41592. changeGazeColor(color: Color3): void;
  41593. /**
  41594. * Exits VR and disposes of the vr experience helper
  41595. */
  41596. dispose(): void;
  41597. /**
  41598. * Gets the name of the VRExperienceHelper class
  41599. * @returns "VRExperienceHelper"
  41600. */
  41601. getClassName(): string;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * States of the webXR experience
  41607. */
  41608. export enum WebXRState {
  41609. /**
  41610. * Transitioning to being in XR mode
  41611. */
  41612. ENTERING_XR = 0,
  41613. /**
  41614. * Transitioning to non XR mode
  41615. */
  41616. EXITING_XR = 1,
  41617. /**
  41618. * In XR mode and presenting
  41619. */
  41620. IN_XR = 2,
  41621. /**
  41622. * Not entered XR mode
  41623. */
  41624. NOT_IN_XR = 3
  41625. }
  41626. /**
  41627. * Abstraction of the XR render target
  41628. */
  41629. export interface WebXRRenderTarget extends IDisposable {
  41630. /**
  41631. * xrpresent context of the canvas which can be used to display/mirror xr content
  41632. */
  41633. canvasContext: WebGLRenderingContext;
  41634. /**
  41635. * xr layer for the canvas
  41636. */
  41637. xrLayer: Nullable<XRWebGLLayer>;
  41638. /**
  41639. * Initializes the xr layer for the session
  41640. * @param xrSession xr session
  41641. * @returns a promise that will resolve once the XR Layer has been created
  41642. */
  41643. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41644. }
  41645. }
  41646. declare module BABYLON {
  41647. /**
  41648. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41649. */
  41650. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41651. private _engine;
  41652. private _canvas;
  41653. /**
  41654. * xrpresent context of the canvas which can be used to display/mirror xr content
  41655. */
  41656. canvasContext: WebGLRenderingContext;
  41657. /**
  41658. * xr layer for the canvas
  41659. */
  41660. xrLayer: Nullable<XRWebGLLayer>;
  41661. /**
  41662. * Initializes the xr layer for the session
  41663. * @param xrSession xr session
  41664. * @returns a promise that will resolve once the XR Layer has been created
  41665. */
  41666. initializeXRLayerAsync(xrSession: any): any;
  41667. /**
  41668. * Initializes the canvas to be added/removed upon entering/exiting xr
  41669. * @param engine the Babylon engine
  41670. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41671. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41672. */
  41673. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41674. /**
  41675. * Disposes of the object
  41676. */
  41677. dispose(): void;
  41678. private _setManagedOutputCanvas;
  41679. private _addCanvas;
  41680. private _removeCanvas;
  41681. }
  41682. }
  41683. declare module BABYLON {
  41684. /**
  41685. * Manages an XRSession to work with Babylon's engine
  41686. * @see https://doc.babylonjs.com/how_to/webxr
  41687. */
  41688. export class WebXRSessionManager implements IDisposable {
  41689. private scene;
  41690. /**
  41691. * Fires every time a new xrFrame arrives which can be used to update the camera
  41692. */
  41693. onXRFrameObservable: Observable<any>;
  41694. /**
  41695. * Fires when the xr session is ended either by the device or manually done
  41696. */
  41697. onXRSessionEnded: Observable<any>;
  41698. /**
  41699. * Underlying xr session
  41700. */
  41701. session: XRSession;
  41702. /**
  41703. * Type of reference space used when creating the session
  41704. */
  41705. referenceSpace: XRReferenceSpace;
  41706. /**
  41707. * Current XR frame
  41708. */
  41709. currentFrame: Nullable<XRFrame>;
  41710. private _xrNavigator;
  41711. private baseLayer;
  41712. private _rttProvider;
  41713. private _sessionEnded;
  41714. /**
  41715. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41716. * @param scene The scene which the session should be created for
  41717. */
  41718. constructor(scene: Scene);
  41719. /**
  41720. * Initializes the manager
  41721. * After initialization enterXR can be called to start an XR session
  41722. * @returns Promise which resolves after it is initialized
  41723. */
  41724. initializeAsync(): Promise<void>;
  41725. /**
  41726. * Initializes an xr session
  41727. * @param xrSessionMode mode to initialize
  41728. * @param optionalFeatures defines optional values to pass to the session builder
  41729. * @returns a promise which will resolve once the session has been initialized
  41730. */
  41731. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41732. /**
  41733. * Sets the reference space on the xr session
  41734. * @param referenceSpace space to set
  41735. * @returns a promise that will resolve once the reference space has been set
  41736. */
  41737. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41738. /**
  41739. * Updates the render state of the session
  41740. * @param state state to set
  41741. * @returns a promise that resolves once the render state has been updated
  41742. */
  41743. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41744. /**
  41745. * Starts rendering to the xr layer
  41746. * @returns a promise that will resolve once rendering has started
  41747. */
  41748. startRenderingToXRAsync(): Promise<void>;
  41749. /**
  41750. * Gets the correct render target texture to be rendered this frame for this eye
  41751. * @param eye the eye for which to get the render target
  41752. * @returns the render target for the specified eye
  41753. */
  41754. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41755. /**
  41756. * Stops the xrSession and restores the renderloop
  41757. * @returns Promise which resolves after it exits XR
  41758. */
  41759. exitXRAsync(): Promise<void>;
  41760. /**
  41761. * Checks if a session would be supported for the creation options specified
  41762. * @param sessionMode session mode to check if supported eg. immersive-vr
  41763. * @returns true if supported
  41764. */
  41765. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41766. /**
  41767. * Creates a WebXRRenderTarget object for the XR session
  41768. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41769. * @returns a WebXR render target to which the session can render
  41770. */
  41771. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  41772. /**
  41773. * @hidden
  41774. * Converts the render layer of xrSession to a render target
  41775. * @param session session to create render target for
  41776. * @param scene scene the new render target should be created for
  41777. */
  41778. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41779. /**
  41780. * Disposes of the session manager
  41781. */
  41782. dispose(): void;
  41783. }
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * WebXR Camera which holds the views for the xrSession
  41788. * @see https://doc.babylonjs.com/how_to/webxr
  41789. */
  41790. export class WebXRCamera extends FreeCamera {
  41791. private static _TmpMatrix;
  41792. /**
  41793. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41794. * @param name the name of the camera
  41795. * @param scene the scene to add the camera to
  41796. */
  41797. constructor(name: string, scene: Scene);
  41798. private _updateNumberOfRigCameras;
  41799. /** @hidden */
  41800. _updateForDualEyeDebugging(): void;
  41801. /**
  41802. * Updates the cameras position from the current pose information of the XR session
  41803. * @param xrSessionManager the session containing pose information
  41804. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41805. */
  41806. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41812. * @see https://doc.babylonjs.com/how_to/webxr
  41813. */
  41814. export class WebXRExperienceHelper implements IDisposable {
  41815. private scene;
  41816. /**
  41817. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41818. */
  41819. container: AbstractMesh;
  41820. /**
  41821. * Camera used to render xr content
  41822. */
  41823. camera: WebXRCamera;
  41824. /**
  41825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41826. */
  41827. state: WebXRState;
  41828. private _setState;
  41829. private static _TmpVector;
  41830. /**
  41831. * Fires when the state of the experience helper has changed
  41832. */
  41833. onStateChangedObservable: Observable<WebXRState>;
  41834. /** Session manager used to keep track of xr session */
  41835. sessionManager: WebXRSessionManager;
  41836. private _nonVRCamera;
  41837. private _originalSceneAutoClear;
  41838. private _supported;
  41839. /**
  41840. * Creates the experience helper
  41841. * @param scene the scene to attach the experience helper to
  41842. * @returns a promise for the experience helper
  41843. */
  41844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41845. /**
  41846. * Creates a WebXRExperienceHelper
  41847. * @param scene The scene the helper should be created in
  41848. */
  41849. private constructor();
  41850. /**
  41851. * Exits XR mode and returns the scene to its original state
  41852. * @returns promise that resolves after xr mode has exited
  41853. */
  41854. exitXRAsync(): Promise<void>;
  41855. /**
  41856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41857. * @param sessionMode options for the XR session
  41858. * @param referenceSpaceType frame of reference of the XR session
  41859. * @param renderTarget the output canvas that will be used to enter XR mode
  41860. * @returns promise that resolves after xr mode has entered
  41861. */
  41862. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41863. /**
  41864. * Updates the global position of the camera by moving the camera's container
  41865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41866. * @param position The desired global position of the camera
  41867. */
  41868. setPositionOfCameraUsingContainer(position: Vector3): void;
  41869. /**
  41870. * Rotates the xr camera by rotating the camera's container around the camera's position
  41871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41872. * @param rotation the desired quaternion rotation to apply to the camera
  41873. */
  41874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41875. /**
  41876. * Disposes of the experience helper
  41877. */
  41878. dispose(): void;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * Button which can be used to enter a different mode of XR
  41884. */
  41885. export class WebXREnterExitUIButton {
  41886. /** button element */
  41887. element: HTMLElement;
  41888. /** XR initialization options for the button */
  41889. sessionMode: XRSessionMode;
  41890. /** Reference space type */
  41891. referenceSpaceType: XRReferenceSpaceType;
  41892. /**
  41893. * Creates a WebXREnterExitUIButton
  41894. * @param element button element
  41895. * @param sessionMode XR initialization session mode
  41896. * @param referenceSpaceType the type of reference space to be used
  41897. */
  41898. constructor(
  41899. /** button element */
  41900. element: HTMLElement,
  41901. /** XR initialization options for the button */
  41902. sessionMode: XRSessionMode,
  41903. /** Reference space type */
  41904. referenceSpaceType: XRReferenceSpaceType);
  41905. /**
  41906. * Overwritable function which can be used to update the button's visuals when the state changes
  41907. * @param activeButton the current active button in the UI
  41908. */
  41909. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41910. }
  41911. /**
  41912. * Options to create the webXR UI
  41913. */
  41914. export class WebXREnterExitUIOptions {
  41915. /**
  41916. * Context to enter xr with
  41917. */
  41918. renderTarget?: Nullable<WebXRRenderTarget>;
  41919. /**
  41920. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41921. */
  41922. customButtons?: Array<WebXREnterExitUIButton>;
  41923. }
  41924. /**
  41925. * UI to allow the user to enter/exit XR mode
  41926. */
  41927. export class WebXREnterExitUI implements IDisposable {
  41928. private scene;
  41929. private _overlay;
  41930. private _buttons;
  41931. private _activeButton;
  41932. /**
  41933. * Fired every time the active button is changed.
  41934. *
  41935. * When xr is entered via a button that launches xr that button will be the callback parameter
  41936. *
  41937. * When exiting xr the callback parameter will be null)
  41938. */
  41939. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41940. /**
  41941. * Creates UI to allow the user to enter/exit XR mode
  41942. * @param scene the scene to add the ui to
  41943. * @param helper the xr experience helper to enter/exit xr with
  41944. * @param options options to configure the UI
  41945. * @returns the created ui
  41946. */
  41947. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41948. private constructor();
  41949. private _updateButtons;
  41950. /**
  41951. * Disposes of the object
  41952. */
  41953. dispose(): void;
  41954. }
  41955. }
  41956. declare module BABYLON {
  41957. /**
  41958. * Represents an XR input
  41959. */
  41960. export class WebXRController {
  41961. private scene;
  41962. /** The underlying input source for the controller */
  41963. inputSource: XRInputSource;
  41964. private parentContainer;
  41965. /**
  41966. * 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
  41967. */
  41968. grip?: AbstractMesh;
  41969. /**
  41970. * Pointer which can be used to select objects or attach a visible laser to
  41971. */
  41972. pointer: AbstractMesh;
  41973. private _gamepadMode;
  41974. /**
  41975. * If available, this is the gamepad object related to this controller.
  41976. * Using this object it is possible to get click events and trackpad changes of the
  41977. * webxr controller that is currently being used.
  41978. */
  41979. gamepadController?: WebVRController;
  41980. /**
  41981. * Event that fires when the controller is removed/disposed
  41982. */
  41983. onDisposeObservable: Observable<{}>;
  41984. private _tmpMatrix;
  41985. private _tmpQuaternion;
  41986. private _tmpVector;
  41987. /**
  41988. * Creates the controller
  41989. * @see https://doc.babylonjs.com/how_to/webxr
  41990. * @param scene the scene which the controller should be associated to
  41991. * @param inputSource the underlying input source for the controller
  41992. * @param parentContainer parent that the controller meshes should be children of
  41993. */
  41994. constructor(scene: Scene,
  41995. /** The underlying input source for the controller */
  41996. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41997. /**
  41998. * Updates the controller pose based on the given XRFrame
  41999. * @param xrFrame xr frame to update the pose with
  42000. * @param referenceSpace reference space to use
  42001. */
  42002. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42003. /**
  42004. * Gets a world space ray coming from the controller
  42005. * @param result the resulting ray
  42006. */
  42007. getWorldPointerRayToRef(result: Ray): void;
  42008. /**
  42009. * Get the scene associated with this controller
  42010. * @returns the scene object
  42011. */
  42012. getScene(): Scene;
  42013. /**
  42014. * Disposes of the object
  42015. */
  42016. dispose(): void;
  42017. }
  42018. }
  42019. declare module BABYLON {
  42020. /**
  42021. * XR input used to track XR inputs such as controllers/rays
  42022. */
  42023. export class WebXRInput implements IDisposable {
  42024. /**
  42025. * Base experience the input listens to
  42026. */
  42027. baseExperience: WebXRExperienceHelper;
  42028. /**
  42029. * XR controllers being tracked
  42030. */
  42031. controllers: Array<WebXRController>;
  42032. private _frameObserver;
  42033. private _stateObserver;
  42034. /**
  42035. * Event when a controller has been connected/added
  42036. */
  42037. onControllerAddedObservable: Observable<WebXRController>;
  42038. /**
  42039. * Event when a controller has been removed/disconnected
  42040. */
  42041. onControllerRemovedObservable: Observable<WebXRController>;
  42042. /**
  42043. * Initializes the WebXRInput
  42044. * @param baseExperience experience helper which the input should be created for
  42045. */
  42046. constructor(
  42047. /**
  42048. * Base experience the input listens to
  42049. */
  42050. baseExperience: WebXRExperienceHelper);
  42051. private _onInputSourcesChange;
  42052. private _addAndRemoveControllers;
  42053. /**
  42054. * Disposes of the object
  42055. */
  42056. dispose(): void;
  42057. }
  42058. }
  42059. declare module BABYLON {
  42060. /**
  42061. * Enables teleportation
  42062. */
  42063. export class WebXRControllerTeleportation {
  42064. private _teleportationFillColor;
  42065. private _teleportationBorderColor;
  42066. private _tmpRay;
  42067. private _tmpVector;
  42068. /**
  42069. * Creates a WebXRControllerTeleportation
  42070. * @param input input manager to add teleportation to
  42071. * @param floorMeshes floormeshes which can be teleported to
  42072. */
  42073. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42074. }
  42075. }
  42076. declare module BABYLON {
  42077. /**
  42078. * Handles pointer input automatically for the pointer of XR controllers
  42079. */
  42080. export class WebXRControllerPointerSelection {
  42081. private static _idCounter;
  42082. private _tmpRay;
  42083. /**
  42084. * Creates a WebXRControllerPointerSelection
  42085. * @param input input manager to setup pointer selection
  42086. */
  42087. constructor(input: WebXRInput);
  42088. private _convertNormalToDirectionOfRay;
  42089. private _updatePointerDistance;
  42090. }
  42091. }
  42092. declare module BABYLON {
  42093. /**
  42094. * Class used to represent data loading progression
  42095. */
  42096. export class SceneLoaderProgressEvent {
  42097. /** defines if data length to load can be evaluated */
  42098. readonly lengthComputable: boolean;
  42099. /** defines the loaded data length */
  42100. readonly loaded: number;
  42101. /** defines the data length to load */
  42102. readonly total: number;
  42103. /**
  42104. * Create a new progress event
  42105. * @param lengthComputable defines if data length to load can be evaluated
  42106. * @param loaded defines the loaded data length
  42107. * @param total defines the data length to load
  42108. */
  42109. constructor(
  42110. /** defines if data length to load can be evaluated */
  42111. lengthComputable: boolean,
  42112. /** defines the loaded data length */
  42113. loaded: number,
  42114. /** defines the data length to load */
  42115. total: number);
  42116. /**
  42117. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42118. * @param event defines the source event
  42119. * @returns a new SceneLoaderProgressEvent
  42120. */
  42121. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42122. }
  42123. /**
  42124. * Interface used by SceneLoader plugins to define supported file extensions
  42125. */
  42126. export interface ISceneLoaderPluginExtensions {
  42127. /**
  42128. * Defines the list of supported extensions
  42129. */
  42130. [extension: string]: {
  42131. isBinary: boolean;
  42132. };
  42133. }
  42134. /**
  42135. * Interface used by SceneLoader plugin factory
  42136. */
  42137. export interface ISceneLoaderPluginFactory {
  42138. /**
  42139. * Defines the name of the factory
  42140. */
  42141. name: string;
  42142. /**
  42143. * Function called to create a new plugin
  42144. * @return the new plugin
  42145. */
  42146. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42147. /**
  42148. * The callback that returns true if the data can be directly loaded.
  42149. * @param data string containing the file data
  42150. * @returns if the data can be loaded directly
  42151. */
  42152. canDirectLoad?(data: string): boolean;
  42153. }
  42154. /**
  42155. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42156. */
  42157. export interface ISceneLoaderPluginBase {
  42158. /**
  42159. * The friendly name of this plugin.
  42160. */
  42161. name: string;
  42162. /**
  42163. * The file extensions supported by this plugin.
  42164. */
  42165. extensions: string | ISceneLoaderPluginExtensions;
  42166. /**
  42167. * The callback called when loading from a url.
  42168. * @param scene scene loading this url
  42169. * @param url url to load
  42170. * @param onSuccess callback called when the file successfully loads
  42171. * @param onProgress callback called while file is loading (if the server supports this mode)
  42172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42173. * @param onError callback called when the file fails to load
  42174. * @returns a file request object
  42175. */
  42176. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42177. /**
  42178. * The callback called when loading from a file object.
  42179. * @param scene scene loading this file
  42180. * @param file defines the file to load
  42181. * @param onSuccess defines the callback to call when data is loaded
  42182. * @param onProgress defines the callback to call during loading process
  42183. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42184. * @param onError defines the callback to call when an error occurs
  42185. * @returns a file request object
  42186. */
  42187. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42188. /**
  42189. * The callback that returns true if the data can be directly loaded.
  42190. * @param data string containing the file data
  42191. * @returns if the data can be loaded directly
  42192. */
  42193. canDirectLoad?(data: string): boolean;
  42194. /**
  42195. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42196. * @param scene scene loading this data
  42197. * @param data string containing the data
  42198. * @returns data to pass to the plugin
  42199. */
  42200. directLoad?(scene: Scene, data: string): any;
  42201. /**
  42202. * The callback that allows custom handling of the root url based on the response url.
  42203. * @param rootUrl the original root url
  42204. * @param responseURL the response url if available
  42205. * @returns the new root url
  42206. */
  42207. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42208. }
  42209. /**
  42210. * Interface used to define a SceneLoader plugin
  42211. */
  42212. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42213. /**
  42214. * Import meshes into a scene.
  42215. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42216. * @param scene The scene to import into
  42217. * @param data The data to import
  42218. * @param rootUrl The root url for scene and resources
  42219. * @param meshes The meshes array to import into
  42220. * @param particleSystems The particle systems array to import into
  42221. * @param skeletons The skeletons array to import into
  42222. * @param onError The callback when import fails
  42223. * @returns True if successful or false otherwise
  42224. */
  42225. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42226. /**
  42227. * Load into a scene.
  42228. * @param scene The scene to load into
  42229. * @param data The data to import
  42230. * @param rootUrl The root url for scene and resources
  42231. * @param onError The callback when import fails
  42232. * @returns True if successful or false otherwise
  42233. */
  42234. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42235. /**
  42236. * Load into an asset container.
  42237. * @param scene The scene to load into
  42238. * @param data The data to import
  42239. * @param rootUrl The root url for scene and resources
  42240. * @param onError The callback when import fails
  42241. * @returns The loaded asset container
  42242. */
  42243. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42244. }
  42245. /**
  42246. * Interface used to define an async SceneLoader plugin
  42247. */
  42248. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42249. /**
  42250. * Import meshes into a scene.
  42251. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42252. * @param scene The scene to import into
  42253. * @param data The data to import
  42254. * @param rootUrl The root url for scene and resources
  42255. * @param onProgress The callback when the load progresses
  42256. * @param fileName Defines the name of the file to load
  42257. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42258. */
  42259. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42260. meshes: AbstractMesh[];
  42261. particleSystems: IParticleSystem[];
  42262. skeletons: Skeleton[];
  42263. animationGroups: AnimationGroup[];
  42264. }>;
  42265. /**
  42266. * Load into a scene.
  42267. * @param scene The scene to load into
  42268. * @param data The data to import
  42269. * @param rootUrl The root url for scene and resources
  42270. * @param onProgress The callback when the load progresses
  42271. * @param fileName Defines the name of the file to load
  42272. * @returns Nothing
  42273. */
  42274. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42275. /**
  42276. * Load into an asset container.
  42277. * @param scene The scene to load into
  42278. * @param data The data to import
  42279. * @param rootUrl The root url for scene and resources
  42280. * @param onProgress The callback when the load progresses
  42281. * @param fileName Defines the name of the file to load
  42282. * @returns The loaded asset container
  42283. */
  42284. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42285. }
  42286. /**
  42287. * Class used to load scene from various file formats using registered plugins
  42288. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42289. */
  42290. export class SceneLoader {
  42291. /**
  42292. * No logging while loading
  42293. */
  42294. static readonly NO_LOGGING: number;
  42295. /**
  42296. * Minimal logging while loading
  42297. */
  42298. static readonly MINIMAL_LOGGING: number;
  42299. /**
  42300. * Summary logging while loading
  42301. */
  42302. static readonly SUMMARY_LOGGING: number;
  42303. /**
  42304. * Detailled logging while loading
  42305. */
  42306. static readonly DETAILED_LOGGING: number;
  42307. /**
  42308. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42309. */
  42310. static ForceFullSceneLoadingForIncremental: boolean;
  42311. /**
  42312. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42313. */
  42314. static ShowLoadingScreen: boolean;
  42315. /**
  42316. * Defines the current logging level (while loading the scene)
  42317. * @ignorenaming
  42318. */
  42319. static loggingLevel: number;
  42320. /**
  42321. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42322. */
  42323. static CleanBoneMatrixWeights: boolean;
  42324. /**
  42325. * Event raised when a plugin is used to load a scene
  42326. */
  42327. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42328. private static _registeredPlugins;
  42329. private static _getDefaultPlugin;
  42330. private static _getPluginForExtension;
  42331. private static _getPluginForDirectLoad;
  42332. private static _getPluginForFilename;
  42333. private static _getDirectLoad;
  42334. private static _loadData;
  42335. private static _getFileInfo;
  42336. /**
  42337. * Gets a plugin that can load the given extension
  42338. * @param extension defines the extension to load
  42339. * @returns a plugin or null if none works
  42340. */
  42341. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42342. /**
  42343. * Gets a boolean indicating that the given extension can be loaded
  42344. * @param extension defines the extension to load
  42345. * @returns true if the extension is supported
  42346. */
  42347. static IsPluginForExtensionAvailable(extension: string): boolean;
  42348. /**
  42349. * Adds a new plugin to the list of registered plugins
  42350. * @param plugin defines the plugin to add
  42351. */
  42352. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42353. /**
  42354. * Import meshes into a scene
  42355. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42356. * @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)
  42357. * @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)
  42358. * @param scene the instance of BABYLON.Scene to append to
  42359. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42360. * @param onProgress a callback with a progress event for each file being loaded
  42361. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42362. * @param pluginExtension the extension used to determine the plugin
  42363. * @returns The loaded plugin
  42364. */
  42365. 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>;
  42366. /**
  42367. * Import meshes into a scene
  42368. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42369. * @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)
  42370. * @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)
  42371. * @param scene the instance of BABYLON.Scene to append to
  42372. * @param onProgress a callback with a progress event for each file being loaded
  42373. * @param pluginExtension the extension used to determine the plugin
  42374. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42375. */
  42376. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42377. meshes: AbstractMesh[];
  42378. particleSystems: IParticleSystem[];
  42379. skeletons: Skeleton[];
  42380. animationGroups: AnimationGroup[];
  42381. }>;
  42382. /**
  42383. * Load a scene
  42384. * @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)
  42385. * @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)
  42386. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42387. * @param onSuccess a callback with the scene when import succeeds
  42388. * @param onProgress a callback with a progress event for each file being loaded
  42389. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42390. * @param pluginExtension the extension used to determine the plugin
  42391. * @returns The loaded plugin
  42392. */
  42393. 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>;
  42394. /**
  42395. * Load a scene
  42396. * @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)
  42397. * @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)
  42398. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42399. * @param onProgress a callback with a progress event for each file being loaded
  42400. * @param pluginExtension the extension used to determine the plugin
  42401. * @returns The loaded scene
  42402. */
  42403. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42404. /**
  42405. * Append a scene
  42406. * @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)
  42407. * @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)
  42408. * @param scene is the instance of BABYLON.Scene to append to
  42409. * @param onSuccess a callback with the scene when import succeeds
  42410. * @param onProgress a callback with a progress event for each file being loaded
  42411. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42412. * @param pluginExtension the extension used to determine the plugin
  42413. * @returns The loaded plugin
  42414. */
  42415. 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>;
  42416. /**
  42417. * Append a scene
  42418. * @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)
  42419. * @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)
  42420. * @param scene is the instance of BABYLON.Scene to append to
  42421. * @param onProgress a callback with a progress event for each file being loaded
  42422. * @param pluginExtension the extension used to determine the plugin
  42423. * @returns The given scene
  42424. */
  42425. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42426. /**
  42427. * Load a scene into an asset container
  42428. * @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)
  42429. * @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)
  42430. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42431. * @param onSuccess a callback with the scene when import succeeds
  42432. * @param onProgress a callback with a progress event for each file being loaded
  42433. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42434. * @param pluginExtension the extension used to determine the plugin
  42435. * @returns The loaded plugin
  42436. */
  42437. 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>;
  42438. /**
  42439. * Load a scene into an asset container
  42440. * @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)
  42441. * @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)
  42442. * @param scene is the instance of Scene to append to
  42443. * @param onProgress a callback with a progress event for each file being loaded
  42444. * @param pluginExtension the extension used to determine the plugin
  42445. * @returns The loaded asset container
  42446. */
  42447. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42448. }
  42449. }
  42450. declare module BABYLON {
  42451. /**
  42452. * Generic Controller
  42453. */
  42454. export class GenericController extends WebVRController {
  42455. /**
  42456. * Base Url for the controller model.
  42457. */
  42458. static readonly MODEL_BASE_URL: string;
  42459. /**
  42460. * File name for the controller model.
  42461. */
  42462. static readonly MODEL_FILENAME: string;
  42463. /**
  42464. * Creates a new GenericController from a gamepad
  42465. * @param vrGamepad the gamepad that the controller should be created from
  42466. */
  42467. constructor(vrGamepad: any);
  42468. /**
  42469. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42470. * @param scene scene in which to add meshes
  42471. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42472. */
  42473. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42474. /**
  42475. * Called once for each button that changed state since the last frame
  42476. * @param buttonIdx Which button index changed
  42477. * @param state New state of the button
  42478. * @param changes Which properties on the state changed since last frame
  42479. */
  42480. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42481. }
  42482. }
  42483. declare module BABYLON {
  42484. /**
  42485. * Defines the WindowsMotionController object that the state of the windows motion controller
  42486. */
  42487. export class WindowsMotionController extends WebVRController {
  42488. /**
  42489. * The base url used to load the left and right controller models
  42490. */
  42491. static MODEL_BASE_URL: string;
  42492. /**
  42493. * The name of the left controller model file
  42494. */
  42495. static MODEL_LEFT_FILENAME: string;
  42496. /**
  42497. * The name of the right controller model file
  42498. */
  42499. static MODEL_RIGHT_FILENAME: string;
  42500. /**
  42501. * The controller name prefix for this controller type
  42502. */
  42503. static readonly GAMEPAD_ID_PREFIX: string;
  42504. /**
  42505. * The controller id pattern for this controller type
  42506. */
  42507. private static readonly GAMEPAD_ID_PATTERN;
  42508. private _loadedMeshInfo;
  42509. private readonly _mapping;
  42510. /**
  42511. * Fired when the trackpad on this controller is clicked
  42512. */
  42513. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42514. /**
  42515. * Fired when the trackpad on this controller is modified
  42516. */
  42517. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42518. /**
  42519. * The current x and y values of this controller's trackpad
  42520. */
  42521. trackpad: StickValues;
  42522. /**
  42523. * Creates a new WindowsMotionController from a gamepad
  42524. * @param vrGamepad the gamepad that the controller should be created from
  42525. */
  42526. constructor(vrGamepad: any);
  42527. /**
  42528. * Fired when the trigger on this controller is modified
  42529. */
  42530. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42531. /**
  42532. * Fired when the menu button on this controller is modified
  42533. */
  42534. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42535. /**
  42536. * Fired when the grip button on this controller is modified
  42537. */
  42538. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42539. /**
  42540. * Fired when the thumbstick button on this controller is modified
  42541. */
  42542. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42543. /**
  42544. * Fired when the touchpad button on this controller is modified
  42545. */
  42546. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42547. /**
  42548. * Fired when the touchpad values on this controller are modified
  42549. */
  42550. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42551. private _updateTrackpad;
  42552. /**
  42553. * Called once per frame by the engine.
  42554. */
  42555. update(): void;
  42556. /**
  42557. * Called once for each button that changed state since the last frame
  42558. * @param buttonIdx Which button index changed
  42559. * @param state New state of the button
  42560. * @param changes Which properties on the state changed since last frame
  42561. */
  42562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42563. /**
  42564. * Moves the buttons on the controller mesh based on their current state
  42565. * @param buttonName the name of the button to move
  42566. * @param buttonValue the value of the button which determines the buttons new position
  42567. */
  42568. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42569. /**
  42570. * Moves the axis on the controller mesh based on its current state
  42571. * @param axis the index of the axis
  42572. * @param axisValue the value of the axis which determines the meshes new position
  42573. * @hidden
  42574. */
  42575. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42576. /**
  42577. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42578. * @param scene scene in which to add meshes
  42579. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42580. */
  42581. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42582. /**
  42583. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42584. * can be transformed by button presses and axes values, based on this._mapping.
  42585. *
  42586. * @param scene scene in which the meshes exist
  42587. * @param meshes list of meshes that make up the controller model to process
  42588. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42589. */
  42590. private processModel;
  42591. private createMeshInfo;
  42592. /**
  42593. * Gets the ray of the controller in the direction the controller is pointing
  42594. * @param length the length the resulting ray should be
  42595. * @returns a ray in the direction the controller is pointing
  42596. */
  42597. getForwardRay(length?: number): Ray;
  42598. /**
  42599. * Disposes of the controller
  42600. */
  42601. dispose(): void;
  42602. }
  42603. }
  42604. declare module BABYLON {
  42605. /**
  42606. * Oculus Touch Controller
  42607. */
  42608. export class OculusTouchController extends WebVRController {
  42609. /**
  42610. * Base Url for the controller model.
  42611. */
  42612. static MODEL_BASE_URL: string;
  42613. /**
  42614. * File name for the left controller model.
  42615. */
  42616. static MODEL_LEFT_FILENAME: string;
  42617. /**
  42618. * File name for the right controller model.
  42619. */
  42620. static MODEL_RIGHT_FILENAME: string;
  42621. /**
  42622. * Base Url for the Quest controller model.
  42623. */
  42624. static QUEST_MODEL_BASE_URL: string;
  42625. /**
  42626. * @hidden
  42627. * If the controllers are running on a device that needs the updated Quest controller models
  42628. */
  42629. static _IsQuest: boolean;
  42630. /**
  42631. * Fired when the secondary trigger on this controller is modified
  42632. */
  42633. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42634. /**
  42635. * Fired when the thumb rest on this controller is modified
  42636. */
  42637. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42638. /**
  42639. * Creates a new OculusTouchController from a gamepad
  42640. * @param vrGamepad the gamepad that the controller should be created from
  42641. */
  42642. constructor(vrGamepad: any);
  42643. /**
  42644. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42645. * @param scene scene in which to add meshes
  42646. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42647. */
  42648. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42649. /**
  42650. * Fired when the A button on this controller is modified
  42651. */
  42652. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42653. /**
  42654. * Fired when the B button on this controller is modified
  42655. */
  42656. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42657. /**
  42658. * Fired when the X button on this controller is modified
  42659. */
  42660. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42661. /**
  42662. * Fired when the Y button on this controller is modified
  42663. */
  42664. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42665. /**
  42666. * Called once for each button that changed state since the last frame
  42667. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42668. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42669. * 2) secondary trigger (same)
  42670. * 3) A (right) X (left), touch, pressed = value
  42671. * 4) B / Y
  42672. * 5) thumb rest
  42673. * @param buttonIdx Which button index changed
  42674. * @param state New state of the button
  42675. * @param changes Which properties on the state changed since last frame
  42676. */
  42677. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /**
  42682. * Vive Controller
  42683. */
  42684. export class ViveController extends WebVRController {
  42685. /**
  42686. * Base Url for the controller model.
  42687. */
  42688. static MODEL_BASE_URL: string;
  42689. /**
  42690. * File name for the controller model.
  42691. */
  42692. static MODEL_FILENAME: string;
  42693. /**
  42694. * Creates a new ViveController from a gamepad
  42695. * @param vrGamepad the gamepad that the controller should be created from
  42696. */
  42697. constructor(vrGamepad: any);
  42698. /**
  42699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42700. * @param scene scene in which to add meshes
  42701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42702. */
  42703. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42704. /**
  42705. * Fired when the left button on this controller is modified
  42706. */
  42707. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42708. /**
  42709. * Fired when the right button on this controller is modified
  42710. */
  42711. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42712. /**
  42713. * Fired when the menu button on this controller is modified
  42714. */
  42715. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42716. /**
  42717. * Called once for each button that changed state since the last frame
  42718. * Vive mapping:
  42719. * 0: touchpad
  42720. * 1: trigger
  42721. * 2: left AND right buttons
  42722. * 3: menu button
  42723. * @param buttonIdx Which button index changed
  42724. * @param state New state of the button
  42725. * @param changes Which properties on the state changed since last frame
  42726. */
  42727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42728. }
  42729. }
  42730. declare module BABYLON {
  42731. /**
  42732. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42733. */
  42734. export class WebXRControllerModelLoader {
  42735. /**
  42736. * Creates the WebXRControllerModelLoader
  42737. * @param input xr input that creates the controllers
  42738. */
  42739. constructor(input: WebXRInput);
  42740. }
  42741. }
  42742. declare module BABYLON {
  42743. /**
  42744. * Contains an array of blocks representing the octree
  42745. */
  42746. export interface IOctreeContainer<T> {
  42747. /**
  42748. * Blocks within the octree
  42749. */
  42750. blocks: Array<OctreeBlock<T>>;
  42751. }
  42752. /**
  42753. * Class used to store a cell in an octree
  42754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42755. */
  42756. export class OctreeBlock<T> {
  42757. /**
  42758. * Gets the content of the current block
  42759. */
  42760. entries: T[];
  42761. /**
  42762. * Gets the list of block children
  42763. */
  42764. blocks: Array<OctreeBlock<T>>;
  42765. private _depth;
  42766. private _maxDepth;
  42767. private _capacity;
  42768. private _minPoint;
  42769. private _maxPoint;
  42770. private _boundingVectors;
  42771. private _creationFunc;
  42772. /**
  42773. * Creates a new block
  42774. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42775. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42776. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42777. * @param depth defines the current depth of this block in the octree
  42778. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42779. * @param creationFunc defines a callback to call when an element is added to the block
  42780. */
  42781. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42782. /**
  42783. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42784. */
  42785. readonly capacity: number;
  42786. /**
  42787. * Gets the minimum vector (in world space) of the block's bounding box
  42788. */
  42789. readonly minPoint: Vector3;
  42790. /**
  42791. * Gets the maximum vector (in world space) of the block's bounding box
  42792. */
  42793. readonly maxPoint: Vector3;
  42794. /**
  42795. * Add a new element to this block
  42796. * @param entry defines the element to add
  42797. */
  42798. addEntry(entry: T): void;
  42799. /**
  42800. * Remove an element from this block
  42801. * @param entry defines the element to remove
  42802. */
  42803. removeEntry(entry: T): void;
  42804. /**
  42805. * Add an array of elements to this block
  42806. * @param entries defines the array of elements to add
  42807. */
  42808. addEntries(entries: T[]): void;
  42809. /**
  42810. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42811. * @param frustumPlanes defines the frustum planes to test
  42812. * @param selection defines the array to store current content if selection is positive
  42813. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42814. */
  42815. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42816. /**
  42817. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42818. * @param sphereCenter defines the bounding sphere center
  42819. * @param sphereRadius defines the bounding sphere radius
  42820. * @param selection defines the array to store current content if selection is positive
  42821. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42822. */
  42823. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42824. /**
  42825. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42826. * @param ray defines the ray to test with
  42827. * @param selection defines the array to store current content if selection is positive
  42828. */
  42829. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42830. /**
  42831. * Subdivide the content into child blocks (this block will then be empty)
  42832. */
  42833. createInnerBlocks(): void;
  42834. /**
  42835. * @hidden
  42836. */
  42837. 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;
  42838. }
  42839. }
  42840. declare module BABYLON {
  42841. /**
  42842. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42844. */
  42845. export class Octree<T> {
  42846. /** 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.) */
  42847. maxDepth: number;
  42848. /**
  42849. * Blocks within the octree containing objects
  42850. */
  42851. blocks: Array<OctreeBlock<T>>;
  42852. /**
  42853. * Content stored in the octree
  42854. */
  42855. dynamicContent: T[];
  42856. private _maxBlockCapacity;
  42857. private _selectionContent;
  42858. private _creationFunc;
  42859. /**
  42860. * Creates a octree
  42861. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42862. * @param creationFunc function to be used to instatiate the octree
  42863. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42864. * @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.)
  42865. */
  42866. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42867. /** 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.) */
  42868. maxDepth?: number);
  42869. /**
  42870. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42871. * @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);
  42872. * @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);
  42873. * @param entries meshes to be added to the octree blocks
  42874. */
  42875. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42876. /**
  42877. * Adds a mesh to the octree
  42878. * @param entry Mesh to add to the octree
  42879. */
  42880. addMesh(entry: T): void;
  42881. /**
  42882. * Remove an element from the octree
  42883. * @param entry defines the element to remove
  42884. */
  42885. removeMesh(entry: T): void;
  42886. /**
  42887. * Selects an array of meshes within the frustum
  42888. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42889. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42890. * @returns array of meshes within the frustum
  42891. */
  42892. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42893. /**
  42894. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42895. * @param sphereCenter defines the bounding sphere center
  42896. * @param sphereRadius defines the bounding sphere radius
  42897. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42898. * @returns an array of objects that intersect the sphere
  42899. */
  42900. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42901. /**
  42902. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42903. * @param ray defines the ray to test with
  42904. * @returns array of intersected objects
  42905. */
  42906. intersectsRay(ray: Ray): SmartArray<T>;
  42907. /**
  42908. * Adds a mesh into the octree block if it intersects the block
  42909. */
  42910. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42911. /**
  42912. * Adds a submesh into the octree block if it intersects the block
  42913. */
  42914. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42915. }
  42916. }
  42917. declare module BABYLON {
  42918. interface Scene {
  42919. /**
  42920. * @hidden
  42921. * Backing Filed
  42922. */
  42923. _selectionOctree: Octree<AbstractMesh>;
  42924. /**
  42925. * Gets the octree used to boost mesh selection (picking)
  42926. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42927. */
  42928. selectionOctree: Octree<AbstractMesh>;
  42929. /**
  42930. * Creates or updates the octree used to boost selection (picking)
  42931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42932. * @param maxCapacity defines the maximum capacity per leaf
  42933. * @param maxDepth defines the maximum depth of the octree
  42934. * @returns an octree of AbstractMesh
  42935. */
  42936. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42937. }
  42938. interface AbstractMesh {
  42939. /**
  42940. * @hidden
  42941. * Backing Field
  42942. */
  42943. _submeshesOctree: Octree<SubMesh>;
  42944. /**
  42945. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42946. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42947. * @param maxCapacity defines the maximum size of each block (64 by default)
  42948. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42949. * @returns the new octree
  42950. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42952. */
  42953. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42954. }
  42955. /**
  42956. * Defines the octree scene component responsible to manage any octrees
  42957. * in a given scene.
  42958. */
  42959. export class OctreeSceneComponent {
  42960. /**
  42961. * The component name help to identify the component in the list of scene components.
  42962. */
  42963. readonly name: string;
  42964. /**
  42965. * The scene the component belongs to.
  42966. */
  42967. scene: Scene;
  42968. /**
  42969. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42970. */
  42971. readonly checksIsEnabled: boolean;
  42972. /**
  42973. * Creates a new instance of the component for the given scene
  42974. * @param scene Defines the scene to register the component in
  42975. */
  42976. constructor(scene: Scene);
  42977. /**
  42978. * Registers the component in a given scene
  42979. */
  42980. register(): void;
  42981. /**
  42982. * Return the list of active meshes
  42983. * @returns the list of active meshes
  42984. */
  42985. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42986. /**
  42987. * Return the list of active sub meshes
  42988. * @param mesh The mesh to get the candidates sub meshes from
  42989. * @returns the list of active sub meshes
  42990. */
  42991. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42992. private _tempRay;
  42993. /**
  42994. * Return the list of sub meshes intersecting with a given local ray
  42995. * @param mesh defines the mesh to find the submesh for
  42996. * @param localRay defines the ray in local space
  42997. * @returns the list of intersecting sub meshes
  42998. */
  42999. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43000. /**
  43001. * Return the list of sub meshes colliding with a collider
  43002. * @param mesh defines the mesh to find the submesh for
  43003. * @param collider defines the collider to evaluate the collision against
  43004. * @returns the list of colliding sub meshes
  43005. */
  43006. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43007. /**
  43008. * Rebuilds the elements related to this component in case of
  43009. * context lost for instance.
  43010. */
  43011. rebuild(): void;
  43012. /**
  43013. * Disposes the component and the associated ressources.
  43014. */
  43015. dispose(): void;
  43016. }
  43017. }
  43018. declare module BABYLON {
  43019. /**
  43020. * Renders a layer on top of an existing scene
  43021. */
  43022. export class UtilityLayerRenderer implements IDisposable {
  43023. /** the original scene that will be rendered on top of */
  43024. originalScene: Scene;
  43025. private _pointerCaptures;
  43026. private _lastPointerEvents;
  43027. private static _DefaultUtilityLayer;
  43028. private static _DefaultKeepDepthUtilityLayer;
  43029. private _sharedGizmoLight;
  43030. private _renderCamera;
  43031. /**
  43032. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43033. * @returns the camera that is used when rendering the utility layer
  43034. */
  43035. getRenderCamera(): Nullable<Camera>;
  43036. /**
  43037. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43038. * @param cam the camera that should be used when rendering the utility layer
  43039. */
  43040. setRenderCamera(cam: Nullable<Camera>): void;
  43041. /**
  43042. * @hidden
  43043. * Light which used by gizmos to get light shading
  43044. */
  43045. _getSharedGizmoLight(): HemisphericLight;
  43046. /**
  43047. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43048. */
  43049. pickUtilitySceneFirst: boolean;
  43050. /**
  43051. * 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)
  43052. */
  43053. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43054. /**
  43055. * 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)
  43056. */
  43057. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43058. /**
  43059. * The scene that is rendered on top of the original scene
  43060. */
  43061. utilityLayerScene: Scene;
  43062. /**
  43063. * If the utility layer should automatically be rendered on top of existing scene
  43064. */
  43065. shouldRender: boolean;
  43066. /**
  43067. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43068. */
  43069. onlyCheckPointerDownEvents: boolean;
  43070. /**
  43071. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43072. */
  43073. processAllEvents: boolean;
  43074. /**
  43075. * Observable raised when the pointer move from the utility layer scene to the main scene
  43076. */
  43077. onPointerOutObservable: Observable<number>;
  43078. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43079. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43080. private _afterRenderObserver;
  43081. private _sceneDisposeObserver;
  43082. private _originalPointerObserver;
  43083. /**
  43084. * Instantiates a UtilityLayerRenderer
  43085. * @param originalScene the original scene that will be rendered on top of
  43086. * @param handleEvents boolean indicating if the utility layer should handle events
  43087. */
  43088. constructor(
  43089. /** the original scene that will be rendered on top of */
  43090. originalScene: Scene, handleEvents?: boolean);
  43091. private _notifyObservers;
  43092. /**
  43093. * Renders the utility layers scene on top of the original scene
  43094. */
  43095. render(): void;
  43096. /**
  43097. * Disposes of the renderer
  43098. */
  43099. dispose(): void;
  43100. private _updateCamera;
  43101. }
  43102. }
  43103. declare module BABYLON {
  43104. /**
  43105. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43106. */
  43107. export class Gizmo implements IDisposable {
  43108. /** The utility layer the gizmo will be added to */
  43109. gizmoLayer: UtilityLayerRenderer;
  43110. /**
  43111. * The root mesh of the gizmo
  43112. */
  43113. _rootMesh: Mesh;
  43114. private _attachedMesh;
  43115. /**
  43116. * Ratio for the scale of the gizmo (Default: 1)
  43117. */
  43118. scaleRatio: number;
  43119. /**
  43120. * If a custom mesh has been set (Default: false)
  43121. */
  43122. protected _customMeshSet: boolean;
  43123. /**
  43124. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43125. * * When set, interactions will be enabled
  43126. */
  43127. attachedMesh: Nullable<AbstractMesh>;
  43128. /**
  43129. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43130. * @param mesh The mesh to replace the default mesh of the gizmo
  43131. */
  43132. setCustomMesh(mesh: Mesh): void;
  43133. /**
  43134. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43135. */
  43136. updateGizmoRotationToMatchAttachedMesh: boolean;
  43137. /**
  43138. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43139. */
  43140. updateGizmoPositionToMatchAttachedMesh: boolean;
  43141. /**
  43142. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43143. */
  43144. updateScale: boolean;
  43145. protected _interactionsEnabled: boolean;
  43146. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43147. private _beforeRenderObserver;
  43148. private _tempVector;
  43149. /**
  43150. * Creates a gizmo
  43151. * @param gizmoLayer The utility layer the gizmo will be added to
  43152. */
  43153. constructor(
  43154. /** The utility layer the gizmo will be added to */
  43155. gizmoLayer?: UtilityLayerRenderer);
  43156. /**
  43157. * Updates the gizmo to match the attached mesh's position/rotation
  43158. */
  43159. protected _update(): void;
  43160. /**
  43161. * Disposes of the gizmo
  43162. */
  43163. dispose(): void;
  43164. }
  43165. }
  43166. declare module BABYLON {
  43167. /**
  43168. * Single plane drag gizmo
  43169. */
  43170. export class PlaneDragGizmo extends Gizmo {
  43171. /**
  43172. * Drag behavior responsible for the gizmos dragging interactions
  43173. */
  43174. dragBehavior: PointerDragBehavior;
  43175. private _pointerObserver;
  43176. /**
  43177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43178. */
  43179. snapDistance: number;
  43180. /**
  43181. * Event that fires each time the gizmo snaps to a new location.
  43182. * * snapDistance is the the change in distance
  43183. */
  43184. onSnapObservable: Observable<{
  43185. snapDistance: number;
  43186. }>;
  43187. private _plane;
  43188. private _coloredMaterial;
  43189. private _hoverMaterial;
  43190. private _isEnabled;
  43191. private _parent;
  43192. /** @hidden */
  43193. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43194. /** @hidden */
  43195. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43196. /**
  43197. * Creates a PlaneDragGizmo
  43198. * @param gizmoLayer The utility layer the gizmo will be added to
  43199. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43200. * @param color The color of the gizmo
  43201. */
  43202. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43203. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43204. /**
  43205. * If the gizmo is enabled
  43206. */
  43207. isEnabled: boolean;
  43208. /**
  43209. * Disposes of the gizmo
  43210. */
  43211. dispose(): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /**
  43216. * Gizmo that enables dragging a mesh along 3 axis
  43217. */
  43218. export class PositionGizmo extends Gizmo {
  43219. /**
  43220. * Internal gizmo used for interactions on the x axis
  43221. */
  43222. xGizmo: AxisDragGizmo;
  43223. /**
  43224. * Internal gizmo used for interactions on the y axis
  43225. */
  43226. yGizmo: AxisDragGizmo;
  43227. /**
  43228. * Internal gizmo used for interactions on the z axis
  43229. */
  43230. zGizmo: AxisDragGizmo;
  43231. /**
  43232. * Internal gizmo used for interactions on the yz plane
  43233. */
  43234. xPlaneGizmo: PlaneDragGizmo;
  43235. /**
  43236. * Internal gizmo used for interactions on the xz plane
  43237. */
  43238. yPlaneGizmo: PlaneDragGizmo;
  43239. /**
  43240. * Internal gizmo used for interactions on the xy plane
  43241. */
  43242. zPlaneGizmo: PlaneDragGizmo;
  43243. /**
  43244. * private variables
  43245. */
  43246. private _meshAttached;
  43247. private _updateGizmoRotationToMatchAttachedMesh;
  43248. private _snapDistance;
  43249. private _scaleRatio;
  43250. /** Fires an event when any of it's sub gizmos are dragged */
  43251. onDragStartObservable: Observable<unknown>;
  43252. /** Fires an event when any of it's sub gizmos are released from dragging */
  43253. onDragEndObservable: Observable<unknown>;
  43254. /**
  43255. * If set to true, planar drag is enabled
  43256. */
  43257. private _planarGizmoEnabled;
  43258. attachedMesh: Nullable<AbstractMesh>;
  43259. /**
  43260. * Creates a PositionGizmo
  43261. * @param gizmoLayer The utility layer the gizmo will be added to
  43262. */
  43263. constructor(gizmoLayer?: UtilityLayerRenderer);
  43264. /**
  43265. * If the planar drag gizmo is enabled
  43266. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43267. */
  43268. planarGizmoEnabled: boolean;
  43269. updateGizmoRotationToMatchAttachedMesh: boolean;
  43270. /**
  43271. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43272. */
  43273. snapDistance: number;
  43274. /**
  43275. * Ratio for the scale of the gizmo (Default: 1)
  43276. */
  43277. scaleRatio: number;
  43278. /**
  43279. * Disposes of the gizmo
  43280. */
  43281. dispose(): void;
  43282. /**
  43283. * CustomMeshes are not supported by this gizmo
  43284. * @param mesh The mesh to replace the default mesh of the gizmo
  43285. */
  43286. setCustomMesh(mesh: Mesh): void;
  43287. }
  43288. }
  43289. declare module BABYLON {
  43290. /**
  43291. * Single axis drag gizmo
  43292. */
  43293. export class AxisDragGizmo extends Gizmo {
  43294. /**
  43295. * Drag behavior responsible for the gizmos dragging interactions
  43296. */
  43297. dragBehavior: PointerDragBehavior;
  43298. private _pointerObserver;
  43299. /**
  43300. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43301. */
  43302. snapDistance: number;
  43303. /**
  43304. * Event that fires each time the gizmo snaps to a new location.
  43305. * * snapDistance is the the change in distance
  43306. */
  43307. onSnapObservable: Observable<{
  43308. snapDistance: number;
  43309. }>;
  43310. private _isEnabled;
  43311. private _parent;
  43312. private _arrow;
  43313. private _coloredMaterial;
  43314. private _hoverMaterial;
  43315. /** @hidden */
  43316. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43317. /** @hidden */
  43318. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43319. /**
  43320. * Creates an AxisDragGizmo
  43321. * @param gizmoLayer The utility layer the gizmo will be added to
  43322. * @param dragAxis The axis which the gizmo will be able to drag on
  43323. * @param color The color of the gizmo
  43324. */
  43325. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43326. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43327. /**
  43328. * If the gizmo is enabled
  43329. */
  43330. isEnabled: boolean;
  43331. /**
  43332. * Disposes of the gizmo
  43333. */
  43334. dispose(): void;
  43335. }
  43336. }
  43337. declare module BABYLON.Debug {
  43338. /**
  43339. * The Axes viewer will show 3 axes in a specific point in space
  43340. */
  43341. export class AxesViewer {
  43342. private _xAxis;
  43343. private _yAxis;
  43344. private _zAxis;
  43345. private _scaleLinesFactor;
  43346. private _instanced;
  43347. /**
  43348. * Gets the hosting scene
  43349. */
  43350. scene: Scene;
  43351. /**
  43352. * Gets or sets a number used to scale line length
  43353. */
  43354. scaleLines: number;
  43355. /** Gets the node hierarchy used to render x-axis */
  43356. readonly xAxis: TransformNode;
  43357. /** Gets the node hierarchy used to render y-axis */
  43358. readonly yAxis: TransformNode;
  43359. /** Gets the node hierarchy used to render z-axis */
  43360. readonly zAxis: TransformNode;
  43361. /**
  43362. * Creates a new AxesViewer
  43363. * @param scene defines the hosting scene
  43364. * @param scaleLines defines a number used to scale line length (1 by default)
  43365. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43366. * @param xAxis defines the node hierarchy used to render the x-axis
  43367. * @param yAxis defines the node hierarchy used to render the y-axis
  43368. * @param zAxis defines the node hierarchy used to render the z-axis
  43369. */
  43370. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43371. /**
  43372. * Force the viewer to update
  43373. * @param position defines the position of the viewer
  43374. * @param xaxis defines the x axis of the viewer
  43375. * @param yaxis defines the y axis of the viewer
  43376. * @param zaxis defines the z axis of the viewer
  43377. */
  43378. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43379. /**
  43380. * Creates an instance of this axes viewer.
  43381. * @returns a new axes viewer with instanced meshes
  43382. */
  43383. createInstance(): AxesViewer;
  43384. /** Releases resources */
  43385. dispose(): void;
  43386. private static _SetRenderingGroupId;
  43387. }
  43388. }
  43389. declare module BABYLON.Debug {
  43390. /**
  43391. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43392. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43393. */
  43394. export class BoneAxesViewer extends AxesViewer {
  43395. /**
  43396. * Gets or sets the target mesh where to display the axes viewer
  43397. */
  43398. mesh: Nullable<Mesh>;
  43399. /**
  43400. * Gets or sets the target bone where to display the axes viewer
  43401. */
  43402. bone: Nullable<Bone>;
  43403. /** Gets current position */
  43404. pos: Vector3;
  43405. /** Gets direction of X axis */
  43406. xaxis: Vector3;
  43407. /** Gets direction of Y axis */
  43408. yaxis: Vector3;
  43409. /** Gets direction of Z axis */
  43410. zaxis: Vector3;
  43411. /**
  43412. * Creates a new BoneAxesViewer
  43413. * @param scene defines the hosting scene
  43414. * @param bone defines the target bone
  43415. * @param mesh defines the target mesh
  43416. * @param scaleLines defines a scaling factor for line length (1 by default)
  43417. */
  43418. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43419. /**
  43420. * Force the viewer to update
  43421. */
  43422. update(): void;
  43423. /** Releases resources */
  43424. dispose(): void;
  43425. }
  43426. }
  43427. declare module BABYLON {
  43428. /**
  43429. * Interface used to define scene explorer extensibility option
  43430. */
  43431. export interface IExplorerExtensibilityOption {
  43432. /**
  43433. * Define the option label
  43434. */
  43435. label: string;
  43436. /**
  43437. * Defines the action to execute on click
  43438. */
  43439. action: (entity: any) => void;
  43440. }
  43441. /**
  43442. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43443. */
  43444. export interface IExplorerExtensibilityGroup {
  43445. /**
  43446. * Defines a predicate to test if a given type mut be extended
  43447. */
  43448. predicate: (entity: any) => boolean;
  43449. /**
  43450. * Gets the list of options added to a type
  43451. */
  43452. entries: IExplorerExtensibilityOption[];
  43453. }
  43454. /**
  43455. * Interface used to define the options to use to create the Inspector
  43456. */
  43457. export interface IInspectorOptions {
  43458. /**
  43459. * Display in overlay mode (default: false)
  43460. */
  43461. overlay?: boolean;
  43462. /**
  43463. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43464. */
  43465. globalRoot?: HTMLElement;
  43466. /**
  43467. * Display the Scene explorer
  43468. */
  43469. showExplorer?: boolean;
  43470. /**
  43471. * Display the property inspector
  43472. */
  43473. showInspector?: boolean;
  43474. /**
  43475. * Display in embed mode (both panes on the right)
  43476. */
  43477. embedMode?: boolean;
  43478. /**
  43479. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43480. */
  43481. handleResize?: boolean;
  43482. /**
  43483. * Allow the panes to popup (default: true)
  43484. */
  43485. enablePopup?: boolean;
  43486. /**
  43487. * Allow the panes to be closed by users (default: true)
  43488. */
  43489. enableClose?: boolean;
  43490. /**
  43491. * Optional list of extensibility entries
  43492. */
  43493. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43494. /**
  43495. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43496. */
  43497. inspectorURL?: string;
  43498. }
  43499. interface Scene {
  43500. /**
  43501. * @hidden
  43502. * Backing field
  43503. */
  43504. _debugLayer: DebugLayer;
  43505. /**
  43506. * Gets the debug layer (aka Inspector) associated with the scene
  43507. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43508. */
  43509. debugLayer: DebugLayer;
  43510. }
  43511. /**
  43512. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43513. * what is happening in your scene
  43514. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43515. */
  43516. export class DebugLayer {
  43517. /**
  43518. * Define the url to get the inspector script from.
  43519. * By default it uses the babylonjs CDN.
  43520. * @ignoreNaming
  43521. */
  43522. static InspectorURL: string;
  43523. private _scene;
  43524. private BJSINSPECTOR;
  43525. private _onPropertyChangedObservable?;
  43526. /**
  43527. * Observable triggered when a property is changed through the inspector.
  43528. */
  43529. readonly onPropertyChangedObservable: any;
  43530. /**
  43531. * Instantiates a new debug layer.
  43532. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43533. * what is happening in your scene
  43534. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43535. * @param scene Defines the scene to inspect
  43536. */
  43537. constructor(scene: Scene);
  43538. /** Creates the inspector window. */
  43539. private _createInspector;
  43540. /**
  43541. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43542. * @param entity defines the entity to select
  43543. * @param lineContainerTitle defines the specific block to highlight
  43544. */
  43545. select(entity: any, lineContainerTitle?: string): void;
  43546. /** Get the inspector from bundle or global */
  43547. private _getGlobalInspector;
  43548. /**
  43549. * Get if the inspector is visible or not.
  43550. * @returns true if visible otherwise, false
  43551. */
  43552. isVisible(): boolean;
  43553. /**
  43554. * Hide the inspector and close its window.
  43555. */
  43556. hide(): void;
  43557. /**
  43558. * Launch the debugLayer.
  43559. * @param config Define the configuration of the inspector
  43560. * @return a promise fulfilled when the debug layer is visible
  43561. */
  43562. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43563. }
  43564. }
  43565. declare module BABYLON {
  43566. /**
  43567. * Class containing static functions to help procedurally build meshes
  43568. */
  43569. export class BoxBuilder {
  43570. /**
  43571. * Creates a box mesh
  43572. * * The parameter `size` sets the size (float) of each box side (default 1)
  43573. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43574. * * 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)
  43575. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43577. * * 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
  43578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43579. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43580. * @param name defines the name of the mesh
  43581. * @param options defines the options used to create the mesh
  43582. * @param scene defines the hosting scene
  43583. * @returns the box mesh
  43584. */
  43585. static CreateBox(name: string, options: {
  43586. size?: number;
  43587. width?: number;
  43588. height?: number;
  43589. depth?: number;
  43590. faceUV?: Vector4[];
  43591. faceColors?: Color4[];
  43592. sideOrientation?: number;
  43593. frontUVs?: Vector4;
  43594. backUVs?: Vector4;
  43595. wrap?: boolean;
  43596. topBaseAt?: number;
  43597. bottomBaseAt?: number;
  43598. updatable?: boolean;
  43599. }, scene?: Nullable<Scene>): Mesh;
  43600. }
  43601. }
  43602. declare module BABYLON {
  43603. /**
  43604. * Class containing static functions to help procedurally build meshes
  43605. */
  43606. export class SphereBuilder {
  43607. /**
  43608. * Creates a sphere mesh
  43609. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43610. * * 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`)
  43611. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43612. * * 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
  43613. * * 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)
  43614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43615. * * 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
  43616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43617. * @param name defines the name of the mesh
  43618. * @param options defines the options used to create the mesh
  43619. * @param scene defines the hosting scene
  43620. * @returns the sphere mesh
  43621. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43622. */
  43623. static CreateSphere(name: string, options: {
  43624. segments?: number;
  43625. diameter?: number;
  43626. diameterX?: number;
  43627. diameterY?: number;
  43628. diameterZ?: number;
  43629. arc?: number;
  43630. slice?: number;
  43631. sideOrientation?: number;
  43632. frontUVs?: Vector4;
  43633. backUVs?: Vector4;
  43634. updatable?: boolean;
  43635. }, scene?: Nullable<Scene>): Mesh;
  43636. }
  43637. }
  43638. declare module BABYLON.Debug {
  43639. /**
  43640. * Used to show the physics impostor around the specific mesh
  43641. */
  43642. export class PhysicsViewer {
  43643. /** @hidden */
  43644. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43645. /** @hidden */
  43646. protected _meshes: Array<Nullable<AbstractMesh>>;
  43647. /** @hidden */
  43648. protected _scene: Nullable<Scene>;
  43649. /** @hidden */
  43650. protected _numMeshes: number;
  43651. /** @hidden */
  43652. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43653. private _renderFunction;
  43654. private _utilityLayer;
  43655. private _debugBoxMesh;
  43656. private _debugSphereMesh;
  43657. private _debugCylinderMesh;
  43658. private _debugMaterial;
  43659. private _debugMeshMeshes;
  43660. /**
  43661. * Creates a new PhysicsViewer
  43662. * @param scene defines the hosting scene
  43663. */
  43664. constructor(scene: Scene);
  43665. /** @hidden */
  43666. protected _updateDebugMeshes(): void;
  43667. /**
  43668. * Renders a specified physic impostor
  43669. * @param impostor defines the impostor to render
  43670. * @param targetMesh defines the mesh represented by the impostor
  43671. * @returns the new debug mesh used to render the impostor
  43672. */
  43673. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43674. /**
  43675. * Hides a specified physic impostor
  43676. * @param impostor defines the impostor to hide
  43677. */
  43678. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43679. private _getDebugMaterial;
  43680. private _getDebugBoxMesh;
  43681. private _getDebugSphereMesh;
  43682. private _getDebugCylinderMesh;
  43683. private _getDebugMeshMesh;
  43684. private _getDebugMesh;
  43685. /** Releases all resources */
  43686. dispose(): void;
  43687. }
  43688. }
  43689. declare module BABYLON {
  43690. /**
  43691. * Class containing static functions to help procedurally build meshes
  43692. */
  43693. export class LinesBuilder {
  43694. /**
  43695. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43696. * * 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
  43697. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43698. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43699. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43700. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43701. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43702. * * 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
  43703. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43706. * @param name defines the name of the new line system
  43707. * @param options defines the options used to create the line system
  43708. * @param scene defines the hosting scene
  43709. * @returns a new line system mesh
  43710. */
  43711. static CreateLineSystem(name: string, options: {
  43712. lines: Vector3[][];
  43713. updatable?: boolean;
  43714. instance?: Nullable<LinesMesh>;
  43715. colors?: Nullable<Color4[][]>;
  43716. useVertexAlpha?: boolean;
  43717. }, scene: Nullable<Scene>): LinesMesh;
  43718. /**
  43719. * Creates a line mesh
  43720. * 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
  43721. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43722. * * The parameter `points` is an array successive Vector3
  43723. * * 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
  43724. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43725. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43726. * * When updating an instance, remember that only point positions can change, not the number of points
  43727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43729. * @param name defines the name of the new line system
  43730. * @param options defines the options used to create the line system
  43731. * @param scene defines the hosting scene
  43732. * @returns a new line mesh
  43733. */
  43734. static CreateLines(name: string, options: {
  43735. points: Vector3[];
  43736. updatable?: boolean;
  43737. instance?: Nullable<LinesMesh>;
  43738. colors?: Color4[];
  43739. useVertexAlpha?: boolean;
  43740. }, scene?: Nullable<Scene>): LinesMesh;
  43741. /**
  43742. * Creates a dashed line mesh
  43743. * * 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
  43744. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43745. * * The parameter `points` is an array successive Vector3
  43746. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43747. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43748. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43749. * * 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
  43750. * * When updating an instance, remember that only point positions can change, not the number of points
  43751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43752. * @param name defines the name of the mesh
  43753. * @param options defines the options used to create the mesh
  43754. * @param scene defines the hosting scene
  43755. * @returns the dashed line mesh
  43756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43757. */
  43758. static CreateDashedLines(name: string, options: {
  43759. points: Vector3[];
  43760. dashSize?: number;
  43761. gapSize?: number;
  43762. dashNb?: number;
  43763. updatable?: boolean;
  43764. instance?: LinesMesh;
  43765. }, scene?: Nullable<Scene>): LinesMesh;
  43766. }
  43767. }
  43768. declare module BABYLON {
  43769. /**
  43770. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43771. * in order to better appreciate the issue one might have.
  43772. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43773. */
  43774. export class RayHelper {
  43775. /**
  43776. * Defines the ray we are currently tryin to visualize.
  43777. */
  43778. ray: Nullable<Ray>;
  43779. private _renderPoints;
  43780. private _renderLine;
  43781. private _renderFunction;
  43782. private _scene;
  43783. private _updateToMeshFunction;
  43784. private _attachedToMesh;
  43785. private _meshSpaceDirection;
  43786. private _meshSpaceOrigin;
  43787. /**
  43788. * Helper function to create a colored helper in a scene in one line.
  43789. * @param ray Defines the ray we are currently tryin to visualize
  43790. * @param scene Defines the scene the ray is used in
  43791. * @param color Defines the color we want to see the ray in
  43792. * @returns The newly created ray helper.
  43793. */
  43794. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43795. /**
  43796. * Instantiate a new ray helper.
  43797. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43798. * in order to better appreciate the issue one might have.
  43799. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43800. * @param ray Defines the ray we are currently tryin to visualize
  43801. */
  43802. constructor(ray: Ray);
  43803. /**
  43804. * Shows the ray we are willing to debug.
  43805. * @param scene Defines the scene the ray needs to be rendered in
  43806. * @param color Defines the color the ray needs to be rendered in
  43807. */
  43808. show(scene: Scene, color?: Color3): void;
  43809. /**
  43810. * Hides the ray we are debugging.
  43811. */
  43812. hide(): void;
  43813. private _render;
  43814. /**
  43815. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43816. * @param mesh Defines the mesh we want the helper attached to
  43817. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43818. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43819. * @param length Defines the length of the ray
  43820. */
  43821. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43822. /**
  43823. * Detach the ray helper from the mesh it has previously been attached to.
  43824. */
  43825. detachFromMesh(): void;
  43826. private _updateToMesh;
  43827. /**
  43828. * Dispose the helper and release its associated resources.
  43829. */
  43830. dispose(): void;
  43831. }
  43832. }
  43833. declare module BABYLON.Debug {
  43834. /**
  43835. * Class used to render a debug view of a given skeleton
  43836. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43837. */
  43838. export class SkeletonViewer {
  43839. /** defines the skeleton to render */
  43840. skeleton: Skeleton;
  43841. /** defines the mesh attached to the skeleton */
  43842. mesh: AbstractMesh;
  43843. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43844. autoUpdateBonesMatrices: boolean;
  43845. /** defines the rendering group id to use with the viewer */
  43846. renderingGroupId: number;
  43847. /** Gets or sets the color used to render the skeleton */
  43848. color: Color3;
  43849. private _scene;
  43850. private _debugLines;
  43851. private _debugMesh;
  43852. private _isEnabled;
  43853. private _renderFunction;
  43854. private _utilityLayer;
  43855. /**
  43856. * Returns the mesh used to render the bones
  43857. */
  43858. readonly debugMesh: Nullable<LinesMesh>;
  43859. /**
  43860. * Creates a new SkeletonViewer
  43861. * @param skeleton defines the skeleton to render
  43862. * @param mesh defines the mesh attached to the skeleton
  43863. * @param scene defines the hosting scene
  43864. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43865. * @param renderingGroupId defines the rendering group id to use with the viewer
  43866. */
  43867. constructor(
  43868. /** defines the skeleton to render */
  43869. skeleton: Skeleton,
  43870. /** defines the mesh attached to the skeleton */
  43871. mesh: AbstractMesh, scene: Scene,
  43872. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43873. autoUpdateBonesMatrices?: boolean,
  43874. /** defines the rendering group id to use with the viewer */
  43875. renderingGroupId?: number);
  43876. /** Gets or sets a boolean indicating if the viewer is enabled */
  43877. isEnabled: boolean;
  43878. private _getBonePosition;
  43879. private _getLinesForBonesWithLength;
  43880. private _getLinesForBonesNoLength;
  43881. /** Update the viewer to sync with current skeleton state */
  43882. update(): void;
  43883. /** Release associated resources */
  43884. dispose(): void;
  43885. }
  43886. }
  43887. declare module BABYLON {
  43888. /**
  43889. * Options to create the null engine
  43890. */
  43891. export class NullEngineOptions {
  43892. /**
  43893. * Render width (Default: 512)
  43894. */
  43895. renderWidth: number;
  43896. /**
  43897. * Render height (Default: 256)
  43898. */
  43899. renderHeight: number;
  43900. /**
  43901. * Texture size (Default: 512)
  43902. */
  43903. textureSize: number;
  43904. /**
  43905. * If delta time between frames should be constant
  43906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43907. */
  43908. deterministicLockstep: boolean;
  43909. /**
  43910. * Maximum about of steps between frames (Default: 4)
  43911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43912. */
  43913. lockstepMaxSteps: number;
  43914. }
  43915. /**
  43916. * The null engine class provides support for headless version of babylon.js.
  43917. * This can be used in server side scenario or for testing purposes
  43918. */
  43919. export class NullEngine extends Engine {
  43920. private _options;
  43921. /**
  43922. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43924. * @returns true if engine is in deterministic lock step mode
  43925. */
  43926. isDeterministicLockStep(): boolean;
  43927. /**
  43928. * Gets the max steps when engine is running in deterministic lock step
  43929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43930. * @returns the max steps
  43931. */
  43932. getLockstepMaxSteps(): number;
  43933. /**
  43934. * Gets the current hardware scaling level.
  43935. * By default the hardware scaling level is computed from the window device ratio.
  43936. * 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.
  43937. * @returns a number indicating the current hardware scaling level
  43938. */
  43939. getHardwareScalingLevel(): number;
  43940. constructor(options?: NullEngineOptions);
  43941. /**
  43942. * Creates a vertex buffer
  43943. * @param vertices the data for the vertex buffer
  43944. * @returns the new WebGL static buffer
  43945. */
  43946. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43947. /**
  43948. * Creates a new index buffer
  43949. * @param indices defines the content of the index buffer
  43950. * @param updatable defines if the index buffer must be updatable
  43951. * @returns a new webGL buffer
  43952. */
  43953. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43954. /**
  43955. * Clear the current render buffer or the current render target (if any is set up)
  43956. * @param color defines the color to use
  43957. * @param backBuffer defines if the back buffer must be cleared
  43958. * @param depth defines if the depth buffer must be cleared
  43959. * @param stencil defines if the stencil buffer must be cleared
  43960. */
  43961. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43962. /**
  43963. * Gets the current render width
  43964. * @param useScreen defines if screen size must be used (or the current render target if any)
  43965. * @returns a number defining the current render width
  43966. */
  43967. getRenderWidth(useScreen?: boolean): number;
  43968. /**
  43969. * Gets the current render height
  43970. * @param useScreen defines if screen size must be used (or the current render target if any)
  43971. * @returns a number defining the current render height
  43972. */
  43973. getRenderHeight(useScreen?: boolean): number;
  43974. /**
  43975. * Set the WebGL's viewport
  43976. * @param viewport defines the viewport element to be used
  43977. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43978. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43979. */
  43980. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43981. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43982. /**
  43983. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43984. * @param pipelineContext defines the pipeline context to use
  43985. * @param uniformsNames defines the list of uniform names
  43986. * @returns an array of webGL uniform locations
  43987. */
  43988. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43989. /**
  43990. * Gets the lsit of active attributes for a given webGL program
  43991. * @param pipelineContext defines the pipeline context to use
  43992. * @param attributesNames defines the list of attribute names to get
  43993. * @returns an array of indices indicating the offset of each attribute
  43994. */
  43995. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43996. /**
  43997. * Binds an effect to the webGL context
  43998. * @param effect defines the effect to bind
  43999. */
  44000. bindSamplers(effect: Effect): void;
  44001. /**
  44002. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44003. * @param effect defines the effect to activate
  44004. */
  44005. enableEffect(effect: Effect): void;
  44006. /**
  44007. * Set various states to the webGL context
  44008. * @param culling defines backface culling state
  44009. * @param zOffset defines the value to apply to zOffset (0 by default)
  44010. * @param force defines if states must be applied even if cache is up to date
  44011. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44012. */
  44013. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44014. /**
  44015. * Set the value of an uniform to an array of int32
  44016. * @param uniform defines the webGL uniform location where to store the value
  44017. * @param array defines the array of int32 to store
  44018. */
  44019. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44020. /**
  44021. * Set the value of an uniform to an array of int32 (stored as vec2)
  44022. * @param uniform defines the webGL uniform location where to store the value
  44023. * @param array defines the array of int32 to store
  44024. */
  44025. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44026. /**
  44027. * Set the value of an uniform to an array of int32 (stored as vec3)
  44028. * @param uniform defines the webGL uniform location where to store the value
  44029. * @param array defines the array of int32 to store
  44030. */
  44031. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44032. /**
  44033. * Set the value of an uniform to an array of int32 (stored as vec4)
  44034. * @param uniform defines the webGL uniform location where to store the value
  44035. * @param array defines the array of int32 to store
  44036. */
  44037. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44038. /**
  44039. * Set the value of an uniform to an array of float32
  44040. * @param uniform defines the webGL uniform location where to store the value
  44041. * @param array defines the array of float32 to store
  44042. */
  44043. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44044. /**
  44045. * Set the value of an uniform to an array of float32 (stored as vec2)
  44046. * @param uniform defines the webGL uniform location where to store the value
  44047. * @param array defines the array of float32 to store
  44048. */
  44049. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44050. /**
  44051. * Set the value of an uniform to an array of float32 (stored as vec3)
  44052. * @param uniform defines the webGL uniform location where to store the value
  44053. * @param array defines the array of float32 to store
  44054. */
  44055. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44056. /**
  44057. * Set the value of an uniform to an array of float32 (stored as vec4)
  44058. * @param uniform defines the webGL uniform location where to store the value
  44059. * @param array defines the array of float32 to store
  44060. */
  44061. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44062. /**
  44063. * Set the value of an uniform to an array of number
  44064. * @param uniform defines the webGL uniform location where to store the value
  44065. * @param array defines the array of number to store
  44066. */
  44067. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44068. /**
  44069. * Set the value of an uniform to an array of number (stored as vec2)
  44070. * @param uniform defines the webGL uniform location where to store the value
  44071. * @param array defines the array of number to store
  44072. */
  44073. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44074. /**
  44075. * Set the value of an uniform to an array of number (stored as vec3)
  44076. * @param uniform defines the webGL uniform location where to store the value
  44077. * @param array defines the array of number to store
  44078. */
  44079. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44080. /**
  44081. * Set the value of an uniform to an array of number (stored as vec4)
  44082. * @param uniform defines the webGL uniform location where to store the value
  44083. * @param array defines the array of number to store
  44084. */
  44085. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44086. /**
  44087. * Set the value of an uniform to an array of float32 (stored as matrices)
  44088. * @param uniform defines the webGL uniform location where to store the value
  44089. * @param matrices defines the array of float32 to store
  44090. */
  44091. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44092. /**
  44093. * Set the value of an uniform to a matrix (3x3)
  44094. * @param uniform defines the webGL uniform location where to store the value
  44095. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44096. */
  44097. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44098. /**
  44099. * Set the value of an uniform to a matrix (2x2)
  44100. * @param uniform defines the webGL uniform location where to store the value
  44101. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44102. */
  44103. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44104. /**
  44105. * Set the value of an uniform to a number (float)
  44106. * @param uniform defines the webGL uniform location where to store the value
  44107. * @param value defines the float number to store
  44108. */
  44109. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44110. /**
  44111. * Set the value of an uniform to a vec2
  44112. * @param uniform defines the webGL uniform location where to store the value
  44113. * @param x defines the 1st component of the value
  44114. * @param y defines the 2nd component of the value
  44115. */
  44116. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44117. /**
  44118. * Set the value of an uniform to a vec3
  44119. * @param uniform defines the webGL uniform location where to store the value
  44120. * @param x defines the 1st component of the value
  44121. * @param y defines the 2nd component of the value
  44122. * @param z defines the 3rd component of the value
  44123. */
  44124. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44125. /**
  44126. * Set the value of an uniform to a boolean
  44127. * @param uniform defines the webGL uniform location where to store the value
  44128. * @param bool defines the boolean to store
  44129. */
  44130. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44131. /**
  44132. * Set the value of an uniform to a vec4
  44133. * @param uniform defines the webGL uniform location where to store the value
  44134. * @param x defines the 1st component of the value
  44135. * @param y defines the 2nd component of the value
  44136. * @param z defines the 3rd component of the value
  44137. * @param w defines the 4th component of the value
  44138. */
  44139. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44140. /**
  44141. * Sets the current alpha mode
  44142. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44143. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44144. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44145. */
  44146. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44147. /**
  44148. * Bind webGl buffers directly to the webGL context
  44149. * @param vertexBuffers defines the vertex buffer to bind
  44150. * @param indexBuffer defines the index buffer to bind
  44151. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44152. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44153. * @param effect defines the effect associated with the vertex buffer
  44154. */
  44155. bindBuffers(vertexBuffers: {
  44156. [key: string]: VertexBuffer;
  44157. }, indexBuffer: DataBuffer, effect: Effect): void;
  44158. /**
  44159. * Force the entire cache to be cleared
  44160. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44161. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44162. */
  44163. wipeCaches(bruteForce?: boolean): void;
  44164. /**
  44165. * Send a draw order
  44166. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44167. * @param indexStart defines the starting index
  44168. * @param indexCount defines the number of index to draw
  44169. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44170. */
  44171. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44172. /**
  44173. * Draw a list of indexed primitives
  44174. * @param fillMode defines the primitive to use
  44175. * @param indexStart defines the starting index
  44176. * @param indexCount defines the number of index to draw
  44177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44178. */
  44179. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44180. /**
  44181. * Draw a list of unindexed primitives
  44182. * @param fillMode defines the primitive to use
  44183. * @param verticesStart defines the index of first vertex to draw
  44184. * @param verticesCount defines the count of vertices to draw
  44185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44186. */
  44187. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44188. /** @hidden */
  44189. _createTexture(): WebGLTexture;
  44190. /** @hidden */
  44191. _releaseTexture(texture: InternalTexture): void;
  44192. /**
  44193. * Usually called from Texture.ts.
  44194. * Passed information to create a WebGLTexture
  44195. * @param urlArg defines a value which contains one of the following:
  44196. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44197. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44198. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44199. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44200. * @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)
  44201. * @param scene needed for loading to the correct scene
  44202. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44203. * @param onLoad optional callback to be called upon successful completion
  44204. * @param onError optional callback to be called upon failure
  44205. * @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
  44206. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44207. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44208. * @param forcedExtension defines the extension to use to pick the right loader
  44209. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44210. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44211. */
  44212. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  44213. /**
  44214. * Creates a new render target texture
  44215. * @param size defines the size of the texture
  44216. * @param options defines the options used to create the texture
  44217. * @returns a new render target texture stored in an InternalTexture
  44218. */
  44219. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44220. /**
  44221. * Update the sampling mode of a given texture
  44222. * @param samplingMode defines the required sampling mode
  44223. * @param texture defines the texture to update
  44224. */
  44225. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44226. /**
  44227. * Binds the frame buffer to the specified texture.
  44228. * @param texture The texture to render to or null for the default canvas
  44229. * @param faceIndex The face of the texture to render to in case of cube texture
  44230. * @param requiredWidth The width of the target to render to
  44231. * @param requiredHeight The height of the target to render to
  44232. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44233. * @param depthStencilTexture The depth stencil texture to use to render
  44234. * @param lodLevel defines le lod level to bind to the frame buffer
  44235. */
  44236. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44237. /**
  44238. * Unbind the current render target texture from the webGL context
  44239. * @param texture defines the render target texture to unbind
  44240. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44241. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44242. */
  44243. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44244. /**
  44245. * Creates a dynamic vertex buffer
  44246. * @param vertices the data for the dynamic vertex buffer
  44247. * @returns the new WebGL dynamic buffer
  44248. */
  44249. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44250. /**
  44251. * Update the content of a dynamic texture
  44252. * @param texture defines the texture to update
  44253. * @param canvas defines the canvas containing the source
  44254. * @param invertY defines if data must be stored with Y axis inverted
  44255. * @param premulAlpha defines if alpha is stored as premultiplied
  44256. * @param format defines the format of the data
  44257. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44258. */
  44259. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44260. /**
  44261. * Gets a boolean indicating if all created effects are ready
  44262. * @returns true if all effects are ready
  44263. */
  44264. areAllEffectsReady(): boolean;
  44265. /**
  44266. * @hidden
  44267. * Get the current error code of the webGL context
  44268. * @returns the error code
  44269. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44270. */
  44271. getError(): number;
  44272. /** @hidden */
  44273. _getUnpackAlignement(): number;
  44274. /** @hidden */
  44275. _unpackFlipY(value: boolean): void;
  44276. /**
  44277. * Update a dynamic index buffer
  44278. * @param indexBuffer defines the target index buffer
  44279. * @param indices defines the data to update
  44280. * @param offset defines the offset in the target index buffer where update should start
  44281. */
  44282. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44283. /**
  44284. * Updates a dynamic vertex buffer.
  44285. * @param vertexBuffer the vertex buffer to update
  44286. * @param vertices the data used to update the vertex buffer
  44287. * @param byteOffset the byte offset of the data (optional)
  44288. * @param byteLength the byte length of the data (optional)
  44289. */
  44290. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44291. /** @hidden */
  44292. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44293. /** @hidden */
  44294. _bindTexture(channel: number, texture: InternalTexture): void;
  44295. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44296. /**
  44297. * 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
  44298. */
  44299. releaseEffects(): void;
  44300. displayLoadingUI(): void;
  44301. hideLoadingUI(): void;
  44302. /** @hidden */
  44303. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44304. /** @hidden */
  44305. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44306. /** @hidden */
  44307. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44308. /** @hidden */
  44309. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /** @hidden */
  44314. export class _OcclusionDataStorage {
  44315. /** @hidden */
  44316. occlusionInternalRetryCounter: number;
  44317. /** @hidden */
  44318. isOcclusionQueryInProgress: boolean;
  44319. /** @hidden */
  44320. isOccluded: boolean;
  44321. /** @hidden */
  44322. occlusionRetryCount: number;
  44323. /** @hidden */
  44324. occlusionType: number;
  44325. /** @hidden */
  44326. occlusionQueryAlgorithmType: number;
  44327. }
  44328. interface Engine {
  44329. /**
  44330. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44331. * @return the new query
  44332. */
  44333. createQuery(): WebGLQuery;
  44334. /**
  44335. * Delete and release a webGL query
  44336. * @param query defines the query to delete
  44337. * @return the current engine
  44338. */
  44339. deleteQuery(query: WebGLQuery): Engine;
  44340. /**
  44341. * Check if a given query has resolved and got its value
  44342. * @param query defines the query to check
  44343. * @returns true if the query got its value
  44344. */
  44345. isQueryResultAvailable(query: WebGLQuery): boolean;
  44346. /**
  44347. * Gets the value of a given query
  44348. * @param query defines the query to check
  44349. * @returns the value of the query
  44350. */
  44351. getQueryResult(query: WebGLQuery): number;
  44352. /**
  44353. * Initiates an occlusion query
  44354. * @param algorithmType defines the algorithm to use
  44355. * @param query defines the query to use
  44356. * @returns the current engine
  44357. * @see http://doc.babylonjs.com/features/occlusionquery
  44358. */
  44359. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44360. /**
  44361. * Ends an occlusion query
  44362. * @see http://doc.babylonjs.com/features/occlusionquery
  44363. * @param algorithmType defines the algorithm to use
  44364. * @returns the current engine
  44365. */
  44366. endOcclusionQuery(algorithmType: number): Engine;
  44367. /**
  44368. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44369. * Please note that only one query can be issued at a time
  44370. * @returns a time token used to track the time span
  44371. */
  44372. startTimeQuery(): Nullable<_TimeToken>;
  44373. /**
  44374. * Ends a time query
  44375. * @param token defines the token used to measure the time span
  44376. * @returns the time spent (in ns)
  44377. */
  44378. endTimeQuery(token: _TimeToken): int;
  44379. /** @hidden */
  44380. _currentNonTimestampToken: Nullable<_TimeToken>;
  44381. /** @hidden */
  44382. _createTimeQuery(): WebGLQuery;
  44383. /** @hidden */
  44384. _deleteTimeQuery(query: WebGLQuery): void;
  44385. /** @hidden */
  44386. _getGlAlgorithmType(algorithmType: number): number;
  44387. /** @hidden */
  44388. _getTimeQueryResult(query: WebGLQuery): any;
  44389. /** @hidden */
  44390. _getTimeQueryAvailability(query: WebGLQuery): any;
  44391. }
  44392. interface AbstractMesh {
  44393. /**
  44394. * Backing filed
  44395. * @hidden
  44396. */
  44397. __occlusionDataStorage: _OcclusionDataStorage;
  44398. /**
  44399. * Access property
  44400. * @hidden
  44401. */
  44402. _occlusionDataStorage: _OcclusionDataStorage;
  44403. /**
  44404. * 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.
  44405. * The default value is -1 which means don't break the query and wait till the result
  44406. * @see http://doc.babylonjs.com/features/occlusionquery
  44407. */
  44408. occlusionRetryCount: number;
  44409. /**
  44410. * 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:
  44411. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44412. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44413. * * 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.
  44414. * @see http://doc.babylonjs.com/features/occlusionquery
  44415. */
  44416. occlusionType: number;
  44417. /**
  44418. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44419. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44420. * * 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.
  44421. * @see http://doc.babylonjs.com/features/occlusionquery
  44422. */
  44423. occlusionQueryAlgorithmType: number;
  44424. /**
  44425. * 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
  44426. * @see http://doc.babylonjs.com/features/occlusionquery
  44427. */
  44428. isOccluded: boolean;
  44429. /**
  44430. * Flag to check the progress status of the query
  44431. * @see http://doc.babylonjs.com/features/occlusionquery
  44432. */
  44433. isOcclusionQueryInProgress: boolean;
  44434. }
  44435. }
  44436. declare module BABYLON {
  44437. /** @hidden */
  44438. export var _forceTransformFeedbackToBundle: boolean;
  44439. interface Engine {
  44440. /**
  44441. * Creates a webGL transform feedback object
  44442. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44443. * @returns the webGL transform feedback object
  44444. */
  44445. createTransformFeedback(): WebGLTransformFeedback;
  44446. /**
  44447. * Delete a webGL transform feedback object
  44448. * @param value defines the webGL transform feedback object to delete
  44449. */
  44450. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44451. /**
  44452. * Bind a webGL transform feedback object to the webgl context
  44453. * @param value defines the webGL transform feedback object to bind
  44454. */
  44455. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44456. /**
  44457. * Begins a transform feedback operation
  44458. * @param usePoints defines if points or triangles must be used
  44459. */
  44460. beginTransformFeedback(usePoints: boolean): void;
  44461. /**
  44462. * Ends a transform feedback operation
  44463. */
  44464. endTransformFeedback(): void;
  44465. /**
  44466. * Specify the varyings to use with transform feedback
  44467. * @param program defines the associated webGL program
  44468. * @param value defines the list of strings representing the varying names
  44469. */
  44470. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44471. /**
  44472. * Bind a webGL buffer for a transform feedback operation
  44473. * @param value defines the webGL buffer to bind
  44474. */
  44475. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44476. }
  44477. }
  44478. declare module BABYLON {
  44479. /**
  44480. * Creation options of the multi render target texture.
  44481. */
  44482. export interface IMultiRenderTargetOptions {
  44483. /**
  44484. * Define if the texture needs to create mip maps after render.
  44485. */
  44486. generateMipMaps?: boolean;
  44487. /**
  44488. * Define the types of all the draw buffers we want to create
  44489. */
  44490. types?: number[];
  44491. /**
  44492. * Define the sampling modes of all the draw buffers we want to create
  44493. */
  44494. samplingModes?: number[];
  44495. /**
  44496. * Define if a depth buffer is required
  44497. */
  44498. generateDepthBuffer?: boolean;
  44499. /**
  44500. * Define if a stencil buffer is required
  44501. */
  44502. generateStencilBuffer?: boolean;
  44503. /**
  44504. * Define if a depth texture is required instead of a depth buffer
  44505. */
  44506. generateDepthTexture?: boolean;
  44507. /**
  44508. * Define the number of desired draw buffers
  44509. */
  44510. textureCount?: number;
  44511. /**
  44512. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44513. */
  44514. doNotChangeAspectRatio?: boolean;
  44515. /**
  44516. * Define the default type of the buffers we are creating
  44517. */
  44518. defaultType?: number;
  44519. }
  44520. /**
  44521. * A multi render target, like a render target provides the ability to render to a texture.
  44522. * Unlike the render target, it can render to several draw buffers in one draw.
  44523. * This is specially interesting in deferred rendering or for any effects requiring more than
  44524. * just one color from a single pass.
  44525. */
  44526. export class MultiRenderTarget extends RenderTargetTexture {
  44527. private _internalTextures;
  44528. private _textures;
  44529. private _multiRenderTargetOptions;
  44530. /**
  44531. * Get if draw buffers are currently supported by the used hardware and browser.
  44532. */
  44533. readonly isSupported: boolean;
  44534. /**
  44535. * Get the list of textures generated by the multi render target.
  44536. */
  44537. readonly textures: Texture[];
  44538. /**
  44539. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44540. */
  44541. readonly depthTexture: Texture;
  44542. /**
  44543. * Set the wrapping mode on U of all the textures we are rendering to.
  44544. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44545. */
  44546. wrapU: number;
  44547. /**
  44548. * Set the wrapping mode on V of all the textures we are rendering to.
  44549. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44550. */
  44551. wrapV: number;
  44552. /**
  44553. * Instantiate a new multi render target texture.
  44554. * A multi render target, like a render target provides the ability to render to a texture.
  44555. * Unlike the render target, it can render to several draw buffers in one draw.
  44556. * This is specially interesting in deferred rendering or for any effects requiring more than
  44557. * just one color from a single pass.
  44558. * @param name Define the name of the texture
  44559. * @param size Define the size of the buffers to render to
  44560. * @param count Define the number of target we are rendering into
  44561. * @param scene Define the scene the texture belongs to
  44562. * @param options Define the options used to create the multi render target
  44563. */
  44564. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44565. /** @hidden */
  44566. _rebuild(): void;
  44567. private _createInternalTextures;
  44568. private _createTextures;
  44569. /**
  44570. * Define the number of samples used if MSAA is enabled.
  44571. */
  44572. samples: number;
  44573. /**
  44574. * Resize all the textures in the multi render target.
  44575. * Be carrefull as it will recreate all the data in the new texture.
  44576. * @param size Define the new size
  44577. */
  44578. resize(size: any): void;
  44579. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44580. /**
  44581. * Dispose the render targets and their associated resources
  44582. */
  44583. dispose(): void;
  44584. /**
  44585. * Release all the underlying texture used as draw buffers.
  44586. */
  44587. releaseInternalTextures(): void;
  44588. }
  44589. }
  44590. declare module BABYLON {
  44591. interface ThinEngine {
  44592. /**
  44593. * Unbind a list of render target textures from the webGL context
  44594. * This is used only when drawBuffer extension or webGL2 are active
  44595. * @param textures defines the render target textures to unbind
  44596. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44597. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44598. */
  44599. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44600. /**
  44601. * Create a multi render target texture
  44602. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44603. * @param size defines the size of the texture
  44604. * @param options defines the creation options
  44605. * @returns the cube texture as an InternalTexture
  44606. */
  44607. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44608. /**
  44609. * Update the sample count for a given multiple render target texture
  44610. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44611. * @param textures defines the textures to update
  44612. * @param samples defines the sample count to set
  44613. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44614. */
  44615. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44616. }
  44617. }
  44618. declare module BABYLON {
  44619. /**
  44620. * Class used to define an additional view for the engine
  44621. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44622. */
  44623. export class EngineView {
  44624. /** Defines the canvas where to render the view */
  44625. target: HTMLCanvasElement;
  44626. /** Defines an optional camera used to render the view (will use active camera else) */
  44627. camera?: Camera;
  44628. }
  44629. interface Engine {
  44630. /**
  44631. * Gets or sets the HTML element to use for attaching events
  44632. */
  44633. inputElement: Nullable<HTMLElement>;
  44634. /**
  44635. * Gets the current engine view
  44636. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44637. */
  44638. activeView: Nullable<EngineView>;
  44639. /** Gets or sets the list of views */
  44640. views: EngineView[];
  44641. /**
  44642. * Register a new child canvas
  44643. * @param canvas defines the canvas to register
  44644. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44645. * @returns the associated view
  44646. */
  44647. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44648. /**
  44649. * Remove a registered child canvas
  44650. * @param canvas defines the canvas to remove
  44651. * @returns the current engine
  44652. */
  44653. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44654. }
  44655. }
  44656. declare module BABYLON {
  44657. /**
  44658. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44659. */
  44660. export interface CubeMapInfo {
  44661. /**
  44662. * The pixel array for the front face.
  44663. * This is stored in format, left to right, up to down format.
  44664. */
  44665. front: Nullable<ArrayBufferView>;
  44666. /**
  44667. * The pixel array for the back face.
  44668. * This is stored in format, left to right, up to down format.
  44669. */
  44670. back: Nullable<ArrayBufferView>;
  44671. /**
  44672. * The pixel array for the left face.
  44673. * This is stored in format, left to right, up to down format.
  44674. */
  44675. left: Nullable<ArrayBufferView>;
  44676. /**
  44677. * The pixel array for the right face.
  44678. * This is stored in format, left to right, up to down format.
  44679. */
  44680. right: Nullable<ArrayBufferView>;
  44681. /**
  44682. * The pixel array for the up face.
  44683. * This is stored in format, left to right, up to down format.
  44684. */
  44685. up: Nullable<ArrayBufferView>;
  44686. /**
  44687. * The pixel array for the down face.
  44688. * This is stored in format, left to right, up to down format.
  44689. */
  44690. down: Nullable<ArrayBufferView>;
  44691. /**
  44692. * The size of the cubemap stored.
  44693. *
  44694. * Each faces will be size * size pixels.
  44695. */
  44696. size: number;
  44697. /**
  44698. * The format of the texture.
  44699. *
  44700. * RGBA, RGB.
  44701. */
  44702. format: number;
  44703. /**
  44704. * The type of the texture data.
  44705. *
  44706. * UNSIGNED_INT, FLOAT.
  44707. */
  44708. type: number;
  44709. /**
  44710. * Specifies whether the texture is in gamma space.
  44711. */
  44712. gammaSpace: boolean;
  44713. }
  44714. /**
  44715. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44716. */
  44717. export class PanoramaToCubeMapTools {
  44718. private static FACE_FRONT;
  44719. private static FACE_BACK;
  44720. private static FACE_RIGHT;
  44721. private static FACE_LEFT;
  44722. private static FACE_DOWN;
  44723. private static FACE_UP;
  44724. /**
  44725. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44726. *
  44727. * @param float32Array The source data.
  44728. * @param inputWidth The width of the input panorama.
  44729. * @param inputHeight The height of the input panorama.
  44730. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44731. * @return The cubemap data
  44732. */
  44733. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44734. private static CreateCubemapTexture;
  44735. private static CalcProjectionSpherical;
  44736. }
  44737. }
  44738. declare module BABYLON {
  44739. /**
  44740. * Helper class dealing with the extraction of spherical polynomial dataArray
  44741. * from a cube map.
  44742. */
  44743. export class CubeMapToSphericalPolynomialTools {
  44744. private static FileFaces;
  44745. /**
  44746. * Converts a texture to the according Spherical Polynomial data.
  44747. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44748. *
  44749. * @param texture The texture to extract the information from.
  44750. * @return The Spherical Polynomial data.
  44751. */
  44752. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44753. /**
  44754. * Converts a cubemap to the according Spherical Polynomial data.
  44755. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44756. *
  44757. * @param cubeInfo The Cube map to extract the information from.
  44758. * @return The Spherical Polynomial data.
  44759. */
  44760. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. interface BaseTexture {
  44765. /**
  44766. * Get the polynomial representation of the texture data.
  44767. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44768. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44769. */
  44770. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44771. }
  44772. }
  44773. declare module BABYLON {
  44774. /** @hidden */
  44775. export var rgbdEncodePixelShader: {
  44776. name: string;
  44777. shader: string;
  44778. };
  44779. }
  44780. declare module BABYLON {
  44781. /** @hidden */
  44782. export var rgbdDecodePixelShader: {
  44783. name: string;
  44784. shader: string;
  44785. };
  44786. }
  44787. declare module BABYLON {
  44788. /**
  44789. * Raw texture data and descriptor sufficient for WebGL texture upload
  44790. */
  44791. export interface EnvironmentTextureInfo {
  44792. /**
  44793. * Version of the environment map
  44794. */
  44795. version: number;
  44796. /**
  44797. * Width of image
  44798. */
  44799. width: number;
  44800. /**
  44801. * Irradiance information stored in the file.
  44802. */
  44803. irradiance: any;
  44804. /**
  44805. * Specular information stored in the file.
  44806. */
  44807. specular: any;
  44808. }
  44809. /**
  44810. * Defines One Image in the file. It requires only the position in the file
  44811. * as well as the length.
  44812. */
  44813. interface BufferImageData {
  44814. /**
  44815. * Length of the image data.
  44816. */
  44817. length: number;
  44818. /**
  44819. * Position of the data from the null terminator delimiting the end of the JSON.
  44820. */
  44821. position: number;
  44822. }
  44823. /**
  44824. * Defines the specular data enclosed in the file.
  44825. * This corresponds to the version 1 of the data.
  44826. */
  44827. export interface EnvironmentTextureSpecularInfoV1 {
  44828. /**
  44829. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44830. */
  44831. specularDataPosition?: number;
  44832. /**
  44833. * This contains all the images data needed to reconstruct the cubemap.
  44834. */
  44835. mipmaps: Array<BufferImageData>;
  44836. /**
  44837. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44838. */
  44839. lodGenerationScale: number;
  44840. }
  44841. /**
  44842. * Sets of helpers addressing the serialization and deserialization of environment texture
  44843. * stored in a BabylonJS env file.
  44844. * Those files are usually stored as .env files.
  44845. */
  44846. export class EnvironmentTextureTools {
  44847. /**
  44848. * Magic number identifying the env file.
  44849. */
  44850. private static _MagicBytes;
  44851. /**
  44852. * Gets the environment info from an env file.
  44853. * @param data The array buffer containing the .env bytes.
  44854. * @returns the environment file info (the json header) if successfully parsed.
  44855. */
  44856. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44857. /**
  44858. * Creates an environment texture from a loaded cube texture.
  44859. * @param texture defines the cube texture to convert in env file
  44860. * @return a promise containing the environment data if succesfull.
  44861. */
  44862. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44863. /**
  44864. * Creates a JSON representation of the spherical data.
  44865. * @param texture defines the texture containing the polynomials
  44866. * @return the JSON representation of the spherical info
  44867. */
  44868. private static _CreateEnvTextureIrradiance;
  44869. /**
  44870. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44871. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44872. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44873. * @return the views described by info providing access to the underlying buffer
  44874. */
  44875. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44876. /**
  44877. * Uploads the texture info contained in the env file to the GPU.
  44878. * @param texture defines the internal texture to upload to
  44879. * @param arrayBuffer defines the buffer cotaining the data to load
  44880. * @param info defines the texture info retrieved through the GetEnvInfo method
  44881. * @returns a promise
  44882. */
  44883. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44884. private static _OnImageReadyAsync;
  44885. /**
  44886. * Uploads the levels of image data to the GPU.
  44887. * @param texture defines the internal texture to upload to
  44888. * @param imageData defines the array buffer views of image data [mipmap][face]
  44889. * @returns a promise
  44890. */
  44891. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44892. /**
  44893. * Uploads spherical polynomials information to the texture.
  44894. * @param texture defines the texture we are trying to upload the information to
  44895. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44896. */
  44897. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44898. /** @hidden */
  44899. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44900. }
  44901. }
  44902. declare module BABYLON {
  44903. /**
  44904. * Contains position and normal vectors for a vertex
  44905. */
  44906. export class PositionNormalVertex {
  44907. /** the position of the vertex (defaut: 0,0,0) */
  44908. position: Vector3;
  44909. /** the normal of the vertex (defaut: 0,1,0) */
  44910. normal: Vector3;
  44911. /**
  44912. * Creates a PositionNormalVertex
  44913. * @param position the position of the vertex (defaut: 0,0,0)
  44914. * @param normal the normal of the vertex (defaut: 0,1,0)
  44915. */
  44916. constructor(
  44917. /** the position of the vertex (defaut: 0,0,0) */
  44918. position?: Vector3,
  44919. /** the normal of the vertex (defaut: 0,1,0) */
  44920. normal?: Vector3);
  44921. /**
  44922. * Clones the PositionNormalVertex
  44923. * @returns the cloned PositionNormalVertex
  44924. */
  44925. clone(): PositionNormalVertex;
  44926. }
  44927. /**
  44928. * Contains position, normal and uv vectors for a vertex
  44929. */
  44930. export class PositionNormalTextureVertex {
  44931. /** the position of the vertex (defaut: 0,0,0) */
  44932. position: Vector3;
  44933. /** the normal of the vertex (defaut: 0,1,0) */
  44934. normal: Vector3;
  44935. /** the uv of the vertex (default: 0,0) */
  44936. uv: Vector2;
  44937. /**
  44938. * Creates a PositionNormalTextureVertex
  44939. * @param position the position of the vertex (defaut: 0,0,0)
  44940. * @param normal the normal of the vertex (defaut: 0,1,0)
  44941. * @param uv the uv of the vertex (default: 0,0)
  44942. */
  44943. constructor(
  44944. /** the position of the vertex (defaut: 0,0,0) */
  44945. position?: Vector3,
  44946. /** the normal of the vertex (defaut: 0,1,0) */
  44947. normal?: Vector3,
  44948. /** the uv of the vertex (default: 0,0) */
  44949. uv?: Vector2);
  44950. /**
  44951. * Clones the PositionNormalTextureVertex
  44952. * @returns the cloned PositionNormalTextureVertex
  44953. */
  44954. clone(): PositionNormalTextureVertex;
  44955. }
  44956. }
  44957. declare module BABYLON {
  44958. /** @hidden */
  44959. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44960. private _genericAttributeLocation;
  44961. private _varyingLocationCount;
  44962. private _varyingLocationMap;
  44963. private _replacements;
  44964. private _textureCount;
  44965. private _uniforms;
  44966. lineProcessor(line: string): string;
  44967. attributeProcessor(attribute: string): string;
  44968. varyingProcessor(varying: string, isFragment: boolean): string;
  44969. uniformProcessor(uniform: string): string;
  44970. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44971. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44972. }
  44973. }
  44974. declare module BABYLON {
  44975. /**
  44976. * Container for accessors for natively-stored mesh data buffers.
  44977. */
  44978. class NativeDataBuffer extends DataBuffer {
  44979. /**
  44980. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44981. */
  44982. nativeIndexBuffer?: any;
  44983. /**
  44984. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44985. */
  44986. nativeVertexBuffer?: any;
  44987. }
  44988. /** @hidden */
  44989. class NativeTexture extends InternalTexture {
  44990. getInternalTexture(): InternalTexture;
  44991. getViewCount(): number;
  44992. }
  44993. /** @hidden */
  44994. export class NativeEngine extends Engine {
  44995. private readonly _native;
  44996. getHardwareScalingLevel(): number;
  44997. constructor();
  44998. /**
  44999. * Can be used to override the current requestAnimationFrame requester.
  45000. * @hidden
  45001. */
  45002. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45003. /**
  45004. * Override default engine behavior.
  45005. * @param color
  45006. * @param backBuffer
  45007. * @param depth
  45008. * @param stencil
  45009. */
  45010. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45011. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45012. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45013. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45014. recordVertexArrayObject(vertexBuffers: {
  45015. [key: string]: VertexBuffer;
  45016. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45017. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45018. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45019. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45020. /**
  45021. * Draw a list of indexed primitives
  45022. * @param fillMode defines the primitive to use
  45023. * @param indexStart defines the starting index
  45024. * @param indexCount defines the number of index to draw
  45025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45026. */
  45027. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45028. /**
  45029. * Draw a list of unindexed primitives
  45030. * @param fillMode defines the primitive to use
  45031. * @param verticesStart defines the index of first vertex to draw
  45032. * @param verticesCount defines the count of vertices to draw
  45033. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45034. */
  45035. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45036. createPipelineContext(): IPipelineContext;
  45037. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45038. /** @hidden */
  45039. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45040. /** @hidden */
  45041. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45042. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45043. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45044. protected _setProgram(program: WebGLProgram): void;
  45045. _releaseEffect(effect: Effect): void;
  45046. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45047. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45048. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45049. bindSamplers(effect: Effect): void;
  45050. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45051. getRenderWidth(useScreen?: boolean): number;
  45052. getRenderHeight(useScreen?: boolean): number;
  45053. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45054. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45055. /**
  45056. * Set the z offset to apply to current rendering
  45057. * @param value defines the offset to apply
  45058. */
  45059. setZOffset(value: number): void;
  45060. /**
  45061. * Gets the current value of the zOffset
  45062. * @returns the current zOffset state
  45063. */
  45064. getZOffset(): number;
  45065. /**
  45066. * Enable or disable depth buffering
  45067. * @param enable defines the state to set
  45068. */
  45069. setDepthBuffer(enable: boolean): void;
  45070. /**
  45071. * Gets a boolean indicating if depth writing is enabled
  45072. * @returns the current depth writing state
  45073. */
  45074. getDepthWrite(): boolean;
  45075. /**
  45076. * Enable or disable depth writing
  45077. * @param enable defines the state to set
  45078. */
  45079. setDepthWrite(enable: boolean): void;
  45080. /**
  45081. * Enable or disable color writing
  45082. * @param enable defines the state to set
  45083. */
  45084. setColorWrite(enable: boolean): void;
  45085. /**
  45086. * Gets a boolean indicating if color writing is enabled
  45087. * @returns the current color writing state
  45088. */
  45089. getColorWrite(): boolean;
  45090. /**
  45091. * Sets alpha constants used by some alpha blending modes
  45092. * @param r defines the red component
  45093. * @param g defines the green component
  45094. * @param b defines the blue component
  45095. * @param a defines the alpha component
  45096. */
  45097. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45098. /**
  45099. * Sets the current alpha mode
  45100. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45101. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45102. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45103. */
  45104. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45105. /**
  45106. * Gets the current alpha mode
  45107. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45108. * @returns the current alpha mode
  45109. */
  45110. getAlphaMode(): number;
  45111. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45112. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45113. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45114. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45115. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45116. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45117. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45118. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45119. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45120. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45121. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45122. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45123. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45124. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45125. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45126. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45127. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45128. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45129. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45130. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45131. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45132. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45133. wipeCaches(bruteForce?: boolean): void;
  45134. _createTexture(): WebGLTexture;
  45135. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45136. /**
  45137. * Usually called from BABYLON.Texture.ts.
  45138. * Passed information to create a WebGLTexture
  45139. * @param urlArg defines a value which contains one of the following:
  45140. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45141. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45142. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45143. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45144. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45145. * @param scene needed for loading to the correct scene
  45146. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45147. * @param onLoad optional callback to be called upon successful completion
  45148. * @param onError optional callback to be called upon failure
  45149. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45150. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45151. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45152. * @param forcedExtension defines the extension to use to pick the right loader
  45153. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45154. */
  45155. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45156. /**
  45157. * Creates a cube texture
  45158. * @param rootUrl defines the url where the files to load is located
  45159. * @param scene defines the current scene
  45160. * @param files defines the list of files to load (1 per face)
  45161. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45162. * @param onLoad defines an optional callback raised when the texture is loaded
  45163. * @param onError defines an optional callback raised if there is an issue to load the texture
  45164. * @param format defines the format of the data
  45165. * @param forcedExtension defines the extension to use to pick the right loader
  45166. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45167. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45168. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45169. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45170. * @returns the cube texture as an InternalTexture
  45171. */
  45172. 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;
  45173. private _getSamplingFilter;
  45174. private static _GetNativeTextureFormat;
  45175. createRenderTargetTexture(size: number | {
  45176. width: number;
  45177. height: number;
  45178. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45180. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45181. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45182. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45183. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45184. /**
  45185. * Updates a dynamic vertex buffer.
  45186. * @param vertexBuffer the vertex buffer to update
  45187. * @param data the data used to update the vertex buffer
  45188. * @param byteOffset the byte offset of the data (optional)
  45189. * @param byteLength the byte length of the data (optional)
  45190. */
  45191. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45192. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45193. private _updateAnisotropicLevel;
  45194. private _getAddressMode;
  45195. /** @hidden */
  45196. _bindTexture(channel: number, texture: InternalTexture): void;
  45197. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45198. releaseEffects(): void;
  45199. /** @hidden */
  45200. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45201. /** @hidden */
  45202. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45203. /** @hidden */
  45204. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45205. /** @hidden */
  45206. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45207. }
  45208. }
  45209. declare module BABYLON {
  45210. /**
  45211. * Gather the list of clipboard event types as constants.
  45212. */
  45213. export class ClipboardEventTypes {
  45214. /**
  45215. * The clipboard event is fired when a copy command is active (pressed).
  45216. */
  45217. static readonly COPY: number;
  45218. /**
  45219. * The clipboard event is fired when a cut command is active (pressed).
  45220. */
  45221. static readonly CUT: number;
  45222. /**
  45223. * The clipboard event is fired when a paste command is active (pressed).
  45224. */
  45225. static readonly PASTE: number;
  45226. }
  45227. /**
  45228. * This class is used to store clipboard related info for the onClipboardObservable event.
  45229. */
  45230. export class ClipboardInfo {
  45231. /**
  45232. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45233. */
  45234. type: number;
  45235. /**
  45236. * Defines the related dom event
  45237. */
  45238. event: ClipboardEvent;
  45239. /**
  45240. *Creates an instance of ClipboardInfo.
  45241. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45242. * @param event Defines the related dom event
  45243. */
  45244. constructor(
  45245. /**
  45246. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45247. */
  45248. type: number,
  45249. /**
  45250. * Defines the related dom event
  45251. */
  45252. event: ClipboardEvent);
  45253. /**
  45254. * Get the clipboard event's type from the keycode.
  45255. * @param keyCode Defines the keyCode for the current keyboard event.
  45256. * @return {number}
  45257. */
  45258. static GetTypeFromCharacter(keyCode: number): number;
  45259. }
  45260. }
  45261. declare module BABYLON {
  45262. /**
  45263. * Google Daydream controller
  45264. */
  45265. export class DaydreamController extends WebVRController {
  45266. /**
  45267. * Base Url for the controller model.
  45268. */
  45269. static MODEL_BASE_URL: string;
  45270. /**
  45271. * File name for the controller model.
  45272. */
  45273. static MODEL_FILENAME: string;
  45274. /**
  45275. * Gamepad Id prefix used to identify Daydream Controller.
  45276. */
  45277. static readonly GAMEPAD_ID_PREFIX: string;
  45278. /**
  45279. * Creates a new DaydreamController from a gamepad
  45280. * @param vrGamepad the gamepad that the controller should be created from
  45281. */
  45282. constructor(vrGamepad: any);
  45283. /**
  45284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45285. * @param scene scene in which to add meshes
  45286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45287. */
  45288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45289. /**
  45290. * Called once for each button that changed state since the last frame
  45291. * @param buttonIdx Which button index changed
  45292. * @param state New state of the button
  45293. * @param changes Which properties on the state changed since last frame
  45294. */
  45295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45296. }
  45297. }
  45298. declare module BABYLON {
  45299. /**
  45300. * Gear VR Controller
  45301. */
  45302. export class GearVRController extends WebVRController {
  45303. /**
  45304. * Base Url for the controller model.
  45305. */
  45306. static MODEL_BASE_URL: string;
  45307. /**
  45308. * File name for the controller model.
  45309. */
  45310. static MODEL_FILENAME: string;
  45311. /**
  45312. * Gamepad Id prefix used to identify this controller.
  45313. */
  45314. static readonly GAMEPAD_ID_PREFIX: string;
  45315. private readonly _buttonIndexToObservableNameMap;
  45316. /**
  45317. * Creates a new GearVRController from a gamepad
  45318. * @param vrGamepad the gamepad that the controller should be created from
  45319. */
  45320. constructor(vrGamepad: any);
  45321. /**
  45322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45323. * @param scene scene in which to add meshes
  45324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45325. */
  45326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45327. /**
  45328. * Called once for each button that changed state since the last frame
  45329. * @param buttonIdx Which button index changed
  45330. * @param state New state of the button
  45331. * @param changes Which properties on the state changed since last frame
  45332. */
  45333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45334. }
  45335. }
  45336. declare module BABYLON {
  45337. /**
  45338. * Class containing static functions to help procedurally build meshes
  45339. */
  45340. export class PolyhedronBuilder {
  45341. /**
  45342. * Creates a polyhedron mesh
  45343. * * 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
  45344. * * The parameter `size` (positive float, default 1) sets the polygon size
  45345. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45346. * * 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`
  45347. * * 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
  45348. * * 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)`)
  45349. * * 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
  45350. * * 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
  45351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45352. * * 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
  45353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45354. * @param name defines the name of the mesh
  45355. * @param options defines the options used to create the mesh
  45356. * @param scene defines the hosting scene
  45357. * @returns the polyhedron mesh
  45358. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45359. */
  45360. static CreatePolyhedron(name: string, options: {
  45361. type?: number;
  45362. size?: number;
  45363. sizeX?: number;
  45364. sizeY?: number;
  45365. sizeZ?: number;
  45366. custom?: any;
  45367. faceUV?: Vector4[];
  45368. faceColors?: Color4[];
  45369. flat?: boolean;
  45370. updatable?: boolean;
  45371. sideOrientation?: number;
  45372. frontUVs?: Vector4;
  45373. backUVs?: Vector4;
  45374. }, scene?: Nullable<Scene>): Mesh;
  45375. }
  45376. }
  45377. declare module BABYLON {
  45378. /**
  45379. * Gizmo that enables scaling a mesh along 3 axis
  45380. */
  45381. export class ScaleGizmo extends Gizmo {
  45382. /**
  45383. * Internal gizmo used for interactions on the x axis
  45384. */
  45385. xGizmo: AxisScaleGizmo;
  45386. /**
  45387. * Internal gizmo used for interactions on the y axis
  45388. */
  45389. yGizmo: AxisScaleGizmo;
  45390. /**
  45391. * Internal gizmo used for interactions on the z axis
  45392. */
  45393. zGizmo: AxisScaleGizmo;
  45394. /**
  45395. * Internal gizmo used to scale all axis equally
  45396. */
  45397. uniformScaleGizmo: AxisScaleGizmo;
  45398. private _meshAttached;
  45399. private _updateGizmoRotationToMatchAttachedMesh;
  45400. private _snapDistance;
  45401. private _scaleRatio;
  45402. private _uniformScalingMesh;
  45403. private _octahedron;
  45404. /** Fires an event when any of it's sub gizmos are dragged */
  45405. onDragStartObservable: Observable<unknown>;
  45406. /** Fires an event when any of it's sub gizmos are released from dragging */
  45407. onDragEndObservable: Observable<unknown>;
  45408. attachedMesh: Nullable<AbstractMesh>;
  45409. /**
  45410. * Creates a ScaleGizmo
  45411. * @param gizmoLayer The utility layer the gizmo will be added to
  45412. */
  45413. constructor(gizmoLayer?: UtilityLayerRenderer);
  45414. updateGizmoRotationToMatchAttachedMesh: boolean;
  45415. /**
  45416. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45417. */
  45418. snapDistance: number;
  45419. /**
  45420. * Ratio for the scale of the gizmo (Default: 1)
  45421. */
  45422. scaleRatio: number;
  45423. /**
  45424. * Disposes of the gizmo
  45425. */
  45426. dispose(): void;
  45427. }
  45428. }
  45429. declare module BABYLON {
  45430. /**
  45431. * Single axis scale gizmo
  45432. */
  45433. export class AxisScaleGizmo extends Gizmo {
  45434. /**
  45435. * Drag behavior responsible for the gizmos dragging interactions
  45436. */
  45437. dragBehavior: PointerDragBehavior;
  45438. private _pointerObserver;
  45439. /**
  45440. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45441. */
  45442. snapDistance: number;
  45443. /**
  45444. * Event that fires each time the gizmo snaps to a new location.
  45445. * * snapDistance is the the change in distance
  45446. */
  45447. onSnapObservable: Observable<{
  45448. snapDistance: number;
  45449. }>;
  45450. /**
  45451. * If the scaling operation should be done on all axis (default: false)
  45452. */
  45453. uniformScaling: boolean;
  45454. private _isEnabled;
  45455. private _parent;
  45456. private _arrow;
  45457. private _coloredMaterial;
  45458. private _hoverMaterial;
  45459. /**
  45460. * Creates an AxisScaleGizmo
  45461. * @param gizmoLayer The utility layer the gizmo will be added to
  45462. * @param dragAxis The axis which the gizmo will be able to scale on
  45463. * @param color The color of the gizmo
  45464. */
  45465. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45466. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45467. /**
  45468. * If the gizmo is enabled
  45469. */
  45470. isEnabled: boolean;
  45471. /**
  45472. * Disposes of the gizmo
  45473. */
  45474. dispose(): void;
  45475. /**
  45476. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45477. * @param mesh The mesh to replace the default mesh of the gizmo
  45478. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45479. */
  45480. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45481. }
  45482. }
  45483. declare module BABYLON {
  45484. /**
  45485. * Bounding box gizmo
  45486. */
  45487. export class BoundingBoxGizmo extends Gizmo {
  45488. private _lineBoundingBox;
  45489. private _rotateSpheresParent;
  45490. private _scaleBoxesParent;
  45491. private _boundingDimensions;
  45492. private _renderObserver;
  45493. private _pointerObserver;
  45494. private _scaleDragSpeed;
  45495. private _tmpQuaternion;
  45496. private _tmpVector;
  45497. private _tmpRotationMatrix;
  45498. /**
  45499. * 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)
  45500. */
  45501. ignoreChildren: boolean;
  45502. /**
  45503. * 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)
  45504. */
  45505. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45506. /**
  45507. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45508. */
  45509. rotationSphereSize: number;
  45510. /**
  45511. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45512. */
  45513. scaleBoxSize: number;
  45514. /**
  45515. * 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)
  45516. */
  45517. fixedDragMeshScreenSize: boolean;
  45518. /**
  45519. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45520. */
  45521. fixedDragMeshScreenSizeDistanceFactor: number;
  45522. /**
  45523. * Fired when a rotation sphere or scale box is dragged
  45524. */
  45525. onDragStartObservable: Observable<{}>;
  45526. /**
  45527. * Fired when a scale box is dragged
  45528. */
  45529. onScaleBoxDragObservable: Observable<{}>;
  45530. /**
  45531. * Fired when a scale box drag is ended
  45532. */
  45533. onScaleBoxDragEndObservable: Observable<{}>;
  45534. /**
  45535. * Fired when a rotation sphere is dragged
  45536. */
  45537. onRotationSphereDragObservable: Observable<{}>;
  45538. /**
  45539. * Fired when a rotation sphere drag is ended
  45540. */
  45541. onRotationSphereDragEndObservable: Observable<{}>;
  45542. /**
  45543. * 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)
  45544. */
  45545. scalePivot: Nullable<Vector3>;
  45546. /**
  45547. * Mesh used as a pivot to rotate the attached mesh
  45548. */
  45549. private _anchorMesh;
  45550. private _existingMeshScale;
  45551. private _dragMesh;
  45552. private pointerDragBehavior;
  45553. private coloredMaterial;
  45554. private hoverColoredMaterial;
  45555. /**
  45556. * Sets the color of the bounding box gizmo
  45557. * @param color the color to set
  45558. */
  45559. setColor(color: Color3): void;
  45560. /**
  45561. * Creates an BoundingBoxGizmo
  45562. * @param gizmoLayer The utility layer the gizmo will be added to
  45563. * @param color The color of the gizmo
  45564. */
  45565. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45567. private _selectNode;
  45568. /**
  45569. * Updates the bounding box information for the Gizmo
  45570. */
  45571. updateBoundingBox(): void;
  45572. private _updateRotationSpheres;
  45573. private _updateScaleBoxes;
  45574. /**
  45575. * Enables rotation on the specified axis and disables rotation on the others
  45576. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45577. */
  45578. setEnabledRotationAxis(axis: string): void;
  45579. /**
  45580. * Enables/disables scaling
  45581. * @param enable if scaling should be enabled
  45582. */
  45583. setEnabledScaling(enable: boolean): void;
  45584. private _updateDummy;
  45585. /**
  45586. * Enables a pointer drag behavior on the bounding box of the gizmo
  45587. */
  45588. enableDragBehavior(): void;
  45589. /**
  45590. * Disposes of the gizmo
  45591. */
  45592. dispose(): void;
  45593. /**
  45594. * 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)
  45595. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45596. * @returns the bounding box mesh with the passed in mesh as a child
  45597. */
  45598. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45599. /**
  45600. * CustomMeshes are not supported by this gizmo
  45601. * @param mesh The mesh to replace the default mesh of the gizmo
  45602. */
  45603. setCustomMesh(mesh: Mesh): void;
  45604. }
  45605. }
  45606. declare module BABYLON {
  45607. /**
  45608. * Single plane rotation gizmo
  45609. */
  45610. export class PlaneRotationGizmo extends Gizmo {
  45611. /**
  45612. * Drag behavior responsible for the gizmos dragging interactions
  45613. */
  45614. dragBehavior: PointerDragBehavior;
  45615. private _pointerObserver;
  45616. /**
  45617. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45618. */
  45619. snapDistance: number;
  45620. /**
  45621. * Event that fires each time the gizmo snaps to a new location.
  45622. * * snapDistance is the the change in distance
  45623. */
  45624. onSnapObservable: Observable<{
  45625. snapDistance: number;
  45626. }>;
  45627. private _isEnabled;
  45628. private _parent;
  45629. /**
  45630. * Creates a PlaneRotationGizmo
  45631. * @param gizmoLayer The utility layer the gizmo will be added to
  45632. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45633. * @param color The color of the gizmo
  45634. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45635. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45636. */
  45637. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45639. /**
  45640. * If the gizmo is enabled
  45641. */
  45642. isEnabled: boolean;
  45643. /**
  45644. * Disposes of the gizmo
  45645. */
  45646. dispose(): void;
  45647. }
  45648. }
  45649. declare module BABYLON {
  45650. /**
  45651. * Gizmo that enables rotating a mesh along 3 axis
  45652. */
  45653. export class RotationGizmo extends Gizmo {
  45654. /**
  45655. * Internal gizmo used for interactions on the x axis
  45656. */
  45657. xGizmo: PlaneRotationGizmo;
  45658. /**
  45659. * Internal gizmo used for interactions on the y axis
  45660. */
  45661. yGizmo: PlaneRotationGizmo;
  45662. /**
  45663. * Internal gizmo used for interactions on the z axis
  45664. */
  45665. zGizmo: PlaneRotationGizmo;
  45666. /** Fires an event when any of it's sub gizmos are dragged */
  45667. onDragStartObservable: Observable<unknown>;
  45668. /** Fires an event when any of it's sub gizmos are released from dragging */
  45669. onDragEndObservable: Observable<unknown>;
  45670. private _meshAttached;
  45671. attachedMesh: Nullable<AbstractMesh>;
  45672. /**
  45673. * Creates a RotationGizmo
  45674. * @param gizmoLayer The utility layer the gizmo will be added to
  45675. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45676. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45677. */
  45678. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45679. updateGizmoRotationToMatchAttachedMesh: boolean;
  45680. /**
  45681. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45682. */
  45683. snapDistance: number;
  45684. /**
  45685. * Ratio for the scale of the gizmo (Default: 1)
  45686. */
  45687. scaleRatio: number;
  45688. /**
  45689. * Disposes of the gizmo
  45690. */
  45691. dispose(): void;
  45692. /**
  45693. * CustomMeshes are not supported by this gizmo
  45694. * @param mesh The mesh to replace the default mesh of the gizmo
  45695. */
  45696. setCustomMesh(mesh: Mesh): void;
  45697. }
  45698. }
  45699. declare module BABYLON {
  45700. /**
  45701. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45702. */
  45703. export class GizmoManager implements IDisposable {
  45704. private scene;
  45705. /**
  45706. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45707. */
  45708. gizmos: {
  45709. positionGizmo: Nullable<PositionGizmo>;
  45710. rotationGizmo: Nullable<RotationGizmo>;
  45711. scaleGizmo: Nullable<ScaleGizmo>;
  45712. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45713. };
  45714. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45715. clearGizmoOnEmptyPointerEvent: boolean;
  45716. /** Fires an event when the manager is attached to a mesh */
  45717. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45718. private _gizmosEnabled;
  45719. private _pointerObserver;
  45720. private _attachedMesh;
  45721. private _boundingBoxColor;
  45722. private _defaultUtilityLayer;
  45723. private _defaultKeepDepthUtilityLayer;
  45724. /**
  45725. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45726. */
  45727. boundingBoxDragBehavior: SixDofDragBehavior;
  45728. /**
  45729. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45730. */
  45731. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45732. /**
  45733. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45734. */
  45735. usePointerToAttachGizmos: boolean;
  45736. /**
  45737. * Utility layer that the bounding box gizmo belongs to
  45738. */
  45739. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45740. /**
  45741. * Utility layer that all gizmos besides bounding box belong to
  45742. */
  45743. readonly utilityLayer: UtilityLayerRenderer;
  45744. /**
  45745. * Instatiates a gizmo manager
  45746. * @param scene the scene to overlay the gizmos on top of
  45747. */
  45748. constructor(scene: Scene);
  45749. /**
  45750. * Attaches a set of gizmos to the specified mesh
  45751. * @param mesh The mesh the gizmo's should be attached to
  45752. */
  45753. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45754. /**
  45755. * If the position gizmo is enabled
  45756. */
  45757. positionGizmoEnabled: boolean;
  45758. /**
  45759. * If the rotation gizmo is enabled
  45760. */
  45761. rotationGizmoEnabled: boolean;
  45762. /**
  45763. * If the scale gizmo is enabled
  45764. */
  45765. scaleGizmoEnabled: boolean;
  45766. /**
  45767. * If the boundingBox gizmo is enabled
  45768. */
  45769. boundingBoxGizmoEnabled: boolean;
  45770. /**
  45771. * Disposes of the gizmo manager
  45772. */
  45773. dispose(): void;
  45774. }
  45775. }
  45776. declare module BABYLON {
  45777. /**
  45778. * A directional light is defined by a direction (what a surprise!).
  45779. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45780. * 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.
  45781. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45782. */
  45783. export class DirectionalLight extends ShadowLight {
  45784. private _shadowFrustumSize;
  45785. /**
  45786. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45787. */
  45788. /**
  45789. * Specifies a fix frustum size for the shadow generation.
  45790. */
  45791. shadowFrustumSize: number;
  45792. private _shadowOrthoScale;
  45793. /**
  45794. * Gets the shadow projection scale against the optimal computed one.
  45795. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45796. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45797. */
  45798. /**
  45799. * Sets the shadow projection scale against the optimal computed one.
  45800. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45801. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45802. */
  45803. shadowOrthoScale: number;
  45804. /**
  45805. * Automatically compute the projection matrix to best fit (including all the casters)
  45806. * on each frame.
  45807. */
  45808. autoUpdateExtends: boolean;
  45809. private _orthoLeft;
  45810. private _orthoRight;
  45811. private _orthoTop;
  45812. private _orthoBottom;
  45813. /**
  45814. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45815. * The directional light is emitted from everywhere in the given direction.
  45816. * It can cast shadows.
  45817. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45818. * @param name The friendly name of the light
  45819. * @param direction The direction of the light
  45820. * @param scene The scene the light belongs to
  45821. */
  45822. constructor(name: string, direction: Vector3, scene: Scene);
  45823. /**
  45824. * Returns the string "DirectionalLight".
  45825. * @return The class name
  45826. */
  45827. getClassName(): string;
  45828. /**
  45829. * Returns the integer 1.
  45830. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45831. */
  45832. getTypeID(): number;
  45833. /**
  45834. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45835. * Returns the DirectionalLight Shadow projection matrix.
  45836. */
  45837. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45838. /**
  45839. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45840. * Returns the DirectionalLight Shadow projection matrix.
  45841. */
  45842. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45843. /**
  45844. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45845. * Returns the DirectionalLight Shadow projection matrix.
  45846. */
  45847. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45848. protected _buildUniformLayout(): void;
  45849. /**
  45850. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45851. * @param effect The effect to update
  45852. * @param lightIndex The index of the light in the effect to update
  45853. * @returns The directional light
  45854. */
  45855. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45856. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45857. /**
  45858. * Gets the minZ used for shadow according to both the scene and the light.
  45859. *
  45860. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45861. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45862. * @param activeCamera The camera we are returning the min for
  45863. * @returns the depth min z
  45864. */
  45865. getDepthMinZ(activeCamera: Camera): number;
  45866. /**
  45867. * Gets the maxZ used for shadow according to both the scene and the light.
  45868. *
  45869. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45870. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45871. * @param activeCamera The camera we are returning the max for
  45872. * @returns the depth max z
  45873. */
  45874. getDepthMaxZ(activeCamera: Camera): number;
  45875. /**
  45876. * Prepares the list of defines specific to the light type.
  45877. * @param defines the list of defines
  45878. * @param lightIndex defines the index of the light for the effect
  45879. */
  45880. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45881. }
  45882. }
  45883. declare module BABYLON {
  45884. /**
  45885. * Class containing static functions to help procedurally build meshes
  45886. */
  45887. export class HemisphereBuilder {
  45888. /**
  45889. * Creates a hemisphere mesh
  45890. * @param name defines the name of the mesh
  45891. * @param options defines the options used to create the mesh
  45892. * @param scene defines the hosting scene
  45893. * @returns the hemisphere mesh
  45894. */
  45895. static CreateHemisphere(name: string, options: {
  45896. segments?: number;
  45897. diameter?: number;
  45898. sideOrientation?: number;
  45899. }, scene: any): Mesh;
  45900. }
  45901. }
  45902. declare module BABYLON {
  45903. /**
  45904. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45905. * These values define a cone of light starting from the position, emitting toward the direction.
  45906. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45907. * and the exponent defines the speed of the decay of the light with distance (reach).
  45908. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45909. */
  45910. export class SpotLight extends ShadowLight {
  45911. private _angle;
  45912. private _innerAngle;
  45913. private _cosHalfAngle;
  45914. private _lightAngleScale;
  45915. private _lightAngleOffset;
  45916. /**
  45917. * Gets the cone angle of the spot light in Radians.
  45918. */
  45919. /**
  45920. * Sets the cone angle of the spot light in Radians.
  45921. */
  45922. angle: number;
  45923. /**
  45924. * Only used in gltf falloff mode, this defines the angle where
  45925. * the directional falloff will start before cutting at angle which could be seen
  45926. * as outer angle.
  45927. */
  45928. /**
  45929. * Only used in gltf falloff mode, this defines the angle where
  45930. * the directional falloff will start before cutting at angle which could be seen
  45931. * as outer angle.
  45932. */
  45933. innerAngle: number;
  45934. private _shadowAngleScale;
  45935. /**
  45936. * Allows scaling the angle of the light for shadow generation only.
  45937. */
  45938. /**
  45939. * Allows scaling the angle of the light for shadow generation only.
  45940. */
  45941. shadowAngleScale: number;
  45942. /**
  45943. * The light decay speed with the distance from the emission spot.
  45944. */
  45945. exponent: number;
  45946. private _projectionTextureMatrix;
  45947. /**
  45948. * Allows reading the projecton texture
  45949. */
  45950. readonly projectionTextureMatrix: Matrix;
  45951. protected _projectionTextureLightNear: number;
  45952. /**
  45953. * Gets the near clip of the Spotlight for texture projection.
  45954. */
  45955. /**
  45956. * Sets the near clip of the Spotlight for texture projection.
  45957. */
  45958. projectionTextureLightNear: number;
  45959. protected _projectionTextureLightFar: number;
  45960. /**
  45961. * Gets the far clip of the Spotlight for texture projection.
  45962. */
  45963. /**
  45964. * Sets the far clip of the Spotlight for texture projection.
  45965. */
  45966. projectionTextureLightFar: number;
  45967. protected _projectionTextureUpDirection: Vector3;
  45968. /**
  45969. * Gets the Up vector of the Spotlight for texture projection.
  45970. */
  45971. /**
  45972. * Sets the Up vector of the Spotlight for texture projection.
  45973. */
  45974. projectionTextureUpDirection: Vector3;
  45975. private _projectionTexture;
  45976. /**
  45977. * Gets the projection texture of the light.
  45978. */
  45979. /**
  45980. * Sets the projection texture of the light.
  45981. */
  45982. projectionTexture: Nullable<BaseTexture>;
  45983. private _projectionTextureViewLightDirty;
  45984. private _projectionTextureProjectionLightDirty;
  45985. private _projectionTextureDirty;
  45986. private _projectionTextureViewTargetVector;
  45987. private _projectionTextureViewLightMatrix;
  45988. private _projectionTextureProjectionLightMatrix;
  45989. private _projectionTextureScalingMatrix;
  45990. /**
  45991. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45992. * It can cast shadows.
  45993. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45994. * @param name The light friendly name
  45995. * @param position The position of the spot light in the scene
  45996. * @param direction The direction of the light in the scene
  45997. * @param angle The cone angle of the light in Radians
  45998. * @param exponent The light decay speed with the distance from the emission spot
  45999. * @param scene The scene the lights belongs to
  46000. */
  46001. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46002. /**
  46003. * Returns the string "SpotLight".
  46004. * @returns the class name
  46005. */
  46006. getClassName(): string;
  46007. /**
  46008. * Returns the integer 2.
  46009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46010. */
  46011. getTypeID(): number;
  46012. /**
  46013. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46014. */
  46015. protected _setDirection(value: Vector3): void;
  46016. /**
  46017. * Overrides the position setter to recompute the projection texture view light Matrix.
  46018. */
  46019. protected _setPosition(value: Vector3): void;
  46020. /**
  46021. * 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.
  46022. * Returns the SpotLight.
  46023. */
  46024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46025. protected _computeProjectionTextureViewLightMatrix(): void;
  46026. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46027. /**
  46028. * Main function for light texture projection matrix computing.
  46029. */
  46030. protected _computeProjectionTextureMatrix(): void;
  46031. protected _buildUniformLayout(): void;
  46032. private _computeAngleValues;
  46033. /**
  46034. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46035. * @param effect The effect to update
  46036. * @param lightIndex The index of the light in the effect to update
  46037. * @returns The spot light
  46038. */
  46039. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46040. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46041. /**
  46042. * Disposes the light and the associated resources.
  46043. */
  46044. dispose(): void;
  46045. /**
  46046. * Prepares the list of defines specific to the light type.
  46047. * @param defines the list of defines
  46048. * @param lightIndex defines the index of the light for the effect
  46049. */
  46050. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46051. }
  46052. }
  46053. declare module BABYLON {
  46054. /**
  46055. * Gizmo that enables viewing a light
  46056. */
  46057. export class LightGizmo extends Gizmo {
  46058. private _lightMesh;
  46059. private _material;
  46060. private cachedPosition;
  46061. private cachedForward;
  46062. /**
  46063. * Creates a LightGizmo
  46064. * @param gizmoLayer The utility layer the gizmo will be added to
  46065. */
  46066. constructor(gizmoLayer?: UtilityLayerRenderer);
  46067. private _light;
  46068. /**
  46069. * The light that the gizmo is attached to
  46070. */
  46071. light: Nullable<Light>;
  46072. /**
  46073. * Gets the material used to render the light gizmo
  46074. */
  46075. readonly material: StandardMaterial;
  46076. /**
  46077. * @hidden
  46078. * Updates the gizmo to match the attached mesh's position/rotation
  46079. */
  46080. protected _update(): void;
  46081. private static _Scale;
  46082. /**
  46083. * Creates the lines for a light mesh
  46084. */
  46085. private static _createLightLines;
  46086. /**
  46087. * Disposes of the light gizmo
  46088. */
  46089. dispose(): void;
  46090. private static _CreateHemisphericLightMesh;
  46091. private static _CreatePointLightMesh;
  46092. private static _CreateSpotLightMesh;
  46093. private static _CreateDirectionalLightMesh;
  46094. }
  46095. }
  46096. declare module BABYLON {
  46097. /** @hidden */
  46098. export var backgroundFragmentDeclaration: {
  46099. name: string;
  46100. shader: string;
  46101. };
  46102. }
  46103. declare module BABYLON {
  46104. /** @hidden */
  46105. export var backgroundUboDeclaration: {
  46106. name: string;
  46107. shader: string;
  46108. };
  46109. }
  46110. declare module BABYLON {
  46111. /** @hidden */
  46112. export var backgroundPixelShader: {
  46113. name: string;
  46114. shader: string;
  46115. };
  46116. }
  46117. declare module BABYLON {
  46118. /** @hidden */
  46119. export var backgroundVertexDeclaration: {
  46120. name: string;
  46121. shader: string;
  46122. };
  46123. }
  46124. declare module BABYLON {
  46125. /** @hidden */
  46126. export var backgroundVertexShader: {
  46127. name: string;
  46128. shader: string;
  46129. };
  46130. }
  46131. declare module BABYLON {
  46132. /**
  46133. * Background material used to create an efficient environement around your scene.
  46134. */
  46135. export class BackgroundMaterial extends PushMaterial {
  46136. /**
  46137. * Standard reflectance value at parallel view angle.
  46138. */
  46139. static StandardReflectance0: number;
  46140. /**
  46141. * Standard reflectance value at grazing angle.
  46142. */
  46143. static StandardReflectance90: number;
  46144. protected _primaryColor: Color3;
  46145. /**
  46146. * Key light Color (multiply against the environement texture)
  46147. */
  46148. primaryColor: Color3;
  46149. protected __perceptualColor: Nullable<Color3>;
  46150. /**
  46151. * Experimental Internal Use Only.
  46152. *
  46153. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46154. * This acts as a helper to set the primary color to a more "human friendly" value.
  46155. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46156. * output color as close as possible from the chosen value.
  46157. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46158. * part of lighting setup.)
  46159. */
  46160. _perceptualColor: Nullable<Color3>;
  46161. protected _primaryColorShadowLevel: float;
  46162. /**
  46163. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46164. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46165. */
  46166. primaryColorShadowLevel: float;
  46167. protected _primaryColorHighlightLevel: float;
  46168. /**
  46169. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46170. * The primary color is used at the level chosen to define what the white area would look.
  46171. */
  46172. primaryColorHighlightLevel: float;
  46173. protected _reflectionTexture: Nullable<BaseTexture>;
  46174. /**
  46175. * Reflection Texture used in the material.
  46176. * Should be author in a specific way for the best result (refer to the documentation).
  46177. */
  46178. reflectionTexture: Nullable<BaseTexture>;
  46179. protected _reflectionBlur: float;
  46180. /**
  46181. * Reflection Texture level of blur.
  46182. *
  46183. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46184. * texture twice.
  46185. */
  46186. reflectionBlur: float;
  46187. protected _diffuseTexture: Nullable<BaseTexture>;
  46188. /**
  46189. * Diffuse Texture used in the material.
  46190. * Should be author in a specific way for the best result (refer to the documentation).
  46191. */
  46192. diffuseTexture: Nullable<BaseTexture>;
  46193. protected _shadowLights: Nullable<IShadowLight[]>;
  46194. /**
  46195. * Specify the list of lights casting shadow on the material.
  46196. * All scene shadow lights will be included if null.
  46197. */
  46198. shadowLights: Nullable<IShadowLight[]>;
  46199. protected _shadowLevel: float;
  46200. /**
  46201. * Helps adjusting the shadow to a softer level if required.
  46202. * 0 means black shadows and 1 means no shadows.
  46203. */
  46204. shadowLevel: float;
  46205. protected _sceneCenter: Vector3;
  46206. /**
  46207. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46208. * It is usually zero but might be interesting to modify according to your setup.
  46209. */
  46210. sceneCenter: Vector3;
  46211. protected _opacityFresnel: boolean;
  46212. /**
  46213. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46214. * This helps ensuring a nice transition when the camera goes under the ground.
  46215. */
  46216. opacityFresnel: boolean;
  46217. protected _reflectionFresnel: boolean;
  46218. /**
  46219. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46220. * This helps adding a mirror texture on the ground.
  46221. */
  46222. reflectionFresnel: boolean;
  46223. protected _reflectionFalloffDistance: number;
  46224. /**
  46225. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46226. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46227. */
  46228. reflectionFalloffDistance: number;
  46229. protected _reflectionAmount: number;
  46230. /**
  46231. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46232. */
  46233. reflectionAmount: number;
  46234. protected _reflectionReflectance0: number;
  46235. /**
  46236. * This specifies the weight of the reflection at grazing angle.
  46237. */
  46238. reflectionReflectance0: number;
  46239. protected _reflectionReflectance90: number;
  46240. /**
  46241. * This specifies the weight of the reflection at a perpendicular point of view.
  46242. */
  46243. reflectionReflectance90: number;
  46244. /**
  46245. * Sets the reflection reflectance fresnel values according to the default standard
  46246. * empirically know to work well :-)
  46247. */
  46248. reflectionStandardFresnelWeight: number;
  46249. protected _useRGBColor: boolean;
  46250. /**
  46251. * Helps to directly use the maps channels instead of their level.
  46252. */
  46253. useRGBColor: boolean;
  46254. protected _enableNoise: boolean;
  46255. /**
  46256. * This helps reducing the banding effect that could occur on the background.
  46257. */
  46258. enableNoise: boolean;
  46259. /**
  46260. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46261. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46262. * Recommended to be keep at 1.0 except for special cases.
  46263. */
  46264. fovMultiplier: number;
  46265. private _fovMultiplier;
  46266. /**
  46267. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46268. */
  46269. useEquirectangularFOV: boolean;
  46270. private _maxSimultaneousLights;
  46271. /**
  46272. * Number of Simultaneous lights allowed on the material.
  46273. */
  46274. maxSimultaneousLights: int;
  46275. /**
  46276. * Default configuration related to image processing available in the Background Material.
  46277. */
  46278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46279. /**
  46280. * Keep track of the image processing observer to allow dispose and replace.
  46281. */
  46282. private _imageProcessingObserver;
  46283. /**
  46284. * Attaches a new image processing configuration to the PBR Material.
  46285. * @param configuration (if null the scene configuration will be use)
  46286. */
  46287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46288. /**
  46289. * Gets the image processing configuration used either in this material.
  46290. */
  46291. /**
  46292. * Sets the Default image processing configuration used either in the this material.
  46293. *
  46294. * If sets to null, the scene one is in use.
  46295. */
  46296. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46297. /**
  46298. * Gets wether the color curves effect is enabled.
  46299. */
  46300. /**
  46301. * Sets wether the color curves effect is enabled.
  46302. */
  46303. cameraColorCurvesEnabled: boolean;
  46304. /**
  46305. * Gets wether the color grading effect is enabled.
  46306. */
  46307. /**
  46308. * Gets wether the color grading effect is enabled.
  46309. */
  46310. cameraColorGradingEnabled: boolean;
  46311. /**
  46312. * Gets wether tonemapping is enabled or not.
  46313. */
  46314. /**
  46315. * Sets wether tonemapping is enabled or not
  46316. */
  46317. cameraToneMappingEnabled: boolean;
  46318. /**
  46319. * The camera exposure used on this material.
  46320. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46321. * This corresponds to a photographic exposure.
  46322. */
  46323. /**
  46324. * The camera exposure used on this material.
  46325. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46326. * This corresponds to a photographic exposure.
  46327. */
  46328. cameraExposure: float;
  46329. /**
  46330. * Gets The camera contrast used on this material.
  46331. */
  46332. /**
  46333. * Sets The camera contrast used on this material.
  46334. */
  46335. cameraContrast: float;
  46336. /**
  46337. * Gets the Color Grading 2D Lookup Texture.
  46338. */
  46339. /**
  46340. * Sets the Color Grading 2D Lookup Texture.
  46341. */
  46342. cameraColorGradingTexture: Nullable<BaseTexture>;
  46343. /**
  46344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46346. * 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;
  46347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46348. */
  46349. /**
  46350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46352. * 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;
  46353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46354. */
  46355. cameraColorCurves: Nullable<ColorCurves>;
  46356. /**
  46357. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46358. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46359. */
  46360. switchToBGR: boolean;
  46361. private _renderTargets;
  46362. private _reflectionControls;
  46363. private _white;
  46364. private _primaryShadowColor;
  46365. private _primaryHighlightColor;
  46366. /**
  46367. * Instantiates a Background Material in the given scene
  46368. * @param name The friendly name of the material
  46369. * @param scene The scene to add the material to
  46370. */
  46371. constructor(name: string, scene: Scene);
  46372. /**
  46373. * Gets a boolean indicating that current material needs to register RTT
  46374. */
  46375. readonly hasRenderTargetTextures: boolean;
  46376. /**
  46377. * The entire material has been created in order to prevent overdraw.
  46378. * @returns false
  46379. */
  46380. needAlphaTesting(): boolean;
  46381. /**
  46382. * The entire material has been created in order to prevent overdraw.
  46383. * @returns true if blending is enable
  46384. */
  46385. needAlphaBlending(): boolean;
  46386. /**
  46387. * Checks wether the material is ready to be rendered for a given mesh.
  46388. * @param mesh The mesh to render
  46389. * @param subMesh The submesh to check against
  46390. * @param useInstances Specify wether or not the material is used with instances
  46391. * @returns true if all the dependencies are ready (Textures, Effects...)
  46392. */
  46393. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46394. /**
  46395. * Compute the primary color according to the chosen perceptual color.
  46396. */
  46397. private _computePrimaryColorFromPerceptualColor;
  46398. /**
  46399. * Compute the highlights and shadow colors according to their chosen levels.
  46400. */
  46401. private _computePrimaryColors;
  46402. /**
  46403. * Build the uniform buffer used in the material.
  46404. */
  46405. buildUniformLayout(): void;
  46406. /**
  46407. * Unbind the material.
  46408. */
  46409. unbind(): void;
  46410. /**
  46411. * Bind only the world matrix to the material.
  46412. * @param world The world matrix to bind.
  46413. */
  46414. bindOnlyWorldMatrix(world: Matrix): void;
  46415. /**
  46416. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46417. * @param world The world matrix to bind.
  46418. * @param subMesh The submesh to bind for.
  46419. */
  46420. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46421. /**
  46422. * Checks to see if a texture is used in the material.
  46423. * @param texture - Base texture to use.
  46424. * @returns - Boolean specifying if a texture is used in the material.
  46425. */
  46426. hasTexture(texture: BaseTexture): boolean;
  46427. /**
  46428. * Dispose the material.
  46429. * @param forceDisposeEffect Force disposal of the associated effect.
  46430. * @param forceDisposeTextures Force disposal of the associated textures.
  46431. */
  46432. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46433. /**
  46434. * Clones the material.
  46435. * @param name The cloned name.
  46436. * @returns The cloned material.
  46437. */
  46438. clone(name: string): BackgroundMaterial;
  46439. /**
  46440. * Serializes the current material to its JSON representation.
  46441. * @returns The JSON representation.
  46442. */
  46443. serialize(): any;
  46444. /**
  46445. * Gets the class name of the material
  46446. * @returns "BackgroundMaterial"
  46447. */
  46448. getClassName(): string;
  46449. /**
  46450. * Parse a JSON input to create back a background material.
  46451. * @param source The JSON data to parse
  46452. * @param scene The scene to create the parsed material in
  46453. * @param rootUrl The root url of the assets the material depends upon
  46454. * @returns the instantiated BackgroundMaterial.
  46455. */
  46456. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46457. }
  46458. }
  46459. declare module BABYLON {
  46460. /**
  46461. * Represents the different options available during the creation of
  46462. * a Environment helper.
  46463. *
  46464. * This can control the default ground, skybox and image processing setup of your scene.
  46465. */
  46466. export interface IEnvironmentHelperOptions {
  46467. /**
  46468. * Specifies wether or not to create a ground.
  46469. * True by default.
  46470. */
  46471. createGround: boolean;
  46472. /**
  46473. * Specifies the ground size.
  46474. * 15 by default.
  46475. */
  46476. groundSize: number;
  46477. /**
  46478. * The texture used on the ground for the main color.
  46479. * Comes from the BabylonJS CDN by default.
  46480. *
  46481. * Remarks: Can be either a texture or a url.
  46482. */
  46483. groundTexture: string | BaseTexture;
  46484. /**
  46485. * The color mixed in the ground texture by default.
  46486. * BabylonJS clearColor by default.
  46487. */
  46488. groundColor: Color3;
  46489. /**
  46490. * Specifies the ground opacity.
  46491. * 1 by default.
  46492. */
  46493. groundOpacity: number;
  46494. /**
  46495. * Enables the ground to receive shadows.
  46496. * True by default.
  46497. */
  46498. enableGroundShadow: boolean;
  46499. /**
  46500. * Helps preventing the shadow to be fully black on the ground.
  46501. * 0.5 by default.
  46502. */
  46503. groundShadowLevel: number;
  46504. /**
  46505. * Creates a mirror texture attach to the ground.
  46506. * false by default.
  46507. */
  46508. enableGroundMirror: boolean;
  46509. /**
  46510. * Specifies the ground mirror size ratio.
  46511. * 0.3 by default as the default kernel is 64.
  46512. */
  46513. groundMirrorSizeRatio: number;
  46514. /**
  46515. * Specifies the ground mirror blur kernel size.
  46516. * 64 by default.
  46517. */
  46518. groundMirrorBlurKernel: number;
  46519. /**
  46520. * Specifies the ground mirror visibility amount.
  46521. * 1 by default
  46522. */
  46523. groundMirrorAmount: number;
  46524. /**
  46525. * Specifies the ground mirror reflectance weight.
  46526. * This uses the standard weight of the background material to setup the fresnel effect
  46527. * of the mirror.
  46528. * 1 by default.
  46529. */
  46530. groundMirrorFresnelWeight: number;
  46531. /**
  46532. * Specifies the ground mirror Falloff distance.
  46533. * This can helps reducing the size of the reflection.
  46534. * 0 by Default.
  46535. */
  46536. groundMirrorFallOffDistance: number;
  46537. /**
  46538. * Specifies the ground mirror texture type.
  46539. * Unsigned Int by Default.
  46540. */
  46541. groundMirrorTextureType: number;
  46542. /**
  46543. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46544. * the shown objects.
  46545. */
  46546. groundYBias: number;
  46547. /**
  46548. * Specifies wether or not to create a skybox.
  46549. * True by default.
  46550. */
  46551. createSkybox: boolean;
  46552. /**
  46553. * Specifies the skybox size.
  46554. * 20 by default.
  46555. */
  46556. skyboxSize: number;
  46557. /**
  46558. * The texture used on the skybox for the main color.
  46559. * Comes from the BabylonJS CDN by default.
  46560. *
  46561. * Remarks: Can be either a texture or a url.
  46562. */
  46563. skyboxTexture: string | BaseTexture;
  46564. /**
  46565. * The color mixed in the skybox texture by default.
  46566. * BabylonJS clearColor by default.
  46567. */
  46568. skyboxColor: Color3;
  46569. /**
  46570. * The background rotation around the Y axis of the scene.
  46571. * This helps aligning the key lights of your scene with the background.
  46572. * 0 by default.
  46573. */
  46574. backgroundYRotation: number;
  46575. /**
  46576. * Compute automatically the size of the elements to best fit with the scene.
  46577. */
  46578. sizeAuto: boolean;
  46579. /**
  46580. * Default position of the rootMesh if autoSize is not true.
  46581. */
  46582. rootPosition: Vector3;
  46583. /**
  46584. * Sets up the image processing in the scene.
  46585. * true by default.
  46586. */
  46587. setupImageProcessing: boolean;
  46588. /**
  46589. * The texture used as your environment texture in the scene.
  46590. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46591. *
  46592. * Remarks: Can be either a texture or a url.
  46593. */
  46594. environmentTexture: string | BaseTexture;
  46595. /**
  46596. * The value of the exposure to apply to the scene.
  46597. * 0.6 by default if setupImageProcessing is true.
  46598. */
  46599. cameraExposure: number;
  46600. /**
  46601. * The value of the contrast to apply to the scene.
  46602. * 1.6 by default if setupImageProcessing is true.
  46603. */
  46604. cameraContrast: number;
  46605. /**
  46606. * Specifies wether or not tonemapping should be enabled in the scene.
  46607. * true by default if setupImageProcessing is true.
  46608. */
  46609. toneMappingEnabled: boolean;
  46610. }
  46611. /**
  46612. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46613. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46614. * It also helps with the default setup of your imageProcessing configuration.
  46615. */
  46616. export class EnvironmentHelper {
  46617. /**
  46618. * Default ground texture URL.
  46619. */
  46620. private static _groundTextureCDNUrl;
  46621. /**
  46622. * Default skybox texture URL.
  46623. */
  46624. private static _skyboxTextureCDNUrl;
  46625. /**
  46626. * Default environment texture URL.
  46627. */
  46628. private static _environmentTextureCDNUrl;
  46629. /**
  46630. * Creates the default options for the helper.
  46631. */
  46632. private static _getDefaultOptions;
  46633. private _rootMesh;
  46634. /**
  46635. * Gets the root mesh created by the helper.
  46636. */
  46637. readonly rootMesh: Mesh;
  46638. private _skybox;
  46639. /**
  46640. * Gets the skybox created by the helper.
  46641. */
  46642. readonly skybox: Nullable<Mesh>;
  46643. private _skyboxTexture;
  46644. /**
  46645. * Gets the skybox texture created by the helper.
  46646. */
  46647. readonly skyboxTexture: Nullable<BaseTexture>;
  46648. private _skyboxMaterial;
  46649. /**
  46650. * Gets the skybox material created by the helper.
  46651. */
  46652. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46653. private _ground;
  46654. /**
  46655. * Gets the ground mesh created by the helper.
  46656. */
  46657. readonly ground: Nullable<Mesh>;
  46658. private _groundTexture;
  46659. /**
  46660. * Gets the ground texture created by the helper.
  46661. */
  46662. readonly groundTexture: Nullable<BaseTexture>;
  46663. private _groundMirror;
  46664. /**
  46665. * Gets the ground mirror created by the helper.
  46666. */
  46667. readonly groundMirror: Nullable<MirrorTexture>;
  46668. /**
  46669. * Gets the ground mirror render list to helps pushing the meshes
  46670. * you wish in the ground reflection.
  46671. */
  46672. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46673. private _groundMaterial;
  46674. /**
  46675. * Gets the ground material created by the helper.
  46676. */
  46677. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46678. /**
  46679. * Stores the creation options.
  46680. */
  46681. private readonly _scene;
  46682. private _options;
  46683. /**
  46684. * This observable will be notified with any error during the creation of the environment,
  46685. * mainly texture creation errors.
  46686. */
  46687. onErrorObservable: Observable<{
  46688. message?: string;
  46689. exception?: any;
  46690. }>;
  46691. /**
  46692. * constructor
  46693. * @param options Defines the options we want to customize the helper
  46694. * @param scene The scene to add the material to
  46695. */
  46696. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46697. /**
  46698. * Updates the background according to the new options
  46699. * @param options
  46700. */
  46701. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46702. /**
  46703. * Sets the primary color of all the available elements.
  46704. * @param color the main color to affect to the ground and the background
  46705. */
  46706. setMainColor(color: Color3): void;
  46707. /**
  46708. * Setup the image processing according to the specified options.
  46709. */
  46710. private _setupImageProcessing;
  46711. /**
  46712. * Setup the environment texture according to the specified options.
  46713. */
  46714. private _setupEnvironmentTexture;
  46715. /**
  46716. * Setup the background according to the specified options.
  46717. */
  46718. private _setupBackground;
  46719. /**
  46720. * Get the scene sizes according to the setup.
  46721. */
  46722. private _getSceneSize;
  46723. /**
  46724. * Setup the ground according to the specified options.
  46725. */
  46726. private _setupGround;
  46727. /**
  46728. * Setup the ground material according to the specified options.
  46729. */
  46730. private _setupGroundMaterial;
  46731. /**
  46732. * Setup the ground diffuse texture according to the specified options.
  46733. */
  46734. private _setupGroundDiffuseTexture;
  46735. /**
  46736. * Setup the ground mirror texture according to the specified options.
  46737. */
  46738. private _setupGroundMirrorTexture;
  46739. /**
  46740. * Setup the ground to receive the mirror texture.
  46741. */
  46742. private _setupMirrorInGroundMaterial;
  46743. /**
  46744. * Setup the skybox according to the specified options.
  46745. */
  46746. private _setupSkybox;
  46747. /**
  46748. * Setup the skybox material according to the specified options.
  46749. */
  46750. private _setupSkyboxMaterial;
  46751. /**
  46752. * Setup the skybox reflection texture according to the specified options.
  46753. */
  46754. private _setupSkyboxReflectionTexture;
  46755. private _errorHandler;
  46756. /**
  46757. * Dispose all the elements created by the Helper.
  46758. */
  46759. dispose(): void;
  46760. }
  46761. }
  46762. declare module BABYLON {
  46763. /**
  46764. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46765. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46766. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46767. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46768. */
  46769. export class PhotoDome extends TransformNode {
  46770. /**
  46771. * Define the image as a Monoscopic panoramic 360 image.
  46772. */
  46773. static readonly MODE_MONOSCOPIC: number;
  46774. /**
  46775. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46776. */
  46777. static readonly MODE_TOPBOTTOM: number;
  46778. /**
  46779. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46780. */
  46781. static readonly MODE_SIDEBYSIDE: number;
  46782. private _useDirectMapping;
  46783. /**
  46784. * The texture being displayed on the sphere
  46785. */
  46786. protected _photoTexture: Texture;
  46787. /**
  46788. * Gets or sets the texture being displayed on the sphere
  46789. */
  46790. photoTexture: Texture;
  46791. /**
  46792. * Observable raised when an error occured while loading the 360 image
  46793. */
  46794. onLoadErrorObservable: Observable<string>;
  46795. /**
  46796. * The skybox material
  46797. */
  46798. protected _material: BackgroundMaterial;
  46799. /**
  46800. * The surface used for the skybox
  46801. */
  46802. protected _mesh: Mesh;
  46803. /**
  46804. * Gets the mesh used for the skybox.
  46805. */
  46806. readonly mesh: Mesh;
  46807. /**
  46808. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46809. * Also see the options.resolution property.
  46810. */
  46811. fovMultiplier: number;
  46812. private _imageMode;
  46813. /**
  46814. * Gets or set the current video mode for the video. It can be:
  46815. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46816. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46817. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46818. */
  46819. imageMode: number;
  46820. /**
  46821. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46822. * @param name Element's name, child elements will append suffixes for their own names.
  46823. * @param urlsOfPhoto defines the url of the photo to display
  46824. * @param options defines an object containing optional or exposed sub element properties
  46825. * @param onError defines a callback called when an error occured while loading the texture
  46826. */
  46827. constructor(name: string, urlOfPhoto: string, options: {
  46828. resolution?: number;
  46829. size?: number;
  46830. useDirectMapping?: boolean;
  46831. faceForward?: boolean;
  46832. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46833. private _onBeforeCameraRenderObserver;
  46834. private _changeImageMode;
  46835. /**
  46836. * Releases resources associated with this node.
  46837. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46838. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46839. */
  46840. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46841. }
  46842. }
  46843. declare module BABYLON {
  46844. /**
  46845. * Class used to host RGBD texture specific utilities
  46846. */
  46847. export class RGBDTextureTools {
  46848. /**
  46849. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46850. * @param texture the texture to expand.
  46851. */
  46852. static ExpandRGBDTexture(texture: Texture): void;
  46853. }
  46854. }
  46855. declare module BABYLON {
  46856. /**
  46857. * Class used to host texture specific utilities
  46858. */
  46859. export class BRDFTextureTools {
  46860. /**
  46861. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46862. * @param scene defines the hosting scene
  46863. * @returns the environment BRDF texture
  46864. */
  46865. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46866. private static _environmentBRDFBase64Texture;
  46867. }
  46868. }
  46869. declare module BABYLON {
  46870. /**
  46871. * @hidden
  46872. */
  46873. export interface IMaterialClearCoatDefines {
  46874. CLEARCOAT: boolean;
  46875. CLEARCOAT_DEFAULTIOR: boolean;
  46876. CLEARCOAT_TEXTURE: boolean;
  46877. CLEARCOAT_TEXTUREDIRECTUV: number;
  46878. CLEARCOAT_BUMP: boolean;
  46879. CLEARCOAT_BUMPDIRECTUV: number;
  46880. CLEARCOAT_TINT: boolean;
  46881. CLEARCOAT_TINT_TEXTURE: boolean;
  46882. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46883. /** @hidden */
  46884. _areTexturesDirty: boolean;
  46885. }
  46886. /**
  46887. * Define the code related to the clear coat parameters of the pbr material.
  46888. */
  46889. export class PBRClearCoatConfiguration {
  46890. /**
  46891. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46892. * The default fits with a polyurethane material.
  46893. */
  46894. private static readonly _DefaultIndexOfRefraction;
  46895. private _isEnabled;
  46896. /**
  46897. * Defines if the clear coat is enabled in the material.
  46898. */
  46899. isEnabled: boolean;
  46900. /**
  46901. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46902. */
  46903. intensity: number;
  46904. /**
  46905. * Defines the clear coat layer roughness.
  46906. */
  46907. roughness: number;
  46908. private _indexOfRefraction;
  46909. /**
  46910. * Defines the index of refraction of the clear coat.
  46911. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46912. * The default fits with a polyurethane material.
  46913. * Changing the default value is more performance intensive.
  46914. */
  46915. indexOfRefraction: number;
  46916. private _texture;
  46917. /**
  46918. * Stores the clear coat values in a texture.
  46919. */
  46920. texture: Nullable<BaseTexture>;
  46921. private _bumpTexture;
  46922. /**
  46923. * Define the clear coat specific bump texture.
  46924. */
  46925. bumpTexture: Nullable<BaseTexture>;
  46926. private _isTintEnabled;
  46927. /**
  46928. * Defines if the clear coat tint is enabled in the material.
  46929. */
  46930. isTintEnabled: boolean;
  46931. /**
  46932. * Defines the clear coat tint of the material.
  46933. * This is only use if tint is enabled
  46934. */
  46935. tintColor: Color3;
  46936. /**
  46937. * Defines the distance at which the tint color should be found in the
  46938. * clear coat media.
  46939. * This is only use if tint is enabled
  46940. */
  46941. tintColorAtDistance: number;
  46942. /**
  46943. * Defines the clear coat layer thickness.
  46944. * This is only use if tint is enabled
  46945. */
  46946. tintThickness: number;
  46947. private _tintTexture;
  46948. /**
  46949. * Stores the clear tint values in a texture.
  46950. * rgb is tint
  46951. * a is a thickness factor
  46952. */
  46953. tintTexture: Nullable<BaseTexture>;
  46954. /** @hidden */
  46955. private _internalMarkAllSubMeshesAsTexturesDirty;
  46956. /** @hidden */
  46957. _markAllSubMeshesAsTexturesDirty(): void;
  46958. /**
  46959. * Instantiate a new istance of clear coat configuration.
  46960. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46961. */
  46962. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46963. /**
  46964. * Gets wehter the submesh is ready to be used or not.
  46965. * @param defines the list of "defines" to update.
  46966. * @param scene defines the scene the material belongs to.
  46967. * @param engine defines the engine the material belongs to.
  46968. * @param disableBumpMap defines wether the material disables bump or not.
  46969. * @returns - boolean indicating that the submesh is ready or not.
  46970. */
  46971. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46972. /**
  46973. * Checks to see if a texture is used in the material.
  46974. * @param defines the list of "defines" to update.
  46975. * @param scene defines the scene to the material belongs to.
  46976. */
  46977. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46978. /**
  46979. * Binds the material data.
  46980. * @param uniformBuffer defines the Uniform buffer to fill in.
  46981. * @param scene defines the scene the material belongs to.
  46982. * @param engine defines the engine the material belongs to.
  46983. * @param disableBumpMap defines wether the material disables bump or not.
  46984. * @param isFrozen defines wether the material is frozen or not.
  46985. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46986. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46987. */
  46988. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46989. /**
  46990. * Checks to see if a texture is used in the material.
  46991. * @param texture - Base texture to use.
  46992. * @returns - Boolean specifying if a texture is used in the material.
  46993. */
  46994. hasTexture(texture: BaseTexture): boolean;
  46995. /**
  46996. * Returns an array of the actively used textures.
  46997. * @param activeTextures Array of BaseTextures
  46998. */
  46999. getActiveTextures(activeTextures: BaseTexture[]): void;
  47000. /**
  47001. * Returns the animatable textures.
  47002. * @param animatables Array of animatable textures.
  47003. */
  47004. getAnimatables(animatables: IAnimatable[]): void;
  47005. /**
  47006. * Disposes the resources of the material.
  47007. * @param forceDisposeTextures - Forces the disposal of all textures.
  47008. */
  47009. dispose(forceDisposeTextures?: boolean): void;
  47010. /**
  47011. * Get the current class name of the texture useful for serialization or dynamic coding.
  47012. * @returns "PBRClearCoatConfiguration"
  47013. */
  47014. getClassName(): string;
  47015. /**
  47016. * Add fallbacks to the effect fallbacks list.
  47017. * @param defines defines the Base texture to use.
  47018. * @param fallbacks defines the current fallback list.
  47019. * @param currentRank defines the current fallback rank.
  47020. * @returns the new fallback rank.
  47021. */
  47022. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47023. /**
  47024. * Add the required uniforms to the current list.
  47025. * @param uniforms defines the current uniform list.
  47026. */
  47027. static AddUniforms(uniforms: string[]): void;
  47028. /**
  47029. * Add the required samplers to the current list.
  47030. * @param samplers defines the current sampler list.
  47031. */
  47032. static AddSamplers(samplers: string[]): void;
  47033. /**
  47034. * Add the required uniforms to the current buffer.
  47035. * @param uniformBuffer defines the current uniform buffer.
  47036. */
  47037. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47038. /**
  47039. * Makes a duplicate of the current configuration into another one.
  47040. * @param clearCoatConfiguration define the config where to copy the info
  47041. */
  47042. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47043. /**
  47044. * Serializes this clear coat configuration.
  47045. * @returns - An object with the serialized config.
  47046. */
  47047. serialize(): any;
  47048. /**
  47049. * Parses a anisotropy Configuration from a serialized object.
  47050. * @param source - Serialized object.
  47051. * @param scene Defines the scene we are parsing for
  47052. * @param rootUrl Defines the rootUrl to load from
  47053. */
  47054. parse(source: any, scene: Scene, rootUrl: string): void;
  47055. }
  47056. }
  47057. declare module BABYLON {
  47058. /**
  47059. * @hidden
  47060. */
  47061. export interface IMaterialAnisotropicDefines {
  47062. ANISOTROPIC: boolean;
  47063. ANISOTROPIC_TEXTURE: boolean;
  47064. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47065. MAINUV1: boolean;
  47066. _areTexturesDirty: boolean;
  47067. _needUVs: boolean;
  47068. }
  47069. /**
  47070. * Define the code related to the anisotropic parameters of the pbr material.
  47071. */
  47072. export class PBRAnisotropicConfiguration {
  47073. private _isEnabled;
  47074. /**
  47075. * Defines if the anisotropy is enabled in the material.
  47076. */
  47077. isEnabled: boolean;
  47078. /**
  47079. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47080. */
  47081. intensity: number;
  47082. /**
  47083. * Defines if the effect is along the tangents, bitangents or in between.
  47084. * By default, the effect is "strectching" the highlights along the tangents.
  47085. */
  47086. direction: Vector2;
  47087. private _texture;
  47088. /**
  47089. * Stores the anisotropy values in a texture.
  47090. * rg is direction (like normal from -1 to 1)
  47091. * b is a intensity
  47092. */
  47093. texture: Nullable<BaseTexture>;
  47094. /** @hidden */
  47095. private _internalMarkAllSubMeshesAsTexturesDirty;
  47096. /** @hidden */
  47097. _markAllSubMeshesAsTexturesDirty(): void;
  47098. /**
  47099. * Instantiate a new istance of anisotropy configuration.
  47100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47101. */
  47102. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47103. /**
  47104. * Specifies that the submesh is ready to be used.
  47105. * @param defines the list of "defines" to update.
  47106. * @param scene defines the scene the material belongs to.
  47107. * @returns - boolean indicating that the submesh is ready or not.
  47108. */
  47109. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47110. /**
  47111. * Checks to see if a texture is used in the material.
  47112. * @param defines the list of "defines" to update.
  47113. * @param mesh the mesh we are preparing the defines for.
  47114. * @param scene defines the scene the material belongs to.
  47115. */
  47116. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47117. /**
  47118. * Binds the material data.
  47119. * @param uniformBuffer defines the Uniform buffer to fill in.
  47120. * @param scene defines the scene the material belongs to.
  47121. * @param isFrozen defines wether the material is frozen or not.
  47122. */
  47123. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47124. /**
  47125. * Checks to see if a texture is used in the material.
  47126. * @param texture - Base texture to use.
  47127. * @returns - Boolean specifying if a texture is used in the material.
  47128. */
  47129. hasTexture(texture: BaseTexture): boolean;
  47130. /**
  47131. * Returns an array of the actively used textures.
  47132. * @param activeTextures Array of BaseTextures
  47133. */
  47134. getActiveTextures(activeTextures: BaseTexture[]): void;
  47135. /**
  47136. * Returns the animatable textures.
  47137. * @param animatables Array of animatable textures.
  47138. */
  47139. getAnimatables(animatables: IAnimatable[]): void;
  47140. /**
  47141. * Disposes the resources of the material.
  47142. * @param forceDisposeTextures - Forces the disposal of all textures.
  47143. */
  47144. dispose(forceDisposeTextures?: boolean): void;
  47145. /**
  47146. * Get the current class name of the texture useful for serialization or dynamic coding.
  47147. * @returns "PBRAnisotropicConfiguration"
  47148. */
  47149. getClassName(): string;
  47150. /**
  47151. * Add fallbacks to the effect fallbacks list.
  47152. * @param defines defines the Base texture to use.
  47153. * @param fallbacks defines the current fallback list.
  47154. * @param currentRank defines the current fallback rank.
  47155. * @returns the new fallback rank.
  47156. */
  47157. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47158. /**
  47159. * Add the required uniforms to the current list.
  47160. * @param uniforms defines the current uniform list.
  47161. */
  47162. static AddUniforms(uniforms: string[]): void;
  47163. /**
  47164. * Add the required uniforms to the current buffer.
  47165. * @param uniformBuffer defines the current uniform buffer.
  47166. */
  47167. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47168. /**
  47169. * Add the required samplers to the current list.
  47170. * @param samplers defines the current sampler list.
  47171. */
  47172. static AddSamplers(samplers: string[]): void;
  47173. /**
  47174. * Makes a duplicate of the current configuration into another one.
  47175. * @param anisotropicConfiguration define the config where to copy the info
  47176. */
  47177. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47178. /**
  47179. * Serializes this anisotropy configuration.
  47180. * @returns - An object with the serialized config.
  47181. */
  47182. serialize(): any;
  47183. /**
  47184. * Parses a anisotropy Configuration from a serialized object.
  47185. * @param source - Serialized object.
  47186. * @param scene Defines the scene we are parsing for
  47187. * @param rootUrl Defines the rootUrl to load from
  47188. */
  47189. parse(source: any, scene: Scene, rootUrl: string): void;
  47190. }
  47191. }
  47192. declare module BABYLON {
  47193. /**
  47194. * @hidden
  47195. */
  47196. export interface IMaterialBRDFDefines {
  47197. BRDF_V_HEIGHT_CORRELATED: boolean;
  47198. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47199. SPHERICAL_HARMONICS: boolean;
  47200. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47201. /** @hidden */
  47202. _areMiscDirty: boolean;
  47203. }
  47204. /**
  47205. * Define the code related to the BRDF parameters of the pbr material.
  47206. */
  47207. export class PBRBRDFConfiguration {
  47208. /**
  47209. * Default value used for the energy conservation.
  47210. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47211. */
  47212. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47213. /**
  47214. * Default value used for the Smith Visibility Height Correlated mode.
  47215. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47216. */
  47217. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47218. /**
  47219. * Default value used for the IBL diffuse part.
  47220. * This can help switching back to the polynomials mode globally which is a tiny bit
  47221. * less GPU intensive at the drawback of a lower quality.
  47222. */
  47223. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47224. /**
  47225. * Default value used for activating energy conservation for the specular workflow.
  47226. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47227. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47228. */
  47229. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47230. private _useEnergyConservation;
  47231. /**
  47232. * Defines if the material uses energy conservation.
  47233. */
  47234. useEnergyConservation: boolean;
  47235. private _useSmithVisibilityHeightCorrelated;
  47236. /**
  47237. * LEGACY Mode set to false
  47238. * Defines if the material uses height smith correlated visibility term.
  47239. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47240. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47241. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47242. * Not relying on height correlated will also disable energy conservation.
  47243. */
  47244. useSmithVisibilityHeightCorrelated: boolean;
  47245. private _useSphericalHarmonics;
  47246. /**
  47247. * LEGACY Mode set to false
  47248. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47249. * diffuse part of the IBL.
  47250. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47251. * to the ground truth.
  47252. */
  47253. useSphericalHarmonics: boolean;
  47254. private _useSpecularGlossinessInputEnergyConservation;
  47255. /**
  47256. * Defines if the material uses energy conservation, when the specular workflow is active.
  47257. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47258. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47259. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47260. */
  47261. useSpecularGlossinessInputEnergyConservation: boolean;
  47262. /** @hidden */
  47263. private _internalMarkAllSubMeshesAsMiscDirty;
  47264. /** @hidden */
  47265. _markAllSubMeshesAsMiscDirty(): void;
  47266. /**
  47267. * Instantiate a new istance of clear coat configuration.
  47268. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47269. */
  47270. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47271. /**
  47272. * Checks to see if a texture is used in the material.
  47273. * @param defines the list of "defines" to update.
  47274. */
  47275. prepareDefines(defines: IMaterialBRDFDefines): void;
  47276. /**
  47277. * Get the current class name of the texture useful for serialization or dynamic coding.
  47278. * @returns "PBRClearCoatConfiguration"
  47279. */
  47280. getClassName(): string;
  47281. /**
  47282. * Makes a duplicate of the current configuration into another one.
  47283. * @param brdfConfiguration define the config where to copy the info
  47284. */
  47285. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47286. /**
  47287. * Serializes this BRDF configuration.
  47288. * @returns - An object with the serialized config.
  47289. */
  47290. serialize(): any;
  47291. /**
  47292. * Parses a anisotropy Configuration from a serialized object.
  47293. * @param source - Serialized object.
  47294. * @param scene Defines the scene we are parsing for
  47295. * @param rootUrl Defines the rootUrl to load from
  47296. */
  47297. parse(source: any, scene: Scene, rootUrl: string): void;
  47298. }
  47299. }
  47300. declare module BABYLON {
  47301. /**
  47302. * @hidden
  47303. */
  47304. export interface IMaterialSheenDefines {
  47305. SHEEN: boolean;
  47306. SHEEN_TEXTURE: boolean;
  47307. SHEEN_TEXTUREDIRECTUV: number;
  47308. SHEEN_LINKWITHALBEDO: boolean;
  47309. /** @hidden */
  47310. _areTexturesDirty: boolean;
  47311. }
  47312. /**
  47313. * Define the code related to the Sheen parameters of the pbr material.
  47314. */
  47315. export class PBRSheenConfiguration {
  47316. private _isEnabled;
  47317. /**
  47318. * Defines if the material uses sheen.
  47319. */
  47320. isEnabled: boolean;
  47321. private _linkSheenWithAlbedo;
  47322. /**
  47323. * Defines if the sheen is linked to the sheen color.
  47324. */
  47325. linkSheenWithAlbedo: boolean;
  47326. /**
  47327. * Defines the sheen intensity.
  47328. */
  47329. intensity: number;
  47330. /**
  47331. * Defines the sheen color.
  47332. */
  47333. color: Color3;
  47334. private _texture;
  47335. /**
  47336. * Stores the sheen tint values in a texture.
  47337. * rgb is tint
  47338. * a is a intensity
  47339. */
  47340. texture: Nullable<BaseTexture>;
  47341. /** @hidden */
  47342. private _internalMarkAllSubMeshesAsTexturesDirty;
  47343. /** @hidden */
  47344. _markAllSubMeshesAsTexturesDirty(): void;
  47345. /**
  47346. * Instantiate a new istance of clear coat configuration.
  47347. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47348. */
  47349. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47350. /**
  47351. * Specifies that the submesh is ready to be used.
  47352. * @param defines the list of "defines" to update.
  47353. * @param scene defines the scene the material belongs to.
  47354. * @returns - boolean indicating that the submesh is ready or not.
  47355. */
  47356. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47357. /**
  47358. * Checks to see if a texture is used in the material.
  47359. * @param defines the list of "defines" to update.
  47360. * @param scene defines the scene the material belongs to.
  47361. */
  47362. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47363. /**
  47364. * Binds the material data.
  47365. * @param uniformBuffer defines the Uniform buffer to fill in.
  47366. * @param scene defines the scene the material belongs to.
  47367. * @param isFrozen defines wether the material is frozen or not.
  47368. */
  47369. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47370. /**
  47371. * Checks to see if a texture is used in the material.
  47372. * @param texture - Base texture to use.
  47373. * @returns - Boolean specifying if a texture is used in the material.
  47374. */
  47375. hasTexture(texture: BaseTexture): boolean;
  47376. /**
  47377. * Returns an array of the actively used textures.
  47378. * @param activeTextures Array of BaseTextures
  47379. */
  47380. getActiveTextures(activeTextures: BaseTexture[]): void;
  47381. /**
  47382. * Returns the animatable textures.
  47383. * @param animatables Array of animatable textures.
  47384. */
  47385. getAnimatables(animatables: IAnimatable[]): void;
  47386. /**
  47387. * Disposes the resources of the material.
  47388. * @param forceDisposeTextures - Forces the disposal of all textures.
  47389. */
  47390. dispose(forceDisposeTextures?: boolean): void;
  47391. /**
  47392. * Get the current class name of the texture useful for serialization or dynamic coding.
  47393. * @returns "PBRSheenConfiguration"
  47394. */
  47395. getClassName(): string;
  47396. /**
  47397. * Add fallbacks to the effect fallbacks list.
  47398. * @param defines defines the Base texture to use.
  47399. * @param fallbacks defines the current fallback list.
  47400. * @param currentRank defines the current fallback rank.
  47401. * @returns the new fallback rank.
  47402. */
  47403. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47404. /**
  47405. * Add the required uniforms to the current list.
  47406. * @param uniforms defines the current uniform list.
  47407. */
  47408. static AddUniforms(uniforms: string[]): void;
  47409. /**
  47410. * Add the required uniforms to the current buffer.
  47411. * @param uniformBuffer defines the current uniform buffer.
  47412. */
  47413. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47414. /**
  47415. * Add the required samplers to the current list.
  47416. * @param samplers defines the current sampler list.
  47417. */
  47418. static AddSamplers(samplers: string[]): void;
  47419. /**
  47420. * Makes a duplicate of the current configuration into another one.
  47421. * @param sheenConfiguration define the config where to copy the info
  47422. */
  47423. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47424. /**
  47425. * Serializes this BRDF configuration.
  47426. * @returns - An object with the serialized config.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Parses a anisotropy Configuration from a serialized object.
  47431. * @param source - Serialized object.
  47432. * @param scene Defines the scene we are parsing for
  47433. * @param rootUrl Defines the rootUrl to load from
  47434. */
  47435. parse(source: any, scene: Scene, rootUrl: string): void;
  47436. }
  47437. }
  47438. declare module BABYLON {
  47439. /**
  47440. * @hidden
  47441. */
  47442. export interface IMaterialSubSurfaceDefines {
  47443. SUBSURFACE: boolean;
  47444. SS_REFRACTION: boolean;
  47445. SS_TRANSLUCENCY: boolean;
  47446. SS_SCATERRING: boolean;
  47447. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47448. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47449. SS_REFRACTIONMAP_3D: boolean;
  47450. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47451. SS_LODINREFRACTIONALPHA: boolean;
  47452. SS_GAMMAREFRACTION: boolean;
  47453. SS_RGBDREFRACTION: boolean;
  47454. SS_LINEARSPECULARREFRACTION: boolean;
  47455. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47456. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47457. /** @hidden */
  47458. _areTexturesDirty: boolean;
  47459. }
  47460. /**
  47461. * Define the code related to the sub surface parameters of the pbr material.
  47462. */
  47463. export class PBRSubSurfaceConfiguration {
  47464. private _isRefractionEnabled;
  47465. /**
  47466. * Defines if the refraction is enabled in the material.
  47467. */
  47468. isRefractionEnabled: boolean;
  47469. private _isTranslucencyEnabled;
  47470. /**
  47471. * Defines if the translucency is enabled in the material.
  47472. */
  47473. isTranslucencyEnabled: boolean;
  47474. private _isScatteringEnabled;
  47475. /**
  47476. * Defines the refraction intensity of the material.
  47477. * The refraction when enabled replaces the Diffuse part of the material.
  47478. * The intensity helps transitionning between diffuse and refraction.
  47479. */
  47480. refractionIntensity: number;
  47481. /**
  47482. * Defines the translucency intensity of the material.
  47483. * When translucency has been enabled, this defines how much of the "translucency"
  47484. * is addded to the diffuse part of the material.
  47485. */
  47486. translucencyIntensity: number;
  47487. /**
  47488. * Defines the scattering intensity of the material.
  47489. * When scattering has been enabled, this defines how much of the "scattered light"
  47490. * is addded to the diffuse part of the material.
  47491. */
  47492. scatteringIntensity: number;
  47493. private _thicknessTexture;
  47494. /**
  47495. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47496. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47497. * 0 would mean minimumThickness
  47498. * 1 would mean maximumThickness
  47499. * The other channels might be use as a mask to vary the different effects intensity.
  47500. */
  47501. thicknessTexture: Nullable<BaseTexture>;
  47502. private _refractionTexture;
  47503. /**
  47504. * Defines the texture to use for refraction.
  47505. */
  47506. refractionTexture: Nullable<BaseTexture>;
  47507. private _indexOfRefraction;
  47508. /**
  47509. * Defines the index of refraction used in the material.
  47510. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47511. */
  47512. indexOfRefraction: number;
  47513. private _invertRefractionY;
  47514. /**
  47515. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47516. */
  47517. invertRefractionY: boolean;
  47518. private _linkRefractionWithTransparency;
  47519. /**
  47520. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47521. * Materials half opaque for instance using refraction could benefit from this control.
  47522. */
  47523. linkRefractionWithTransparency: boolean;
  47524. /**
  47525. * Defines the minimum thickness stored in the thickness map.
  47526. * If no thickness map is defined, this value will be used to simulate thickness.
  47527. */
  47528. minimumThickness: number;
  47529. /**
  47530. * Defines the maximum thickness stored in the thickness map.
  47531. */
  47532. maximumThickness: number;
  47533. /**
  47534. * Defines the volume tint of the material.
  47535. * This is used for both translucency and scattering.
  47536. */
  47537. tintColor: Color3;
  47538. /**
  47539. * Defines the distance at which the tint color should be found in the media.
  47540. * This is used for refraction only.
  47541. */
  47542. tintColorAtDistance: number;
  47543. /**
  47544. * Defines how far each channel transmit through the media.
  47545. * It is defined as a color to simplify it selection.
  47546. */
  47547. diffusionDistance: Color3;
  47548. private _useMaskFromThicknessTexture;
  47549. /**
  47550. * Stores the intensity of the different subsurface effects in the thickness texture.
  47551. * * the green channel is the translucency intensity.
  47552. * * the blue channel is the scattering intensity.
  47553. * * the alpha channel is the refraction intensity.
  47554. */
  47555. useMaskFromThicknessTexture: boolean;
  47556. /** @hidden */
  47557. private _internalMarkAllSubMeshesAsTexturesDirty;
  47558. /** @hidden */
  47559. _markAllSubMeshesAsTexturesDirty(): void;
  47560. /**
  47561. * Instantiate a new istance of sub surface configuration.
  47562. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47563. */
  47564. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47565. /**
  47566. * Gets wehter the submesh is ready to be used or not.
  47567. * @param defines the list of "defines" to update.
  47568. * @param scene defines the scene the material belongs to.
  47569. * @returns - boolean indicating that the submesh is ready or not.
  47570. */
  47571. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47572. /**
  47573. * Checks to see if a texture is used in the material.
  47574. * @param defines the list of "defines" to update.
  47575. * @param scene defines the scene to the material belongs to.
  47576. */
  47577. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47578. /**
  47579. * Binds the material data.
  47580. * @param uniformBuffer defines the Uniform buffer to fill in.
  47581. * @param scene defines the scene the material belongs to.
  47582. * @param engine defines the engine the material belongs to.
  47583. * @param isFrozen defines wether the material is frozen or not.
  47584. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47585. */
  47586. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47587. /**
  47588. * Unbinds the material from the mesh.
  47589. * @param activeEffect defines the effect that should be unbound from.
  47590. * @returns true if unbound, otherwise false
  47591. */
  47592. unbind(activeEffect: Effect): boolean;
  47593. /**
  47594. * Returns the texture used for refraction or null if none is used.
  47595. * @param scene defines the scene the material belongs to.
  47596. * @returns - Refraction texture if present. If no refraction texture and refraction
  47597. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47598. */
  47599. private _getRefractionTexture;
  47600. /**
  47601. * Returns true if alpha blending should be disabled.
  47602. */
  47603. readonly disableAlphaBlending: boolean;
  47604. /**
  47605. * Fills the list of render target textures.
  47606. * @param renderTargets the list of render targets to update
  47607. */
  47608. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47609. /**
  47610. * Checks to see if a texture is used in the material.
  47611. * @param texture - Base texture to use.
  47612. * @returns - Boolean specifying if a texture is used in the material.
  47613. */
  47614. hasTexture(texture: BaseTexture): boolean;
  47615. /**
  47616. * Gets a boolean indicating that current material needs to register RTT
  47617. * @returns true if this uses a render target otherwise false.
  47618. */
  47619. hasRenderTargetTextures(): boolean;
  47620. /**
  47621. * Returns an array of the actively used textures.
  47622. * @param activeTextures Array of BaseTextures
  47623. */
  47624. getActiveTextures(activeTextures: BaseTexture[]): void;
  47625. /**
  47626. * Returns the animatable textures.
  47627. * @param animatables Array of animatable textures.
  47628. */
  47629. getAnimatables(animatables: IAnimatable[]): void;
  47630. /**
  47631. * Disposes the resources of the material.
  47632. * @param forceDisposeTextures - Forces the disposal of all textures.
  47633. */
  47634. dispose(forceDisposeTextures?: boolean): void;
  47635. /**
  47636. * Get the current class name of the texture useful for serialization or dynamic coding.
  47637. * @returns "PBRSubSurfaceConfiguration"
  47638. */
  47639. getClassName(): string;
  47640. /**
  47641. * Add fallbacks to the effect fallbacks list.
  47642. * @param defines defines the Base texture to use.
  47643. * @param fallbacks defines the current fallback list.
  47644. * @param currentRank defines the current fallback rank.
  47645. * @returns the new fallback rank.
  47646. */
  47647. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47648. /**
  47649. * Add the required uniforms to the current list.
  47650. * @param uniforms defines the current uniform list.
  47651. */
  47652. static AddUniforms(uniforms: string[]): void;
  47653. /**
  47654. * Add the required samplers to the current list.
  47655. * @param samplers defines the current sampler list.
  47656. */
  47657. static AddSamplers(samplers: string[]): void;
  47658. /**
  47659. * Add the required uniforms to the current buffer.
  47660. * @param uniformBuffer defines the current uniform buffer.
  47661. */
  47662. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47663. /**
  47664. * Makes a duplicate of the current configuration into another one.
  47665. * @param configuration define the config where to copy the info
  47666. */
  47667. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47668. /**
  47669. * Serializes this Sub Surface configuration.
  47670. * @returns - An object with the serialized config.
  47671. */
  47672. serialize(): any;
  47673. /**
  47674. * Parses a anisotropy Configuration from a serialized object.
  47675. * @param source - Serialized object.
  47676. * @param scene Defines the scene we are parsing for
  47677. * @param rootUrl Defines the rootUrl to load from
  47678. */
  47679. parse(source: any, scene: Scene, rootUrl: string): void;
  47680. }
  47681. }
  47682. declare module BABYLON {
  47683. /** @hidden */
  47684. export var pbrFragmentDeclaration: {
  47685. name: string;
  47686. shader: string;
  47687. };
  47688. }
  47689. declare module BABYLON {
  47690. /** @hidden */
  47691. export var pbrUboDeclaration: {
  47692. name: string;
  47693. shader: string;
  47694. };
  47695. }
  47696. declare module BABYLON {
  47697. /** @hidden */
  47698. export var pbrFragmentExtraDeclaration: {
  47699. name: string;
  47700. shader: string;
  47701. };
  47702. }
  47703. declare module BABYLON {
  47704. /** @hidden */
  47705. export var pbrFragmentSamplersDeclaration: {
  47706. name: string;
  47707. shader: string;
  47708. };
  47709. }
  47710. declare module BABYLON {
  47711. /** @hidden */
  47712. export var pbrHelperFunctions: {
  47713. name: string;
  47714. shader: string;
  47715. };
  47716. }
  47717. declare module BABYLON {
  47718. /** @hidden */
  47719. export var harmonicsFunctions: {
  47720. name: string;
  47721. shader: string;
  47722. };
  47723. }
  47724. declare module BABYLON {
  47725. /** @hidden */
  47726. export var pbrDirectLightingSetupFunctions: {
  47727. name: string;
  47728. shader: string;
  47729. };
  47730. }
  47731. declare module BABYLON {
  47732. /** @hidden */
  47733. export var pbrDirectLightingFalloffFunctions: {
  47734. name: string;
  47735. shader: string;
  47736. };
  47737. }
  47738. declare module BABYLON {
  47739. /** @hidden */
  47740. export var pbrBRDFFunctions: {
  47741. name: string;
  47742. shader: string;
  47743. };
  47744. }
  47745. declare module BABYLON {
  47746. /** @hidden */
  47747. export var pbrDirectLightingFunctions: {
  47748. name: string;
  47749. shader: string;
  47750. };
  47751. }
  47752. declare module BABYLON {
  47753. /** @hidden */
  47754. export var pbrIBLFunctions: {
  47755. name: string;
  47756. shader: string;
  47757. };
  47758. }
  47759. declare module BABYLON {
  47760. /** @hidden */
  47761. export var pbrDebug: {
  47762. name: string;
  47763. shader: string;
  47764. };
  47765. }
  47766. declare module BABYLON {
  47767. /** @hidden */
  47768. export var pbrPixelShader: {
  47769. name: string;
  47770. shader: string;
  47771. };
  47772. }
  47773. declare module BABYLON {
  47774. /** @hidden */
  47775. export var pbrVertexDeclaration: {
  47776. name: string;
  47777. shader: string;
  47778. };
  47779. }
  47780. declare module BABYLON {
  47781. /** @hidden */
  47782. export var pbrVertexShader: {
  47783. name: string;
  47784. shader: string;
  47785. };
  47786. }
  47787. declare module BABYLON {
  47788. /**
  47789. * Manages the defines for the PBR Material.
  47790. * @hidden
  47791. */
  47792. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47793. PBR: boolean;
  47794. MAINUV1: boolean;
  47795. MAINUV2: boolean;
  47796. UV1: boolean;
  47797. UV2: boolean;
  47798. ALBEDO: boolean;
  47799. ALBEDODIRECTUV: number;
  47800. VERTEXCOLOR: boolean;
  47801. AMBIENT: boolean;
  47802. AMBIENTDIRECTUV: number;
  47803. AMBIENTINGRAYSCALE: boolean;
  47804. OPACITY: boolean;
  47805. VERTEXALPHA: boolean;
  47806. OPACITYDIRECTUV: number;
  47807. OPACITYRGB: boolean;
  47808. ALPHATEST: boolean;
  47809. DEPTHPREPASS: boolean;
  47810. ALPHABLEND: boolean;
  47811. ALPHAFROMALBEDO: boolean;
  47812. ALPHATESTVALUE: string;
  47813. SPECULAROVERALPHA: boolean;
  47814. RADIANCEOVERALPHA: boolean;
  47815. ALPHAFRESNEL: boolean;
  47816. LINEARALPHAFRESNEL: boolean;
  47817. PREMULTIPLYALPHA: boolean;
  47818. EMISSIVE: boolean;
  47819. EMISSIVEDIRECTUV: number;
  47820. REFLECTIVITY: boolean;
  47821. REFLECTIVITYDIRECTUV: number;
  47822. SPECULARTERM: boolean;
  47823. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47824. MICROSURFACEAUTOMATIC: boolean;
  47825. LODBASEDMICROSFURACE: boolean;
  47826. MICROSURFACEMAP: boolean;
  47827. MICROSURFACEMAPDIRECTUV: number;
  47828. METALLICWORKFLOW: boolean;
  47829. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47830. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47831. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47832. AOSTOREINMETALMAPRED: boolean;
  47833. METALLICF0FACTORFROMMETALLICMAP: boolean;
  47834. ENVIRONMENTBRDF: boolean;
  47835. ENVIRONMENTBRDF_RGBD: boolean;
  47836. NORMAL: boolean;
  47837. TANGENT: boolean;
  47838. BUMP: boolean;
  47839. BUMPDIRECTUV: number;
  47840. OBJECTSPACE_NORMALMAP: boolean;
  47841. PARALLAX: boolean;
  47842. PARALLAXOCCLUSION: boolean;
  47843. NORMALXYSCALE: boolean;
  47844. LIGHTMAP: boolean;
  47845. LIGHTMAPDIRECTUV: number;
  47846. USELIGHTMAPASSHADOWMAP: boolean;
  47847. GAMMALIGHTMAP: boolean;
  47848. RGBDLIGHTMAP: boolean;
  47849. REFLECTION: boolean;
  47850. REFLECTIONMAP_3D: boolean;
  47851. REFLECTIONMAP_SPHERICAL: boolean;
  47852. REFLECTIONMAP_PLANAR: boolean;
  47853. REFLECTIONMAP_CUBIC: boolean;
  47854. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47855. REFLECTIONMAP_PROJECTION: boolean;
  47856. REFLECTIONMAP_SKYBOX: boolean;
  47857. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47858. REFLECTIONMAP_EXPLICIT: boolean;
  47859. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47860. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47861. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47862. INVERTCUBICMAP: boolean;
  47863. USESPHERICALFROMREFLECTIONMAP: boolean;
  47864. USEIRRADIANCEMAP: boolean;
  47865. SPHERICAL_HARMONICS: boolean;
  47866. USESPHERICALINVERTEX: boolean;
  47867. REFLECTIONMAP_OPPOSITEZ: boolean;
  47868. LODINREFLECTIONALPHA: boolean;
  47869. GAMMAREFLECTION: boolean;
  47870. RGBDREFLECTION: boolean;
  47871. LINEARSPECULARREFLECTION: boolean;
  47872. RADIANCEOCCLUSION: boolean;
  47873. HORIZONOCCLUSION: boolean;
  47874. INSTANCES: boolean;
  47875. NUM_BONE_INFLUENCERS: number;
  47876. BonesPerMesh: number;
  47877. BONETEXTURE: boolean;
  47878. NONUNIFORMSCALING: boolean;
  47879. MORPHTARGETS: boolean;
  47880. MORPHTARGETS_NORMAL: boolean;
  47881. MORPHTARGETS_TANGENT: boolean;
  47882. MORPHTARGETS_UV: boolean;
  47883. NUM_MORPH_INFLUENCERS: number;
  47884. IMAGEPROCESSING: boolean;
  47885. VIGNETTE: boolean;
  47886. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47887. VIGNETTEBLENDMODEOPAQUE: boolean;
  47888. TONEMAPPING: boolean;
  47889. TONEMAPPING_ACES: boolean;
  47890. CONTRAST: boolean;
  47891. COLORCURVES: boolean;
  47892. COLORGRADING: boolean;
  47893. COLORGRADING3D: boolean;
  47894. SAMPLER3DGREENDEPTH: boolean;
  47895. SAMPLER3DBGRMAP: boolean;
  47896. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47897. EXPOSURE: boolean;
  47898. MULTIVIEW: boolean;
  47899. USEPHYSICALLIGHTFALLOFF: boolean;
  47900. USEGLTFLIGHTFALLOFF: boolean;
  47901. TWOSIDEDLIGHTING: boolean;
  47902. SHADOWFLOAT: boolean;
  47903. CLIPPLANE: boolean;
  47904. CLIPPLANE2: boolean;
  47905. CLIPPLANE3: boolean;
  47906. CLIPPLANE4: boolean;
  47907. POINTSIZE: boolean;
  47908. FOG: boolean;
  47909. LOGARITHMICDEPTH: boolean;
  47910. FORCENORMALFORWARD: boolean;
  47911. SPECULARAA: boolean;
  47912. CLEARCOAT: boolean;
  47913. CLEARCOAT_DEFAULTIOR: boolean;
  47914. CLEARCOAT_TEXTURE: boolean;
  47915. CLEARCOAT_TEXTUREDIRECTUV: number;
  47916. CLEARCOAT_BUMP: boolean;
  47917. CLEARCOAT_BUMPDIRECTUV: number;
  47918. CLEARCOAT_TINT: boolean;
  47919. CLEARCOAT_TINT_TEXTURE: boolean;
  47920. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47921. ANISOTROPIC: boolean;
  47922. ANISOTROPIC_TEXTURE: boolean;
  47923. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47924. BRDF_V_HEIGHT_CORRELATED: boolean;
  47925. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47926. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47927. SHEEN: boolean;
  47928. SHEEN_TEXTURE: boolean;
  47929. SHEEN_TEXTUREDIRECTUV: number;
  47930. SHEEN_LINKWITHALBEDO: boolean;
  47931. SUBSURFACE: boolean;
  47932. SS_REFRACTION: boolean;
  47933. SS_TRANSLUCENCY: boolean;
  47934. SS_SCATERRING: boolean;
  47935. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47936. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47937. SS_REFRACTIONMAP_3D: boolean;
  47938. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47939. SS_LODINREFRACTIONALPHA: boolean;
  47940. SS_GAMMAREFRACTION: boolean;
  47941. SS_RGBDREFRACTION: boolean;
  47942. SS_LINEARSPECULARREFRACTION: boolean;
  47943. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47944. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47945. UNLIT: boolean;
  47946. DEBUGMODE: number;
  47947. /**
  47948. * Initializes the PBR Material defines.
  47949. */
  47950. constructor();
  47951. /**
  47952. * Resets the PBR Material defines.
  47953. */
  47954. reset(): void;
  47955. }
  47956. /**
  47957. * The Physically based material base class of BJS.
  47958. *
  47959. * This offers the main features of a standard PBR material.
  47960. * For more information, please refer to the documentation :
  47961. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47962. */
  47963. export abstract class PBRBaseMaterial extends PushMaterial {
  47964. /**
  47965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47966. */
  47967. static readonly PBRMATERIAL_OPAQUE: number;
  47968. /**
  47969. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47970. */
  47971. static readonly PBRMATERIAL_ALPHATEST: number;
  47972. /**
  47973. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47974. */
  47975. static readonly PBRMATERIAL_ALPHABLEND: number;
  47976. /**
  47977. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47978. * They are also discarded below the alpha cutoff threshold to improve performances.
  47979. */
  47980. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47981. /**
  47982. * Defines the default value of how much AO map is occluding the analytical lights
  47983. * (point spot...).
  47984. */
  47985. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47986. /**
  47987. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47988. */
  47989. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47990. /**
  47991. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47992. * to enhance interoperability with other engines.
  47993. */
  47994. static readonly LIGHTFALLOFF_GLTF: number;
  47995. /**
  47996. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47997. * to enhance interoperability with other materials.
  47998. */
  47999. static readonly LIGHTFALLOFF_STANDARD: number;
  48000. /**
  48001. * Intensity of the direct lights e.g. the four lights available in your scene.
  48002. * This impacts both the direct diffuse and specular highlights.
  48003. */
  48004. protected _directIntensity: number;
  48005. /**
  48006. * Intensity of the emissive part of the material.
  48007. * This helps controlling the emissive effect without modifying the emissive color.
  48008. */
  48009. protected _emissiveIntensity: number;
  48010. /**
  48011. * Intensity of the environment e.g. how much the environment will light the object
  48012. * either through harmonics for rough material or through the refelction for shiny ones.
  48013. */
  48014. protected _environmentIntensity: number;
  48015. /**
  48016. * This is a special control allowing the reduction of the specular highlights coming from the
  48017. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48018. */
  48019. protected _specularIntensity: number;
  48020. /**
  48021. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48022. */
  48023. private _lightingInfos;
  48024. /**
  48025. * Debug Control allowing disabling the bump map on this material.
  48026. */
  48027. protected _disableBumpMap: boolean;
  48028. /**
  48029. * AKA Diffuse Texture in standard nomenclature.
  48030. */
  48031. protected _albedoTexture: Nullable<BaseTexture>;
  48032. /**
  48033. * AKA Occlusion Texture in other nomenclature.
  48034. */
  48035. protected _ambientTexture: Nullable<BaseTexture>;
  48036. /**
  48037. * AKA Occlusion Texture Intensity in other nomenclature.
  48038. */
  48039. protected _ambientTextureStrength: number;
  48040. /**
  48041. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48042. * 1 means it completely occludes it
  48043. * 0 mean it has no impact
  48044. */
  48045. protected _ambientTextureImpactOnAnalyticalLights: number;
  48046. /**
  48047. * Stores the alpha values in a texture.
  48048. */
  48049. protected _opacityTexture: Nullable<BaseTexture>;
  48050. /**
  48051. * Stores the reflection values in a texture.
  48052. */
  48053. protected _reflectionTexture: Nullable<BaseTexture>;
  48054. /**
  48055. * Stores the emissive values in a texture.
  48056. */
  48057. protected _emissiveTexture: Nullable<BaseTexture>;
  48058. /**
  48059. * AKA Specular texture in other nomenclature.
  48060. */
  48061. protected _reflectivityTexture: Nullable<BaseTexture>;
  48062. /**
  48063. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48064. */
  48065. protected _metallicTexture: Nullable<BaseTexture>;
  48066. /**
  48067. * Specifies the metallic scalar of the metallic/roughness workflow.
  48068. * Can also be used to scale the metalness values of the metallic texture.
  48069. */
  48070. protected _metallic: Nullable<number>;
  48071. /**
  48072. * Specifies the roughness scalar of the metallic/roughness workflow.
  48073. * Can also be used to scale the roughness values of the metallic texture.
  48074. */
  48075. protected _roughness: Nullable<number>;
  48076. /**
  48077. * Specifies the an F0 factor to help configuring the material F0.
  48078. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48079. * to 0.5 the previously hard coded value stays the same.
  48080. * Can also be used to scale the F0 values of the metallic texture.
  48081. */
  48082. protected _metallicF0Factor: number;
  48083. /**
  48084. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48085. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48086. * your expectation as it multiplies with the texture data.
  48087. */
  48088. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48089. /**
  48090. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48091. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48092. */
  48093. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48094. /**
  48095. * Stores surface normal data used to displace a mesh in a texture.
  48096. */
  48097. protected _bumpTexture: Nullable<BaseTexture>;
  48098. /**
  48099. * Stores the pre-calculated light information of a mesh in a texture.
  48100. */
  48101. protected _lightmapTexture: Nullable<BaseTexture>;
  48102. /**
  48103. * The color of a material in ambient lighting.
  48104. */
  48105. protected _ambientColor: Color3;
  48106. /**
  48107. * AKA Diffuse Color in other nomenclature.
  48108. */
  48109. protected _albedoColor: Color3;
  48110. /**
  48111. * AKA Specular Color in other nomenclature.
  48112. */
  48113. protected _reflectivityColor: Color3;
  48114. /**
  48115. * The color applied when light is reflected from a material.
  48116. */
  48117. protected _reflectionColor: Color3;
  48118. /**
  48119. * The color applied when light is emitted from a material.
  48120. */
  48121. protected _emissiveColor: Color3;
  48122. /**
  48123. * AKA Glossiness in other nomenclature.
  48124. */
  48125. protected _microSurface: number;
  48126. /**
  48127. * Specifies that the material will use the light map as a show map.
  48128. */
  48129. protected _useLightmapAsShadowmap: boolean;
  48130. /**
  48131. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48132. * makes the reflect vector face the model (under horizon).
  48133. */
  48134. protected _useHorizonOcclusion: boolean;
  48135. /**
  48136. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48137. * too much the area relying on ambient texture to define their ambient occlusion.
  48138. */
  48139. protected _useRadianceOcclusion: boolean;
  48140. /**
  48141. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48142. */
  48143. protected _useAlphaFromAlbedoTexture: boolean;
  48144. /**
  48145. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48146. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48147. */
  48148. protected _useSpecularOverAlpha: boolean;
  48149. /**
  48150. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48151. */
  48152. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48153. /**
  48154. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48155. */
  48156. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48157. /**
  48158. * Specifies if the metallic texture contains the roughness information in its green channel.
  48159. */
  48160. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48161. /**
  48162. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48163. */
  48164. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48165. /**
  48166. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48167. */
  48168. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48169. /**
  48170. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48171. */
  48172. protected _useAmbientInGrayScale: boolean;
  48173. /**
  48174. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48175. * The material will try to infer what glossiness each pixel should be.
  48176. */
  48177. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48178. /**
  48179. * Defines the falloff type used in this material.
  48180. * It by default is Physical.
  48181. */
  48182. protected _lightFalloff: number;
  48183. /**
  48184. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48185. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48186. */
  48187. protected _useRadianceOverAlpha: boolean;
  48188. /**
  48189. * Allows using an object space normal map (instead of tangent space).
  48190. */
  48191. protected _useObjectSpaceNormalMap: boolean;
  48192. /**
  48193. * Allows using the bump map in parallax mode.
  48194. */
  48195. protected _useParallax: boolean;
  48196. /**
  48197. * Allows using the bump map in parallax occlusion mode.
  48198. */
  48199. protected _useParallaxOcclusion: boolean;
  48200. /**
  48201. * Controls the scale bias of the parallax mode.
  48202. */
  48203. protected _parallaxScaleBias: number;
  48204. /**
  48205. * If sets to true, disables all the lights affecting the material.
  48206. */
  48207. protected _disableLighting: boolean;
  48208. /**
  48209. * Number of Simultaneous lights allowed on the material.
  48210. */
  48211. protected _maxSimultaneousLights: number;
  48212. /**
  48213. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48214. */
  48215. protected _invertNormalMapX: boolean;
  48216. /**
  48217. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48218. */
  48219. protected _invertNormalMapY: boolean;
  48220. /**
  48221. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48222. */
  48223. protected _twoSidedLighting: boolean;
  48224. /**
  48225. * Defines the alpha limits in alpha test mode.
  48226. */
  48227. protected _alphaCutOff: number;
  48228. /**
  48229. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48230. */
  48231. protected _forceAlphaTest: boolean;
  48232. /**
  48233. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48234. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48235. */
  48236. protected _useAlphaFresnel: boolean;
  48237. /**
  48238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48239. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48240. */
  48241. protected _useLinearAlphaFresnel: boolean;
  48242. /**
  48243. * The transparency mode of the material.
  48244. */
  48245. protected _transparencyMode: Nullable<number>;
  48246. /**
  48247. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48248. * from cos thetav and roughness:
  48249. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48250. */
  48251. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48252. /**
  48253. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48254. */
  48255. protected _forceIrradianceInFragment: boolean;
  48256. /**
  48257. * Force normal to face away from face.
  48258. */
  48259. protected _forceNormalForward: boolean;
  48260. /**
  48261. * Enables specular anti aliasing in the PBR shader.
  48262. * It will both interacts on the Geometry for analytical and IBL lighting.
  48263. * It also prefilter the roughness map based on the bump values.
  48264. */
  48265. protected _enableSpecularAntiAliasing: boolean;
  48266. /**
  48267. * Default configuration related to image processing available in the PBR Material.
  48268. */
  48269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48270. /**
  48271. * Keep track of the image processing observer to allow dispose and replace.
  48272. */
  48273. private _imageProcessingObserver;
  48274. /**
  48275. * Attaches a new image processing configuration to the PBR Material.
  48276. * @param configuration
  48277. */
  48278. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48279. /**
  48280. * Stores the available render targets.
  48281. */
  48282. private _renderTargets;
  48283. /**
  48284. * Sets the global ambient color for the material used in lighting calculations.
  48285. */
  48286. private _globalAmbientColor;
  48287. /**
  48288. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48289. */
  48290. private _useLogarithmicDepth;
  48291. /**
  48292. * If set to true, no lighting calculations will be applied.
  48293. */
  48294. private _unlit;
  48295. private _debugMode;
  48296. /**
  48297. * @hidden
  48298. * This is reserved for the inspector.
  48299. * Defines the material debug mode.
  48300. * It helps seeing only some components of the material while troubleshooting.
  48301. */
  48302. debugMode: number;
  48303. /**
  48304. * @hidden
  48305. * This is reserved for the inspector.
  48306. * Specify from where on screen the debug mode should start.
  48307. * The value goes from -1 (full screen) to 1 (not visible)
  48308. * It helps with side by side comparison against the final render
  48309. * This defaults to -1
  48310. */
  48311. private debugLimit;
  48312. /**
  48313. * @hidden
  48314. * This is reserved for the inspector.
  48315. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48316. * You can use the factor to better multiply the final value.
  48317. */
  48318. private debugFactor;
  48319. /**
  48320. * Defines the clear coat layer parameters for the material.
  48321. */
  48322. readonly clearCoat: PBRClearCoatConfiguration;
  48323. /**
  48324. * Defines the anisotropic parameters for the material.
  48325. */
  48326. readonly anisotropy: PBRAnisotropicConfiguration;
  48327. /**
  48328. * Defines the BRDF parameters for the material.
  48329. */
  48330. readonly brdf: PBRBRDFConfiguration;
  48331. /**
  48332. * Defines the Sheen parameters for the material.
  48333. */
  48334. readonly sheen: PBRSheenConfiguration;
  48335. /**
  48336. * Defines the SubSurface parameters for the material.
  48337. */
  48338. readonly subSurface: PBRSubSurfaceConfiguration;
  48339. /**
  48340. * Custom callback helping to override the default shader used in the material.
  48341. */
  48342. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48343. protected _rebuildInParallel: boolean;
  48344. /**
  48345. * Instantiates a new PBRMaterial instance.
  48346. *
  48347. * @param name The material name
  48348. * @param scene The scene the material will be use in.
  48349. */
  48350. constructor(name: string, scene: Scene);
  48351. /**
  48352. * Gets a boolean indicating that current material needs to register RTT
  48353. */
  48354. readonly hasRenderTargetTextures: boolean;
  48355. /**
  48356. * Gets the name of the material class.
  48357. */
  48358. getClassName(): string;
  48359. /**
  48360. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48361. */
  48362. /**
  48363. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48364. */
  48365. useLogarithmicDepth: boolean;
  48366. /**
  48367. * Gets the current transparency mode.
  48368. */
  48369. /**
  48370. * Sets the transparency mode of the material.
  48371. *
  48372. * | Value | Type | Description |
  48373. * | ----- | ----------------------------------- | ----------- |
  48374. * | 0 | OPAQUE | |
  48375. * | 1 | ALPHATEST | |
  48376. * | 2 | ALPHABLEND | |
  48377. * | 3 | ALPHATESTANDBLEND | |
  48378. *
  48379. */
  48380. transparencyMode: Nullable<number>;
  48381. /**
  48382. * Returns true if alpha blending should be disabled.
  48383. */
  48384. private readonly _disableAlphaBlending;
  48385. /**
  48386. * Specifies whether or not this material should be rendered in alpha blend mode.
  48387. */
  48388. needAlphaBlending(): boolean;
  48389. /**
  48390. * Specifies if the mesh will require alpha blending.
  48391. * @param mesh - BJS mesh.
  48392. */
  48393. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48394. /**
  48395. * Specifies whether or not this material should be rendered in alpha test mode.
  48396. */
  48397. needAlphaTesting(): boolean;
  48398. /**
  48399. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48400. */
  48401. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48402. /**
  48403. * Gets the texture used for the alpha test.
  48404. */
  48405. getAlphaTestTexture(): Nullable<BaseTexture>;
  48406. /**
  48407. * Specifies that the submesh is ready to be used.
  48408. * @param mesh - BJS mesh.
  48409. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48410. * @param useInstances - Specifies that instances should be used.
  48411. * @returns - boolean indicating that the submesh is ready or not.
  48412. */
  48413. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48414. /**
  48415. * Specifies if the material uses metallic roughness workflow.
  48416. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48417. */
  48418. isMetallicWorkflow(): boolean;
  48419. private _prepareEffect;
  48420. private _prepareDefines;
  48421. /**
  48422. * Force shader compilation
  48423. */
  48424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48425. /**
  48426. * Initializes the uniform buffer layout for the shader.
  48427. */
  48428. buildUniformLayout(): void;
  48429. /**
  48430. * Unbinds the material from the mesh
  48431. */
  48432. unbind(): void;
  48433. /**
  48434. * Binds the submesh data.
  48435. * @param world - The world matrix.
  48436. * @param mesh - The BJS mesh.
  48437. * @param subMesh - A submesh of the BJS mesh.
  48438. */
  48439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48440. /**
  48441. * Returns the animatable textures.
  48442. * @returns - Array of animatable textures.
  48443. */
  48444. getAnimatables(): IAnimatable[];
  48445. /**
  48446. * Returns the texture used for reflections.
  48447. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48448. */
  48449. private _getReflectionTexture;
  48450. /**
  48451. * Returns an array of the actively used textures.
  48452. * @returns - Array of BaseTextures
  48453. */
  48454. getActiveTextures(): BaseTexture[];
  48455. /**
  48456. * Checks to see if a texture is used in the material.
  48457. * @param texture - Base texture to use.
  48458. * @returns - Boolean specifying if a texture is used in the material.
  48459. */
  48460. hasTexture(texture: BaseTexture): boolean;
  48461. /**
  48462. * Disposes the resources of the material.
  48463. * @param forceDisposeEffect - Forces the disposal of effects.
  48464. * @param forceDisposeTextures - Forces the disposal of all textures.
  48465. */
  48466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * The Physically based material of BJS.
  48472. *
  48473. * This offers the main features of a standard PBR material.
  48474. * For more information, please refer to the documentation :
  48475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48476. */
  48477. export class PBRMaterial extends PBRBaseMaterial {
  48478. /**
  48479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48480. */
  48481. static readonly PBRMATERIAL_OPAQUE: number;
  48482. /**
  48483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48484. */
  48485. static readonly PBRMATERIAL_ALPHATEST: number;
  48486. /**
  48487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48488. */
  48489. static readonly PBRMATERIAL_ALPHABLEND: number;
  48490. /**
  48491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48492. * They are also discarded below the alpha cutoff threshold to improve performances.
  48493. */
  48494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48495. /**
  48496. * Defines the default value of how much AO map is occluding the analytical lights
  48497. * (point spot...).
  48498. */
  48499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48500. /**
  48501. * Intensity of the direct lights e.g. the four lights available in your scene.
  48502. * This impacts both the direct diffuse and specular highlights.
  48503. */
  48504. directIntensity: number;
  48505. /**
  48506. * Intensity of the emissive part of the material.
  48507. * This helps controlling the emissive effect without modifying the emissive color.
  48508. */
  48509. emissiveIntensity: number;
  48510. /**
  48511. * Intensity of the environment e.g. how much the environment will light the object
  48512. * either through harmonics for rough material or through the refelction for shiny ones.
  48513. */
  48514. environmentIntensity: number;
  48515. /**
  48516. * This is a special control allowing the reduction of the specular highlights coming from the
  48517. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48518. */
  48519. specularIntensity: number;
  48520. /**
  48521. * Debug Control allowing disabling the bump map on this material.
  48522. */
  48523. disableBumpMap: boolean;
  48524. /**
  48525. * AKA Diffuse Texture in standard nomenclature.
  48526. */
  48527. albedoTexture: BaseTexture;
  48528. /**
  48529. * AKA Occlusion Texture in other nomenclature.
  48530. */
  48531. ambientTexture: BaseTexture;
  48532. /**
  48533. * AKA Occlusion Texture Intensity in other nomenclature.
  48534. */
  48535. ambientTextureStrength: number;
  48536. /**
  48537. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48538. * 1 means it completely occludes it
  48539. * 0 mean it has no impact
  48540. */
  48541. ambientTextureImpactOnAnalyticalLights: number;
  48542. /**
  48543. * Stores the alpha values in a texture.
  48544. */
  48545. opacityTexture: BaseTexture;
  48546. /**
  48547. * Stores the reflection values in a texture.
  48548. */
  48549. reflectionTexture: Nullable<BaseTexture>;
  48550. /**
  48551. * Stores the emissive values in a texture.
  48552. */
  48553. emissiveTexture: BaseTexture;
  48554. /**
  48555. * AKA Specular texture in other nomenclature.
  48556. */
  48557. reflectivityTexture: BaseTexture;
  48558. /**
  48559. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48560. */
  48561. metallicTexture: BaseTexture;
  48562. /**
  48563. * Specifies the metallic scalar of the metallic/roughness workflow.
  48564. * Can also be used to scale the metalness values of the metallic texture.
  48565. */
  48566. metallic: Nullable<number>;
  48567. /**
  48568. * Specifies the roughness scalar of the metallic/roughness workflow.
  48569. * Can also be used to scale the roughness values of the metallic texture.
  48570. */
  48571. roughness: Nullable<number>;
  48572. /**
  48573. * Specifies the an F0 factor to help configuring the material F0.
  48574. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48575. * to 0.5 the previously hard coded value stays the same.
  48576. * Can also be used to scale the F0 values of the metallic texture.
  48577. */
  48578. metallicF0Factor: number;
  48579. /**
  48580. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48581. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48582. * your expectation as it multiplies with the texture data.
  48583. */
  48584. useMetallicF0FactorFromMetallicTexture: boolean;
  48585. /**
  48586. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48587. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48588. */
  48589. microSurfaceTexture: BaseTexture;
  48590. /**
  48591. * Stores surface normal data used to displace a mesh in a texture.
  48592. */
  48593. bumpTexture: BaseTexture;
  48594. /**
  48595. * Stores the pre-calculated light information of a mesh in a texture.
  48596. */
  48597. lightmapTexture: BaseTexture;
  48598. /**
  48599. * Stores the refracted light information in a texture.
  48600. */
  48601. refractionTexture: Nullable<BaseTexture>;
  48602. /**
  48603. * The color of a material in ambient lighting.
  48604. */
  48605. ambientColor: Color3;
  48606. /**
  48607. * AKA Diffuse Color in other nomenclature.
  48608. */
  48609. albedoColor: Color3;
  48610. /**
  48611. * AKA Specular Color in other nomenclature.
  48612. */
  48613. reflectivityColor: Color3;
  48614. /**
  48615. * The color reflected from the material.
  48616. */
  48617. reflectionColor: Color3;
  48618. /**
  48619. * The color emitted from the material.
  48620. */
  48621. emissiveColor: Color3;
  48622. /**
  48623. * AKA Glossiness in other nomenclature.
  48624. */
  48625. microSurface: number;
  48626. /**
  48627. * source material index of refraction (IOR)' / 'destination material IOR.
  48628. */
  48629. indexOfRefraction: number;
  48630. /**
  48631. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48632. */
  48633. invertRefractionY: boolean;
  48634. /**
  48635. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48636. * Materials half opaque for instance using refraction could benefit from this control.
  48637. */
  48638. linkRefractionWithTransparency: boolean;
  48639. /**
  48640. * If true, the light map contains occlusion information instead of lighting info.
  48641. */
  48642. useLightmapAsShadowmap: boolean;
  48643. /**
  48644. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48645. */
  48646. useAlphaFromAlbedoTexture: boolean;
  48647. /**
  48648. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48649. */
  48650. forceAlphaTest: boolean;
  48651. /**
  48652. * Defines the alpha limits in alpha test mode.
  48653. */
  48654. alphaCutOff: number;
  48655. /**
  48656. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48657. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48658. */
  48659. useSpecularOverAlpha: boolean;
  48660. /**
  48661. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48662. */
  48663. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48664. /**
  48665. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48666. */
  48667. useRoughnessFromMetallicTextureAlpha: boolean;
  48668. /**
  48669. * Specifies if the metallic texture contains the roughness information in its green channel.
  48670. */
  48671. useRoughnessFromMetallicTextureGreen: boolean;
  48672. /**
  48673. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48674. */
  48675. useMetallnessFromMetallicTextureBlue: boolean;
  48676. /**
  48677. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48678. */
  48679. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48680. /**
  48681. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48682. */
  48683. useAmbientInGrayScale: boolean;
  48684. /**
  48685. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48686. * The material will try to infer what glossiness each pixel should be.
  48687. */
  48688. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48689. /**
  48690. * BJS is using an harcoded light falloff based on a manually sets up range.
  48691. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48692. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48693. */
  48694. /**
  48695. * BJS is using an harcoded light falloff based on a manually sets up range.
  48696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48698. */
  48699. usePhysicalLightFalloff: boolean;
  48700. /**
  48701. * In order to support the falloff compatibility with gltf, a special mode has been added
  48702. * to reproduce the gltf light falloff.
  48703. */
  48704. /**
  48705. * In order to support the falloff compatibility with gltf, a special mode has been added
  48706. * to reproduce the gltf light falloff.
  48707. */
  48708. useGLTFLightFalloff: boolean;
  48709. /**
  48710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48712. */
  48713. useRadianceOverAlpha: boolean;
  48714. /**
  48715. * Allows using an object space normal map (instead of tangent space).
  48716. */
  48717. useObjectSpaceNormalMap: boolean;
  48718. /**
  48719. * Allows using the bump map in parallax mode.
  48720. */
  48721. useParallax: boolean;
  48722. /**
  48723. * Allows using the bump map in parallax occlusion mode.
  48724. */
  48725. useParallaxOcclusion: boolean;
  48726. /**
  48727. * Controls the scale bias of the parallax mode.
  48728. */
  48729. parallaxScaleBias: number;
  48730. /**
  48731. * If sets to true, disables all the lights affecting the material.
  48732. */
  48733. disableLighting: boolean;
  48734. /**
  48735. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48736. */
  48737. forceIrradianceInFragment: boolean;
  48738. /**
  48739. * Number of Simultaneous lights allowed on the material.
  48740. */
  48741. maxSimultaneousLights: number;
  48742. /**
  48743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48744. */
  48745. invertNormalMapX: boolean;
  48746. /**
  48747. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48748. */
  48749. invertNormalMapY: boolean;
  48750. /**
  48751. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48752. */
  48753. twoSidedLighting: boolean;
  48754. /**
  48755. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48756. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48757. */
  48758. useAlphaFresnel: boolean;
  48759. /**
  48760. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48761. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48762. */
  48763. useLinearAlphaFresnel: boolean;
  48764. /**
  48765. * Let user defines the brdf lookup texture used for IBL.
  48766. * A default 8bit version is embedded but you could point at :
  48767. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48768. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48769. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48770. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48771. */
  48772. environmentBRDFTexture: Nullable<BaseTexture>;
  48773. /**
  48774. * Force normal to face away from face.
  48775. */
  48776. forceNormalForward: boolean;
  48777. /**
  48778. * Enables specular anti aliasing in the PBR shader.
  48779. * It will both interacts on the Geometry for analytical and IBL lighting.
  48780. * It also prefilter the roughness map based on the bump values.
  48781. */
  48782. enableSpecularAntiAliasing: boolean;
  48783. /**
  48784. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48785. * makes the reflect vector face the model (under horizon).
  48786. */
  48787. useHorizonOcclusion: boolean;
  48788. /**
  48789. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48790. * too much the area relying on ambient texture to define their ambient occlusion.
  48791. */
  48792. useRadianceOcclusion: boolean;
  48793. /**
  48794. * If set to true, no lighting calculations will be applied.
  48795. */
  48796. unlit: boolean;
  48797. /**
  48798. * Gets the image processing configuration used either in this material.
  48799. */
  48800. /**
  48801. * Sets the Default image processing configuration used either in the this material.
  48802. *
  48803. * If sets to null, the scene one is in use.
  48804. */
  48805. imageProcessingConfiguration: ImageProcessingConfiguration;
  48806. /**
  48807. * Gets wether the color curves effect is enabled.
  48808. */
  48809. /**
  48810. * Sets wether the color curves effect is enabled.
  48811. */
  48812. cameraColorCurvesEnabled: boolean;
  48813. /**
  48814. * Gets wether the color grading effect is enabled.
  48815. */
  48816. /**
  48817. * Gets wether the color grading effect is enabled.
  48818. */
  48819. cameraColorGradingEnabled: boolean;
  48820. /**
  48821. * Gets wether tonemapping is enabled or not.
  48822. */
  48823. /**
  48824. * Sets wether tonemapping is enabled or not
  48825. */
  48826. cameraToneMappingEnabled: boolean;
  48827. /**
  48828. * The camera exposure used on this material.
  48829. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48830. * This corresponds to a photographic exposure.
  48831. */
  48832. /**
  48833. * The camera exposure used on this material.
  48834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48835. * This corresponds to a photographic exposure.
  48836. */
  48837. cameraExposure: number;
  48838. /**
  48839. * Gets The camera contrast used on this material.
  48840. */
  48841. /**
  48842. * Sets The camera contrast used on this material.
  48843. */
  48844. cameraContrast: number;
  48845. /**
  48846. * Gets the Color Grading 2D Lookup Texture.
  48847. */
  48848. /**
  48849. * Sets the Color Grading 2D Lookup Texture.
  48850. */
  48851. cameraColorGradingTexture: Nullable<BaseTexture>;
  48852. /**
  48853. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48855. * 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;
  48856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48857. */
  48858. /**
  48859. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48861. * 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;
  48862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48863. */
  48864. cameraColorCurves: Nullable<ColorCurves>;
  48865. /**
  48866. * Instantiates a new PBRMaterial instance.
  48867. *
  48868. * @param name The material name
  48869. * @param scene The scene the material will be use in.
  48870. */
  48871. constructor(name: string, scene: Scene);
  48872. /**
  48873. * Returns the name of this material class.
  48874. */
  48875. getClassName(): string;
  48876. /**
  48877. * Makes a duplicate of the current material.
  48878. * @param name - name to use for the new material.
  48879. */
  48880. clone(name: string): PBRMaterial;
  48881. /**
  48882. * Serializes this PBR Material.
  48883. * @returns - An object with the serialized material.
  48884. */
  48885. serialize(): any;
  48886. /**
  48887. * Parses a PBR Material from a serialized object.
  48888. * @param source - Serialized object.
  48889. * @param scene - BJS scene instance.
  48890. * @param rootUrl - url for the scene object
  48891. * @returns - PBRMaterial
  48892. */
  48893. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /**
  48898. * Direct draw surface info
  48899. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48900. */
  48901. export interface DDSInfo {
  48902. /**
  48903. * Width of the texture
  48904. */
  48905. width: number;
  48906. /**
  48907. * Width of the texture
  48908. */
  48909. height: number;
  48910. /**
  48911. * Number of Mipmaps for the texture
  48912. * @see https://en.wikipedia.org/wiki/Mipmap
  48913. */
  48914. mipmapCount: number;
  48915. /**
  48916. * If the textures format is a known fourCC format
  48917. * @see https://www.fourcc.org/
  48918. */
  48919. isFourCC: boolean;
  48920. /**
  48921. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48922. */
  48923. isRGB: boolean;
  48924. /**
  48925. * If the texture is a lumincance format
  48926. */
  48927. isLuminance: boolean;
  48928. /**
  48929. * If this is a cube texture
  48930. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48931. */
  48932. isCube: boolean;
  48933. /**
  48934. * If the texture is a compressed format eg. FOURCC_DXT1
  48935. */
  48936. isCompressed: boolean;
  48937. /**
  48938. * The dxgiFormat of the texture
  48939. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48940. */
  48941. dxgiFormat: number;
  48942. /**
  48943. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48944. */
  48945. textureType: number;
  48946. /**
  48947. * Sphericle polynomial created for the dds texture
  48948. */
  48949. sphericalPolynomial?: SphericalPolynomial;
  48950. }
  48951. /**
  48952. * Class used to provide DDS decompression tools
  48953. */
  48954. export class DDSTools {
  48955. /**
  48956. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48957. */
  48958. static StoreLODInAlphaChannel: boolean;
  48959. /**
  48960. * Gets DDS information from an array buffer
  48961. * @param arrayBuffer defines the array buffer to read data from
  48962. * @returns the DDS information
  48963. */
  48964. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48965. private static _FloatView;
  48966. private static _Int32View;
  48967. private static _ToHalfFloat;
  48968. private static _FromHalfFloat;
  48969. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48970. private static _GetHalfFloatRGBAArrayBuffer;
  48971. private static _GetFloatRGBAArrayBuffer;
  48972. private static _GetFloatAsUIntRGBAArrayBuffer;
  48973. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48974. private static _GetRGBAArrayBuffer;
  48975. private static _ExtractLongWordOrder;
  48976. private static _GetRGBArrayBuffer;
  48977. private static _GetLuminanceArrayBuffer;
  48978. /**
  48979. * Uploads DDS Levels to a Babylon Texture
  48980. * @hidden
  48981. */
  48982. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48983. }
  48984. interface ThinEngine {
  48985. /**
  48986. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48987. * @param rootUrl defines the url where the file to load is located
  48988. * @param scene defines the current scene
  48989. * @param lodScale defines scale to apply to the mip map selection
  48990. * @param lodOffset defines offset to apply to the mip map selection
  48991. * @param onLoad defines an optional callback raised when the texture is loaded
  48992. * @param onError defines an optional callback raised if there is an issue to load the texture
  48993. * @param format defines the format of the data
  48994. * @param forcedExtension defines the extension to use to pick the right loader
  48995. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48996. * @returns the cube texture as an InternalTexture
  48997. */
  48998. 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;
  48999. }
  49000. }
  49001. declare module BABYLON {
  49002. /**
  49003. * Implementation of the DDS Texture Loader.
  49004. * @hidden
  49005. */
  49006. export class _DDSTextureLoader implements IInternalTextureLoader {
  49007. /**
  49008. * Defines wether the loader supports cascade loading the different faces.
  49009. */
  49010. readonly supportCascades: boolean;
  49011. /**
  49012. * This returns if the loader support the current file information.
  49013. * @param extension defines the file extension of the file being loaded
  49014. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49015. * @param fallback defines the fallback internal texture if any
  49016. * @param isBase64 defines whether the texture is encoded as a base64
  49017. * @param isBuffer defines whether the texture data are stored as a buffer
  49018. * @returns true if the loader can load the specified file
  49019. */
  49020. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49021. /**
  49022. * Transform the url before loading if required.
  49023. * @param rootUrl the url of the texture
  49024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49025. * @returns the transformed texture
  49026. */
  49027. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49028. /**
  49029. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49030. * @param rootUrl the url of the texture
  49031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49032. * @returns the fallback texture
  49033. */
  49034. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49035. /**
  49036. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49037. * @param data contains the texture data
  49038. * @param texture defines the BabylonJS internal texture
  49039. * @param createPolynomials will be true if polynomials have been requested
  49040. * @param onLoad defines the callback to trigger once the texture is ready
  49041. * @param onError defines the callback to trigger in case of error
  49042. */
  49043. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49044. /**
  49045. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49046. * @param data contains the texture data
  49047. * @param texture defines the BabylonJS internal texture
  49048. * @param callback defines the method to call once ready to upload
  49049. */
  49050. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49051. }
  49052. }
  49053. declare module BABYLON {
  49054. /**
  49055. * Implementation of the ENV Texture Loader.
  49056. * @hidden
  49057. */
  49058. export class _ENVTextureLoader implements IInternalTextureLoader {
  49059. /**
  49060. * Defines wether the loader supports cascade loading the different faces.
  49061. */
  49062. readonly supportCascades: boolean;
  49063. /**
  49064. * This returns if the loader support the current file information.
  49065. * @param extension defines the file extension of the file being loaded
  49066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49067. * @param fallback defines the fallback internal texture if any
  49068. * @param isBase64 defines whether the texture is encoded as a base64
  49069. * @param isBuffer defines whether the texture data are stored as a buffer
  49070. * @returns true if the loader can load the specified file
  49071. */
  49072. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49073. /**
  49074. * Transform the url before loading if required.
  49075. * @param rootUrl the url of the texture
  49076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49077. * @returns the transformed texture
  49078. */
  49079. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49080. /**
  49081. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49082. * @param rootUrl the url of the texture
  49083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49084. * @returns the fallback texture
  49085. */
  49086. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49087. /**
  49088. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49089. * @param data contains the texture data
  49090. * @param texture defines the BabylonJS internal texture
  49091. * @param createPolynomials will be true if polynomials have been requested
  49092. * @param onLoad defines the callback to trigger once the texture is ready
  49093. * @param onError defines the callback to trigger in case of error
  49094. */
  49095. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49096. /**
  49097. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49098. * @param data contains the texture data
  49099. * @param texture defines the BabylonJS internal texture
  49100. * @param callback defines the method to call once ready to upload
  49101. */
  49102. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49103. }
  49104. }
  49105. declare module BABYLON {
  49106. /**
  49107. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49108. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49109. */
  49110. export class KhronosTextureContainer {
  49111. /** contents of the KTX container file */
  49112. arrayBuffer: any;
  49113. private static HEADER_LEN;
  49114. private static COMPRESSED_2D;
  49115. private static COMPRESSED_3D;
  49116. private static TEX_2D;
  49117. private static TEX_3D;
  49118. /**
  49119. * Gets the openGL type
  49120. */
  49121. glType: number;
  49122. /**
  49123. * Gets the openGL type size
  49124. */
  49125. glTypeSize: number;
  49126. /**
  49127. * Gets the openGL format
  49128. */
  49129. glFormat: number;
  49130. /**
  49131. * Gets the openGL internal format
  49132. */
  49133. glInternalFormat: number;
  49134. /**
  49135. * Gets the base internal format
  49136. */
  49137. glBaseInternalFormat: number;
  49138. /**
  49139. * Gets image width in pixel
  49140. */
  49141. pixelWidth: number;
  49142. /**
  49143. * Gets image height in pixel
  49144. */
  49145. pixelHeight: number;
  49146. /**
  49147. * Gets image depth in pixels
  49148. */
  49149. pixelDepth: number;
  49150. /**
  49151. * Gets the number of array elements
  49152. */
  49153. numberOfArrayElements: number;
  49154. /**
  49155. * Gets the number of faces
  49156. */
  49157. numberOfFaces: number;
  49158. /**
  49159. * Gets the number of mipmap levels
  49160. */
  49161. numberOfMipmapLevels: number;
  49162. /**
  49163. * Gets the bytes of key value data
  49164. */
  49165. bytesOfKeyValueData: number;
  49166. /**
  49167. * Gets the load type
  49168. */
  49169. loadType: number;
  49170. /**
  49171. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49172. */
  49173. isInvalid: boolean;
  49174. /**
  49175. * Creates a new KhronosTextureContainer
  49176. * @param arrayBuffer contents of the KTX container file
  49177. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49178. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49179. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49180. */
  49181. constructor(
  49182. /** contents of the KTX container file */
  49183. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49184. /**
  49185. * Uploads KTX content to a Babylon Texture.
  49186. * It is assumed that the texture has already been created & is currently bound
  49187. * @hidden
  49188. */
  49189. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49190. private _upload2DCompressedLevels;
  49191. }
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Implementation of the KTX Texture Loader.
  49196. * @hidden
  49197. */
  49198. export class _KTXTextureLoader implements IInternalTextureLoader {
  49199. /**
  49200. * Defines wether the loader supports cascade loading the different faces.
  49201. */
  49202. readonly supportCascades: boolean;
  49203. /**
  49204. * This returns if the loader support the current file information.
  49205. * @param extension defines the file extension of the file being loaded
  49206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49207. * @param fallback defines the fallback internal texture if any
  49208. * @param isBase64 defines whether the texture is encoded as a base64
  49209. * @param isBuffer defines whether the texture data are stored as a buffer
  49210. * @returns true if the loader can load the specified file
  49211. */
  49212. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49213. /**
  49214. * Transform the url before loading if required.
  49215. * @param rootUrl the url of the texture
  49216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49217. * @returns the transformed texture
  49218. */
  49219. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49220. /**
  49221. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49222. * @param rootUrl the url of the texture
  49223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49224. * @returns the fallback texture
  49225. */
  49226. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49227. /**
  49228. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49229. * @param data contains the texture data
  49230. * @param texture defines the BabylonJS internal texture
  49231. * @param createPolynomials will be true if polynomials have been requested
  49232. * @param onLoad defines the callback to trigger once the texture is ready
  49233. * @param onError defines the callback to trigger in case of error
  49234. */
  49235. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49236. /**
  49237. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49238. * @param data contains the texture data
  49239. * @param texture defines the BabylonJS internal texture
  49240. * @param callback defines the method to call once ready to upload
  49241. */
  49242. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /**
  49247. * Options for the default xr helper
  49248. */
  49249. export class WebXRDefaultExperienceOptions {
  49250. /**
  49251. * Floor meshes that should be used for teleporting
  49252. */
  49253. floorMeshes: Array<AbstractMesh>;
  49254. /**
  49255. * Enable or disable default UI to enter XR
  49256. */
  49257. disableDefaultUI: boolean;
  49258. }
  49259. /**
  49260. * Default experience which provides a similar setup to the previous webVRExperience
  49261. */
  49262. export class WebXRDefaultExperience {
  49263. /**
  49264. * Base experience
  49265. */
  49266. baseExperience: WebXRExperienceHelper;
  49267. /**
  49268. * Input experience extension
  49269. */
  49270. input: WebXRInput;
  49271. /**
  49272. * Loads the controller models
  49273. */
  49274. controllerModelLoader: WebXRControllerModelLoader;
  49275. /**
  49276. * Enables laser pointer and selection
  49277. */
  49278. pointerSelection: WebXRControllerPointerSelection;
  49279. /**
  49280. * Enables teleportation
  49281. */
  49282. teleportation: WebXRControllerTeleportation;
  49283. /**
  49284. * Enables ui for enetering/exiting xr
  49285. */
  49286. enterExitUI: WebXREnterExitUI;
  49287. /**
  49288. * Default target xr should render to
  49289. */
  49290. renderTarget: WebXRRenderTarget;
  49291. /**
  49292. * Creates the default xr experience
  49293. * @param scene scene
  49294. * @param options options for basic configuration
  49295. * @returns resulting WebXRDefaultExperience
  49296. */
  49297. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49298. private constructor();
  49299. /**
  49300. * DIsposes of the experience helper
  49301. */
  49302. dispose(): void;
  49303. }
  49304. }
  49305. declare module BABYLON {
  49306. /** @hidden */
  49307. export var _forceSceneHelpersToBundle: boolean;
  49308. interface Scene {
  49309. /**
  49310. * Creates a default light for the scene.
  49311. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49312. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49313. */
  49314. createDefaultLight(replace?: boolean): void;
  49315. /**
  49316. * Creates a default camera for the scene.
  49317. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49318. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49319. * @param replace has default false, when true replaces the active camera in the scene
  49320. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49321. */
  49322. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49323. /**
  49324. * Creates a default camera and a default light.
  49325. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49326. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49327. * @param replace has the default false, when true replaces the active camera/light in the scene
  49328. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49329. */
  49330. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49331. /**
  49332. * Creates a new sky box
  49333. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49334. * @param environmentTexture defines the texture to use as environment texture
  49335. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49336. * @param scale defines the overall scale of the skybox
  49337. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49338. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49339. * @returns a new mesh holding the sky box
  49340. */
  49341. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49342. /**
  49343. * Creates a new environment
  49344. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49345. * @param options defines the options you can use to configure the environment
  49346. * @returns the new EnvironmentHelper
  49347. */
  49348. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49349. /**
  49350. * Creates a new VREXperienceHelper
  49351. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49352. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49353. * @returns a new VREXperienceHelper
  49354. */
  49355. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49356. /**
  49357. * Creates a new WebXRDefaultExperience
  49358. * @see http://doc.babylonjs.com/how_to/webxr
  49359. * @param options experience options
  49360. * @returns a promise for a new WebXRDefaultExperience
  49361. */
  49362. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49363. }
  49364. }
  49365. declare module BABYLON {
  49366. /**
  49367. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49368. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49369. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49370. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49371. */
  49372. export class VideoDome extends TransformNode {
  49373. /**
  49374. * Define the video source as a Monoscopic panoramic 360 video.
  49375. */
  49376. static readonly MODE_MONOSCOPIC: number;
  49377. /**
  49378. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49379. */
  49380. static readonly MODE_TOPBOTTOM: number;
  49381. /**
  49382. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49383. */
  49384. static readonly MODE_SIDEBYSIDE: number;
  49385. private _halfDome;
  49386. private _useDirectMapping;
  49387. /**
  49388. * The video texture being displayed on the sphere
  49389. */
  49390. protected _videoTexture: VideoTexture;
  49391. /**
  49392. * Gets the video texture being displayed on the sphere
  49393. */
  49394. readonly videoTexture: VideoTexture;
  49395. /**
  49396. * The skybox material
  49397. */
  49398. protected _material: BackgroundMaterial;
  49399. /**
  49400. * The surface used for the skybox
  49401. */
  49402. protected _mesh: Mesh;
  49403. /**
  49404. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49405. */
  49406. private _halfDomeMask;
  49407. /**
  49408. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49409. * Also see the options.resolution property.
  49410. */
  49411. fovMultiplier: number;
  49412. private _videoMode;
  49413. /**
  49414. * Gets or set the current video mode for the video. It can be:
  49415. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49416. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49417. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49418. */
  49419. videoMode: number;
  49420. /**
  49421. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49422. *
  49423. */
  49424. /**
  49425. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49426. */
  49427. halfDome: boolean;
  49428. /**
  49429. * Oberserver used in Stereoscopic VR Mode.
  49430. */
  49431. private _onBeforeCameraRenderObserver;
  49432. /**
  49433. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49434. * @param name Element's name, child elements will append suffixes for their own names.
  49435. * @param urlsOrVideo defines the url(s) or the video element to use
  49436. * @param options An object containing optional or exposed sub element properties
  49437. */
  49438. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49439. resolution?: number;
  49440. clickToPlay?: boolean;
  49441. autoPlay?: boolean;
  49442. loop?: boolean;
  49443. size?: number;
  49444. poster?: string;
  49445. faceForward?: boolean;
  49446. useDirectMapping?: boolean;
  49447. halfDomeMode?: boolean;
  49448. }, scene: Scene);
  49449. private _changeVideoMode;
  49450. /**
  49451. * Releases resources associated with this node.
  49452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49454. */
  49455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49456. }
  49457. }
  49458. declare module BABYLON {
  49459. /**
  49460. * This class can be used to get instrumentation data from a Babylon engine
  49461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49462. */
  49463. export class EngineInstrumentation implements IDisposable {
  49464. /**
  49465. * Define the instrumented engine.
  49466. */
  49467. engine: Engine;
  49468. private _captureGPUFrameTime;
  49469. private _gpuFrameTimeToken;
  49470. private _gpuFrameTime;
  49471. private _captureShaderCompilationTime;
  49472. private _shaderCompilationTime;
  49473. private _onBeginFrameObserver;
  49474. private _onEndFrameObserver;
  49475. private _onBeforeShaderCompilationObserver;
  49476. private _onAfterShaderCompilationObserver;
  49477. /**
  49478. * Gets the perf counter used for GPU frame time
  49479. */
  49480. readonly gpuFrameTimeCounter: PerfCounter;
  49481. /**
  49482. * Gets the GPU frame time capture status
  49483. */
  49484. /**
  49485. * Enable or disable the GPU frame time capture
  49486. */
  49487. captureGPUFrameTime: boolean;
  49488. /**
  49489. * Gets the perf counter used for shader compilation time
  49490. */
  49491. readonly shaderCompilationTimeCounter: PerfCounter;
  49492. /**
  49493. * Gets the shader compilation time capture status
  49494. */
  49495. /**
  49496. * Enable or disable the shader compilation time capture
  49497. */
  49498. captureShaderCompilationTime: boolean;
  49499. /**
  49500. * Instantiates a new engine instrumentation.
  49501. * This class can be used to get instrumentation data from a Babylon engine
  49502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49503. * @param engine Defines the engine to instrument
  49504. */
  49505. constructor(
  49506. /**
  49507. * Define the instrumented engine.
  49508. */
  49509. engine: Engine);
  49510. /**
  49511. * Dispose and release associated resources.
  49512. */
  49513. dispose(): void;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * This class can be used to get instrumentation data from a Babylon engine
  49519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49520. */
  49521. export class SceneInstrumentation implements IDisposable {
  49522. /**
  49523. * Defines the scene to instrument
  49524. */
  49525. scene: Scene;
  49526. private _captureActiveMeshesEvaluationTime;
  49527. private _activeMeshesEvaluationTime;
  49528. private _captureRenderTargetsRenderTime;
  49529. private _renderTargetsRenderTime;
  49530. private _captureFrameTime;
  49531. private _frameTime;
  49532. private _captureRenderTime;
  49533. private _renderTime;
  49534. private _captureInterFrameTime;
  49535. private _interFrameTime;
  49536. private _captureParticlesRenderTime;
  49537. private _particlesRenderTime;
  49538. private _captureSpritesRenderTime;
  49539. private _spritesRenderTime;
  49540. private _capturePhysicsTime;
  49541. private _physicsTime;
  49542. private _captureAnimationsTime;
  49543. private _animationsTime;
  49544. private _captureCameraRenderTime;
  49545. private _cameraRenderTime;
  49546. private _onBeforeActiveMeshesEvaluationObserver;
  49547. private _onAfterActiveMeshesEvaluationObserver;
  49548. private _onBeforeRenderTargetsRenderObserver;
  49549. private _onAfterRenderTargetsRenderObserver;
  49550. private _onAfterRenderObserver;
  49551. private _onBeforeDrawPhaseObserver;
  49552. private _onAfterDrawPhaseObserver;
  49553. private _onBeforeAnimationsObserver;
  49554. private _onBeforeParticlesRenderingObserver;
  49555. private _onAfterParticlesRenderingObserver;
  49556. private _onBeforeSpritesRenderingObserver;
  49557. private _onAfterSpritesRenderingObserver;
  49558. private _onBeforePhysicsObserver;
  49559. private _onAfterPhysicsObserver;
  49560. private _onAfterAnimationsObserver;
  49561. private _onBeforeCameraRenderObserver;
  49562. private _onAfterCameraRenderObserver;
  49563. /**
  49564. * Gets the perf counter used for active meshes evaluation time
  49565. */
  49566. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49567. /**
  49568. * Gets the active meshes evaluation time capture status
  49569. */
  49570. /**
  49571. * Enable or disable the active meshes evaluation time capture
  49572. */
  49573. captureActiveMeshesEvaluationTime: boolean;
  49574. /**
  49575. * Gets the perf counter used for render targets render time
  49576. */
  49577. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49578. /**
  49579. * Gets the render targets render time capture status
  49580. */
  49581. /**
  49582. * Enable or disable the render targets render time capture
  49583. */
  49584. captureRenderTargetsRenderTime: boolean;
  49585. /**
  49586. * Gets the perf counter used for particles render time
  49587. */
  49588. readonly particlesRenderTimeCounter: PerfCounter;
  49589. /**
  49590. * Gets the particles render time capture status
  49591. */
  49592. /**
  49593. * Enable or disable the particles render time capture
  49594. */
  49595. captureParticlesRenderTime: boolean;
  49596. /**
  49597. * Gets the perf counter used for sprites render time
  49598. */
  49599. readonly spritesRenderTimeCounter: PerfCounter;
  49600. /**
  49601. * Gets the sprites render time capture status
  49602. */
  49603. /**
  49604. * Enable or disable the sprites render time capture
  49605. */
  49606. captureSpritesRenderTime: boolean;
  49607. /**
  49608. * Gets the perf counter used for physics time
  49609. */
  49610. readonly physicsTimeCounter: PerfCounter;
  49611. /**
  49612. * Gets the physics time capture status
  49613. */
  49614. /**
  49615. * Enable or disable the physics time capture
  49616. */
  49617. capturePhysicsTime: boolean;
  49618. /**
  49619. * Gets the perf counter used for animations time
  49620. */
  49621. readonly animationsTimeCounter: PerfCounter;
  49622. /**
  49623. * Gets the animations time capture status
  49624. */
  49625. /**
  49626. * Enable or disable the animations time capture
  49627. */
  49628. captureAnimationsTime: boolean;
  49629. /**
  49630. * Gets the perf counter used for frame time capture
  49631. */
  49632. readonly frameTimeCounter: PerfCounter;
  49633. /**
  49634. * Gets the frame time capture status
  49635. */
  49636. /**
  49637. * Enable or disable the frame time capture
  49638. */
  49639. captureFrameTime: boolean;
  49640. /**
  49641. * Gets the perf counter used for inter-frames time capture
  49642. */
  49643. readonly interFrameTimeCounter: PerfCounter;
  49644. /**
  49645. * Gets the inter-frames time capture status
  49646. */
  49647. /**
  49648. * Enable or disable the inter-frames time capture
  49649. */
  49650. captureInterFrameTime: boolean;
  49651. /**
  49652. * Gets the perf counter used for render time capture
  49653. */
  49654. readonly renderTimeCounter: PerfCounter;
  49655. /**
  49656. * Gets the render time capture status
  49657. */
  49658. /**
  49659. * Enable or disable the render time capture
  49660. */
  49661. captureRenderTime: boolean;
  49662. /**
  49663. * Gets the perf counter used for camera render time capture
  49664. */
  49665. readonly cameraRenderTimeCounter: PerfCounter;
  49666. /**
  49667. * Gets the camera render time capture status
  49668. */
  49669. /**
  49670. * Enable or disable the camera render time capture
  49671. */
  49672. captureCameraRenderTime: boolean;
  49673. /**
  49674. * Gets the perf counter used for draw calls
  49675. */
  49676. readonly drawCallsCounter: PerfCounter;
  49677. /**
  49678. * Instantiates a new scene instrumentation.
  49679. * This class can be used to get instrumentation data from a Babylon engine
  49680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49681. * @param scene Defines the scene to instrument
  49682. */
  49683. constructor(
  49684. /**
  49685. * Defines the scene to instrument
  49686. */
  49687. scene: Scene);
  49688. /**
  49689. * Dispose and release associated resources.
  49690. */
  49691. dispose(): void;
  49692. }
  49693. }
  49694. declare module BABYLON {
  49695. /** @hidden */
  49696. export var glowMapGenerationPixelShader: {
  49697. name: string;
  49698. shader: string;
  49699. };
  49700. }
  49701. declare module BABYLON {
  49702. /** @hidden */
  49703. export var glowMapGenerationVertexShader: {
  49704. name: string;
  49705. shader: string;
  49706. };
  49707. }
  49708. declare module BABYLON {
  49709. /**
  49710. * Effect layer options. This helps customizing the behaviour
  49711. * of the effect layer.
  49712. */
  49713. export interface IEffectLayerOptions {
  49714. /**
  49715. * Multiplication factor apply to the canvas size to compute the render target size
  49716. * used to generated the objects (the smaller the faster).
  49717. */
  49718. mainTextureRatio: number;
  49719. /**
  49720. * Enforces a fixed size texture to ensure effect stability across devices.
  49721. */
  49722. mainTextureFixedSize?: number;
  49723. /**
  49724. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49725. */
  49726. alphaBlendingMode: number;
  49727. /**
  49728. * The camera attached to the layer.
  49729. */
  49730. camera: Nullable<Camera>;
  49731. /**
  49732. * The rendering group to draw the layer in.
  49733. */
  49734. renderingGroupId: number;
  49735. }
  49736. /**
  49737. * The effect layer Helps adding post process effect blended with the main pass.
  49738. *
  49739. * This can be for instance use to generate glow or higlight effects on the scene.
  49740. *
  49741. * The effect layer class can not be used directly and is intented to inherited from to be
  49742. * customized per effects.
  49743. */
  49744. export abstract class EffectLayer {
  49745. private _vertexBuffers;
  49746. private _indexBuffer;
  49747. private _cachedDefines;
  49748. private _effectLayerMapGenerationEffect;
  49749. private _effectLayerOptions;
  49750. private _mergeEffect;
  49751. protected _scene: Scene;
  49752. protected _engine: Engine;
  49753. protected _maxSize: number;
  49754. protected _mainTextureDesiredSize: ISize;
  49755. protected _mainTexture: RenderTargetTexture;
  49756. protected _shouldRender: boolean;
  49757. protected _postProcesses: PostProcess[];
  49758. protected _textures: BaseTexture[];
  49759. protected _emissiveTextureAndColor: {
  49760. texture: Nullable<BaseTexture>;
  49761. color: Color4;
  49762. };
  49763. /**
  49764. * The name of the layer
  49765. */
  49766. name: string;
  49767. /**
  49768. * The clear color of the texture used to generate the glow map.
  49769. */
  49770. neutralColor: Color4;
  49771. /**
  49772. * Specifies wether the highlight layer is enabled or not.
  49773. */
  49774. isEnabled: boolean;
  49775. /**
  49776. * Gets the camera attached to the layer.
  49777. */
  49778. readonly camera: Nullable<Camera>;
  49779. /**
  49780. * Gets the rendering group id the layer should render in.
  49781. */
  49782. renderingGroupId: number;
  49783. /**
  49784. * An event triggered when the effect layer has been disposed.
  49785. */
  49786. onDisposeObservable: Observable<EffectLayer>;
  49787. /**
  49788. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49789. */
  49790. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49791. /**
  49792. * An event triggered when the generated texture is being merged in the scene.
  49793. */
  49794. onBeforeComposeObservable: Observable<EffectLayer>;
  49795. /**
  49796. * An event triggered when the mesh is rendered into the effect render target.
  49797. */
  49798. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  49799. /**
  49800. * An event triggered after the mesh has been rendered into the effect render target.
  49801. */
  49802. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  49803. /**
  49804. * An event triggered when the generated texture has been merged in the scene.
  49805. */
  49806. onAfterComposeObservable: Observable<EffectLayer>;
  49807. /**
  49808. * An event triggered when the efffect layer changes its size.
  49809. */
  49810. onSizeChangedObservable: Observable<EffectLayer>;
  49811. /** @hidden */
  49812. static _SceneComponentInitialization: (scene: Scene) => void;
  49813. /**
  49814. * Instantiates a new effect Layer and references it in the scene.
  49815. * @param name The name of the layer
  49816. * @param scene The scene to use the layer in
  49817. */
  49818. constructor(
  49819. /** The Friendly of the effect in the scene */
  49820. name: string, scene: Scene);
  49821. /**
  49822. * Get the effect name of the layer.
  49823. * @return The effect name
  49824. */
  49825. abstract getEffectName(): string;
  49826. /**
  49827. * Checks for the readiness of the element composing the layer.
  49828. * @param subMesh the mesh to check for
  49829. * @param useInstances specify wether or not to use instances to render the mesh
  49830. * @return true if ready otherwise, false
  49831. */
  49832. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49833. /**
  49834. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49835. * @returns true if the effect requires stencil during the main canvas render pass.
  49836. */
  49837. abstract needStencil(): boolean;
  49838. /**
  49839. * Create the merge effect. This is the shader use to blit the information back
  49840. * to the main canvas at the end of the scene rendering.
  49841. * @returns The effect containing the shader used to merge the effect on the main canvas
  49842. */
  49843. protected abstract _createMergeEffect(): Effect;
  49844. /**
  49845. * Creates the render target textures and post processes used in the effect layer.
  49846. */
  49847. protected abstract _createTextureAndPostProcesses(): void;
  49848. /**
  49849. * Implementation specific of rendering the generating effect on the main canvas.
  49850. * @param effect The effect used to render through
  49851. */
  49852. protected abstract _internalRender(effect: Effect): void;
  49853. /**
  49854. * Sets the required values for both the emissive texture and and the main color.
  49855. */
  49856. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49857. /**
  49858. * Free any resources and references associated to a mesh.
  49859. * Internal use
  49860. * @param mesh The mesh to free.
  49861. */
  49862. abstract _disposeMesh(mesh: Mesh): void;
  49863. /**
  49864. * Serializes this layer (Glow or Highlight for example)
  49865. * @returns a serialized layer object
  49866. */
  49867. abstract serialize?(): any;
  49868. /**
  49869. * Initializes the effect layer with the required options.
  49870. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49871. */
  49872. protected _init(options: Partial<IEffectLayerOptions>): void;
  49873. /**
  49874. * Generates the index buffer of the full screen quad blending to the main canvas.
  49875. */
  49876. private _generateIndexBuffer;
  49877. /**
  49878. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49879. */
  49880. private _generateVertexBuffer;
  49881. /**
  49882. * Sets the main texture desired size which is the closest power of two
  49883. * of the engine canvas size.
  49884. */
  49885. private _setMainTextureSize;
  49886. /**
  49887. * Creates the main texture for the effect layer.
  49888. */
  49889. protected _createMainTexture(): void;
  49890. /**
  49891. * Adds specific effects defines.
  49892. * @param defines The defines to add specifics to.
  49893. */
  49894. protected _addCustomEffectDefines(defines: string[]): void;
  49895. /**
  49896. * Checks for the readiness of the element composing the layer.
  49897. * @param subMesh the mesh to check for
  49898. * @param useInstances specify wether or not to use instances to render the mesh
  49899. * @param emissiveTexture the associated emissive texture used to generate the glow
  49900. * @return true if ready otherwise, false
  49901. */
  49902. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49903. /**
  49904. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49905. */
  49906. render(): void;
  49907. /**
  49908. * Determine if a given mesh will be used in the current effect.
  49909. * @param mesh mesh to test
  49910. * @returns true if the mesh will be used
  49911. */
  49912. hasMesh(mesh: AbstractMesh): boolean;
  49913. /**
  49914. * Returns true if the layer contains information to display, otherwise false.
  49915. * @returns true if the glow layer should be rendered
  49916. */
  49917. shouldRender(): boolean;
  49918. /**
  49919. * Returns true if the mesh should render, otherwise false.
  49920. * @param mesh The mesh to render
  49921. * @returns true if it should render otherwise false
  49922. */
  49923. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49924. /**
  49925. * Returns true if the mesh can be rendered, otherwise false.
  49926. * @param mesh The mesh to render
  49927. * @param material The material used on the mesh
  49928. * @returns true if it can be rendered otherwise false
  49929. */
  49930. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49931. /**
  49932. * Returns true if the mesh should render, otherwise false.
  49933. * @param mesh The mesh to render
  49934. * @returns true if it should render otherwise false
  49935. */
  49936. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49937. /**
  49938. * Renders the submesh passed in parameter to the generation map.
  49939. */
  49940. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49941. /**
  49942. * Defines wether the current material of the mesh should be use to render the effect.
  49943. * @param mesh defines the current mesh to render
  49944. */
  49945. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  49946. /**
  49947. * Rebuild the required buffers.
  49948. * @hidden Internal use only.
  49949. */
  49950. _rebuild(): void;
  49951. /**
  49952. * Dispose only the render target textures and post process.
  49953. */
  49954. private _disposeTextureAndPostProcesses;
  49955. /**
  49956. * Dispose the highlight layer and free resources.
  49957. */
  49958. dispose(): void;
  49959. /**
  49960. * Gets the class name of the effect layer
  49961. * @returns the string with the class name of the effect layer
  49962. */
  49963. getClassName(): string;
  49964. /**
  49965. * Creates an effect layer from parsed effect layer data
  49966. * @param parsedEffectLayer defines effect layer data
  49967. * @param scene defines the current scene
  49968. * @param rootUrl defines the root URL containing the effect layer information
  49969. * @returns a parsed effect Layer
  49970. */
  49971. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49972. }
  49973. }
  49974. declare module BABYLON {
  49975. interface AbstractScene {
  49976. /**
  49977. * The list of effect layers (highlights/glow) added to the scene
  49978. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49979. * @see http://doc.babylonjs.com/how_to/glow_layer
  49980. */
  49981. effectLayers: Array<EffectLayer>;
  49982. /**
  49983. * Removes the given effect layer from this scene.
  49984. * @param toRemove defines the effect layer to remove
  49985. * @returns the index of the removed effect layer
  49986. */
  49987. removeEffectLayer(toRemove: EffectLayer): number;
  49988. /**
  49989. * Adds the given effect layer to this scene
  49990. * @param newEffectLayer defines the effect layer to add
  49991. */
  49992. addEffectLayer(newEffectLayer: EffectLayer): void;
  49993. }
  49994. /**
  49995. * Defines the layer scene component responsible to manage any effect layers
  49996. * in a given scene.
  49997. */
  49998. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49999. /**
  50000. * The component name helpfull to identify the component in the list of scene components.
  50001. */
  50002. readonly name: string;
  50003. /**
  50004. * The scene the component belongs to.
  50005. */
  50006. scene: Scene;
  50007. private _engine;
  50008. private _renderEffects;
  50009. private _needStencil;
  50010. private _previousStencilState;
  50011. /**
  50012. * Creates a new instance of the component for the given scene
  50013. * @param scene Defines the scene to register the component in
  50014. */
  50015. constructor(scene: Scene);
  50016. /**
  50017. * Registers the component in a given scene
  50018. */
  50019. register(): void;
  50020. /**
  50021. * Rebuilds the elements related to this component in case of
  50022. * context lost for instance.
  50023. */
  50024. rebuild(): void;
  50025. /**
  50026. * Serializes the component data to the specified json object
  50027. * @param serializationObject The object to serialize to
  50028. */
  50029. serialize(serializationObject: any): void;
  50030. /**
  50031. * Adds all the elements from the container to the scene
  50032. * @param container the container holding the elements
  50033. */
  50034. addFromContainer(container: AbstractScene): void;
  50035. /**
  50036. * Removes all the elements in the container from the scene
  50037. * @param container contains the elements to remove
  50038. * @param dispose if the removed element should be disposed (default: false)
  50039. */
  50040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50041. /**
  50042. * Disposes the component and the associated ressources.
  50043. */
  50044. dispose(): void;
  50045. private _isReadyForMesh;
  50046. private _renderMainTexture;
  50047. private _setStencil;
  50048. private _setStencilBack;
  50049. private _draw;
  50050. private _drawCamera;
  50051. private _drawRenderingGroup;
  50052. }
  50053. }
  50054. declare module BABYLON {
  50055. /** @hidden */
  50056. export var glowMapMergePixelShader: {
  50057. name: string;
  50058. shader: string;
  50059. };
  50060. }
  50061. declare module BABYLON {
  50062. /** @hidden */
  50063. export var glowMapMergeVertexShader: {
  50064. name: string;
  50065. shader: string;
  50066. };
  50067. }
  50068. declare module BABYLON {
  50069. interface AbstractScene {
  50070. /**
  50071. * Return a the first highlight layer of the scene with a given name.
  50072. * @param name The name of the highlight layer to look for.
  50073. * @return The highlight layer if found otherwise null.
  50074. */
  50075. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50076. }
  50077. /**
  50078. * Glow layer options. This helps customizing the behaviour
  50079. * of the glow layer.
  50080. */
  50081. export interface IGlowLayerOptions {
  50082. /**
  50083. * Multiplication factor apply to the canvas size to compute the render target size
  50084. * used to generated the glowing objects (the smaller the faster).
  50085. */
  50086. mainTextureRatio: number;
  50087. /**
  50088. * Enforces a fixed size texture to ensure resize independant blur.
  50089. */
  50090. mainTextureFixedSize?: number;
  50091. /**
  50092. * How big is the kernel of the blur texture.
  50093. */
  50094. blurKernelSize: number;
  50095. /**
  50096. * The camera attached to the layer.
  50097. */
  50098. camera: Nullable<Camera>;
  50099. /**
  50100. * Enable MSAA by chosing the number of samples.
  50101. */
  50102. mainTextureSamples?: number;
  50103. /**
  50104. * The rendering group to draw the layer in.
  50105. */
  50106. renderingGroupId: number;
  50107. }
  50108. /**
  50109. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50110. *
  50111. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50112. *
  50113. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50114. */
  50115. export class GlowLayer extends EffectLayer {
  50116. /**
  50117. * Effect Name of the layer.
  50118. */
  50119. static readonly EffectName: string;
  50120. /**
  50121. * The default blur kernel size used for the glow.
  50122. */
  50123. static DefaultBlurKernelSize: number;
  50124. /**
  50125. * The default texture size ratio used for the glow.
  50126. */
  50127. static DefaultTextureRatio: number;
  50128. /**
  50129. * Sets the kernel size of the blur.
  50130. */
  50131. /**
  50132. * Gets the kernel size of the blur.
  50133. */
  50134. blurKernelSize: number;
  50135. /**
  50136. * Sets the glow intensity.
  50137. */
  50138. /**
  50139. * Gets the glow intensity.
  50140. */
  50141. intensity: number;
  50142. private _options;
  50143. private _intensity;
  50144. private _horizontalBlurPostprocess1;
  50145. private _verticalBlurPostprocess1;
  50146. private _horizontalBlurPostprocess2;
  50147. private _verticalBlurPostprocess2;
  50148. private _blurTexture1;
  50149. private _blurTexture2;
  50150. private _postProcesses1;
  50151. private _postProcesses2;
  50152. private _includedOnlyMeshes;
  50153. private _excludedMeshes;
  50154. private _meshesUsingTheirOwnMaterials;
  50155. /**
  50156. * Callback used to let the user override the color selection on a per mesh basis
  50157. */
  50158. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50159. /**
  50160. * Callback used to let the user override the texture selection on a per mesh basis
  50161. */
  50162. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50163. /**
  50164. * Instantiates a new glow Layer and references it to the scene.
  50165. * @param name The name of the layer
  50166. * @param scene The scene to use the layer in
  50167. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50168. */
  50169. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50170. /**
  50171. * Get the effect name of the layer.
  50172. * @return The effect name
  50173. */
  50174. getEffectName(): string;
  50175. /**
  50176. * Create the merge effect. This is the shader use to blit the information back
  50177. * to the main canvas at the end of the scene rendering.
  50178. */
  50179. protected _createMergeEffect(): Effect;
  50180. /**
  50181. * Creates the render target textures and post processes used in the glow layer.
  50182. */
  50183. protected _createTextureAndPostProcesses(): void;
  50184. /**
  50185. * Checks for the readiness of the element composing the layer.
  50186. * @param subMesh the mesh to check for
  50187. * @param useInstances specify wether or not to use instances to render the mesh
  50188. * @param emissiveTexture the associated emissive texture used to generate the glow
  50189. * @return true if ready otherwise, false
  50190. */
  50191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50192. /**
  50193. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50194. */
  50195. needStencil(): boolean;
  50196. /**
  50197. * Returns true if the mesh can be rendered, otherwise false.
  50198. * @param mesh The mesh to render
  50199. * @param material The material used on the mesh
  50200. * @returns true if it can be rendered otherwise false
  50201. */
  50202. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50203. /**
  50204. * Implementation specific of rendering the generating effect on the main canvas.
  50205. * @param effect The effect used to render through
  50206. */
  50207. protected _internalRender(effect: Effect): void;
  50208. /**
  50209. * Sets the required values for both the emissive texture and and the main color.
  50210. */
  50211. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50212. /**
  50213. * Returns true if the mesh should render, otherwise false.
  50214. * @param mesh The mesh to render
  50215. * @returns true if it should render otherwise false
  50216. */
  50217. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50218. /**
  50219. * Adds specific effects defines.
  50220. * @param defines The defines to add specifics to.
  50221. */
  50222. protected _addCustomEffectDefines(defines: string[]): void;
  50223. /**
  50224. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50225. * @param mesh The mesh to exclude from the glow layer
  50226. */
  50227. addExcludedMesh(mesh: Mesh): void;
  50228. /**
  50229. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50230. * @param mesh The mesh to remove
  50231. */
  50232. removeExcludedMesh(mesh: Mesh): void;
  50233. /**
  50234. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50235. * @param mesh The mesh to include in the glow layer
  50236. */
  50237. addIncludedOnlyMesh(mesh: Mesh): void;
  50238. /**
  50239. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50240. * @param mesh The mesh to remove
  50241. */
  50242. removeIncludedOnlyMesh(mesh: Mesh): void;
  50243. /**
  50244. * Determine if a given mesh will be used in the glow layer
  50245. * @param mesh The mesh to test
  50246. * @returns true if the mesh will be highlighted by the current glow layer
  50247. */
  50248. hasMesh(mesh: AbstractMesh): boolean;
  50249. /**
  50250. * Defines wether the current material of the mesh should be use to render the effect.
  50251. * @param mesh defines the current mesh to render
  50252. */
  50253. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50254. /**
  50255. * Add a mesh to be rendered through its own material and not with emissive only.
  50256. * @param mesh The mesh for which we need to use its material
  50257. */
  50258. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50259. /**
  50260. * Remove a mesh from being rendered through its own material and not with emissive only.
  50261. * @param mesh The mesh for which we need to not use its material
  50262. */
  50263. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50264. /**
  50265. * Free any resources and references associated to a mesh.
  50266. * Internal use
  50267. * @param mesh The mesh to free.
  50268. * @hidden
  50269. */
  50270. _disposeMesh(mesh: Mesh): void;
  50271. /**
  50272. * Gets the class name of the effect layer
  50273. * @returns the string with the class name of the effect layer
  50274. */
  50275. getClassName(): string;
  50276. /**
  50277. * Serializes this glow layer
  50278. * @returns a serialized glow layer object
  50279. */
  50280. serialize(): any;
  50281. /**
  50282. * Creates a Glow Layer from parsed glow layer data
  50283. * @param parsedGlowLayer defines glow layer data
  50284. * @param scene defines the current scene
  50285. * @param rootUrl defines the root URL containing the glow layer information
  50286. * @returns a parsed Glow Layer
  50287. */
  50288. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50289. }
  50290. }
  50291. declare module BABYLON {
  50292. /** @hidden */
  50293. export var glowBlurPostProcessPixelShader: {
  50294. name: string;
  50295. shader: string;
  50296. };
  50297. }
  50298. declare module BABYLON {
  50299. interface AbstractScene {
  50300. /**
  50301. * Return a the first highlight layer of the scene with a given name.
  50302. * @param name The name of the highlight layer to look for.
  50303. * @return The highlight layer if found otherwise null.
  50304. */
  50305. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50306. }
  50307. /**
  50308. * Highlight layer options. This helps customizing the behaviour
  50309. * of the highlight layer.
  50310. */
  50311. export interface IHighlightLayerOptions {
  50312. /**
  50313. * Multiplication factor apply to the canvas size to compute the render target size
  50314. * used to generated the glowing objects (the smaller the faster).
  50315. */
  50316. mainTextureRatio: number;
  50317. /**
  50318. * Enforces a fixed size texture to ensure resize independant blur.
  50319. */
  50320. mainTextureFixedSize?: number;
  50321. /**
  50322. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50323. * of the picture to blur (the smaller the faster).
  50324. */
  50325. blurTextureSizeRatio: number;
  50326. /**
  50327. * How big in texel of the blur texture is the vertical blur.
  50328. */
  50329. blurVerticalSize: number;
  50330. /**
  50331. * How big in texel of the blur texture is the horizontal blur.
  50332. */
  50333. blurHorizontalSize: number;
  50334. /**
  50335. * Alpha blending mode used to apply the blur. Default is combine.
  50336. */
  50337. alphaBlendingMode: number;
  50338. /**
  50339. * The camera attached to the layer.
  50340. */
  50341. camera: Nullable<Camera>;
  50342. /**
  50343. * Should we display highlight as a solid stroke?
  50344. */
  50345. isStroke?: boolean;
  50346. /**
  50347. * The rendering group to draw the layer in.
  50348. */
  50349. renderingGroupId: number;
  50350. }
  50351. /**
  50352. * The highlight layer Helps adding a glow effect around a mesh.
  50353. *
  50354. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50355. * glowy meshes to your scene.
  50356. *
  50357. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50358. */
  50359. export class HighlightLayer extends EffectLayer {
  50360. name: string;
  50361. /**
  50362. * Effect Name of the highlight layer.
  50363. */
  50364. static readonly EffectName: string;
  50365. /**
  50366. * The neutral color used during the preparation of the glow effect.
  50367. * This is black by default as the blend operation is a blend operation.
  50368. */
  50369. static NeutralColor: Color4;
  50370. /**
  50371. * Stencil value used for glowing meshes.
  50372. */
  50373. static GlowingMeshStencilReference: number;
  50374. /**
  50375. * Stencil value used for the other meshes in the scene.
  50376. */
  50377. static NormalMeshStencilReference: number;
  50378. /**
  50379. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50380. */
  50381. innerGlow: boolean;
  50382. /**
  50383. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50384. */
  50385. outerGlow: boolean;
  50386. /**
  50387. * Specifies the horizontal size of the blur.
  50388. */
  50389. /**
  50390. * Gets the horizontal size of the blur.
  50391. */
  50392. blurHorizontalSize: number;
  50393. /**
  50394. * Specifies the vertical size of the blur.
  50395. */
  50396. /**
  50397. * Gets the vertical size of the blur.
  50398. */
  50399. blurVerticalSize: number;
  50400. /**
  50401. * An event triggered when the highlight layer is being blurred.
  50402. */
  50403. onBeforeBlurObservable: Observable<HighlightLayer>;
  50404. /**
  50405. * An event triggered when the highlight layer has been blurred.
  50406. */
  50407. onAfterBlurObservable: Observable<HighlightLayer>;
  50408. private _instanceGlowingMeshStencilReference;
  50409. private _options;
  50410. private _downSamplePostprocess;
  50411. private _horizontalBlurPostprocess;
  50412. private _verticalBlurPostprocess;
  50413. private _blurTexture;
  50414. private _meshes;
  50415. private _excludedMeshes;
  50416. /**
  50417. * Instantiates a new highlight Layer and references it to the scene..
  50418. * @param name The name of the layer
  50419. * @param scene The scene to use the layer in
  50420. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50421. */
  50422. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50423. /**
  50424. * Get the effect name of the layer.
  50425. * @return The effect name
  50426. */
  50427. getEffectName(): string;
  50428. /**
  50429. * Create the merge effect. This is the shader use to blit the information back
  50430. * to the main canvas at the end of the scene rendering.
  50431. */
  50432. protected _createMergeEffect(): Effect;
  50433. /**
  50434. * Creates the render target textures and post processes used in the highlight layer.
  50435. */
  50436. protected _createTextureAndPostProcesses(): void;
  50437. /**
  50438. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50439. */
  50440. needStencil(): boolean;
  50441. /**
  50442. * Checks for the readiness of the element composing the layer.
  50443. * @param subMesh the mesh to check for
  50444. * @param useInstances specify wether or not to use instances to render the mesh
  50445. * @param emissiveTexture the associated emissive texture used to generate the glow
  50446. * @return true if ready otherwise, false
  50447. */
  50448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50449. /**
  50450. * Implementation specific of rendering the generating effect on the main canvas.
  50451. * @param effect The effect used to render through
  50452. */
  50453. protected _internalRender(effect: Effect): void;
  50454. /**
  50455. * Returns true if the layer contains information to display, otherwise false.
  50456. */
  50457. shouldRender(): boolean;
  50458. /**
  50459. * Returns true if the mesh should render, otherwise false.
  50460. * @param mesh The mesh to render
  50461. * @returns true if it should render otherwise false
  50462. */
  50463. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50464. /**
  50465. * Sets the required values for both the emissive texture and and the main color.
  50466. */
  50467. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50468. /**
  50469. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50470. * @param mesh The mesh to exclude from the highlight layer
  50471. */
  50472. addExcludedMesh(mesh: Mesh): void;
  50473. /**
  50474. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50475. * @param mesh The mesh to highlight
  50476. */
  50477. removeExcludedMesh(mesh: Mesh): void;
  50478. /**
  50479. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50480. * @param mesh mesh to test
  50481. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50482. */
  50483. hasMesh(mesh: AbstractMesh): boolean;
  50484. /**
  50485. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50486. * @param mesh The mesh to highlight
  50487. * @param color The color of the highlight
  50488. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50489. */
  50490. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50491. /**
  50492. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50493. * @param mesh The mesh to highlight
  50494. */
  50495. removeMesh(mesh: Mesh): void;
  50496. /**
  50497. * Force the stencil to the normal expected value for none glowing parts
  50498. */
  50499. private _defaultStencilReference;
  50500. /**
  50501. * Free any resources and references associated to a mesh.
  50502. * Internal use
  50503. * @param mesh The mesh to free.
  50504. * @hidden
  50505. */
  50506. _disposeMesh(mesh: Mesh): void;
  50507. /**
  50508. * Dispose the highlight layer and free resources.
  50509. */
  50510. dispose(): void;
  50511. /**
  50512. * Gets the class name of the effect layer
  50513. * @returns the string with the class name of the effect layer
  50514. */
  50515. getClassName(): string;
  50516. /**
  50517. * Serializes this Highlight layer
  50518. * @returns a serialized Highlight layer object
  50519. */
  50520. serialize(): any;
  50521. /**
  50522. * Creates a Highlight layer from parsed Highlight layer data
  50523. * @param parsedHightlightLayer defines the Highlight layer data
  50524. * @param scene defines the current scene
  50525. * @param rootUrl defines the root URL containing the Highlight layer information
  50526. * @returns a parsed Highlight layer
  50527. */
  50528. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50529. }
  50530. }
  50531. declare module BABYLON {
  50532. interface AbstractScene {
  50533. /**
  50534. * The list of layers (background and foreground) of the scene
  50535. */
  50536. layers: Array<Layer>;
  50537. }
  50538. /**
  50539. * Defines the layer scene component responsible to manage any layers
  50540. * in a given scene.
  50541. */
  50542. export class LayerSceneComponent implements ISceneComponent {
  50543. /**
  50544. * The component name helpfull to identify the component in the list of scene components.
  50545. */
  50546. readonly name: string;
  50547. /**
  50548. * The scene the component belongs to.
  50549. */
  50550. scene: Scene;
  50551. private _engine;
  50552. /**
  50553. * Creates a new instance of the component for the given scene
  50554. * @param scene Defines the scene to register the component in
  50555. */
  50556. constructor(scene: Scene);
  50557. /**
  50558. * Registers the component in a given scene
  50559. */
  50560. register(): void;
  50561. /**
  50562. * Rebuilds the elements related to this component in case of
  50563. * context lost for instance.
  50564. */
  50565. rebuild(): void;
  50566. /**
  50567. * Disposes the component and the associated ressources.
  50568. */
  50569. dispose(): void;
  50570. private _draw;
  50571. private _drawCameraPredicate;
  50572. private _drawCameraBackground;
  50573. private _drawCameraForeground;
  50574. private _drawRenderTargetPredicate;
  50575. private _drawRenderTargetBackground;
  50576. private _drawRenderTargetForeground;
  50577. /**
  50578. * Adds all the elements from the container to the scene
  50579. * @param container the container holding the elements
  50580. */
  50581. addFromContainer(container: AbstractScene): void;
  50582. /**
  50583. * Removes all the elements in the container from the scene
  50584. * @param container contains the elements to remove
  50585. * @param dispose if the removed element should be disposed (default: false)
  50586. */
  50587. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50588. }
  50589. }
  50590. declare module BABYLON {
  50591. /** @hidden */
  50592. export var layerPixelShader: {
  50593. name: string;
  50594. shader: string;
  50595. };
  50596. }
  50597. declare module BABYLON {
  50598. /** @hidden */
  50599. export var layerVertexShader: {
  50600. name: string;
  50601. shader: string;
  50602. };
  50603. }
  50604. declare module BABYLON {
  50605. /**
  50606. * This represents a full screen 2d layer.
  50607. * This can be useful to display a picture in the background of your scene for instance.
  50608. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50609. */
  50610. export class Layer {
  50611. /**
  50612. * Define the name of the layer.
  50613. */
  50614. name: string;
  50615. /**
  50616. * Define the texture the layer should display.
  50617. */
  50618. texture: Nullable<Texture>;
  50619. /**
  50620. * Is the layer in background or foreground.
  50621. */
  50622. isBackground: boolean;
  50623. /**
  50624. * Define the color of the layer (instead of texture).
  50625. */
  50626. color: Color4;
  50627. /**
  50628. * Define the scale of the layer in order to zoom in out of the texture.
  50629. */
  50630. scale: Vector2;
  50631. /**
  50632. * Define an offset for the layer in order to shift the texture.
  50633. */
  50634. offset: Vector2;
  50635. /**
  50636. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50637. */
  50638. alphaBlendingMode: number;
  50639. /**
  50640. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50641. * Alpha test will not mix with the background color in case of transparency.
  50642. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50643. */
  50644. alphaTest: boolean;
  50645. /**
  50646. * Define a mask to restrict the layer to only some of the scene cameras.
  50647. */
  50648. layerMask: number;
  50649. /**
  50650. * Define the list of render target the layer is visible into.
  50651. */
  50652. renderTargetTextures: RenderTargetTexture[];
  50653. /**
  50654. * Define if the layer is only used in renderTarget or if it also
  50655. * renders in the main frame buffer of the canvas.
  50656. */
  50657. renderOnlyInRenderTargetTextures: boolean;
  50658. private _scene;
  50659. private _vertexBuffers;
  50660. private _indexBuffer;
  50661. private _effect;
  50662. private _alphaTestEffect;
  50663. /**
  50664. * An event triggered when the layer is disposed.
  50665. */
  50666. onDisposeObservable: Observable<Layer>;
  50667. private _onDisposeObserver;
  50668. /**
  50669. * Back compatibility with callback before the onDisposeObservable existed.
  50670. * The set callback will be triggered when the layer has been disposed.
  50671. */
  50672. onDispose: () => void;
  50673. /**
  50674. * An event triggered before rendering the scene
  50675. */
  50676. onBeforeRenderObservable: Observable<Layer>;
  50677. private _onBeforeRenderObserver;
  50678. /**
  50679. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50680. * The set callback will be triggered just before rendering the layer.
  50681. */
  50682. onBeforeRender: () => void;
  50683. /**
  50684. * An event triggered after rendering the scene
  50685. */
  50686. onAfterRenderObservable: Observable<Layer>;
  50687. private _onAfterRenderObserver;
  50688. /**
  50689. * Back compatibility with callback before the onAfterRenderObservable existed.
  50690. * The set callback will be triggered just after rendering the layer.
  50691. */
  50692. onAfterRender: () => void;
  50693. /**
  50694. * Instantiates a new layer.
  50695. * This represents a full screen 2d layer.
  50696. * This can be useful to display a picture in the background of your scene for instance.
  50697. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50698. * @param name Define the name of the layer in the scene
  50699. * @param imgUrl Define the url of the texture to display in the layer
  50700. * @param scene Define the scene the layer belongs to
  50701. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50702. * @param color Defines a color for the layer
  50703. */
  50704. constructor(
  50705. /**
  50706. * Define the name of the layer.
  50707. */
  50708. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50709. private _createIndexBuffer;
  50710. /** @hidden */
  50711. _rebuild(): void;
  50712. /**
  50713. * Renders the layer in the scene.
  50714. */
  50715. render(): void;
  50716. /**
  50717. * Disposes and releases the associated ressources.
  50718. */
  50719. dispose(): void;
  50720. }
  50721. }
  50722. declare module BABYLON {
  50723. /** @hidden */
  50724. export var lensFlarePixelShader: {
  50725. name: string;
  50726. shader: string;
  50727. };
  50728. }
  50729. declare module BABYLON {
  50730. /** @hidden */
  50731. export var lensFlareVertexShader: {
  50732. name: string;
  50733. shader: string;
  50734. };
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50739. * It is usually composed of several `lensFlare`.
  50740. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50741. */
  50742. export class LensFlareSystem {
  50743. /**
  50744. * Define the name of the lens flare system
  50745. */
  50746. name: string;
  50747. /**
  50748. * List of lens flares used in this system.
  50749. */
  50750. lensFlares: LensFlare[];
  50751. /**
  50752. * Define a limit from the border the lens flare can be visible.
  50753. */
  50754. borderLimit: number;
  50755. /**
  50756. * Define a viewport border we do not want to see the lens flare in.
  50757. */
  50758. viewportBorder: number;
  50759. /**
  50760. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50761. */
  50762. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50763. /**
  50764. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50765. */
  50766. layerMask: number;
  50767. /**
  50768. * Define the id of the lens flare system in the scene.
  50769. * (equal to name by default)
  50770. */
  50771. id: string;
  50772. private _scene;
  50773. private _emitter;
  50774. private _vertexBuffers;
  50775. private _indexBuffer;
  50776. private _effect;
  50777. private _positionX;
  50778. private _positionY;
  50779. private _isEnabled;
  50780. /** @hidden */
  50781. static _SceneComponentInitialization: (scene: Scene) => void;
  50782. /**
  50783. * Instantiates a lens flare system.
  50784. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50785. * It is usually composed of several `lensFlare`.
  50786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50787. * @param name Define the name of the lens flare system in the scene
  50788. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50789. * @param scene Define the scene the lens flare system belongs to
  50790. */
  50791. constructor(
  50792. /**
  50793. * Define the name of the lens flare system
  50794. */
  50795. name: string, emitter: any, scene: Scene);
  50796. /**
  50797. * Define if the lens flare system is enabled.
  50798. */
  50799. isEnabled: boolean;
  50800. /**
  50801. * Get the scene the effects belongs to.
  50802. * @returns the scene holding the lens flare system
  50803. */
  50804. getScene(): Scene;
  50805. /**
  50806. * Get the emitter of the lens flare system.
  50807. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50808. * @returns the emitter of the lens flare system
  50809. */
  50810. getEmitter(): any;
  50811. /**
  50812. * Set the emitter of the lens flare system.
  50813. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50814. * @param newEmitter Define the new emitter of the system
  50815. */
  50816. setEmitter(newEmitter: any): void;
  50817. /**
  50818. * Get the lens flare system emitter position.
  50819. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50820. * @returns the position
  50821. */
  50822. getEmitterPosition(): Vector3;
  50823. /**
  50824. * @hidden
  50825. */
  50826. computeEffectivePosition(globalViewport: Viewport): boolean;
  50827. /** @hidden */
  50828. _isVisible(): boolean;
  50829. /**
  50830. * @hidden
  50831. */
  50832. render(): boolean;
  50833. /**
  50834. * Dispose and release the lens flare with its associated resources.
  50835. */
  50836. dispose(): void;
  50837. /**
  50838. * Parse a lens flare system from a JSON repressentation
  50839. * @param parsedLensFlareSystem Define the JSON to parse
  50840. * @param scene Define the scene the parsed system should be instantiated in
  50841. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50842. * @returns the parsed system
  50843. */
  50844. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50845. /**
  50846. * Serialize the current Lens Flare System into a JSON representation.
  50847. * @returns the serialized JSON
  50848. */
  50849. serialize(): any;
  50850. }
  50851. }
  50852. declare module BABYLON {
  50853. /**
  50854. * This represents one of the lens effect in a `lensFlareSystem`.
  50855. * It controls one of the indiviual texture used in the effect.
  50856. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50857. */
  50858. export class LensFlare {
  50859. /**
  50860. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50861. */
  50862. size: number;
  50863. /**
  50864. * 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.
  50865. */
  50866. position: number;
  50867. /**
  50868. * Define the lens color.
  50869. */
  50870. color: Color3;
  50871. /**
  50872. * Define the lens texture.
  50873. */
  50874. texture: Nullable<Texture>;
  50875. /**
  50876. * Define the alpha mode to render this particular lens.
  50877. */
  50878. alphaMode: number;
  50879. private _system;
  50880. /**
  50881. * Creates a new Lens Flare.
  50882. * This represents one of the lens effect in a `lensFlareSystem`.
  50883. * It controls one of the indiviual texture used in the effect.
  50884. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50885. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50886. * @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.
  50887. * @param color Define the lens color
  50888. * @param imgUrl Define the lens texture url
  50889. * @param system Define the `lensFlareSystem` this flare is part of
  50890. * @returns The newly created Lens Flare
  50891. */
  50892. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50893. /**
  50894. * Instantiates a new Lens Flare.
  50895. * This represents one of the lens effect in a `lensFlareSystem`.
  50896. * It controls one of the indiviual texture used in the effect.
  50897. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50898. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50899. * @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.
  50900. * @param color Define the lens color
  50901. * @param imgUrl Define the lens texture url
  50902. * @param system Define the `lensFlareSystem` this flare is part of
  50903. */
  50904. constructor(
  50905. /**
  50906. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50907. */
  50908. size: number,
  50909. /**
  50910. * 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.
  50911. */
  50912. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50913. /**
  50914. * Dispose and release the lens flare with its associated resources.
  50915. */
  50916. dispose(): void;
  50917. }
  50918. }
  50919. declare module BABYLON {
  50920. interface AbstractScene {
  50921. /**
  50922. * The list of lens flare system added to the scene
  50923. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50924. */
  50925. lensFlareSystems: Array<LensFlareSystem>;
  50926. /**
  50927. * Removes the given lens flare system from this scene.
  50928. * @param toRemove The lens flare system to remove
  50929. * @returns The index of the removed lens flare system
  50930. */
  50931. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50932. /**
  50933. * Adds the given lens flare system to this scene
  50934. * @param newLensFlareSystem The lens flare system to add
  50935. */
  50936. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50937. /**
  50938. * Gets a lens flare system using its name
  50939. * @param name defines the name to look for
  50940. * @returns the lens flare system or null if not found
  50941. */
  50942. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50943. /**
  50944. * Gets a lens flare system using its id
  50945. * @param id defines the id to look for
  50946. * @returns the lens flare system or null if not found
  50947. */
  50948. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50949. }
  50950. /**
  50951. * Defines the lens flare scene component responsible to manage any lens flares
  50952. * in a given scene.
  50953. */
  50954. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50955. /**
  50956. * The component name helpfull to identify the component in the list of scene components.
  50957. */
  50958. readonly name: string;
  50959. /**
  50960. * The scene the component belongs to.
  50961. */
  50962. scene: Scene;
  50963. /**
  50964. * Creates a new instance of the component for the given scene
  50965. * @param scene Defines the scene to register the component in
  50966. */
  50967. constructor(scene: Scene);
  50968. /**
  50969. * Registers the component in a given scene
  50970. */
  50971. register(): void;
  50972. /**
  50973. * Rebuilds the elements related to this component in case of
  50974. * context lost for instance.
  50975. */
  50976. rebuild(): void;
  50977. /**
  50978. * Adds all the elements from the container to the scene
  50979. * @param container the container holding the elements
  50980. */
  50981. addFromContainer(container: AbstractScene): void;
  50982. /**
  50983. * Removes all the elements in the container from the scene
  50984. * @param container contains the elements to remove
  50985. * @param dispose if the removed element should be disposed (default: false)
  50986. */
  50987. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50988. /**
  50989. * Serializes the component data to the specified json object
  50990. * @param serializationObject The object to serialize to
  50991. */
  50992. serialize(serializationObject: any): void;
  50993. /**
  50994. * Disposes the component and the associated ressources.
  50995. */
  50996. dispose(): void;
  50997. private _draw;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * Defines the shadow generator component responsible to manage any shadow generators
  51003. * in a given scene.
  51004. */
  51005. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51006. /**
  51007. * The component name helpfull to identify the component in the list of scene components.
  51008. */
  51009. readonly name: string;
  51010. /**
  51011. * The scene the component belongs to.
  51012. */
  51013. scene: Scene;
  51014. /**
  51015. * Creates a new instance of the component for the given scene
  51016. * @param scene Defines the scene to register the component in
  51017. */
  51018. constructor(scene: Scene);
  51019. /**
  51020. * Registers the component in a given scene
  51021. */
  51022. register(): void;
  51023. /**
  51024. * Rebuilds the elements related to this component in case of
  51025. * context lost for instance.
  51026. */
  51027. rebuild(): void;
  51028. /**
  51029. * Serializes the component data to the specified json object
  51030. * @param serializationObject The object to serialize to
  51031. */
  51032. serialize(serializationObject: any): void;
  51033. /**
  51034. * Adds all the elements from the container to the scene
  51035. * @param container the container holding the elements
  51036. */
  51037. addFromContainer(container: AbstractScene): void;
  51038. /**
  51039. * Removes all the elements in the container from the scene
  51040. * @param container contains the elements to remove
  51041. * @param dispose if the removed element should be disposed (default: false)
  51042. */
  51043. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51044. /**
  51045. * Rebuilds the elements related to this component in case of
  51046. * context lost for instance.
  51047. */
  51048. dispose(): void;
  51049. private _gatherRenderTargets;
  51050. }
  51051. }
  51052. declare module BABYLON {
  51053. /**
  51054. * A point light is a light defined by an unique point in world space.
  51055. * The light is emitted in every direction from this point.
  51056. * A good example of a point light is a standard light bulb.
  51057. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51058. */
  51059. export class PointLight extends ShadowLight {
  51060. private _shadowAngle;
  51061. /**
  51062. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51063. * This specifies what angle the shadow will use to be created.
  51064. *
  51065. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51066. */
  51067. /**
  51068. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51069. * This specifies what angle the shadow will use to be created.
  51070. *
  51071. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51072. */
  51073. shadowAngle: number;
  51074. /**
  51075. * Gets the direction if it has been set.
  51076. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51077. */
  51078. /**
  51079. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51080. */
  51081. direction: Vector3;
  51082. /**
  51083. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51084. * A PointLight emits the light in every direction.
  51085. * It can cast shadows.
  51086. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51087. * ```javascript
  51088. * var pointLight = new PointLight("pl", camera.position, scene);
  51089. * ```
  51090. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51091. * @param name The light friendly name
  51092. * @param position The position of the point light in the scene
  51093. * @param scene The scene the lights belongs to
  51094. */
  51095. constructor(name: string, position: Vector3, scene: Scene);
  51096. /**
  51097. * Returns the string "PointLight"
  51098. * @returns the class name
  51099. */
  51100. getClassName(): string;
  51101. /**
  51102. * Returns the integer 0.
  51103. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51104. */
  51105. getTypeID(): number;
  51106. /**
  51107. * Specifies wether or not the shadowmap should be a cube texture.
  51108. * @returns true if the shadowmap needs to be a cube texture.
  51109. */
  51110. needCube(): boolean;
  51111. /**
  51112. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51113. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51114. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51115. */
  51116. getShadowDirection(faceIndex?: number): Vector3;
  51117. /**
  51118. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51119. * - fov = PI / 2
  51120. * - aspect ratio : 1.0
  51121. * - z-near and far equal to the active camera minZ and maxZ.
  51122. * Returns the PointLight.
  51123. */
  51124. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51125. protected _buildUniformLayout(): void;
  51126. /**
  51127. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51128. * @param effect The effect to update
  51129. * @param lightIndex The index of the light in the effect to update
  51130. * @returns The point light
  51131. */
  51132. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51133. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51134. /**
  51135. * Prepares the list of defines specific to the light type.
  51136. * @param defines the list of defines
  51137. * @param lightIndex defines the index of the light for the effect
  51138. */
  51139. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51140. }
  51141. }
  51142. declare module BABYLON {
  51143. /**
  51144. * Header information of HDR texture files.
  51145. */
  51146. export interface HDRInfo {
  51147. /**
  51148. * The height of the texture in pixels.
  51149. */
  51150. height: number;
  51151. /**
  51152. * The width of the texture in pixels.
  51153. */
  51154. width: number;
  51155. /**
  51156. * The index of the beginning of the data in the binary file.
  51157. */
  51158. dataPosition: number;
  51159. }
  51160. /**
  51161. * This groups tools to convert HDR texture to native colors array.
  51162. */
  51163. export class HDRTools {
  51164. private static Ldexp;
  51165. private static Rgbe2float;
  51166. private static readStringLine;
  51167. /**
  51168. * Reads header information from an RGBE texture stored in a native array.
  51169. * More information on this format are available here:
  51170. * https://en.wikipedia.org/wiki/RGBE_image_format
  51171. *
  51172. * @param uint8array The binary file stored in native array.
  51173. * @return The header information.
  51174. */
  51175. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51176. /**
  51177. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51178. * This RGBE texture needs to store the information as a panorama.
  51179. *
  51180. * More information on this format are available here:
  51181. * https://en.wikipedia.org/wiki/RGBE_image_format
  51182. *
  51183. * @param buffer The binary file stored in an array buffer.
  51184. * @param size The expected size of the extracted cubemap.
  51185. * @return The Cube Map information.
  51186. */
  51187. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51188. /**
  51189. * Returns the pixels data extracted from an RGBE texture.
  51190. * This pixels will be stored left to right up to down in the R G B order in one array.
  51191. *
  51192. * More information on this format are available here:
  51193. * https://en.wikipedia.org/wiki/RGBE_image_format
  51194. *
  51195. * @param uint8array The binary file stored in an array buffer.
  51196. * @param hdrInfo The header information of the file.
  51197. * @return The pixels data in RGB right to left up to down order.
  51198. */
  51199. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51200. private static RGBE_ReadPixels_RLE;
  51201. }
  51202. }
  51203. declare module BABYLON {
  51204. /**
  51205. * This represents a texture coming from an HDR input.
  51206. *
  51207. * The only supported format is currently panorama picture stored in RGBE format.
  51208. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51209. */
  51210. export class HDRCubeTexture extends BaseTexture {
  51211. private static _facesMapping;
  51212. private _generateHarmonics;
  51213. private _noMipmap;
  51214. private _textureMatrix;
  51215. private _size;
  51216. private _onLoad;
  51217. private _onError;
  51218. /**
  51219. * The texture URL.
  51220. */
  51221. url: string;
  51222. /**
  51223. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51224. */
  51225. coordinatesMode: number;
  51226. protected _isBlocking: boolean;
  51227. /**
  51228. * Sets wether or not the texture is blocking during loading.
  51229. */
  51230. /**
  51231. * Gets wether or not the texture is blocking during loading.
  51232. */
  51233. isBlocking: boolean;
  51234. protected _rotationY: number;
  51235. /**
  51236. * Sets texture matrix rotation angle around Y axis in radians.
  51237. */
  51238. /**
  51239. * Gets texture matrix rotation angle around Y axis radians.
  51240. */
  51241. rotationY: number;
  51242. /**
  51243. * Gets or sets the center of the bounding box associated with the cube texture
  51244. * It must define where the camera used to render the texture was set
  51245. */
  51246. boundingBoxPosition: Vector3;
  51247. private _boundingBoxSize;
  51248. /**
  51249. * Gets or sets the size of the bounding box associated with the cube texture
  51250. * When defined, the cubemap will switch to local mode
  51251. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51252. * @example https://www.babylonjs-playground.com/#RNASML
  51253. */
  51254. boundingBoxSize: Vector3;
  51255. /**
  51256. * Instantiates an HDRTexture from the following parameters.
  51257. *
  51258. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51259. * @param scene The scene the texture will be used in
  51260. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51261. * @param noMipmap Forces to not generate the mipmap if true
  51262. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51263. * @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)
  51264. * @param reserved Reserved flag for internal use.
  51265. */
  51266. 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>);
  51267. /**
  51268. * Get the current class name of the texture useful for serialization or dynamic coding.
  51269. * @returns "HDRCubeTexture"
  51270. */
  51271. getClassName(): string;
  51272. /**
  51273. * Occurs when the file is raw .hdr file.
  51274. */
  51275. private loadTexture;
  51276. clone(): HDRCubeTexture;
  51277. delayLoad(): void;
  51278. /**
  51279. * Get the texture reflection matrix used to rotate/transform the reflection.
  51280. * @returns the reflection matrix
  51281. */
  51282. getReflectionTextureMatrix(): Matrix;
  51283. /**
  51284. * Set the texture reflection matrix used to rotate/transform the reflection.
  51285. * @param value Define the reflection matrix to set
  51286. */
  51287. setReflectionTextureMatrix(value: Matrix): void;
  51288. /**
  51289. * Parses a JSON representation of an HDR Texture in order to create the texture
  51290. * @param parsedTexture Define the JSON representation
  51291. * @param scene Define the scene the texture should be created in
  51292. * @param rootUrl Define the root url in case we need to load relative dependencies
  51293. * @returns the newly created texture after parsing
  51294. */
  51295. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51296. serialize(): any;
  51297. }
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * Class used to control physics engine
  51302. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51303. */
  51304. export class PhysicsEngine implements IPhysicsEngine {
  51305. private _physicsPlugin;
  51306. /**
  51307. * Global value used to control the smallest number supported by the simulation
  51308. */
  51309. static Epsilon: number;
  51310. private _impostors;
  51311. private _joints;
  51312. /**
  51313. * Gets the gravity vector used by the simulation
  51314. */
  51315. gravity: Vector3;
  51316. /**
  51317. * Factory used to create the default physics plugin.
  51318. * @returns The default physics plugin
  51319. */
  51320. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51321. /**
  51322. * Creates a new Physics Engine
  51323. * @param gravity defines the gravity vector used by the simulation
  51324. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51325. */
  51326. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51327. /**
  51328. * Sets the gravity vector used by the simulation
  51329. * @param gravity defines the gravity vector to use
  51330. */
  51331. setGravity(gravity: Vector3): void;
  51332. /**
  51333. * Set the time step of the physics engine.
  51334. * Default is 1/60.
  51335. * To slow it down, enter 1/600 for example.
  51336. * To speed it up, 1/30
  51337. * @param newTimeStep defines the new timestep to apply to this world.
  51338. */
  51339. setTimeStep(newTimeStep?: number): void;
  51340. /**
  51341. * Get the time step of the physics engine.
  51342. * @returns the current time step
  51343. */
  51344. getTimeStep(): number;
  51345. /**
  51346. * Release all resources
  51347. */
  51348. dispose(): void;
  51349. /**
  51350. * Gets the name of the current physics plugin
  51351. * @returns the name of the plugin
  51352. */
  51353. getPhysicsPluginName(): string;
  51354. /**
  51355. * Adding a new impostor for the impostor tracking.
  51356. * This will be done by the impostor itself.
  51357. * @param impostor the impostor to add
  51358. */
  51359. addImpostor(impostor: PhysicsImpostor): void;
  51360. /**
  51361. * Remove an impostor from the engine.
  51362. * This impostor and its mesh will not longer be updated by the physics engine.
  51363. * @param impostor the impostor to remove
  51364. */
  51365. removeImpostor(impostor: PhysicsImpostor): void;
  51366. /**
  51367. * Add a joint to the physics engine
  51368. * @param mainImpostor defines the main impostor to which the joint is added.
  51369. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51370. * @param joint defines the joint that will connect both impostors.
  51371. */
  51372. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51373. /**
  51374. * Removes a joint from the simulation
  51375. * @param mainImpostor defines the impostor used with the joint
  51376. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51377. * @param joint defines the joint to remove
  51378. */
  51379. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51380. /**
  51381. * Called by the scene. No need to call it.
  51382. * @param delta defines the timespam between frames
  51383. */
  51384. _step(delta: number): void;
  51385. /**
  51386. * Gets the current plugin used to run the simulation
  51387. * @returns current plugin
  51388. */
  51389. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51390. /**
  51391. * Gets the list of physic impostors
  51392. * @returns an array of PhysicsImpostor
  51393. */
  51394. getImpostors(): Array<PhysicsImpostor>;
  51395. /**
  51396. * Gets the impostor for a physics enabled object
  51397. * @param object defines the object impersonated by the impostor
  51398. * @returns the PhysicsImpostor or null if not found
  51399. */
  51400. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51401. /**
  51402. * Gets the impostor for a physics body object
  51403. * @param body defines physics body used by the impostor
  51404. * @returns the PhysicsImpostor or null if not found
  51405. */
  51406. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51407. /**
  51408. * Does a raycast in the physics world
  51409. * @param from when should the ray start?
  51410. * @param to when should the ray end?
  51411. * @returns PhysicsRaycastResult
  51412. */
  51413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51414. }
  51415. }
  51416. declare module BABYLON {
  51417. /** @hidden */
  51418. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51419. private _useDeltaForWorldStep;
  51420. world: any;
  51421. name: string;
  51422. private _physicsMaterials;
  51423. private _fixedTimeStep;
  51424. private _cannonRaycastResult;
  51425. private _raycastResult;
  51426. private _physicsBodysToRemoveAfterStep;
  51427. BJSCANNON: any;
  51428. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51429. setGravity(gravity: Vector3): void;
  51430. setTimeStep(timeStep: number): void;
  51431. getTimeStep(): number;
  51432. executeStep(delta: number): void;
  51433. private _removeMarkedPhysicsBodiesFromWorld;
  51434. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51435. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51436. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51437. private _processChildMeshes;
  51438. removePhysicsBody(impostor: PhysicsImpostor): void;
  51439. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51440. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51441. private _addMaterial;
  51442. private _checkWithEpsilon;
  51443. private _createShape;
  51444. private _createHeightmap;
  51445. private _minus90X;
  51446. private _plus90X;
  51447. private _tmpPosition;
  51448. private _tmpDeltaPosition;
  51449. private _tmpUnityRotation;
  51450. private _updatePhysicsBodyTransformation;
  51451. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51452. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51453. isSupported(): boolean;
  51454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51455. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51456. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51457. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51458. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51459. getBodyMass(impostor: PhysicsImpostor): number;
  51460. getBodyFriction(impostor: PhysicsImpostor): number;
  51461. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51462. getBodyRestitution(impostor: PhysicsImpostor): number;
  51463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51464. sleepBody(impostor: PhysicsImpostor): void;
  51465. wakeUpBody(impostor: PhysicsImpostor): void;
  51466. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51467. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51468. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51469. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51470. getRadius(impostor: PhysicsImpostor): number;
  51471. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51472. dispose(): void;
  51473. private _extendNamespace;
  51474. /**
  51475. * Does a raycast in the physics world
  51476. * @param from when should the ray start?
  51477. * @param to when should the ray end?
  51478. * @returns PhysicsRaycastResult
  51479. */
  51480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51481. }
  51482. }
  51483. declare module BABYLON {
  51484. /** @hidden */
  51485. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51486. world: any;
  51487. name: string;
  51488. BJSOIMO: any;
  51489. private _raycastResult;
  51490. constructor(iterations?: number, oimoInjection?: any);
  51491. setGravity(gravity: Vector3): void;
  51492. setTimeStep(timeStep: number): void;
  51493. getTimeStep(): number;
  51494. private _tmpImpostorsArray;
  51495. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51496. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51497. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51498. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51499. private _tmpPositionVector;
  51500. removePhysicsBody(impostor: PhysicsImpostor): void;
  51501. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51502. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51503. isSupported(): boolean;
  51504. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51505. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51506. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51507. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51508. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51509. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51510. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51511. getBodyMass(impostor: PhysicsImpostor): number;
  51512. getBodyFriction(impostor: PhysicsImpostor): number;
  51513. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51514. getBodyRestitution(impostor: PhysicsImpostor): number;
  51515. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51516. sleepBody(impostor: PhysicsImpostor): void;
  51517. wakeUpBody(impostor: PhysicsImpostor): void;
  51518. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51519. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51520. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51521. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51522. getRadius(impostor: PhysicsImpostor): number;
  51523. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51524. dispose(): void;
  51525. /**
  51526. * Does a raycast in the physics world
  51527. * @param from when should the ray start?
  51528. * @param to when should the ray end?
  51529. * @returns PhysicsRaycastResult
  51530. */
  51531. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51532. }
  51533. }
  51534. declare module BABYLON {
  51535. /**
  51536. * Class containing static functions to help procedurally build meshes
  51537. */
  51538. export class RibbonBuilder {
  51539. /**
  51540. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51541. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51542. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51543. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51544. * * 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
  51545. * * 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
  51546. * * 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
  51547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51548. * * 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
  51549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51550. * * 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
  51551. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51552. * * 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
  51553. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51555. * @param name defines the name of the mesh
  51556. * @param options defines the options used to create the mesh
  51557. * @param scene defines the hosting scene
  51558. * @returns the ribbon mesh
  51559. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51561. */
  51562. static CreateRibbon(name: string, options: {
  51563. pathArray: Vector3[][];
  51564. closeArray?: boolean;
  51565. closePath?: boolean;
  51566. offset?: number;
  51567. updatable?: boolean;
  51568. sideOrientation?: number;
  51569. frontUVs?: Vector4;
  51570. backUVs?: Vector4;
  51571. instance?: Mesh;
  51572. invertUV?: boolean;
  51573. uvs?: Vector2[];
  51574. colors?: Color4[];
  51575. }, scene?: Nullable<Scene>): Mesh;
  51576. }
  51577. }
  51578. declare module BABYLON {
  51579. /**
  51580. * Class containing static functions to help procedurally build meshes
  51581. */
  51582. export class ShapeBuilder {
  51583. /**
  51584. * 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.
  51585. * * 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.
  51586. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51587. * * 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.
  51588. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51589. * * 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
  51590. * * 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
  51591. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51593. * * 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
  51594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51596. * @param name defines the name of the mesh
  51597. * @param options defines the options used to create the mesh
  51598. * @param scene defines the hosting scene
  51599. * @returns the extruded shape mesh
  51600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51602. */
  51603. static ExtrudeShape(name: string, options: {
  51604. shape: Vector3[];
  51605. path: Vector3[];
  51606. scale?: number;
  51607. rotation?: number;
  51608. cap?: number;
  51609. updatable?: boolean;
  51610. sideOrientation?: number;
  51611. frontUVs?: Vector4;
  51612. backUVs?: Vector4;
  51613. instance?: Mesh;
  51614. invertUV?: boolean;
  51615. }, scene?: Nullable<Scene>): Mesh;
  51616. /**
  51617. * Creates an custom extruded shape mesh.
  51618. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51619. * * 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.
  51620. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51621. * * 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
  51622. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51623. * * 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
  51624. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51625. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51626. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51627. * * 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
  51628. * * 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
  51629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51631. * * 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
  51632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51634. * @param name defines the name of the mesh
  51635. * @param options defines the options used to create the mesh
  51636. * @param scene defines the hosting scene
  51637. * @returns the custom extruded shape mesh
  51638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51641. */
  51642. static ExtrudeShapeCustom(name: string, options: {
  51643. shape: Vector3[];
  51644. path: Vector3[];
  51645. scaleFunction?: any;
  51646. rotationFunction?: any;
  51647. ribbonCloseArray?: boolean;
  51648. ribbonClosePath?: boolean;
  51649. cap?: number;
  51650. updatable?: boolean;
  51651. sideOrientation?: number;
  51652. frontUVs?: Vector4;
  51653. backUVs?: Vector4;
  51654. instance?: Mesh;
  51655. invertUV?: boolean;
  51656. }, scene?: Nullable<Scene>): Mesh;
  51657. private static _ExtrudeShapeGeneric;
  51658. }
  51659. }
  51660. declare module BABYLON {
  51661. /**
  51662. * AmmoJS Physics plugin
  51663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51664. * @see https://github.com/kripken/ammo.js/
  51665. */
  51666. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51667. private _useDeltaForWorldStep;
  51668. /**
  51669. * Reference to the Ammo library
  51670. */
  51671. bjsAMMO: any;
  51672. /**
  51673. * Created ammoJS world which physics bodies are added to
  51674. */
  51675. world: any;
  51676. /**
  51677. * Name of the plugin
  51678. */
  51679. name: string;
  51680. private _timeStep;
  51681. private _fixedTimeStep;
  51682. private _maxSteps;
  51683. private _tmpQuaternion;
  51684. private _tmpAmmoTransform;
  51685. private _tmpAmmoQuaternion;
  51686. private _tmpAmmoConcreteContactResultCallback;
  51687. private _collisionConfiguration;
  51688. private _dispatcher;
  51689. private _overlappingPairCache;
  51690. private _solver;
  51691. private _softBodySolver;
  51692. private _tmpAmmoVectorA;
  51693. private _tmpAmmoVectorB;
  51694. private _tmpAmmoVectorC;
  51695. private _tmpAmmoVectorD;
  51696. private _tmpContactCallbackResult;
  51697. private _tmpAmmoVectorRCA;
  51698. private _tmpAmmoVectorRCB;
  51699. private _raycastResult;
  51700. private static readonly DISABLE_COLLISION_FLAG;
  51701. private static readonly KINEMATIC_FLAG;
  51702. private static readonly DISABLE_DEACTIVATION_FLAG;
  51703. /**
  51704. * Initializes the ammoJS plugin
  51705. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51706. * @param ammoInjection can be used to inject your own ammo reference
  51707. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51708. */
  51709. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51710. /**
  51711. * Sets the gravity of the physics world (m/(s^2))
  51712. * @param gravity Gravity to set
  51713. */
  51714. setGravity(gravity: Vector3): void;
  51715. /**
  51716. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51717. * @param timeStep timestep to use in seconds
  51718. */
  51719. setTimeStep(timeStep: number): void;
  51720. /**
  51721. * 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)
  51722. * @param fixedTimeStep fixedTimeStep to use in seconds
  51723. */
  51724. setFixedTimeStep(fixedTimeStep: number): void;
  51725. /**
  51726. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51727. * @param maxSteps the maximum number of steps by the physics engine per frame
  51728. */
  51729. setMaxSteps(maxSteps: number): void;
  51730. /**
  51731. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51732. * @returns the current timestep in seconds
  51733. */
  51734. getTimeStep(): number;
  51735. private _isImpostorInContact;
  51736. private _isImpostorPairInContact;
  51737. private _stepSimulation;
  51738. /**
  51739. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51740. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51741. * After the step the babylon meshes are set to the position of the physics imposters
  51742. * @param delta amount of time to step forward
  51743. * @param impostors array of imposters to update before/after the step
  51744. */
  51745. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51746. /**
  51747. * Update babylon mesh to match physics world object
  51748. * @param impostor imposter to match
  51749. */
  51750. private _afterSoftStep;
  51751. /**
  51752. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51753. * @param impostor imposter to match
  51754. */
  51755. private _ropeStep;
  51756. /**
  51757. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51758. * @param impostor imposter to match
  51759. */
  51760. private _softbodyOrClothStep;
  51761. private _tmpVector;
  51762. private _tmpMatrix;
  51763. /**
  51764. * Applies an impulse on the imposter
  51765. * @param impostor imposter to apply impulse to
  51766. * @param force amount of force to be applied to the imposter
  51767. * @param contactPoint the location to apply the impulse on the imposter
  51768. */
  51769. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51770. /**
  51771. * Applies a force on the imposter
  51772. * @param impostor imposter to apply force
  51773. * @param force amount of force to be applied to the imposter
  51774. * @param contactPoint the location to apply the force on the imposter
  51775. */
  51776. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51777. /**
  51778. * Creates a physics body using the plugin
  51779. * @param impostor the imposter to create the physics body on
  51780. */
  51781. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51782. /**
  51783. * Removes the physics body from the imposter and disposes of the body's memory
  51784. * @param impostor imposter to remove the physics body from
  51785. */
  51786. removePhysicsBody(impostor: PhysicsImpostor): void;
  51787. /**
  51788. * Generates a joint
  51789. * @param impostorJoint the imposter joint to create the joint with
  51790. */
  51791. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51792. /**
  51793. * Removes a joint
  51794. * @param impostorJoint the imposter joint to remove the joint from
  51795. */
  51796. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51797. private _addMeshVerts;
  51798. /**
  51799. * Initialise the soft body vertices to match its object's (mesh) vertices
  51800. * Softbody vertices (nodes) are in world space and to match this
  51801. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51802. * @param impostor to create the softbody for
  51803. */
  51804. private _softVertexData;
  51805. /**
  51806. * Create an impostor's soft body
  51807. * @param impostor to create the softbody for
  51808. */
  51809. private _createSoftbody;
  51810. /**
  51811. * Create cloth for an impostor
  51812. * @param impostor to create the softbody for
  51813. */
  51814. private _createCloth;
  51815. /**
  51816. * Create rope for an impostor
  51817. * @param impostor to create the softbody for
  51818. */
  51819. private _createRope;
  51820. private _addHullVerts;
  51821. private _createShape;
  51822. /**
  51823. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51824. * @param impostor imposter containing the physics body and babylon object
  51825. */
  51826. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51827. /**
  51828. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51829. * @param impostor imposter containing the physics body and babylon object
  51830. * @param newPosition new position
  51831. * @param newRotation new rotation
  51832. */
  51833. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51834. /**
  51835. * If this plugin is supported
  51836. * @returns true if its supported
  51837. */
  51838. isSupported(): boolean;
  51839. /**
  51840. * Sets the linear velocity of the physics body
  51841. * @param impostor imposter to set the velocity on
  51842. * @param velocity velocity to set
  51843. */
  51844. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51845. /**
  51846. * Sets the angular velocity of the physics body
  51847. * @param impostor imposter to set the velocity on
  51848. * @param velocity velocity to set
  51849. */
  51850. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51851. /**
  51852. * gets the linear velocity
  51853. * @param impostor imposter to get linear velocity from
  51854. * @returns linear velocity
  51855. */
  51856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51857. /**
  51858. * gets the angular velocity
  51859. * @param impostor imposter to get angular velocity from
  51860. * @returns angular velocity
  51861. */
  51862. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51863. /**
  51864. * Sets the mass of physics body
  51865. * @param impostor imposter to set the mass on
  51866. * @param mass mass to set
  51867. */
  51868. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51869. /**
  51870. * Gets the mass of the physics body
  51871. * @param impostor imposter to get the mass from
  51872. * @returns mass
  51873. */
  51874. getBodyMass(impostor: PhysicsImpostor): number;
  51875. /**
  51876. * Gets friction of the impostor
  51877. * @param impostor impostor to get friction from
  51878. * @returns friction value
  51879. */
  51880. getBodyFriction(impostor: PhysicsImpostor): number;
  51881. /**
  51882. * Sets friction of the impostor
  51883. * @param impostor impostor to set friction on
  51884. * @param friction friction value
  51885. */
  51886. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51887. /**
  51888. * Gets restitution of the impostor
  51889. * @param impostor impostor to get restitution from
  51890. * @returns restitution value
  51891. */
  51892. getBodyRestitution(impostor: PhysicsImpostor): number;
  51893. /**
  51894. * Sets resitution of the impostor
  51895. * @param impostor impostor to set resitution on
  51896. * @param restitution resitution value
  51897. */
  51898. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51899. /**
  51900. * Gets pressure inside the impostor
  51901. * @param impostor impostor to get pressure from
  51902. * @returns pressure value
  51903. */
  51904. getBodyPressure(impostor: PhysicsImpostor): number;
  51905. /**
  51906. * Sets pressure inside a soft body impostor
  51907. * Cloth and rope must remain 0 pressure
  51908. * @param impostor impostor to set pressure on
  51909. * @param pressure pressure value
  51910. */
  51911. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51912. /**
  51913. * Gets stiffness of the impostor
  51914. * @param impostor impostor to get stiffness from
  51915. * @returns pressure value
  51916. */
  51917. getBodyStiffness(impostor: PhysicsImpostor): number;
  51918. /**
  51919. * Sets stiffness of the impostor
  51920. * @param impostor impostor to set stiffness on
  51921. * @param stiffness stiffness value from 0 to 1
  51922. */
  51923. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51924. /**
  51925. * Gets velocityIterations of the impostor
  51926. * @param impostor impostor to get velocity iterations from
  51927. * @returns velocityIterations value
  51928. */
  51929. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51930. /**
  51931. * Sets velocityIterations of the impostor
  51932. * @param impostor impostor to set velocity iterations on
  51933. * @param velocityIterations velocityIterations value
  51934. */
  51935. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51936. /**
  51937. * Gets positionIterations of the impostor
  51938. * @param impostor impostor to get position iterations from
  51939. * @returns positionIterations value
  51940. */
  51941. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51942. /**
  51943. * Sets positionIterations of the impostor
  51944. * @param impostor impostor to set position on
  51945. * @param positionIterations positionIterations value
  51946. */
  51947. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51948. /**
  51949. * Append an anchor to a cloth object
  51950. * @param impostor is the cloth impostor to add anchor to
  51951. * @param otherImpostor is the rigid impostor to anchor to
  51952. * @param width ratio across width from 0 to 1
  51953. * @param height ratio up height from 0 to 1
  51954. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51955. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51956. */
  51957. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51958. /**
  51959. * Append an hook to a rope object
  51960. * @param impostor is the rope impostor to add hook to
  51961. * @param otherImpostor is the rigid impostor to hook to
  51962. * @param length ratio along the rope from 0 to 1
  51963. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51964. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51965. */
  51966. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51967. /**
  51968. * Sleeps the physics body and stops it from being active
  51969. * @param impostor impostor to sleep
  51970. */
  51971. sleepBody(impostor: PhysicsImpostor): void;
  51972. /**
  51973. * Activates the physics body
  51974. * @param impostor impostor to activate
  51975. */
  51976. wakeUpBody(impostor: PhysicsImpostor): void;
  51977. /**
  51978. * Updates the distance parameters of the joint
  51979. * @param joint joint to update
  51980. * @param maxDistance maximum distance of the joint
  51981. * @param minDistance minimum distance of the joint
  51982. */
  51983. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51984. /**
  51985. * Sets a motor on the joint
  51986. * @param joint joint to set motor on
  51987. * @param speed speed of the motor
  51988. * @param maxForce maximum force of the motor
  51989. * @param motorIndex index of the motor
  51990. */
  51991. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51992. /**
  51993. * Sets the motors limit
  51994. * @param joint joint to set limit on
  51995. * @param upperLimit upper limit
  51996. * @param lowerLimit lower limit
  51997. */
  51998. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51999. /**
  52000. * Syncs the position and rotation of a mesh with the impostor
  52001. * @param mesh mesh to sync
  52002. * @param impostor impostor to update the mesh with
  52003. */
  52004. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52005. /**
  52006. * Gets the radius of the impostor
  52007. * @param impostor impostor to get radius from
  52008. * @returns the radius
  52009. */
  52010. getRadius(impostor: PhysicsImpostor): number;
  52011. /**
  52012. * Gets the box size of the impostor
  52013. * @param impostor impostor to get box size from
  52014. * @param result the resulting box size
  52015. */
  52016. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52017. /**
  52018. * Disposes of the impostor
  52019. */
  52020. dispose(): void;
  52021. /**
  52022. * Does a raycast in the physics world
  52023. * @param from when should the ray start?
  52024. * @param to when should the ray end?
  52025. * @returns PhysicsRaycastResult
  52026. */
  52027. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52028. }
  52029. }
  52030. declare module BABYLON {
  52031. interface AbstractScene {
  52032. /**
  52033. * The list of reflection probes added to the scene
  52034. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52035. */
  52036. reflectionProbes: Array<ReflectionProbe>;
  52037. /**
  52038. * Removes the given reflection probe from this scene.
  52039. * @param toRemove The reflection probe to remove
  52040. * @returns The index of the removed reflection probe
  52041. */
  52042. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52043. /**
  52044. * Adds the given reflection probe to this scene.
  52045. * @param newReflectionProbe The reflection probe to add
  52046. */
  52047. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52048. }
  52049. /**
  52050. * Class used to generate realtime reflection / refraction cube textures
  52051. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52052. */
  52053. export class ReflectionProbe {
  52054. /** defines the name of the probe */
  52055. name: string;
  52056. private _scene;
  52057. private _renderTargetTexture;
  52058. private _projectionMatrix;
  52059. private _viewMatrix;
  52060. private _target;
  52061. private _add;
  52062. private _attachedMesh;
  52063. private _invertYAxis;
  52064. /** Gets or sets probe position (center of the cube map) */
  52065. position: Vector3;
  52066. /**
  52067. * Creates a new reflection probe
  52068. * @param name defines the name of the probe
  52069. * @param size defines the texture resolution (for each face)
  52070. * @param scene defines the hosting scene
  52071. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52072. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52073. */
  52074. constructor(
  52075. /** defines the name of the probe */
  52076. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52077. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52078. samples: number;
  52079. /** Gets or sets the refresh rate to use (on every frame by default) */
  52080. refreshRate: number;
  52081. /**
  52082. * Gets the hosting scene
  52083. * @returns a Scene
  52084. */
  52085. getScene(): Scene;
  52086. /** Gets the internal CubeTexture used to render to */
  52087. readonly cubeTexture: RenderTargetTexture;
  52088. /** Gets the list of meshes to render */
  52089. readonly renderList: Nullable<AbstractMesh[]>;
  52090. /**
  52091. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52092. * @param mesh defines the mesh to attach to
  52093. */
  52094. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52095. /**
  52096. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52097. * @param renderingGroupId The rendering group id corresponding to its index
  52098. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52099. */
  52100. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52101. /**
  52102. * Clean all associated resources
  52103. */
  52104. dispose(): void;
  52105. /**
  52106. * Converts the reflection probe information to a readable string for debug purpose.
  52107. * @param fullDetails Supports for multiple levels of logging within scene loading
  52108. * @returns the human readable reflection probe info
  52109. */
  52110. toString(fullDetails?: boolean): string;
  52111. /**
  52112. * Get the class name of the relfection probe.
  52113. * @returns "ReflectionProbe"
  52114. */
  52115. getClassName(): string;
  52116. /**
  52117. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52118. * @returns The JSON representation of the texture
  52119. */
  52120. serialize(): any;
  52121. /**
  52122. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52123. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52124. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52125. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52126. * @returns The parsed reflection probe if successful
  52127. */
  52128. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /** @hidden */
  52133. export var _BabylonLoaderRegistered: boolean;
  52134. /**
  52135. * Helps setting up some configuration for the babylon file loader.
  52136. */
  52137. export class BabylonFileLoaderConfiguration {
  52138. /**
  52139. * The loader does not allow injecting custom physix engine into the plugins.
  52140. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52141. * So you could set this variable to your engine import to make it work.
  52142. */
  52143. static LoaderInjectedPhysicsEngine: any;
  52144. }
  52145. }
  52146. declare module BABYLON {
  52147. /**
  52148. * The Physically based simple base material of BJS.
  52149. *
  52150. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52151. * It is used as the base class for both the specGloss and metalRough conventions.
  52152. */
  52153. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52154. /**
  52155. * Number of Simultaneous lights allowed on the material.
  52156. */
  52157. maxSimultaneousLights: number;
  52158. /**
  52159. * If sets to true, disables all the lights affecting the material.
  52160. */
  52161. disableLighting: boolean;
  52162. /**
  52163. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52164. */
  52165. environmentTexture: BaseTexture;
  52166. /**
  52167. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52168. */
  52169. invertNormalMapX: boolean;
  52170. /**
  52171. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52172. */
  52173. invertNormalMapY: boolean;
  52174. /**
  52175. * Normal map used in the model.
  52176. */
  52177. normalTexture: BaseTexture;
  52178. /**
  52179. * Emissivie color used to self-illuminate the model.
  52180. */
  52181. emissiveColor: Color3;
  52182. /**
  52183. * Emissivie texture used to self-illuminate the model.
  52184. */
  52185. emissiveTexture: BaseTexture;
  52186. /**
  52187. * Occlusion Channel Strenght.
  52188. */
  52189. occlusionStrength: number;
  52190. /**
  52191. * Occlusion Texture of the material (adding extra occlusion effects).
  52192. */
  52193. occlusionTexture: BaseTexture;
  52194. /**
  52195. * Defines the alpha limits in alpha test mode.
  52196. */
  52197. alphaCutOff: number;
  52198. /**
  52199. * Gets the current double sided mode.
  52200. */
  52201. /**
  52202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52203. */
  52204. doubleSided: boolean;
  52205. /**
  52206. * Stores the pre-calculated light information of a mesh in a texture.
  52207. */
  52208. lightmapTexture: BaseTexture;
  52209. /**
  52210. * If true, the light map contains occlusion information instead of lighting info.
  52211. */
  52212. useLightmapAsShadowmap: boolean;
  52213. /**
  52214. * Instantiates a new PBRMaterial instance.
  52215. *
  52216. * @param name The material name
  52217. * @param scene The scene the material will be use in.
  52218. */
  52219. constructor(name: string, scene: Scene);
  52220. getClassName(): string;
  52221. }
  52222. }
  52223. declare module BABYLON {
  52224. /**
  52225. * The PBR material of BJS following the metal roughness convention.
  52226. *
  52227. * This fits to the PBR convention in the GLTF definition:
  52228. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52229. */
  52230. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52231. /**
  52232. * The base color has two different interpretations depending on the value of metalness.
  52233. * When the material is a metal, the base color is the specific measured reflectance value
  52234. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52235. * of the material.
  52236. */
  52237. baseColor: Color3;
  52238. /**
  52239. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52240. * well as opacity information in the alpha channel.
  52241. */
  52242. baseTexture: BaseTexture;
  52243. /**
  52244. * Specifies the metallic scalar value of the material.
  52245. * Can also be used to scale the metalness values of the metallic texture.
  52246. */
  52247. metallic: number;
  52248. /**
  52249. * Specifies the roughness scalar value of the material.
  52250. * Can also be used to scale the roughness values of the metallic texture.
  52251. */
  52252. roughness: number;
  52253. /**
  52254. * Texture containing both the metallic value in the B channel and the
  52255. * roughness value in the G channel to keep better precision.
  52256. */
  52257. metallicRoughnessTexture: BaseTexture;
  52258. /**
  52259. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52260. *
  52261. * @param name The material name
  52262. * @param scene The scene the material will be use in.
  52263. */
  52264. constructor(name: string, scene: Scene);
  52265. /**
  52266. * Return the currrent class name of the material.
  52267. */
  52268. getClassName(): string;
  52269. /**
  52270. * Makes a duplicate of the current material.
  52271. * @param name - name to use for the new material.
  52272. */
  52273. clone(name: string): PBRMetallicRoughnessMaterial;
  52274. /**
  52275. * Serialize the material to a parsable JSON object.
  52276. */
  52277. serialize(): any;
  52278. /**
  52279. * Parses a JSON object correponding to the serialize function.
  52280. */
  52281. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52282. }
  52283. }
  52284. declare module BABYLON {
  52285. /**
  52286. * The PBR material of BJS following the specular glossiness convention.
  52287. *
  52288. * This fits to the PBR convention in the GLTF definition:
  52289. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52290. */
  52291. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52292. /**
  52293. * Specifies the diffuse color of the material.
  52294. */
  52295. diffuseColor: Color3;
  52296. /**
  52297. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52298. * channel.
  52299. */
  52300. diffuseTexture: BaseTexture;
  52301. /**
  52302. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52303. */
  52304. specularColor: Color3;
  52305. /**
  52306. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52307. */
  52308. glossiness: number;
  52309. /**
  52310. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52311. */
  52312. specularGlossinessTexture: BaseTexture;
  52313. /**
  52314. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52315. *
  52316. * @param name The material name
  52317. * @param scene The scene the material will be use in.
  52318. */
  52319. constructor(name: string, scene: Scene);
  52320. /**
  52321. * Return the currrent class name of the material.
  52322. */
  52323. getClassName(): string;
  52324. /**
  52325. * Makes a duplicate of the current material.
  52326. * @param name - name to use for the new material.
  52327. */
  52328. clone(name: string): PBRSpecularGlossinessMaterial;
  52329. /**
  52330. * Serialize the material to a parsable JSON object.
  52331. */
  52332. serialize(): any;
  52333. /**
  52334. * Parses a JSON object correponding to the serialize function.
  52335. */
  52336. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52337. }
  52338. }
  52339. declare module BABYLON {
  52340. /**
  52341. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52342. * It can help converting any input color in a desired output one. This can then be used to create effects
  52343. * from sepia, black and white to sixties or futuristic rendering...
  52344. *
  52345. * The only supported format is currently 3dl.
  52346. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52347. */
  52348. export class ColorGradingTexture extends BaseTexture {
  52349. /**
  52350. * The current texture matrix. (will always be identity in color grading texture)
  52351. */
  52352. private _textureMatrix;
  52353. /**
  52354. * The texture URL.
  52355. */
  52356. url: string;
  52357. /**
  52358. * Empty line regex stored for GC.
  52359. */
  52360. private static _noneEmptyLineRegex;
  52361. private _engine;
  52362. /**
  52363. * Instantiates a ColorGradingTexture from the following parameters.
  52364. *
  52365. * @param url The location of the color gradind data (currently only supporting 3dl)
  52366. * @param scene The scene the texture will be used in
  52367. */
  52368. constructor(url: string, scene: Scene);
  52369. /**
  52370. * Returns the texture matrix used in most of the material.
  52371. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52372. */
  52373. getTextureMatrix(): Matrix;
  52374. /**
  52375. * Occurs when the file being loaded is a .3dl LUT file.
  52376. */
  52377. private load3dlTexture;
  52378. /**
  52379. * Starts the loading process of the texture.
  52380. */
  52381. private loadTexture;
  52382. /**
  52383. * Clones the color gradind texture.
  52384. */
  52385. clone(): ColorGradingTexture;
  52386. /**
  52387. * Called during delayed load for textures.
  52388. */
  52389. delayLoad(): void;
  52390. /**
  52391. * Parses a color grading texture serialized by Babylon.
  52392. * @param parsedTexture The texture information being parsedTexture
  52393. * @param scene The scene to load the texture in
  52394. * @param rootUrl The root url of the data assets to load
  52395. * @return A color gradind texture
  52396. */
  52397. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52398. /**
  52399. * Serializes the LUT texture to json format.
  52400. */
  52401. serialize(): any;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52407. */
  52408. export class EquiRectangularCubeTexture extends BaseTexture {
  52409. /** The six faces of the cube. */
  52410. private static _FacesMapping;
  52411. private _noMipmap;
  52412. private _onLoad;
  52413. private _onError;
  52414. /** The size of the cubemap. */
  52415. private _size;
  52416. /** The buffer of the image. */
  52417. private _buffer;
  52418. /** The width of the input image. */
  52419. private _width;
  52420. /** The height of the input image. */
  52421. private _height;
  52422. /** The URL to the image. */
  52423. url: string;
  52424. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52425. coordinatesMode: number;
  52426. /**
  52427. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52428. * @param url The location of the image
  52429. * @param scene The scene the texture will be used in
  52430. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52431. * @param noMipmap Forces to not generate the mipmap if true
  52432. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52433. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52434. * @param onLoad — defines a callback called when texture is loaded
  52435. * @param onError — defines a callback called if there is an error
  52436. */
  52437. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52438. /**
  52439. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52440. */
  52441. private loadImage;
  52442. /**
  52443. * Convert the image buffer into a cubemap and create a CubeTexture.
  52444. */
  52445. private loadTexture;
  52446. /**
  52447. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52448. * @param buffer The ArrayBuffer that should be converted.
  52449. * @returns The buffer as Float32Array.
  52450. */
  52451. private getFloat32ArrayFromArrayBuffer;
  52452. /**
  52453. * Get the current class name of the texture useful for serialization or dynamic coding.
  52454. * @returns "EquiRectangularCubeTexture"
  52455. */
  52456. getClassName(): string;
  52457. /**
  52458. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52459. * @returns A clone of the current EquiRectangularCubeTexture.
  52460. */
  52461. clone(): EquiRectangularCubeTexture;
  52462. }
  52463. }
  52464. declare module BABYLON {
  52465. /**
  52466. * Based on jsTGALoader - Javascript loader for TGA file
  52467. * By Vincent Thibault
  52468. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52469. */
  52470. export class TGATools {
  52471. private static _TYPE_INDEXED;
  52472. private static _TYPE_RGB;
  52473. private static _TYPE_GREY;
  52474. private static _TYPE_RLE_INDEXED;
  52475. private static _TYPE_RLE_RGB;
  52476. private static _TYPE_RLE_GREY;
  52477. private static _ORIGIN_MASK;
  52478. private static _ORIGIN_SHIFT;
  52479. private static _ORIGIN_BL;
  52480. private static _ORIGIN_BR;
  52481. private static _ORIGIN_UL;
  52482. private static _ORIGIN_UR;
  52483. /**
  52484. * Gets the header of a TGA file
  52485. * @param data defines the TGA data
  52486. * @returns the header
  52487. */
  52488. static GetTGAHeader(data: Uint8Array): any;
  52489. /**
  52490. * Uploads TGA content to a Babylon Texture
  52491. * @hidden
  52492. */
  52493. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52494. /** @hidden */
  52495. 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;
  52496. /** @hidden */
  52497. 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;
  52498. /** @hidden */
  52499. 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;
  52500. /** @hidden */
  52501. 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;
  52502. /** @hidden */
  52503. 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;
  52504. /** @hidden */
  52505. 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;
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * Implementation of the TGA Texture Loader.
  52511. * @hidden
  52512. */
  52513. export class _TGATextureLoader implements IInternalTextureLoader {
  52514. /**
  52515. * Defines wether the loader supports cascade loading the different faces.
  52516. */
  52517. readonly supportCascades: boolean;
  52518. /**
  52519. * This returns if the loader support the current file information.
  52520. * @param extension defines the file extension of the file being loaded
  52521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52522. * @param fallback defines the fallback internal texture if any
  52523. * @param isBase64 defines whether the texture is encoded as a base64
  52524. * @param isBuffer defines whether the texture data are stored as a buffer
  52525. * @returns true if the loader can load the specified file
  52526. */
  52527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52528. /**
  52529. * Transform the url before loading if required.
  52530. * @param rootUrl the url of the texture
  52531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52532. * @returns the transformed texture
  52533. */
  52534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52535. /**
  52536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52537. * @param rootUrl the url of the texture
  52538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52539. * @returns the fallback texture
  52540. */
  52541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52542. /**
  52543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52544. * @param data contains the texture data
  52545. * @param texture defines the BabylonJS internal texture
  52546. * @param createPolynomials will be true if polynomials have been requested
  52547. * @param onLoad defines the callback to trigger once the texture is ready
  52548. * @param onError defines the callback to trigger in case of error
  52549. */
  52550. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52551. /**
  52552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52553. * @param data contains the texture data
  52554. * @param texture defines the BabylonJS internal texture
  52555. * @param callback defines the method to call once ready to upload
  52556. */
  52557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52558. }
  52559. }
  52560. declare module BABYLON {
  52561. /**
  52562. * Info about the .basis files
  52563. */
  52564. class BasisFileInfo {
  52565. /**
  52566. * If the file has alpha
  52567. */
  52568. hasAlpha: boolean;
  52569. /**
  52570. * Info about each image of the basis file
  52571. */
  52572. images: Array<{
  52573. levels: Array<{
  52574. width: number;
  52575. height: number;
  52576. transcodedPixels: ArrayBufferView;
  52577. }>;
  52578. }>;
  52579. }
  52580. /**
  52581. * Result of transcoding a basis file
  52582. */
  52583. class TranscodeResult {
  52584. /**
  52585. * Info about the .basis file
  52586. */
  52587. fileInfo: BasisFileInfo;
  52588. /**
  52589. * Format to use when loading the file
  52590. */
  52591. format: number;
  52592. }
  52593. /**
  52594. * Configuration options for the Basis transcoder
  52595. */
  52596. export class BasisTranscodeConfiguration {
  52597. /**
  52598. * Supported compression formats used to determine the supported output format of the transcoder
  52599. */
  52600. supportedCompressionFormats?: {
  52601. /**
  52602. * etc1 compression format
  52603. */
  52604. etc1?: boolean;
  52605. /**
  52606. * s3tc compression format
  52607. */
  52608. s3tc?: boolean;
  52609. /**
  52610. * pvrtc compression format
  52611. */
  52612. pvrtc?: boolean;
  52613. /**
  52614. * etc2 compression format
  52615. */
  52616. etc2?: boolean;
  52617. };
  52618. /**
  52619. * If mipmap levels should be loaded for transcoded images (Default: true)
  52620. */
  52621. loadMipmapLevels?: boolean;
  52622. /**
  52623. * Index of a single image to load (Default: all images)
  52624. */
  52625. loadSingleImage?: number;
  52626. }
  52627. /**
  52628. * Used to load .Basis files
  52629. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52630. */
  52631. export class BasisTools {
  52632. private static _IgnoreSupportedFormats;
  52633. /**
  52634. * URL to use when loading the basis transcoder
  52635. */
  52636. static JSModuleURL: string;
  52637. /**
  52638. * URL to use when loading the wasm module for the transcoder
  52639. */
  52640. static WasmModuleURL: string;
  52641. /**
  52642. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52643. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52644. * @returns internal format corresponding to the Basis format
  52645. */
  52646. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52647. private static _WorkerPromise;
  52648. private static _Worker;
  52649. private static _actionId;
  52650. private static _CreateWorkerAsync;
  52651. /**
  52652. * Transcodes a loaded image file to compressed pixel data
  52653. * @param imageData image data to transcode
  52654. * @param config configuration options for the transcoding
  52655. * @returns a promise resulting in the transcoded image
  52656. */
  52657. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52658. /**
  52659. * Loads a texture from the transcode result
  52660. * @param texture texture load to
  52661. * @param transcodeResult the result of transcoding the basis file to load from
  52662. */
  52663. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52664. }
  52665. }
  52666. declare module BABYLON {
  52667. /**
  52668. * Loader for .basis file format
  52669. */
  52670. export class _BasisTextureLoader implements IInternalTextureLoader {
  52671. /**
  52672. * Defines whether the loader supports cascade loading the different faces.
  52673. */
  52674. readonly supportCascades: boolean;
  52675. /**
  52676. * This returns if the loader support the current file information.
  52677. * @param extension defines the file extension of the file being loaded
  52678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52679. * @param fallback defines the fallback internal texture if any
  52680. * @param isBase64 defines whether the texture is encoded as a base64
  52681. * @param isBuffer defines whether the texture data are stored as a buffer
  52682. * @returns true if the loader can load the specified file
  52683. */
  52684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52685. /**
  52686. * Transform the url before loading if required.
  52687. * @param rootUrl the url of the texture
  52688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52689. * @returns the transformed texture
  52690. */
  52691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52692. /**
  52693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52694. * @param rootUrl the url of the texture
  52695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52696. * @returns the fallback texture
  52697. */
  52698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52699. /**
  52700. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52701. * @param data contains the texture data
  52702. * @param texture defines the BabylonJS internal texture
  52703. * @param createPolynomials will be true if polynomials have been requested
  52704. * @param onLoad defines the callback to trigger once the texture is ready
  52705. * @param onError defines the callback to trigger in case of error
  52706. */
  52707. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52708. /**
  52709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52710. * @param data contains the texture data
  52711. * @param texture defines the BabylonJS internal texture
  52712. * @param callback defines the method to call once ready to upload
  52713. */
  52714. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52715. }
  52716. }
  52717. declare module BABYLON {
  52718. /**
  52719. * 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.
  52720. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52722. */
  52723. export class CustomProceduralTexture extends ProceduralTexture {
  52724. private _animate;
  52725. private _time;
  52726. private _config;
  52727. private _texturePath;
  52728. /**
  52729. * Instantiates a new Custom Procedural Texture.
  52730. * 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.
  52731. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52732. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52733. * @param name Define the name of the texture
  52734. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52735. * @param size Define the size of the texture to create
  52736. * @param scene Define the scene the texture belongs to
  52737. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52738. * @param generateMipMaps Define if the texture should creates mip maps or not
  52739. */
  52740. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52741. private _loadJson;
  52742. /**
  52743. * Is the texture ready to be used ? (rendered at least once)
  52744. * @returns true if ready, otherwise, false.
  52745. */
  52746. isReady(): boolean;
  52747. /**
  52748. * Render the texture to its associated render target.
  52749. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52750. */
  52751. render(useCameraPostProcess?: boolean): void;
  52752. /**
  52753. * Update the list of dependant textures samplers in the shader.
  52754. */
  52755. updateTextures(): void;
  52756. /**
  52757. * Update the uniform values of the procedural texture in the shader.
  52758. */
  52759. updateShaderUniforms(): void;
  52760. /**
  52761. * Define if the texture animates or not.
  52762. */
  52763. animate: boolean;
  52764. }
  52765. }
  52766. declare module BABYLON {
  52767. /** @hidden */
  52768. export var noisePixelShader: {
  52769. name: string;
  52770. shader: string;
  52771. };
  52772. }
  52773. declare module BABYLON {
  52774. /**
  52775. * Class used to generate noise procedural textures
  52776. */
  52777. export class NoiseProceduralTexture extends ProceduralTexture {
  52778. private _time;
  52779. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52780. brightness: number;
  52781. /** Defines the number of octaves to process */
  52782. octaves: number;
  52783. /** Defines the level of persistence (0.8 by default) */
  52784. persistence: number;
  52785. /** Gets or sets animation speed factor (default is 1) */
  52786. animationSpeedFactor: number;
  52787. /**
  52788. * Creates a new NoiseProceduralTexture
  52789. * @param name defines the name fo the texture
  52790. * @param size defines the size of the texture (default is 256)
  52791. * @param scene defines the hosting scene
  52792. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52793. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52794. */
  52795. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52796. private _updateShaderUniforms;
  52797. protected _getDefines(): string;
  52798. /** Generate the current state of the procedural texture */
  52799. render(useCameraPostProcess?: boolean): void;
  52800. /**
  52801. * Serializes this noise procedural texture
  52802. * @returns a serialized noise procedural texture object
  52803. */
  52804. serialize(): any;
  52805. /**
  52806. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52807. * @param parsedTexture defines parsed texture data
  52808. * @param scene defines the current scene
  52809. * @param rootUrl defines the root URL containing noise procedural texture information
  52810. * @returns a parsed NoiseProceduralTexture
  52811. */
  52812. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52813. }
  52814. }
  52815. declare module BABYLON {
  52816. /**
  52817. * Raw cube texture where the raw buffers are passed in
  52818. */
  52819. export class RawCubeTexture extends CubeTexture {
  52820. /**
  52821. * Creates a cube texture where the raw buffers are passed in.
  52822. * @param scene defines the scene the texture is attached to
  52823. * @param data defines the array of data to use to create each face
  52824. * @param size defines the size of the textures
  52825. * @param format defines the format of the data
  52826. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52827. * @param generateMipMaps defines if the engine should generate the mip levels
  52828. * @param invertY defines if data must be stored with Y axis inverted
  52829. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52830. * @param compression defines the compression used (null by default)
  52831. */
  52832. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52833. /**
  52834. * Updates the raw cube texture.
  52835. * @param data defines the data to store
  52836. * @param format defines the data format
  52837. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52838. * @param invertY defines if data must be stored with Y axis inverted
  52839. * @param compression defines the compression used (null by default)
  52840. * @param level defines which level of the texture to update
  52841. */
  52842. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52843. /**
  52844. * Updates a raw cube texture with RGBD encoded data.
  52845. * @param data defines the array of data [mipmap][face] to use to create each face
  52846. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52849. * @returns a promsie that resolves when the operation is complete
  52850. */
  52851. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52852. /**
  52853. * Clones the raw cube texture.
  52854. * @return a new cube texture
  52855. */
  52856. clone(): CubeTexture;
  52857. /** @hidden */
  52858. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52859. }
  52860. }
  52861. declare module BABYLON {
  52862. /**
  52863. * Class used to store 3D textures containing user data
  52864. */
  52865. export class RawTexture3D extends Texture {
  52866. /** Gets or sets the texture format to use */
  52867. format: number;
  52868. private _engine;
  52869. /**
  52870. * Create a new RawTexture3D
  52871. * @param data defines the data of the texture
  52872. * @param width defines the width of the texture
  52873. * @param height defines the height of the texture
  52874. * @param depth defines the depth of the texture
  52875. * @param format defines the texture format to use
  52876. * @param scene defines the hosting scene
  52877. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52878. * @param invertY defines if texture must be stored with Y axis inverted
  52879. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52880. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52881. */
  52882. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52883. /** Gets or sets the texture format to use */
  52884. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52885. /**
  52886. * Update the texture with new data
  52887. * @param data defines the data to store in the texture
  52888. */
  52889. update(data: ArrayBufferView): void;
  52890. }
  52891. }
  52892. declare module BABYLON {
  52893. /**
  52894. * Class used to store 2D array textures containing user data
  52895. */
  52896. export class RawTexture2DArray extends Texture {
  52897. /** Gets or sets the texture format to use */
  52898. format: number;
  52899. private _engine;
  52900. /**
  52901. * Create a new RawTexture2DArray
  52902. * @param data defines the data of the texture
  52903. * @param width defines the width of the texture
  52904. * @param height defines the height of the texture
  52905. * @param depth defines the number of layers of the texture
  52906. * @param format defines the texture format to use
  52907. * @param scene defines the hosting scene
  52908. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52909. * @param invertY defines if texture must be stored with Y axis inverted
  52910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52911. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52912. */
  52913. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52914. /** Gets or sets the texture format to use */
  52915. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52916. /**
  52917. * Update the texture with new data
  52918. * @param data defines the data to store in the texture
  52919. */
  52920. update(data: ArrayBufferView): void;
  52921. }
  52922. }
  52923. declare module BABYLON {
  52924. /**
  52925. * Creates a refraction texture used by refraction channel of the standard material.
  52926. * It is like a mirror but to see through a material.
  52927. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52928. */
  52929. export class RefractionTexture extends RenderTargetTexture {
  52930. /**
  52931. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52932. * 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.
  52933. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52934. */
  52935. refractionPlane: Plane;
  52936. /**
  52937. * Define how deep under the surface we should see.
  52938. */
  52939. depth: number;
  52940. /**
  52941. * Creates a refraction texture used by refraction channel of the standard material.
  52942. * It is like a mirror but to see through a material.
  52943. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52944. * @param name Define the texture name
  52945. * @param size Define the size of the underlying texture
  52946. * @param scene Define the scene the refraction belongs to
  52947. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52948. */
  52949. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52950. /**
  52951. * Clone the refraction texture.
  52952. * @returns the cloned texture
  52953. */
  52954. clone(): RefractionTexture;
  52955. /**
  52956. * Serialize the texture to a JSON representation you could use in Parse later on
  52957. * @returns the serialized JSON representation
  52958. */
  52959. serialize(): any;
  52960. }
  52961. }
  52962. declare module BABYLON {
  52963. /**
  52964. * Defines the options related to the creation of an HtmlElementTexture
  52965. */
  52966. export interface IHtmlElementTextureOptions {
  52967. /**
  52968. * Defines wether mip maps should be created or not.
  52969. */
  52970. generateMipMaps?: boolean;
  52971. /**
  52972. * Defines the sampling mode of the texture.
  52973. */
  52974. samplingMode?: number;
  52975. /**
  52976. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52977. */
  52978. engine: Nullable<ThinEngine>;
  52979. /**
  52980. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52981. */
  52982. scene: Nullable<Scene>;
  52983. }
  52984. /**
  52985. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52986. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52987. * is automatically managed.
  52988. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52989. * in your application.
  52990. *
  52991. * As the update is not automatic, you need to call them manually.
  52992. */
  52993. export class HtmlElementTexture extends BaseTexture {
  52994. /**
  52995. * The texture URL.
  52996. */
  52997. element: HTMLVideoElement | HTMLCanvasElement;
  52998. private static readonly DefaultOptions;
  52999. private _textureMatrix;
  53000. private _engine;
  53001. private _isVideo;
  53002. private _generateMipMaps;
  53003. private _samplingMode;
  53004. /**
  53005. * Instantiates a HtmlElementTexture from the following parameters.
  53006. *
  53007. * @param name Defines the name of the texture
  53008. * @param element Defines the video or canvas the texture is filled with
  53009. * @param options Defines the other none mandatory texture creation options
  53010. */
  53011. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53012. private _createInternalTexture;
  53013. /**
  53014. * Returns the texture matrix used in most of the material.
  53015. */
  53016. getTextureMatrix(): Matrix;
  53017. /**
  53018. * Updates the content of the texture.
  53019. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53020. */
  53021. update(invertY?: Nullable<boolean>): void;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. /**
  53026. * Enum used to define the target of a block
  53027. */
  53028. export enum NodeMaterialBlockTargets {
  53029. /** Vertex shader */
  53030. Vertex = 1,
  53031. /** Fragment shader */
  53032. Fragment = 2,
  53033. /** Neutral */
  53034. Neutral = 4,
  53035. /** Vertex and Fragment */
  53036. VertexAndFragment = 3
  53037. }
  53038. }
  53039. declare module BABYLON {
  53040. /**
  53041. * Defines the kind of connection point for node based material
  53042. */
  53043. export enum NodeMaterialBlockConnectionPointTypes {
  53044. /** Float */
  53045. Float = 1,
  53046. /** Int */
  53047. Int = 2,
  53048. /** Vector2 */
  53049. Vector2 = 4,
  53050. /** Vector3 */
  53051. Vector3 = 8,
  53052. /** Vector4 */
  53053. Vector4 = 16,
  53054. /** Color3 */
  53055. Color3 = 32,
  53056. /** Color4 */
  53057. Color4 = 64,
  53058. /** Matrix */
  53059. Matrix = 128,
  53060. /** Detect type based on connection */
  53061. AutoDetect = 1024,
  53062. /** Output type that will be defined by input type */
  53063. BasedOnInput = 2048
  53064. }
  53065. }
  53066. declare module BABYLON {
  53067. /**
  53068. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53069. */
  53070. export enum NodeMaterialBlockConnectionPointMode {
  53071. /** Value is an uniform */
  53072. Uniform = 0,
  53073. /** Value is a mesh attribute */
  53074. Attribute = 1,
  53075. /** Value is a varying between vertex and fragment shaders */
  53076. Varying = 2,
  53077. /** Mode is undefined */
  53078. Undefined = 3
  53079. }
  53080. }
  53081. declare module BABYLON {
  53082. /**
  53083. * Enum used to define system values e.g. values automatically provided by the system
  53084. */
  53085. export enum NodeMaterialSystemValues {
  53086. /** World */
  53087. World = 1,
  53088. /** View */
  53089. View = 2,
  53090. /** Projection */
  53091. Projection = 3,
  53092. /** ViewProjection */
  53093. ViewProjection = 4,
  53094. /** WorldView */
  53095. WorldView = 5,
  53096. /** WorldViewProjection */
  53097. WorldViewProjection = 6,
  53098. /** CameraPosition */
  53099. CameraPosition = 7,
  53100. /** Fog Color */
  53101. FogColor = 8,
  53102. /** Delta time */
  53103. DeltaTime = 9
  53104. }
  53105. }
  53106. declare module BABYLON {
  53107. /**
  53108. * Root class for all node material optimizers
  53109. */
  53110. export class NodeMaterialOptimizer {
  53111. /**
  53112. * Function used to optimize a NodeMaterial graph
  53113. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53114. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53115. */
  53116. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53117. }
  53118. }
  53119. declare module BABYLON {
  53120. /**
  53121. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53122. */
  53123. export class TransformBlock extends NodeMaterialBlock {
  53124. /**
  53125. * Defines the value to use to complement W value to transform it to a Vector4
  53126. */
  53127. complementW: number;
  53128. /**
  53129. * Defines the value to use to complement z value to transform it to a Vector4
  53130. */
  53131. complementZ: number;
  53132. /**
  53133. * Creates a new TransformBlock
  53134. * @param name defines the block name
  53135. */
  53136. constructor(name: string);
  53137. /**
  53138. * Gets the current class name
  53139. * @returns the class name
  53140. */
  53141. getClassName(): string;
  53142. /**
  53143. * Gets the vector input
  53144. */
  53145. readonly vector: NodeMaterialConnectionPoint;
  53146. /**
  53147. * Gets the output component
  53148. */
  53149. readonly output: NodeMaterialConnectionPoint;
  53150. /**
  53151. * Gets the matrix transform input
  53152. */
  53153. readonly transform: NodeMaterialConnectionPoint;
  53154. protected _buildBlock(state: NodeMaterialBuildState): this;
  53155. serialize(): any;
  53156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53157. protected _dumpPropertiesCode(): string;
  53158. }
  53159. }
  53160. declare module BABYLON {
  53161. /**
  53162. * Block used to output the vertex position
  53163. */
  53164. export class VertexOutputBlock extends NodeMaterialBlock {
  53165. /**
  53166. * Creates a new VertexOutputBlock
  53167. * @param name defines the block name
  53168. */
  53169. constructor(name: string);
  53170. /**
  53171. * Gets the current class name
  53172. * @returns the class name
  53173. */
  53174. getClassName(): string;
  53175. /**
  53176. * Gets the vector input component
  53177. */
  53178. readonly vector: NodeMaterialConnectionPoint;
  53179. protected _buildBlock(state: NodeMaterialBuildState): this;
  53180. }
  53181. }
  53182. declare module BABYLON {
  53183. /**
  53184. * Block used to output the final color
  53185. */
  53186. export class FragmentOutputBlock extends NodeMaterialBlock {
  53187. /**
  53188. * Create a new FragmentOutputBlock
  53189. * @param name defines the block name
  53190. */
  53191. constructor(name: string);
  53192. /**
  53193. * Gets the current class name
  53194. * @returns the class name
  53195. */
  53196. getClassName(): string;
  53197. /**
  53198. * Gets the rgba input component
  53199. */
  53200. readonly rgba: NodeMaterialConnectionPoint;
  53201. /**
  53202. * Gets the rgb input component
  53203. */
  53204. readonly rgb: NodeMaterialConnectionPoint;
  53205. /**
  53206. * Gets the a input component
  53207. */
  53208. readonly a: NodeMaterialConnectionPoint;
  53209. protected _buildBlock(state: NodeMaterialBuildState): this;
  53210. }
  53211. }
  53212. declare module BABYLON {
  53213. /**
  53214. * Block used to read a reflection texture from a sampler
  53215. */
  53216. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53217. private _define3DName;
  53218. private _defineCubicName;
  53219. private _defineExplicitName;
  53220. private _defineProjectionName;
  53221. private _defineLocalCubicName;
  53222. private _defineSphericalName;
  53223. private _definePlanarName;
  53224. private _defineEquirectangularName;
  53225. private _defineMirroredEquirectangularFixedName;
  53226. private _defineEquirectangularFixedName;
  53227. private _defineSkyboxName;
  53228. private _cubeSamplerName;
  53229. private _2DSamplerName;
  53230. private _positionUVWName;
  53231. private _directionWName;
  53232. private _reflectionCoordsName;
  53233. private _reflection2DCoordsName;
  53234. private _reflectionColorName;
  53235. private _reflectionMatrixName;
  53236. /**
  53237. * Gets or sets the texture associated with the node
  53238. */
  53239. texture: Nullable<BaseTexture>;
  53240. /**
  53241. * Create a new TextureBlock
  53242. * @param name defines the block name
  53243. */
  53244. constructor(name: string);
  53245. /**
  53246. * Gets the current class name
  53247. * @returns the class name
  53248. */
  53249. getClassName(): string;
  53250. /**
  53251. * Gets the world position input component
  53252. */
  53253. readonly position: NodeMaterialConnectionPoint;
  53254. /**
  53255. * Gets the world position input component
  53256. */
  53257. readonly worldPosition: NodeMaterialConnectionPoint;
  53258. /**
  53259. * Gets the world normal input component
  53260. */
  53261. readonly worldNormal: NodeMaterialConnectionPoint;
  53262. /**
  53263. * Gets the world input component
  53264. */
  53265. readonly world: NodeMaterialConnectionPoint;
  53266. /**
  53267. * Gets the camera (or eye) position component
  53268. */
  53269. readonly cameraPosition: NodeMaterialConnectionPoint;
  53270. /**
  53271. * Gets the view input component
  53272. */
  53273. readonly view: NodeMaterialConnectionPoint;
  53274. /**
  53275. * Gets the rgb output component
  53276. */
  53277. readonly rgb: NodeMaterialConnectionPoint;
  53278. /**
  53279. * Gets the r output component
  53280. */
  53281. readonly r: NodeMaterialConnectionPoint;
  53282. /**
  53283. * Gets the g output component
  53284. */
  53285. readonly g: NodeMaterialConnectionPoint;
  53286. /**
  53287. * Gets the b output component
  53288. */
  53289. readonly b: NodeMaterialConnectionPoint;
  53290. autoConfigure(material: NodeMaterial): void;
  53291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53292. isReady(): boolean;
  53293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53294. private _injectVertexCode;
  53295. private _writeOutput;
  53296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53297. protected _dumpPropertiesCode(): string;
  53298. serialize(): any;
  53299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Interface used to configure the node material editor
  53305. */
  53306. export interface INodeMaterialEditorOptions {
  53307. /** Define the URl to load node editor script */
  53308. editorURL?: string;
  53309. }
  53310. /** @hidden */
  53311. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53312. /** BONES */
  53313. NUM_BONE_INFLUENCERS: number;
  53314. BonesPerMesh: number;
  53315. BONETEXTURE: boolean;
  53316. /** MORPH TARGETS */
  53317. MORPHTARGETS: boolean;
  53318. MORPHTARGETS_NORMAL: boolean;
  53319. MORPHTARGETS_TANGENT: boolean;
  53320. MORPHTARGETS_UV: boolean;
  53321. NUM_MORPH_INFLUENCERS: number;
  53322. /** IMAGE PROCESSING */
  53323. IMAGEPROCESSING: boolean;
  53324. VIGNETTE: boolean;
  53325. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53326. VIGNETTEBLENDMODEOPAQUE: boolean;
  53327. TONEMAPPING: boolean;
  53328. TONEMAPPING_ACES: boolean;
  53329. CONTRAST: boolean;
  53330. EXPOSURE: boolean;
  53331. COLORCURVES: boolean;
  53332. COLORGRADING: boolean;
  53333. COLORGRADING3D: boolean;
  53334. SAMPLER3DGREENDEPTH: boolean;
  53335. SAMPLER3DBGRMAP: boolean;
  53336. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53337. /** MISC. */
  53338. BUMPDIRECTUV: number;
  53339. constructor();
  53340. setValue(name: string, value: boolean): void;
  53341. }
  53342. /**
  53343. * Class used to configure NodeMaterial
  53344. */
  53345. export interface INodeMaterialOptions {
  53346. /**
  53347. * Defines if blocks should emit comments
  53348. */
  53349. emitComments: boolean;
  53350. }
  53351. /**
  53352. * Class used to create a node based material built by assembling shader blocks
  53353. */
  53354. export class NodeMaterial extends PushMaterial {
  53355. private static _BuildIdGenerator;
  53356. private _options;
  53357. private _vertexCompilationState;
  53358. private _fragmentCompilationState;
  53359. private _sharedData;
  53360. private _buildId;
  53361. private _buildWasSuccessful;
  53362. private _cachedWorldViewMatrix;
  53363. private _cachedWorldViewProjectionMatrix;
  53364. private _optimizers;
  53365. private _animationFrame;
  53366. /** Define the URl to load node editor script */
  53367. static EditorURL: string;
  53368. private BJSNODEMATERIALEDITOR;
  53369. /** Get the inspector from bundle or global */
  53370. private _getGlobalNodeMaterialEditor;
  53371. /**
  53372. * 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)
  53373. */
  53374. ignoreAlpha: boolean;
  53375. /**
  53376. * Defines the maximum number of lights that can be used in the material
  53377. */
  53378. maxSimultaneousLights: number;
  53379. /**
  53380. * Observable raised when the material is built
  53381. */
  53382. onBuildObservable: Observable<NodeMaterial>;
  53383. /**
  53384. * Gets or sets the root nodes of the material vertex shader
  53385. */
  53386. _vertexOutputNodes: NodeMaterialBlock[];
  53387. /**
  53388. * Gets or sets the root nodes of the material fragment (pixel) shader
  53389. */
  53390. _fragmentOutputNodes: NodeMaterialBlock[];
  53391. /** Gets or sets options to control the node material overall behavior */
  53392. options: INodeMaterialOptions;
  53393. /**
  53394. * Default configuration related to image processing available in the standard Material.
  53395. */
  53396. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53397. /**
  53398. * Gets the image processing configuration used either in this material.
  53399. */
  53400. /**
  53401. * Sets the Default image processing configuration used either in the this material.
  53402. *
  53403. * If sets to null, the scene one is in use.
  53404. */
  53405. imageProcessingConfiguration: ImageProcessingConfiguration;
  53406. /**
  53407. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53408. */
  53409. attachedBlocks: NodeMaterialBlock[];
  53410. /**
  53411. * Create a new node based material
  53412. * @param name defines the material name
  53413. * @param scene defines the hosting scene
  53414. * @param options defines creation option
  53415. */
  53416. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53417. /**
  53418. * Gets the current class name of the material e.g. "NodeMaterial"
  53419. * @returns the class name
  53420. */
  53421. getClassName(): string;
  53422. /**
  53423. * Keep track of the image processing observer to allow dispose and replace.
  53424. */
  53425. private _imageProcessingObserver;
  53426. /**
  53427. * Attaches a new image processing configuration to the Standard Material.
  53428. * @param configuration
  53429. */
  53430. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53431. /**
  53432. * Get a block by its name
  53433. * @param name defines the name of the block to retrieve
  53434. * @returns the required block or null if not found
  53435. */
  53436. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53437. /**
  53438. * Get a block by its name
  53439. * @param predicate defines the predicate used to find the good candidate
  53440. * @returns the required block or null if not found
  53441. */
  53442. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53443. /**
  53444. * Get an input block by its name
  53445. * @param predicate defines the predicate used to find the good candidate
  53446. * @returns the required input block or null if not found
  53447. */
  53448. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53449. /**
  53450. * Gets the list of input blocks attached to this material
  53451. * @returns an array of InputBlocks
  53452. */
  53453. getInputBlocks(): InputBlock[];
  53454. /**
  53455. * Adds a new optimizer to the list of optimizers
  53456. * @param optimizer defines the optimizers to add
  53457. * @returns the current material
  53458. */
  53459. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53460. /**
  53461. * Remove an optimizer from the list of optimizers
  53462. * @param optimizer defines the optimizers to remove
  53463. * @returns the current material
  53464. */
  53465. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53466. /**
  53467. * Add a new block to the list of output nodes
  53468. * @param node defines the node to add
  53469. * @returns the current material
  53470. */
  53471. addOutputNode(node: NodeMaterialBlock): this;
  53472. /**
  53473. * Remove a block from the list of root nodes
  53474. * @param node defines the node to remove
  53475. * @returns the current material
  53476. */
  53477. removeOutputNode(node: NodeMaterialBlock): this;
  53478. private _addVertexOutputNode;
  53479. private _removeVertexOutputNode;
  53480. private _addFragmentOutputNode;
  53481. private _removeFragmentOutputNode;
  53482. /**
  53483. * Specifies if the material will require alpha blending
  53484. * @returns a boolean specifying if alpha blending is needed
  53485. */
  53486. needAlphaBlending(): boolean;
  53487. /**
  53488. * Specifies if this material should be rendered in alpha test mode
  53489. * @returns a boolean specifying if an alpha test is needed.
  53490. */
  53491. needAlphaTesting(): boolean;
  53492. private _initializeBlock;
  53493. private _resetDualBlocks;
  53494. /**
  53495. * Build the material and generates the inner effect
  53496. * @param verbose defines if the build should log activity
  53497. */
  53498. build(verbose?: boolean): void;
  53499. /**
  53500. * Runs an otpimization phase to try to improve the shader code
  53501. */
  53502. optimize(): void;
  53503. private _prepareDefinesForAttributes;
  53504. /**
  53505. * Get if the submesh is ready to be used and all its information available.
  53506. * Child classes can use it to update shaders
  53507. * @param mesh defines the mesh to check
  53508. * @param subMesh defines which submesh to check
  53509. * @param useInstances specifies that instances should be used
  53510. * @returns a boolean indicating that the submesh is ready or not
  53511. */
  53512. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53513. /**
  53514. * Get a string representing the shaders built by the current node graph
  53515. */
  53516. readonly compiledShaders: string;
  53517. /**
  53518. * Binds the world matrix to the material
  53519. * @param world defines the world transformation matrix
  53520. */
  53521. bindOnlyWorldMatrix(world: Matrix): void;
  53522. /**
  53523. * Binds the submesh to this material by preparing the effect and shader to draw
  53524. * @param world defines the world transformation matrix
  53525. * @param mesh defines the mesh containing the submesh
  53526. * @param subMesh defines the submesh to bind the material to
  53527. */
  53528. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53529. /**
  53530. * Gets the active textures from the material
  53531. * @returns an array of textures
  53532. */
  53533. getActiveTextures(): BaseTexture[];
  53534. /**
  53535. * Gets the list of texture blocks
  53536. * @returns an array of texture blocks
  53537. */
  53538. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53539. /**
  53540. * Specifies if the material uses a texture
  53541. * @param texture defines the texture to check against the material
  53542. * @returns a boolean specifying if the material uses the texture
  53543. */
  53544. hasTexture(texture: BaseTexture): boolean;
  53545. /**
  53546. * Disposes the material
  53547. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53548. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53549. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53550. */
  53551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53552. /** Creates the node editor window. */
  53553. private _createNodeEditor;
  53554. /**
  53555. * Launch the node material editor
  53556. * @param config Define the configuration of the editor
  53557. * @return a promise fulfilled when the node editor is visible
  53558. */
  53559. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53560. /**
  53561. * Clear the current material
  53562. */
  53563. clear(): void;
  53564. /**
  53565. * Clear the current material and set it to a default state
  53566. */
  53567. setToDefault(): void;
  53568. /**
  53569. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53570. * @param url defines the url to load from
  53571. * @returns a promise that will fullfil when the material is fully loaded
  53572. */
  53573. loadAsync(url: string): Promise<void>;
  53574. private _gatherBlocks;
  53575. /**
  53576. * Generate a string containing the code declaration required to create an equivalent of this material
  53577. * @returns a string
  53578. */
  53579. generateCode(): string;
  53580. /**
  53581. * Serializes this material in a JSON representation
  53582. * @returns the serialized material object
  53583. */
  53584. serialize(): any;
  53585. private _restoreConnections;
  53586. /**
  53587. * Clear the current graph and load a new one from a serialization object
  53588. * @param source defines the JSON representation of the material
  53589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53590. */
  53591. loadFromSerialization(source: any, rootUrl?: string): void;
  53592. /**
  53593. * Creates a node material from parsed material data
  53594. * @param source defines the JSON representation of the material
  53595. * @param scene defines the hosting scene
  53596. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53597. * @returns a new node material
  53598. */
  53599. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53600. /**
  53601. * Creates a new node material set to default basic configuration
  53602. * @param name defines the name of the material
  53603. * @param scene defines the hosting scene
  53604. * @returns a new NodeMaterial
  53605. */
  53606. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. /**
  53611. * Block used to read a texture from a sampler
  53612. */
  53613. export class TextureBlock extends NodeMaterialBlock {
  53614. private _defineName;
  53615. private _linearDefineName;
  53616. private _samplerName;
  53617. private _transformedUVName;
  53618. private _textureTransformName;
  53619. private _textureInfoName;
  53620. private _mainUVName;
  53621. private _mainUVDefineName;
  53622. /**
  53623. * Gets or sets the texture associated with the node
  53624. */
  53625. texture: Nullable<Texture>;
  53626. /**
  53627. * Create a new TextureBlock
  53628. * @param name defines the block name
  53629. */
  53630. constructor(name: string);
  53631. /**
  53632. * Gets the current class name
  53633. * @returns the class name
  53634. */
  53635. getClassName(): string;
  53636. /**
  53637. * Gets the uv input component
  53638. */
  53639. readonly uv: NodeMaterialConnectionPoint;
  53640. /**
  53641. * Gets the rgba output component
  53642. */
  53643. readonly rgba: NodeMaterialConnectionPoint;
  53644. /**
  53645. * Gets the rgb output component
  53646. */
  53647. readonly rgb: NodeMaterialConnectionPoint;
  53648. /**
  53649. * Gets the r output component
  53650. */
  53651. readonly r: NodeMaterialConnectionPoint;
  53652. /**
  53653. * Gets the g output component
  53654. */
  53655. readonly g: NodeMaterialConnectionPoint;
  53656. /**
  53657. * Gets the b output component
  53658. */
  53659. readonly b: NodeMaterialConnectionPoint;
  53660. /**
  53661. * Gets the a output component
  53662. */
  53663. readonly a: NodeMaterialConnectionPoint;
  53664. readonly target: NodeMaterialBlockTargets;
  53665. autoConfigure(material: NodeMaterial): void;
  53666. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53668. isReady(): boolean;
  53669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53670. private readonly _isMixed;
  53671. private _injectVertexCode;
  53672. private _writeOutput;
  53673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53674. protected _dumpPropertiesCode(): string;
  53675. serialize(): any;
  53676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53677. }
  53678. }
  53679. declare module BABYLON {
  53680. /**
  53681. * Class used to store shared data between 2 NodeMaterialBuildState
  53682. */
  53683. export class NodeMaterialBuildStateSharedData {
  53684. /**
  53685. * Gets the list of emitted varyings
  53686. */
  53687. temps: string[];
  53688. /**
  53689. * Gets the list of emitted varyings
  53690. */
  53691. varyings: string[];
  53692. /**
  53693. * Gets the varying declaration string
  53694. */
  53695. varyingDeclaration: string;
  53696. /**
  53697. * Input blocks
  53698. */
  53699. inputBlocks: InputBlock[];
  53700. /**
  53701. * Input blocks
  53702. */
  53703. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53704. /**
  53705. * Bindable blocks (Blocks that need to set data to the effect)
  53706. */
  53707. bindableBlocks: NodeMaterialBlock[];
  53708. /**
  53709. * List of blocks that can provide a compilation fallback
  53710. */
  53711. blocksWithFallbacks: NodeMaterialBlock[];
  53712. /**
  53713. * List of blocks that can provide a define update
  53714. */
  53715. blocksWithDefines: NodeMaterialBlock[];
  53716. /**
  53717. * List of blocks that can provide a repeatable content
  53718. */
  53719. repeatableContentBlocks: NodeMaterialBlock[];
  53720. /**
  53721. * List of blocks that can provide a dynamic list of uniforms
  53722. */
  53723. dynamicUniformBlocks: NodeMaterialBlock[];
  53724. /**
  53725. * List of blocks that can block the isReady function for the material
  53726. */
  53727. blockingBlocks: NodeMaterialBlock[];
  53728. /**
  53729. * Gets the list of animated inputs
  53730. */
  53731. animatedInputs: InputBlock[];
  53732. /**
  53733. * Build Id used to avoid multiple recompilations
  53734. */
  53735. buildId: number;
  53736. /** List of emitted variables */
  53737. variableNames: {
  53738. [key: string]: number;
  53739. };
  53740. /** List of emitted defines */
  53741. defineNames: {
  53742. [key: string]: number;
  53743. };
  53744. /** Should emit comments? */
  53745. emitComments: boolean;
  53746. /** Emit build activity */
  53747. verbose: boolean;
  53748. /** Gets or sets the hosting scene */
  53749. scene: Scene;
  53750. /**
  53751. * Gets the compilation hints emitted at compilation time
  53752. */
  53753. hints: {
  53754. needWorldViewMatrix: boolean;
  53755. needWorldViewProjectionMatrix: boolean;
  53756. needAlphaBlending: boolean;
  53757. needAlphaTesting: boolean;
  53758. };
  53759. /**
  53760. * List of compilation checks
  53761. */
  53762. checks: {
  53763. emitVertex: boolean;
  53764. emitFragment: boolean;
  53765. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53766. };
  53767. /** Creates a new shared data */
  53768. constructor();
  53769. /**
  53770. * Emits console errors and exceptions if there is a failing check
  53771. */
  53772. emitErrors(): void;
  53773. }
  53774. }
  53775. declare module BABYLON {
  53776. /**
  53777. * Class used to store node based material build state
  53778. */
  53779. export class NodeMaterialBuildState {
  53780. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53781. supportUniformBuffers: boolean;
  53782. /**
  53783. * Gets the list of emitted attributes
  53784. */
  53785. attributes: string[];
  53786. /**
  53787. * Gets the list of emitted uniforms
  53788. */
  53789. uniforms: string[];
  53790. /**
  53791. * Gets the list of emitted constants
  53792. */
  53793. constants: string[];
  53794. /**
  53795. * Gets the list of emitted samplers
  53796. */
  53797. samplers: string[];
  53798. /**
  53799. * Gets the list of emitted functions
  53800. */
  53801. functions: {
  53802. [key: string]: string;
  53803. };
  53804. /**
  53805. * Gets the list of emitted extensions
  53806. */
  53807. extensions: {
  53808. [key: string]: string;
  53809. };
  53810. /**
  53811. * Gets the target of the compilation state
  53812. */
  53813. target: NodeMaterialBlockTargets;
  53814. /**
  53815. * Gets the list of emitted counters
  53816. */
  53817. counters: {
  53818. [key: string]: number;
  53819. };
  53820. /**
  53821. * Shared data between multiple NodeMaterialBuildState instances
  53822. */
  53823. sharedData: NodeMaterialBuildStateSharedData;
  53824. /** @hidden */
  53825. _vertexState: NodeMaterialBuildState;
  53826. /** @hidden */
  53827. _attributeDeclaration: string;
  53828. /** @hidden */
  53829. _uniformDeclaration: string;
  53830. /** @hidden */
  53831. _constantDeclaration: string;
  53832. /** @hidden */
  53833. _samplerDeclaration: string;
  53834. /** @hidden */
  53835. _varyingTransfer: string;
  53836. private _repeatableContentAnchorIndex;
  53837. /** @hidden */
  53838. _builtCompilationString: string;
  53839. /**
  53840. * Gets the emitted compilation strings
  53841. */
  53842. compilationString: string;
  53843. /**
  53844. * Finalize the compilation strings
  53845. * @param state defines the current compilation state
  53846. */
  53847. finalize(state: NodeMaterialBuildState): void;
  53848. /** @hidden */
  53849. readonly _repeatableContentAnchor: string;
  53850. /** @hidden */
  53851. _getFreeVariableName(prefix: string): string;
  53852. /** @hidden */
  53853. _getFreeDefineName(prefix: string): string;
  53854. /** @hidden */
  53855. _excludeVariableName(name: string): void;
  53856. /** @hidden */
  53857. _emit2DSampler(name: string): void;
  53858. /** @hidden */
  53859. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53860. /** @hidden */
  53861. _emitExtension(name: string, extension: string): void;
  53862. /** @hidden */
  53863. _emitFunction(name: string, code: string, comments: string): void;
  53864. /** @hidden */
  53865. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53866. replaceStrings?: {
  53867. search: RegExp;
  53868. replace: string;
  53869. }[];
  53870. repeatKey?: string;
  53871. }): string;
  53872. /** @hidden */
  53873. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53874. repeatKey?: string;
  53875. removeAttributes?: boolean;
  53876. removeUniforms?: boolean;
  53877. removeVaryings?: boolean;
  53878. removeIfDef?: boolean;
  53879. replaceStrings?: {
  53880. search: RegExp;
  53881. replace: string;
  53882. }[];
  53883. }, storeKey?: string): void;
  53884. /** @hidden */
  53885. _registerTempVariable(name: string): boolean;
  53886. /** @hidden */
  53887. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53888. /** @hidden */
  53889. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53890. /** @hidden */
  53891. _emitFloat(value: number): string;
  53892. }
  53893. }
  53894. declare module BABYLON {
  53895. /**
  53896. * Defines a block that can be used inside a node based material
  53897. */
  53898. export class NodeMaterialBlock {
  53899. private _buildId;
  53900. private _buildTarget;
  53901. private _target;
  53902. private _isFinalMerger;
  53903. private _isInput;
  53904. /** @hidden */
  53905. _codeVariableName: string;
  53906. /** @hidden */
  53907. _inputs: NodeMaterialConnectionPoint[];
  53908. /** @hidden */
  53909. _outputs: NodeMaterialConnectionPoint[];
  53910. /** @hidden */
  53911. _preparationId: number;
  53912. /**
  53913. * Gets or sets the name of the block
  53914. */
  53915. name: string;
  53916. /**
  53917. * Gets or sets the unique id of the node
  53918. */
  53919. uniqueId: number;
  53920. /**
  53921. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53922. */
  53923. readonly isFinalMerger: boolean;
  53924. /**
  53925. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53926. */
  53927. readonly isInput: boolean;
  53928. /**
  53929. * Gets or sets the build Id
  53930. */
  53931. buildId: number;
  53932. /**
  53933. * Gets or sets the target of the block
  53934. */
  53935. target: NodeMaterialBlockTargets;
  53936. /**
  53937. * Gets the list of input points
  53938. */
  53939. readonly inputs: NodeMaterialConnectionPoint[];
  53940. /** Gets the list of output points */
  53941. readonly outputs: NodeMaterialConnectionPoint[];
  53942. /**
  53943. * Find an input by its name
  53944. * @param name defines the name of the input to look for
  53945. * @returns the input or null if not found
  53946. */
  53947. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53948. /**
  53949. * Find an output by its name
  53950. * @param name defines the name of the outputto look for
  53951. * @returns the output or null if not found
  53952. */
  53953. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53954. /**
  53955. * Creates a new NodeMaterialBlock
  53956. * @param name defines the block name
  53957. * @param target defines the target of that block (Vertex by default)
  53958. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53959. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53960. */
  53961. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53962. /**
  53963. * Initialize the block and prepare the context for build
  53964. * @param state defines the state that will be used for the build
  53965. */
  53966. initialize(state: NodeMaterialBuildState): void;
  53967. /**
  53968. * Bind data to effect. Will only be called for blocks with isBindable === true
  53969. * @param effect defines the effect to bind data to
  53970. * @param nodeMaterial defines the hosting NodeMaterial
  53971. * @param mesh defines the mesh that will be rendered
  53972. */
  53973. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53974. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53975. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53976. protected _writeFloat(value: number): string;
  53977. /**
  53978. * Gets the current class name e.g. "NodeMaterialBlock"
  53979. * @returns the class name
  53980. */
  53981. getClassName(): string;
  53982. /**
  53983. * Register a new input. Must be called inside a block constructor
  53984. * @param name defines the connection point name
  53985. * @param type defines the connection point type
  53986. * @param isOptional defines a boolean indicating that this input can be omitted
  53987. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53988. * @returns the current block
  53989. */
  53990. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53991. /**
  53992. * Register a new output. Must be called inside a block constructor
  53993. * @param name defines the connection point name
  53994. * @param type defines the connection point type
  53995. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53996. * @returns the current block
  53997. */
  53998. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53999. /**
  54000. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54001. * @param forOutput defines an optional connection point to check compatibility with
  54002. * @returns the first available input or null
  54003. */
  54004. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54005. /**
  54006. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54007. * @param forBlock defines an optional block to check compatibility with
  54008. * @returns the first available input or null
  54009. */
  54010. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54011. /**
  54012. * Gets the sibling of the given output
  54013. * @param current defines the current output
  54014. * @returns the next output in the list or null
  54015. */
  54016. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54017. /**
  54018. * Connect current block with another block
  54019. * @param other defines the block to connect with
  54020. * @param options define the various options to help pick the right connections
  54021. * @returns the current block
  54022. */
  54023. connectTo(other: NodeMaterialBlock, options?: {
  54024. input?: string;
  54025. output?: string;
  54026. outputSwizzle?: string;
  54027. }): this | undefined;
  54028. protected _buildBlock(state: NodeMaterialBuildState): void;
  54029. /**
  54030. * Add uniforms, samplers and uniform buffers at compilation time
  54031. * @param state defines the state to update
  54032. * @param nodeMaterial defines the node material requesting the update
  54033. * @param defines defines the material defines to update
  54034. * @param uniformBuffers defines the list of uniform buffer names
  54035. */
  54036. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54037. /**
  54038. * Add potential fallbacks if shader compilation fails
  54039. * @param mesh defines the mesh to be rendered
  54040. * @param fallbacks defines the current prioritized list of fallbacks
  54041. */
  54042. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54043. /**
  54044. * Initialize defines for shader compilation
  54045. * @param mesh defines the mesh to be rendered
  54046. * @param nodeMaterial defines the node material requesting the update
  54047. * @param defines defines the material defines to update
  54048. * @param useInstances specifies that instances should be used
  54049. */
  54050. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54051. /**
  54052. * Update defines for shader compilation
  54053. * @param mesh defines the mesh to be rendered
  54054. * @param nodeMaterial defines the node material requesting the update
  54055. * @param defines defines the material defines to update
  54056. * @param useInstances specifies that instances should be used
  54057. */
  54058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54059. /**
  54060. * Lets the block try to connect some inputs automatically
  54061. * @param material defines the hosting NodeMaterial
  54062. */
  54063. autoConfigure(material: NodeMaterial): void;
  54064. /**
  54065. * Function called when a block is declared as repeatable content generator
  54066. * @param vertexShaderState defines the current compilation state for the vertex shader
  54067. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54068. * @param mesh defines the mesh to be rendered
  54069. * @param defines defines the material defines to update
  54070. */
  54071. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54072. /**
  54073. * Checks if the block is ready
  54074. * @param mesh defines the mesh to be rendered
  54075. * @param nodeMaterial defines the node material requesting the update
  54076. * @param defines defines the material defines to update
  54077. * @param useInstances specifies that instances should be used
  54078. * @returns true if the block is ready
  54079. */
  54080. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54081. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54082. private _processBuild;
  54083. /**
  54084. * Compile the current node and generate the shader code
  54085. * @param state defines the current compilation state (uniforms, samplers, current string)
  54086. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54087. * @returns true if already built
  54088. */
  54089. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54090. protected _inputRename(name: string): string;
  54091. protected _outputRename(name: string): string;
  54092. protected _dumpPropertiesCode(): string;
  54093. /** @hidden */
  54094. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54095. /** @hidden */
  54096. _dumpCodeForOutputConnections(): string;
  54097. /**
  54098. * Clone the current block to a new identical block
  54099. * @param scene defines the hosting scene
  54100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54101. * @returns a copy of the current block
  54102. */
  54103. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54104. /**
  54105. * Serializes this block in a JSON representation
  54106. * @returns the serialized block object
  54107. */
  54108. serialize(): any;
  54109. /** @hidden */
  54110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54111. /**
  54112. * Release resources
  54113. */
  54114. dispose(): void;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * Enum defining the type of animations supported by InputBlock
  54120. */
  54121. export enum AnimatedInputBlockTypes {
  54122. /** No animation */
  54123. None = 0,
  54124. /** Time based animation. Will only work for floats */
  54125. Time = 1
  54126. }
  54127. }
  54128. declare module BABYLON {
  54129. /**
  54130. * Block used to expose an input value
  54131. */
  54132. export class InputBlock extends NodeMaterialBlock {
  54133. private _mode;
  54134. private _associatedVariableName;
  54135. private _storedValue;
  54136. private _valueCallback;
  54137. private _type;
  54138. private _animationType;
  54139. /** Gets or set a value used to limit the range of float values */
  54140. min: number;
  54141. /** Gets or set a value used to limit the range of float values */
  54142. max: number;
  54143. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54144. matrixMode: number;
  54145. /** @hidden */
  54146. _systemValue: Nullable<NodeMaterialSystemValues>;
  54147. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54148. visibleInInspector: boolean;
  54149. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54150. isConstant: boolean;
  54151. /**
  54152. * Gets or sets the connection point type (default is float)
  54153. */
  54154. readonly type: NodeMaterialBlockConnectionPointTypes;
  54155. /**
  54156. * Creates a new InputBlock
  54157. * @param name defines the block name
  54158. * @param target defines the target of that block (Vertex by default)
  54159. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54160. */
  54161. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54162. /**
  54163. * Gets the output component
  54164. */
  54165. readonly output: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Set the source of this connection point to a vertex attribute
  54168. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54169. * @returns the current connection point
  54170. */
  54171. setAsAttribute(attributeName?: string): InputBlock;
  54172. /**
  54173. * Set the source of this connection point to a system value
  54174. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54175. * @returns the current connection point
  54176. */
  54177. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54178. /**
  54179. * Gets or sets the value of that point.
  54180. * Please note that this value will be ignored if valueCallback is defined
  54181. */
  54182. value: any;
  54183. /**
  54184. * Gets or sets a callback used to get the value of that point.
  54185. * Please note that setting this value will force the connection point to ignore the value property
  54186. */
  54187. valueCallback: () => any;
  54188. /**
  54189. * Gets or sets the associated variable name in the shader
  54190. */
  54191. associatedVariableName: string;
  54192. /** Gets or sets the type of animation applied to the input */
  54193. animationType: AnimatedInputBlockTypes;
  54194. /**
  54195. * Gets a boolean indicating that this connection point not defined yet
  54196. */
  54197. readonly isUndefined: boolean;
  54198. /**
  54199. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54200. * In this case the connection point name must be the name of the uniform to use.
  54201. * Can only be set on inputs
  54202. */
  54203. isUniform: boolean;
  54204. /**
  54205. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54206. * In this case the connection point name must be the name of the attribute to use
  54207. * Can only be set on inputs
  54208. */
  54209. isAttribute: boolean;
  54210. /**
  54211. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54212. * Can only be set on exit points
  54213. */
  54214. isVarying: boolean;
  54215. /**
  54216. * Gets a boolean indicating that the current connection point is a system value
  54217. */
  54218. readonly isSystemValue: boolean;
  54219. /**
  54220. * Gets or sets the current well known value or null if not defined as a system value
  54221. */
  54222. systemValue: Nullable<NodeMaterialSystemValues>;
  54223. /**
  54224. * Gets the current class name
  54225. * @returns the class name
  54226. */
  54227. getClassName(): string;
  54228. /**
  54229. * Animate the input if animationType !== None
  54230. * @param scene defines the rendering scene
  54231. */
  54232. animate(scene: Scene): void;
  54233. private _emitDefine;
  54234. initialize(state: NodeMaterialBuildState): void;
  54235. /**
  54236. * Set the input block to its default value (based on its type)
  54237. */
  54238. setDefaultValue(): void;
  54239. private _emitConstant;
  54240. private _emit;
  54241. /** @hidden */
  54242. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54243. /** @hidden */
  54244. _transmit(effect: Effect, scene: Scene): void;
  54245. protected _buildBlock(state: NodeMaterialBuildState): void;
  54246. protected _dumpPropertiesCode(): string;
  54247. serialize(): any;
  54248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54249. }
  54250. }
  54251. declare module BABYLON {
  54252. /**
  54253. * Defines a connection point for a block
  54254. */
  54255. export class NodeMaterialConnectionPoint {
  54256. /** @hidden */
  54257. _ownerBlock: NodeMaterialBlock;
  54258. /** @hidden */
  54259. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54260. private _endpoints;
  54261. private _associatedVariableName;
  54262. /** @hidden */
  54263. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54264. /** @hidden */
  54265. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54266. private _type;
  54267. /** @hidden */
  54268. _enforceAssociatedVariableName: boolean;
  54269. /**
  54270. * Gets or sets the additional types supported by this connection point
  54271. */
  54272. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54273. /**
  54274. * Gets or sets the additional types excluded by this connection point
  54275. */
  54276. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54277. /**
  54278. * Observable triggered when this point is connected
  54279. */
  54280. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54281. /**
  54282. * Gets or sets the associated variable name in the shader
  54283. */
  54284. associatedVariableName: string;
  54285. /**
  54286. * Gets or sets the connection point type (default is float)
  54287. */
  54288. type: NodeMaterialBlockConnectionPointTypes;
  54289. /**
  54290. * Gets or sets the connection point name
  54291. */
  54292. name: string;
  54293. /**
  54294. * Gets or sets a boolean indicating that this connection point can be omitted
  54295. */
  54296. isOptional: boolean;
  54297. /**
  54298. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54299. */
  54300. define: string;
  54301. /** @hidden */
  54302. _prioritizeVertex: boolean;
  54303. private _target;
  54304. /** Gets or sets the target of that connection point */
  54305. target: NodeMaterialBlockTargets;
  54306. /**
  54307. * Gets a boolean indicating that the current point is connected
  54308. */
  54309. readonly isConnected: boolean;
  54310. /**
  54311. * Gets a boolean indicating that the current point is connected to an input block
  54312. */
  54313. readonly isConnectedToInputBlock: boolean;
  54314. /**
  54315. * Gets a the connected input block (if any)
  54316. */
  54317. readonly connectInputBlock: Nullable<InputBlock>;
  54318. /** Get the other side of the connection (if any) */
  54319. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54320. /** Get the block that owns this connection point */
  54321. readonly ownerBlock: NodeMaterialBlock;
  54322. /** Get the block connected on the other side of this connection (if any) */
  54323. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54324. /** Get the block connected on the endpoints of this connection (if any) */
  54325. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54326. /** Gets the list of connected endpoints */
  54327. readonly endpoints: NodeMaterialConnectionPoint[];
  54328. /** Gets a boolean indicating if that output point is connected to at least one input */
  54329. readonly hasEndpoints: boolean;
  54330. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54331. readonly isConnectedInVertexShader: boolean;
  54332. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54333. readonly isConnectedInFragmentShader: boolean;
  54334. /**
  54335. * Creates a new connection point
  54336. * @param name defines the connection point name
  54337. * @param ownerBlock defines the block hosting this connection point
  54338. */
  54339. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54340. /**
  54341. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54342. * @returns the class name
  54343. */
  54344. getClassName(): string;
  54345. /**
  54346. * Gets an boolean indicating if the current point can be connected to another point
  54347. * @param connectionPoint defines the other connection point
  54348. * @returns true if the connection is possible
  54349. */
  54350. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54351. /**
  54352. * Connect this point to another connection point
  54353. * @param connectionPoint defines the other connection point
  54354. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54355. * @returns the current connection point
  54356. */
  54357. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54358. /**
  54359. * Disconnect this point from one of his endpoint
  54360. * @param endpoint defines the other connection point
  54361. * @returns the current connection point
  54362. */
  54363. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54364. /**
  54365. * Serializes this point in a JSON representation
  54366. * @returns the serialized point object
  54367. */
  54368. serialize(): any;
  54369. /**
  54370. * Release resources
  54371. */
  54372. dispose(): void;
  54373. }
  54374. }
  54375. declare module BABYLON {
  54376. /**
  54377. * Block used to add support for vertex skinning (bones)
  54378. */
  54379. export class BonesBlock extends NodeMaterialBlock {
  54380. /**
  54381. * Creates a new BonesBlock
  54382. * @param name defines the block name
  54383. */
  54384. constructor(name: string);
  54385. /**
  54386. * Initialize the block and prepare the context for build
  54387. * @param state defines the state that will be used for the build
  54388. */
  54389. initialize(state: NodeMaterialBuildState): void;
  54390. /**
  54391. * Gets the current class name
  54392. * @returns the class name
  54393. */
  54394. getClassName(): string;
  54395. /**
  54396. * Gets the matrix indices input component
  54397. */
  54398. readonly matricesIndices: NodeMaterialConnectionPoint;
  54399. /**
  54400. * Gets the matrix weights input component
  54401. */
  54402. readonly matricesWeights: NodeMaterialConnectionPoint;
  54403. /**
  54404. * Gets the extra matrix indices input component
  54405. */
  54406. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the extra matrix weights input component
  54409. */
  54410. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54411. /**
  54412. * Gets the world input component
  54413. */
  54414. readonly world: NodeMaterialConnectionPoint;
  54415. /**
  54416. * Gets the output component
  54417. */
  54418. readonly output: NodeMaterialConnectionPoint;
  54419. autoConfigure(material: NodeMaterial): void;
  54420. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54422. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54423. protected _buildBlock(state: NodeMaterialBuildState): this;
  54424. }
  54425. }
  54426. declare module BABYLON {
  54427. /**
  54428. * Block used to add support for instances
  54429. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54430. */
  54431. export class InstancesBlock extends NodeMaterialBlock {
  54432. /**
  54433. * Creates a new InstancesBlock
  54434. * @param name defines the block name
  54435. */
  54436. constructor(name: string);
  54437. /**
  54438. * Gets the current class name
  54439. * @returns the class name
  54440. */
  54441. getClassName(): string;
  54442. /**
  54443. * Gets the first world row input component
  54444. */
  54445. readonly world0: NodeMaterialConnectionPoint;
  54446. /**
  54447. * Gets the second world row input component
  54448. */
  54449. readonly world1: NodeMaterialConnectionPoint;
  54450. /**
  54451. * Gets the third world row input component
  54452. */
  54453. readonly world2: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the forth world row input component
  54456. */
  54457. readonly world3: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the world input component
  54460. */
  54461. readonly world: NodeMaterialConnectionPoint;
  54462. /**
  54463. * Gets the output component
  54464. */
  54465. readonly output: NodeMaterialConnectionPoint;
  54466. autoConfigure(material: NodeMaterial): void;
  54467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54468. protected _buildBlock(state: NodeMaterialBuildState): this;
  54469. }
  54470. }
  54471. declare module BABYLON {
  54472. /**
  54473. * Block used to add morph targets support to vertex shader
  54474. */
  54475. export class MorphTargetsBlock extends NodeMaterialBlock {
  54476. private _repeatableContentAnchor;
  54477. private _repeatebleContentGenerated;
  54478. /**
  54479. * Create a new MorphTargetsBlock
  54480. * @param name defines the block name
  54481. */
  54482. constructor(name: string);
  54483. /**
  54484. * Gets the current class name
  54485. * @returns the class name
  54486. */
  54487. getClassName(): string;
  54488. /**
  54489. * Gets the position input component
  54490. */
  54491. readonly position: NodeMaterialConnectionPoint;
  54492. /**
  54493. * Gets the normal input component
  54494. */
  54495. readonly normal: NodeMaterialConnectionPoint;
  54496. /**
  54497. * Gets the tangent input component
  54498. */
  54499. readonly tangent: NodeMaterialConnectionPoint;
  54500. /**
  54501. * Gets the tangent input component
  54502. */
  54503. readonly uv: NodeMaterialConnectionPoint;
  54504. /**
  54505. * Gets the position output component
  54506. */
  54507. readonly positionOutput: NodeMaterialConnectionPoint;
  54508. /**
  54509. * Gets the normal output component
  54510. */
  54511. readonly normalOutput: NodeMaterialConnectionPoint;
  54512. /**
  54513. * Gets the tangent output component
  54514. */
  54515. readonly tangentOutput: NodeMaterialConnectionPoint;
  54516. /**
  54517. * Gets the tangent output component
  54518. */
  54519. readonly uvOutput: NodeMaterialConnectionPoint;
  54520. initialize(state: NodeMaterialBuildState): void;
  54521. autoConfigure(material: NodeMaterial): void;
  54522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54523. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54524. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54525. protected _buildBlock(state: NodeMaterialBuildState): this;
  54526. }
  54527. }
  54528. declare module BABYLON {
  54529. /**
  54530. * Block used to get data information from a light
  54531. */
  54532. export class LightInformationBlock extends NodeMaterialBlock {
  54533. private _lightDataUniformName;
  54534. private _lightColorUniformName;
  54535. private _lightTypeDefineName;
  54536. /**
  54537. * Gets or sets the light associated with this block
  54538. */
  54539. light: Nullable<Light>;
  54540. /**
  54541. * Creates a new LightInformationBlock
  54542. * @param name defines the block name
  54543. */
  54544. constructor(name: string);
  54545. /**
  54546. * Gets the current class name
  54547. * @returns the class name
  54548. */
  54549. getClassName(): string;
  54550. /**
  54551. * Gets the world position input component
  54552. */
  54553. readonly worldPosition: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the direction output component
  54556. */
  54557. readonly direction: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the direction output component
  54560. */
  54561. readonly color: NodeMaterialConnectionPoint;
  54562. /**
  54563. * Gets the direction output component
  54564. */
  54565. readonly intensity: NodeMaterialConnectionPoint;
  54566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54568. protected _buildBlock(state: NodeMaterialBuildState): this;
  54569. serialize(): any;
  54570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54571. }
  54572. }
  54573. declare module BABYLON {
  54574. /**
  54575. * Block used to add image processing support to fragment shader
  54576. */
  54577. export class ImageProcessingBlock extends NodeMaterialBlock {
  54578. /**
  54579. * Create a new ImageProcessingBlock
  54580. * @param name defines the block name
  54581. */
  54582. constructor(name: string);
  54583. /**
  54584. * Gets the current class name
  54585. * @returns the class name
  54586. */
  54587. getClassName(): string;
  54588. /**
  54589. * Gets the color input component
  54590. */
  54591. readonly color: NodeMaterialConnectionPoint;
  54592. /**
  54593. * Gets the output component
  54594. */
  54595. readonly output: NodeMaterialConnectionPoint;
  54596. /**
  54597. * Initialize the block and prepare the context for build
  54598. * @param state defines the state that will be used for the build
  54599. */
  54600. initialize(state: NodeMaterialBuildState): void;
  54601. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54604. protected _buildBlock(state: NodeMaterialBuildState): this;
  54605. }
  54606. }
  54607. declare module BABYLON {
  54608. /**
  54609. * Block used to pertub normals based on a normal map
  54610. */
  54611. export class PerturbNormalBlock extends NodeMaterialBlock {
  54612. private _tangentSpaceParameterName;
  54613. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54614. invertX: boolean;
  54615. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54616. invertY: boolean;
  54617. /**
  54618. * Create a new PerturbNormalBlock
  54619. * @param name defines the block name
  54620. */
  54621. constructor(name: string);
  54622. /**
  54623. * Gets the current class name
  54624. * @returns the class name
  54625. */
  54626. getClassName(): string;
  54627. /**
  54628. * Gets the world position input component
  54629. */
  54630. readonly worldPosition: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the world normal input component
  54633. */
  54634. readonly worldNormal: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the uv input component
  54637. */
  54638. readonly uv: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the normal map color input component
  54641. */
  54642. readonly normalMapColor: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the strength input component
  54645. */
  54646. readonly strength: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the output component
  54649. */
  54650. readonly output: NodeMaterialConnectionPoint;
  54651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54653. autoConfigure(material: NodeMaterial): void;
  54654. protected _buildBlock(state: NodeMaterialBuildState): this;
  54655. protected _dumpPropertiesCode(): string;
  54656. serialize(): any;
  54657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54658. }
  54659. }
  54660. declare module BABYLON {
  54661. /**
  54662. * Block used to discard a pixel if a value is smaller than a cutoff
  54663. */
  54664. export class DiscardBlock extends NodeMaterialBlock {
  54665. /**
  54666. * Create a new DiscardBlock
  54667. * @param name defines the block name
  54668. */
  54669. constructor(name: string);
  54670. /**
  54671. * Gets the current class name
  54672. * @returns the class name
  54673. */
  54674. getClassName(): string;
  54675. /**
  54676. * Gets the color input component
  54677. */
  54678. readonly value: NodeMaterialConnectionPoint;
  54679. /**
  54680. * Gets the cutoff input component
  54681. */
  54682. readonly cutoff: NodeMaterialConnectionPoint;
  54683. protected _buildBlock(state: NodeMaterialBuildState): this;
  54684. }
  54685. }
  54686. declare module BABYLON {
  54687. /**
  54688. * Block used to add support for scene fog
  54689. */
  54690. export class FogBlock extends NodeMaterialBlock {
  54691. private _fogDistanceName;
  54692. private _fogParameters;
  54693. /**
  54694. * Create a new FogBlock
  54695. * @param name defines the block name
  54696. */
  54697. constructor(name: string);
  54698. /**
  54699. * Gets the current class name
  54700. * @returns the class name
  54701. */
  54702. getClassName(): string;
  54703. /**
  54704. * Gets the world position input component
  54705. */
  54706. readonly worldPosition: NodeMaterialConnectionPoint;
  54707. /**
  54708. * Gets the view input component
  54709. */
  54710. readonly view: NodeMaterialConnectionPoint;
  54711. /**
  54712. * Gets the color input component
  54713. */
  54714. readonly input: NodeMaterialConnectionPoint;
  54715. /**
  54716. * Gets the fog color input component
  54717. */
  54718. readonly fogColor: NodeMaterialConnectionPoint;
  54719. /**
  54720. * Gets the output component
  54721. */
  54722. readonly output: NodeMaterialConnectionPoint;
  54723. autoConfigure(material: NodeMaterial): void;
  54724. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54726. protected _buildBlock(state: NodeMaterialBuildState): this;
  54727. }
  54728. }
  54729. declare module BABYLON {
  54730. /**
  54731. * Block used to add light in the fragment shader
  54732. */
  54733. export class LightBlock extends NodeMaterialBlock {
  54734. private _lightId;
  54735. /**
  54736. * Gets or sets the light associated with this block
  54737. */
  54738. light: Nullable<Light>;
  54739. /**
  54740. * Create a new LightBlock
  54741. * @param name defines the block name
  54742. */
  54743. constructor(name: string);
  54744. /**
  54745. * Gets the current class name
  54746. * @returns the class name
  54747. */
  54748. getClassName(): string;
  54749. /**
  54750. * Gets the world position input component
  54751. */
  54752. readonly worldPosition: NodeMaterialConnectionPoint;
  54753. /**
  54754. * Gets the world normal input component
  54755. */
  54756. readonly worldNormal: NodeMaterialConnectionPoint;
  54757. /**
  54758. * Gets the camera (or eye) position component
  54759. */
  54760. readonly cameraPosition: NodeMaterialConnectionPoint;
  54761. /**
  54762. * Gets the glossiness component
  54763. */
  54764. readonly glossiness: NodeMaterialConnectionPoint;
  54765. /**
  54766. * Gets the glossinness power component
  54767. */
  54768. readonly glossPower: NodeMaterialConnectionPoint;
  54769. /**
  54770. * Gets the diffuse color component
  54771. */
  54772. readonly diffuseColor: NodeMaterialConnectionPoint;
  54773. /**
  54774. * Gets the specular color component
  54775. */
  54776. readonly specularColor: NodeMaterialConnectionPoint;
  54777. /**
  54778. * Gets the diffuse output component
  54779. */
  54780. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54781. /**
  54782. * Gets the specular output component
  54783. */
  54784. readonly specularOutput: NodeMaterialConnectionPoint;
  54785. autoConfigure(material: NodeMaterial): void;
  54786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54787. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54789. private _injectVertexCode;
  54790. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54791. serialize(): any;
  54792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54793. }
  54794. }
  54795. declare module BABYLON {
  54796. /**
  54797. * Block used to multiply 2 values
  54798. */
  54799. export class MultiplyBlock extends NodeMaterialBlock {
  54800. /**
  54801. * Creates a new MultiplyBlock
  54802. * @param name defines the block name
  54803. */
  54804. constructor(name: string);
  54805. /**
  54806. * Gets the current class name
  54807. * @returns the class name
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Gets the left operand input component
  54812. */
  54813. readonly left: NodeMaterialConnectionPoint;
  54814. /**
  54815. * Gets the right operand input component
  54816. */
  54817. readonly right: NodeMaterialConnectionPoint;
  54818. /**
  54819. * Gets the output component
  54820. */
  54821. readonly output: NodeMaterialConnectionPoint;
  54822. protected _buildBlock(state: NodeMaterialBuildState): this;
  54823. }
  54824. }
  54825. declare module BABYLON {
  54826. /**
  54827. * Block used to add 2 vectors
  54828. */
  54829. export class AddBlock extends NodeMaterialBlock {
  54830. /**
  54831. * Creates a new AddBlock
  54832. * @param name defines the block name
  54833. */
  54834. constructor(name: string);
  54835. /**
  54836. * Gets the current class name
  54837. * @returns the class name
  54838. */
  54839. getClassName(): string;
  54840. /**
  54841. * Gets the left operand input component
  54842. */
  54843. readonly left: NodeMaterialConnectionPoint;
  54844. /**
  54845. * Gets the right operand input component
  54846. */
  54847. readonly right: NodeMaterialConnectionPoint;
  54848. /**
  54849. * Gets the output component
  54850. */
  54851. readonly output: NodeMaterialConnectionPoint;
  54852. protected _buildBlock(state: NodeMaterialBuildState): this;
  54853. }
  54854. }
  54855. declare module BABYLON {
  54856. /**
  54857. * Block used to scale a vector by a float
  54858. */
  54859. export class ScaleBlock extends NodeMaterialBlock {
  54860. /**
  54861. * Creates a new ScaleBlock
  54862. * @param name defines the block name
  54863. */
  54864. constructor(name: string);
  54865. /**
  54866. * Gets the current class name
  54867. * @returns the class name
  54868. */
  54869. getClassName(): string;
  54870. /**
  54871. * Gets the input component
  54872. */
  54873. readonly input: NodeMaterialConnectionPoint;
  54874. /**
  54875. * Gets the factor input component
  54876. */
  54877. readonly factor: NodeMaterialConnectionPoint;
  54878. /**
  54879. * Gets the output component
  54880. */
  54881. readonly output: NodeMaterialConnectionPoint;
  54882. protected _buildBlock(state: NodeMaterialBuildState): this;
  54883. }
  54884. }
  54885. declare module BABYLON {
  54886. /**
  54887. * Block used to clamp a float
  54888. */
  54889. export class ClampBlock extends NodeMaterialBlock {
  54890. /** Gets or sets the minimum range */
  54891. minimum: number;
  54892. /** Gets or sets the maximum range */
  54893. maximum: number;
  54894. /**
  54895. * Creates a new ClampBlock
  54896. * @param name defines the block name
  54897. */
  54898. constructor(name: string);
  54899. /**
  54900. * Gets the current class name
  54901. * @returns the class name
  54902. */
  54903. getClassName(): string;
  54904. /**
  54905. * Gets the value input component
  54906. */
  54907. readonly value: NodeMaterialConnectionPoint;
  54908. /**
  54909. * Gets the output component
  54910. */
  54911. readonly output: NodeMaterialConnectionPoint;
  54912. protected _buildBlock(state: NodeMaterialBuildState): this;
  54913. protected _dumpPropertiesCode(): string;
  54914. serialize(): any;
  54915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54916. }
  54917. }
  54918. declare module BABYLON {
  54919. /**
  54920. * Block used to apply a cross product between 2 vectors
  54921. */
  54922. export class CrossBlock extends NodeMaterialBlock {
  54923. /**
  54924. * Creates a new CrossBlock
  54925. * @param name defines the block name
  54926. */
  54927. constructor(name: string);
  54928. /**
  54929. * Gets the current class name
  54930. * @returns the class name
  54931. */
  54932. getClassName(): string;
  54933. /**
  54934. * Gets the left operand input component
  54935. */
  54936. readonly left: NodeMaterialConnectionPoint;
  54937. /**
  54938. * Gets the right operand input component
  54939. */
  54940. readonly right: NodeMaterialConnectionPoint;
  54941. /**
  54942. * Gets the output component
  54943. */
  54944. readonly output: NodeMaterialConnectionPoint;
  54945. protected _buildBlock(state: NodeMaterialBuildState): this;
  54946. }
  54947. }
  54948. declare module BABYLON {
  54949. /**
  54950. * Block used to apply a dot product between 2 vectors
  54951. */
  54952. export class DotBlock extends NodeMaterialBlock {
  54953. /**
  54954. * Creates a new DotBlock
  54955. * @param name defines the block name
  54956. */
  54957. constructor(name: string);
  54958. /**
  54959. * Gets the current class name
  54960. * @returns the class name
  54961. */
  54962. getClassName(): string;
  54963. /**
  54964. * Gets the left operand input component
  54965. */
  54966. readonly left: NodeMaterialConnectionPoint;
  54967. /**
  54968. * Gets the right operand input component
  54969. */
  54970. readonly right: NodeMaterialConnectionPoint;
  54971. /**
  54972. * Gets the output component
  54973. */
  54974. readonly output: NodeMaterialConnectionPoint;
  54975. protected _buildBlock(state: NodeMaterialBuildState): this;
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. /**
  54980. * Block used to remap a float from a range to a new one
  54981. */
  54982. export class RemapBlock extends NodeMaterialBlock {
  54983. /**
  54984. * Gets or sets the source range
  54985. */
  54986. sourceRange: Vector2;
  54987. /**
  54988. * Gets or sets the target range
  54989. */
  54990. targetRange: Vector2;
  54991. /**
  54992. * Creates a new RemapBlock
  54993. * @param name defines the block name
  54994. */
  54995. constructor(name: string);
  54996. /**
  54997. * Gets the current class name
  54998. * @returns the class name
  54999. */
  55000. getClassName(): string;
  55001. /**
  55002. * Gets the input component
  55003. */
  55004. readonly input: NodeMaterialConnectionPoint;
  55005. /**
  55006. * Gets the source min input component
  55007. */
  55008. readonly sourceMin: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Gets the source max input component
  55011. */
  55012. readonly sourceMax: NodeMaterialConnectionPoint;
  55013. /**
  55014. * Gets the target min input component
  55015. */
  55016. readonly targetMin: NodeMaterialConnectionPoint;
  55017. /**
  55018. * Gets the target max input component
  55019. */
  55020. readonly targetMax: NodeMaterialConnectionPoint;
  55021. /**
  55022. * Gets the output component
  55023. */
  55024. readonly output: NodeMaterialConnectionPoint;
  55025. protected _buildBlock(state: NodeMaterialBuildState): this;
  55026. protected _dumpPropertiesCode(): string;
  55027. serialize(): any;
  55028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55029. }
  55030. }
  55031. declare module BABYLON {
  55032. /**
  55033. * Block used to normalize a vector
  55034. */
  55035. export class NormalizeBlock extends NodeMaterialBlock {
  55036. /**
  55037. * Creates a new NormalizeBlock
  55038. * @param name defines the block name
  55039. */
  55040. constructor(name: string);
  55041. /**
  55042. * Gets the current class name
  55043. * @returns the class name
  55044. */
  55045. getClassName(): string;
  55046. /**
  55047. * Gets the input component
  55048. */
  55049. readonly input: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the output component
  55052. */
  55053. readonly output: NodeMaterialConnectionPoint;
  55054. protected _buildBlock(state: NodeMaterialBuildState): this;
  55055. }
  55056. }
  55057. declare module BABYLON {
  55058. /**
  55059. * Operations supported by the Trigonometry block
  55060. */
  55061. export enum TrigonometryBlockOperations {
  55062. /** Cos */
  55063. Cos = 0,
  55064. /** Sin */
  55065. Sin = 1,
  55066. /** Abs */
  55067. Abs = 2,
  55068. /** Exp */
  55069. Exp = 3,
  55070. /** Exp2 */
  55071. Exp2 = 4,
  55072. /** Round */
  55073. Round = 5,
  55074. /** Floor */
  55075. Floor = 6,
  55076. /** Ceiling */
  55077. Ceiling = 7,
  55078. /** Square root */
  55079. Sqrt = 8,
  55080. /** Log */
  55081. Log = 9,
  55082. /** Tangent */
  55083. Tan = 10,
  55084. /** Arc tangent */
  55085. ArcTan = 11,
  55086. /** Arc cosinus */
  55087. ArcCos = 12,
  55088. /** Arc sinus */
  55089. ArcSin = 13,
  55090. /** Fraction */
  55091. Fract = 14,
  55092. /** Sign */
  55093. Sign = 15,
  55094. /** To radians (from degrees) */
  55095. Radians = 16,
  55096. /** To degrees (from radians) */
  55097. Degrees = 17
  55098. }
  55099. /**
  55100. * Block used to apply trigonometry operation to floats
  55101. */
  55102. export class TrigonometryBlock extends NodeMaterialBlock {
  55103. /**
  55104. * Gets or sets the operation applied by the block
  55105. */
  55106. operation: TrigonometryBlockOperations;
  55107. /**
  55108. * Creates a new TrigonometryBlock
  55109. * @param name defines the block name
  55110. */
  55111. constructor(name: string);
  55112. /**
  55113. * Gets the current class name
  55114. * @returns the class name
  55115. */
  55116. getClassName(): string;
  55117. /**
  55118. * Gets the input component
  55119. */
  55120. readonly input: NodeMaterialConnectionPoint;
  55121. /**
  55122. * Gets the output component
  55123. */
  55124. readonly output: NodeMaterialConnectionPoint;
  55125. protected _buildBlock(state: NodeMaterialBuildState): this;
  55126. serialize(): any;
  55127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55128. }
  55129. }
  55130. declare module BABYLON {
  55131. /**
  55132. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55133. */
  55134. export class ColorMergerBlock extends NodeMaterialBlock {
  55135. /**
  55136. * Create a new ColorMergerBlock
  55137. * @param name defines the block name
  55138. */
  55139. constructor(name: string);
  55140. /**
  55141. * Gets the current class name
  55142. * @returns the class name
  55143. */
  55144. getClassName(): string;
  55145. /**
  55146. * Gets the r component (input)
  55147. */
  55148. readonly r: NodeMaterialConnectionPoint;
  55149. /**
  55150. * Gets the g component (input)
  55151. */
  55152. readonly g: NodeMaterialConnectionPoint;
  55153. /**
  55154. * Gets the b component (input)
  55155. */
  55156. readonly b: NodeMaterialConnectionPoint;
  55157. /**
  55158. * Gets the a component (input)
  55159. */
  55160. readonly a: NodeMaterialConnectionPoint;
  55161. /**
  55162. * Gets the rgba component (output)
  55163. */
  55164. readonly rgba: NodeMaterialConnectionPoint;
  55165. /**
  55166. * Gets the rgb component (output)
  55167. */
  55168. readonly rgb: NodeMaterialConnectionPoint;
  55169. protected _buildBlock(state: NodeMaterialBuildState): this;
  55170. }
  55171. }
  55172. declare module BABYLON {
  55173. /**
  55174. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55175. */
  55176. export class VectorMergerBlock extends NodeMaterialBlock {
  55177. /**
  55178. * Create a new VectorMergerBlock
  55179. * @param name defines the block name
  55180. */
  55181. constructor(name: string);
  55182. /**
  55183. * Gets the current class name
  55184. * @returns the class name
  55185. */
  55186. getClassName(): string;
  55187. /**
  55188. * Gets the x component (input)
  55189. */
  55190. readonly x: NodeMaterialConnectionPoint;
  55191. /**
  55192. * Gets the y component (input)
  55193. */
  55194. readonly y: NodeMaterialConnectionPoint;
  55195. /**
  55196. * Gets the z component (input)
  55197. */
  55198. readonly z: NodeMaterialConnectionPoint;
  55199. /**
  55200. * Gets the w component (input)
  55201. */
  55202. readonly w: NodeMaterialConnectionPoint;
  55203. /**
  55204. * Gets the xyzw component (output)
  55205. */
  55206. readonly xyzw: NodeMaterialConnectionPoint;
  55207. /**
  55208. * Gets the xyz component (output)
  55209. */
  55210. readonly xyz: NodeMaterialConnectionPoint;
  55211. /**
  55212. * Gets the xy component (output)
  55213. */
  55214. readonly xy: NodeMaterialConnectionPoint;
  55215. protected _buildBlock(state: NodeMaterialBuildState): this;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55221. */
  55222. export class ColorSplitterBlock extends NodeMaterialBlock {
  55223. /**
  55224. * Create a new ColorSplitterBlock
  55225. * @param name defines the block name
  55226. */
  55227. constructor(name: string);
  55228. /**
  55229. * Gets the current class name
  55230. * @returns the class name
  55231. */
  55232. getClassName(): string;
  55233. /**
  55234. * Gets the rgba component (input)
  55235. */
  55236. readonly rgba: NodeMaterialConnectionPoint;
  55237. /**
  55238. * Gets the rgb component (input)
  55239. */
  55240. readonly rgbIn: NodeMaterialConnectionPoint;
  55241. /**
  55242. * Gets the rgb component (output)
  55243. */
  55244. readonly rgbOut: NodeMaterialConnectionPoint;
  55245. /**
  55246. * Gets the r component (output)
  55247. */
  55248. readonly r: NodeMaterialConnectionPoint;
  55249. /**
  55250. * Gets the g component (output)
  55251. */
  55252. readonly g: NodeMaterialConnectionPoint;
  55253. /**
  55254. * Gets the b component (output)
  55255. */
  55256. readonly b: NodeMaterialConnectionPoint;
  55257. /**
  55258. * Gets the a component (output)
  55259. */
  55260. readonly a: NodeMaterialConnectionPoint;
  55261. protected _inputRename(name: string): string;
  55262. protected _outputRename(name: string): string;
  55263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55264. }
  55265. }
  55266. declare module BABYLON {
  55267. /**
  55268. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55269. */
  55270. export class VectorSplitterBlock extends NodeMaterialBlock {
  55271. /**
  55272. * Create a new VectorSplitterBlock
  55273. * @param name defines the block name
  55274. */
  55275. constructor(name: string);
  55276. /**
  55277. * Gets the current class name
  55278. * @returns the class name
  55279. */
  55280. getClassName(): string;
  55281. /**
  55282. * Gets the xyzw component (input)
  55283. */
  55284. readonly xyzw: NodeMaterialConnectionPoint;
  55285. /**
  55286. * Gets the xyz component (input)
  55287. */
  55288. readonly xyzIn: NodeMaterialConnectionPoint;
  55289. /**
  55290. * Gets the xy component (input)
  55291. */
  55292. readonly xyIn: NodeMaterialConnectionPoint;
  55293. /**
  55294. * Gets the xyz component (output)
  55295. */
  55296. readonly xyzOut: NodeMaterialConnectionPoint;
  55297. /**
  55298. * Gets the xy component (output)
  55299. */
  55300. readonly xyOut: NodeMaterialConnectionPoint;
  55301. /**
  55302. * Gets the x component (output)
  55303. */
  55304. readonly x: NodeMaterialConnectionPoint;
  55305. /**
  55306. * Gets the y component (output)
  55307. */
  55308. readonly y: NodeMaterialConnectionPoint;
  55309. /**
  55310. * Gets the z component (output)
  55311. */
  55312. readonly z: NodeMaterialConnectionPoint;
  55313. /**
  55314. * Gets the w component (output)
  55315. */
  55316. readonly w: NodeMaterialConnectionPoint;
  55317. protected _inputRename(name: string): string;
  55318. protected _outputRename(name: string): string;
  55319. protected _buildBlock(state: NodeMaterialBuildState): this;
  55320. }
  55321. }
  55322. declare module BABYLON {
  55323. /**
  55324. * Block used to lerp between 2 values
  55325. */
  55326. export class LerpBlock extends NodeMaterialBlock {
  55327. /**
  55328. * Creates a new LerpBlock
  55329. * @param name defines the block name
  55330. */
  55331. constructor(name: string);
  55332. /**
  55333. * Gets the current class name
  55334. * @returns the class name
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Gets the left operand input component
  55339. */
  55340. readonly left: NodeMaterialConnectionPoint;
  55341. /**
  55342. * Gets the right operand input component
  55343. */
  55344. readonly right: NodeMaterialConnectionPoint;
  55345. /**
  55346. * Gets the gradient operand input component
  55347. */
  55348. readonly gradient: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the output component
  55351. */
  55352. readonly output: NodeMaterialConnectionPoint;
  55353. protected _buildBlock(state: NodeMaterialBuildState): this;
  55354. }
  55355. }
  55356. declare module BABYLON {
  55357. /**
  55358. * Block used to divide 2 vectors
  55359. */
  55360. export class DivideBlock extends NodeMaterialBlock {
  55361. /**
  55362. * Creates a new DivideBlock
  55363. * @param name defines the block name
  55364. */
  55365. constructor(name: string);
  55366. /**
  55367. * Gets the current class name
  55368. * @returns the class name
  55369. */
  55370. getClassName(): string;
  55371. /**
  55372. * Gets the left operand input component
  55373. */
  55374. readonly left: NodeMaterialConnectionPoint;
  55375. /**
  55376. * Gets the right operand input component
  55377. */
  55378. readonly right: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the output component
  55381. */
  55382. readonly output: NodeMaterialConnectionPoint;
  55383. protected _buildBlock(state: NodeMaterialBuildState): this;
  55384. }
  55385. }
  55386. declare module BABYLON {
  55387. /**
  55388. * Block used to subtract 2 vectors
  55389. */
  55390. export class SubtractBlock extends NodeMaterialBlock {
  55391. /**
  55392. * Creates a new SubtractBlock
  55393. * @param name defines the block name
  55394. */
  55395. constructor(name: string);
  55396. /**
  55397. * Gets the current class name
  55398. * @returns the class name
  55399. */
  55400. getClassName(): string;
  55401. /**
  55402. * Gets the left operand input component
  55403. */
  55404. readonly left: NodeMaterialConnectionPoint;
  55405. /**
  55406. * Gets the right operand input component
  55407. */
  55408. readonly right: NodeMaterialConnectionPoint;
  55409. /**
  55410. * Gets the output component
  55411. */
  55412. readonly output: NodeMaterialConnectionPoint;
  55413. protected _buildBlock(state: NodeMaterialBuildState): this;
  55414. }
  55415. }
  55416. declare module BABYLON {
  55417. /**
  55418. * Block used to step a value
  55419. */
  55420. export class StepBlock extends NodeMaterialBlock {
  55421. /**
  55422. * Creates a new StepBlock
  55423. * @param name defines the block name
  55424. */
  55425. constructor(name: string);
  55426. /**
  55427. * Gets the current class name
  55428. * @returns the class name
  55429. */
  55430. getClassName(): string;
  55431. /**
  55432. * Gets the value operand input component
  55433. */
  55434. readonly value: NodeMaterialConnectionPoint;
  55435. /**
  55436. * Gets the edge operand input component
  55437. */
  55438. readonly edge: NodeMaterialConnectionPoint;
  55439. /**
  55440. * Gets the output component
  55441. */
  55442. readonly output: NodeMaterialConnectionPoint;
  55443. protected _buildBlock(state: NodeMaterialBuildState): this;
  55444. }
  55445. }
  55446. declare module BABYLON {
  55447. /**
  55448. * Block used to get the opposite (1 - x) of a value
  55449. */
  55450. export class OneMinusBlock extends NodeMaterialBlock {
  55451. /**
  55452. * Creates a new OneMinusBlock
  55453. * @param name defines the block name
  55454. */
  55455. constructor(name: string);
  55456. /**
  55457. * Gets the current class name
  55458. * @returns the class name
  55459. */
  55460. getClassName(): string;
  55461. /**
  55462. * Gets the input component
  55463. */
  55464. readonly input: NodeMaterialConnectionPoint;
  55465. /**
  55466. * Gets the output component
  55467. */
  55468. readonly output: NodeMaterialConnectionPoint;
  55469. protected _buildBlock(state: NodeMaterialBuildState): this;
  55470. }
  55471. }
  55472. declare module BABYLON {
  55473. /**
  55474. * Block used to get the view direction
  55475. */
  55476. export class ViewDirectionBlock extends NodeMaterialBlock {
  55477. /**
  55478. * Creates a new ViewDirectionBlock
  55479. * @param name defines the block name
  55480. */
  55481. constructor(name: string);
  55482. /**
  55483. * Gets the current class name
  55484. * @returns the class name
  55485. */
  55486. getClassName(): string;
  55487. /**
  55488. * Gets the world position component
  55489. */
  55490. readonly worldPosition: NodeMaterialConnectionPoint;
  55491. /**
  55492. * Gets the camera position component
  55493. */
  55494. readonly cameraPosition: NodeMaterialConnectionPoint;
  55495. /**
  55496. * Gets the output component
  55497. */
  55498. readonly output: NodeMaterialConnectionPoint;
  55499. autoConfigure(material: NodeMaterial): void;
  55500. protected _buildBlock(state: NodeMaterialBuildState): this;
  55501. }
  55502. }
  55503. declare module BABYLON {
  55504. /**
  55505. * Block used to compute fresnel value
  55506. */
  55507. export class FresnelBlock extends NodeMaterialBlock {
  55508. /**
  55509. * Create a new FresnelBlock
  55510. * @param name defines the block name
  55511. */
  55512. constructor(name: string);
  55513. /**
  55514. * Gets the current class name
  55515. * @returns the class name
  55516. */
  55517. getClassName(): string;
  55518. /**
  55519. * Gets the world normal input component
  55520. */
  55521. readonly worldNormal: NodeMaterialConnectionPoint;
  55522. /**
  55523. * Gets the view direction input component
  55524. */
  55525. readonly viewDirection: NodeMaterialConnectionPoint;
  55526. /**
  55527. * Gets the bias input component
  55528. */
  55529. readonly bias: NodeMaterialConnectionPoint;
  55530. /**
  55531. * Gets the camera (or eye) position component
  55532. */
  55533. readonly power: NodeMaterialConnectionPoint;
  55534. /**
  55535. * Gets the fresnel output component
  55536. */
  55537. readonly fresnel: NodeMaterialConnectionPoint;
  55538. autoConfigure(material: NodeMaterial): void;
  55539. protected _buildBlock(state: NodeMaterialBuildState): this;
  55540. }
  55541. }
  55542. declare module BABYLON {
  55543. /**
  55544. * Block used to get the max of 2 values
  55545. */
  55546. export class MaxBlock extends NodeMaterialBlock {
  55547. /**
  55548. * Creates a new MaxBlock
  55549. * @param name defines the block name
  55550. */
  55551. constructor(name: string);
  55552. /**
  55553. * Gets the current class name
  55554. * @returns the class name
  55555. */
  55556. getClassName(): string;
  55557. /**
  55558. * Gets the left operand input component
  55559. */
  55560. readonly left: NodeMaterialConnectionPoint;
  55561. /**
  55562. * Gets the right operand input component
  55563. */
  55564. readonly right: NodeMaterialConnectionPoint;
  55565. /**
  55566. * Gets the output component
  55567. */
  55568. readonly output: NodeMaterialConnectionPoint;
  55569. protected _buildBlock(state: NodeMaterialBuildState): this;
  55570. }
  55571. }
  55572. declare module BABYLON {
  55573. /**
  55574. * Block used to get the min of 2 values
  55575. */
  55576. export class MinBlock extends NodeMaterialBlock {
  55577. /**
  55578. * Creates a new MinBlock
  55579. * @param name defines the block name
  55580. */
  55581. constructor(name: string);
  55582. /**
  55583. * Gets the current class name
  55584. * @returns the class name
  55585. */
  55586. getClassName(): string;
  55587. /**
  55588. * Gets the left operand input component
  55589. */
  55590. readonly left: NodeMaterialConnectionPoint;
  55591. /**
  55592. * Gets the right operand input component
  55593. */
  55594. readonly right: NodeMaterialConnectionPoint;
  55595. /**
  55596. * Gets the output component
  55597. */
  55598. readonly output: NodeMaterialConnectionPoint;
  55599. protected _buildBlock(state: NodeMaterialBuildState): this;
  55600. }
  55601. }
  55602. declare module BABYLON {
  55603. /**
  55604. * Block used to get the distance between 2 values
  55605. */
  55606. export class DistanceBlock extends NodeMaterialBlock {
  55607. /**
  55608. * Creates a new DistanceBlock
  55609. * @param name defines the block name
  55610. */
  55611. constructor(name: string);
  55612. /**
  55613. * Gets the current class name
  55614. * @returns the class name
  55615. */
  55616. getClassName(): string;
  55617. /**
  55618. * Gets the left operand input component
  55619. */
  55620. readonly left: NodeMaterialConnectionPoint;
  55621. /**
  55622. * Gets the right operand input component
  55623. */
  55624. readonly right: NodeMaterialConnectionPoint;
  55625. /**
  55626. * Gets the output component
  55627. */
  55628. readonly output: NodeMaterialConnectionPoint;
  55629. protected _buildBlock(state: NodeMaterialBuildState): this;
  55630. }
  55631. }
  55632. declare module BABYLON {
  55633. /**
  55634. * Block used to get the length of a vector
  55635. */
  55636. export class LengthBlock extends NodeMaterialBlock {
  55637. /**
  55638. * Creates a new LengthBlock
  55639. * @param name defines the block name
  55640. */
  55641. constructor(name: string);
  55642. /**
  55643. * Gets the current class name
  55644. * @returns the class name
  55645. */
  55646. getClassName(): string;
  55647. /**
  55648. * Gets the value input component
  55649. */
  55650. readonly value: NodeMaterialConnectionPoint;
  55651. /**
  55652. * Gets the output component
  55653. */
  55654. readonly output: NodeMaterialConnectionPoint;
  55655. protected _buildBlock(state: NodeMaterialBuildState): this;
  55656. }
  55657. }
  55658. declare module BABYLON {
  55659. /**
  55660. * Block used to get negative version of a value (i.e. x * -1)
  55661. */
  55662. export class NegateBlock extends NodeMaterialBlock {
  55663. /**
  55664. * Creates a new NegateBlock
  55665. * @param name defines the block name
  55666. */
  55667. constructor(name: string);
  55668. /**
  55669. * Gets the current class name
  55670. * @returns the class name
  55671. */
  55672. getClassName(): string;
  55673. /**
  55674. * Gets the value input component
  55675. */
  55676. readonly value: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the output component
  55679. */
  55680. readonly output: NodeMaterialConnectionPoint;
  55681. protected _buildBlock(state: NodeMaterialBuildState): this;
  55682. }
  55683. }
  55684. declare module BABYLON {
  55685. /**
  55686. * Block used to get the value of the first parameter raised to the power of the second
  55687. */
  55688. export class PowBlock extends NodeMaterialBlock {
  55689. /**
  55690. * Creates a new PowBlock
  55691. * @param name defines the block name
  55692. */
  55693. constructor(name: string);
  55694. /**
  55695. * Gets the current class name
  55696. * @returns the class name
  55697. */
  55698. getClassName(): string;
  55699. /**
  55700. * Gets the value operand input component
  55701. */
  55702. readonly value: NodeMaterialConnectionPoint;
  55703. /**
  55704. * Gets the power operand input component
  55705. */
  55706. readonly power: NodeMaterialConnectionPoint;
  55707. /**
  55708. * Gets the output component
  55709. */
  55710. readonly output: NodeMaterialConnectionPoint;
  55711. protected _buildBlock(state: NodeMaterialBuildState): this;
  55712. }
  55713. }
  55714. declare module BABYLON {
  55715. /**
  55716. * Block used to get a random number
  55717. */
  55718. export class RandomNumberBlock extends NodeMaterialBlock {
  55719. /**
  55720. * Creates a new RandomNumberBlock
  55721. * @param name defines the block name
  55722. */
  55723. constructor(name: string);
  55724. /**
  55725. * Gets the current class name
  55726. * @returns the class name
  55727. */
  55728. getClassName(): string;
  55729. /**
  55730. * Gets the seed input component
  55731. */
  55732. readonly seed: NodeMaterialConnectionPoint;
  55733. /**
  55734. * Gets the output component
  55735. */
  55736. readonly output: NodeMaterialConnectionPoint;
  55737. protected _buildBlock(state: NodeMaterialBuildState): this;
  55738. }
  55739. }
  55740. declare module BABYLON {
  55741. /**
  55742. * Block used to compute arc tangent of 2 values
  55743. */
  55744. export class ArcTan2Block extends NodeMaterialBlock {
  55745. /**
  55746. * Creates a new ArcTan2Block
  55747. * @param name defines the block name
  55748. */
  55749. constructor(name: string);
  55750. /**
  55751. * Gets the current class name
  55752. * @returns the class name
  55753. */
  55754. getClassName(): string;
  55755. /**
  55756. * Gets the x operand input component
  55757. */
  55758. readonly x: NodeMaterialConnectionPoint;
  55759. /**
  55760. * Gets the y operand input component
  55761. */
  55762. readonly y: NodeMaterialConnectionPoint;
  55763. /**
  55764. * Gets the output component
  55765. */
  55766. readonly output: NodeMaterialConnectionPoint;
  55767. protected _buildBlock(state: NodeMaterialBuildState): this;
  55768. }
  55769. }
  55770. declare module BABYLON {
  55771. /**
  55772. * Block used to smooth step a value
  55773. */
  55774. export class SmoothStepBlock extends NodeMaterialBlock {
  55775. /**
  55776. * Creates a new SmoothStepBlock
  55777. * @param name defines the block name
  55778. */
  55779. constructor(name: string);
  55780. /**
  55781. * Gets the current class name
  55782. * @returns the class name
  55783. */
  55784. getClassName(): string;
  55785. /**
  55786. * Gets the value operand input component
  55787. */
  55788. readonly value: NodeMaterialConnectionPoint;
  55789. /**
  55790. * Gets the first edge operand input component
  55791. */
  55792. readonly edge0: NodeMaterialConnectionPoint;
  55793. /**
  55794. * Gets the second edge operand input component
  55795. */
  55796. readonly edge1: NodeMaterialConnectionPoint;
  55797. /**
  55798. * Gets the output component
  55799. */
  55800. readonly output: NodeMaterialConnectionPoint;
  55801. protected _buildBlock(state: NodeMaterialBuildState): this;
  55802. }
  55803. }
  55804. declare module BABYLON {
  55805. /**
  55806. * Block used to get the reciprocal (1 / x) of a value
  55807. */
  55808. export class ReciprocalBlock extends NodeMaterialBlock {
  55809. /**
  55810. * Creates a new ReciprocalBlock
  55811. * @param name defines the block name
  55812. */
  55813. constructor(name: string);
  55814. /**
  55815. * Gets the current class name
  55816. * @returns the class name
  55817. */
  55818. getClassName(): string;
  55819. /**
  55820. * Gets the input component
  55821. */
  55822. readonly input: NodeMaterialConnectionPoint;
  55823. /**
  55824. * Gets the output component
  55825. */
  55826. readonly output: NodeMaterialConnectionPoint;
  55827. protected _buildBlock(state: NodeMaterialBuildState): this;
  55828. }
  55829. }
  55830. declare module BABYLON {
  55831. /**
  55832. * Block used to replace a color by another one
  55833. */
  55834. export class ReplaceColorBlock extends NodeMaterialBlock {
  55835. /**
  55836. * Creates a new ReplaceColorBlock
  55837. * @param name defines the block name
  55838. */
  55839. constructor(name: string);
  55840. /**
  55841. * Gets the current class name
  55842. * @returns the class name
  55843. */
  55844. getClassName(): string;
  55845. /**
  55846. * Gets the value input component
  55847. */
  55848. readonly value: NodeMaterialConnectionPoint;
  55849. /**
  55850. * Gets the reference input component
  55851. */
  55852. readonly reference: NodeMaterialConnectionPoint;
  55853. /**
  55854. * Gets the distance input component
  55855. */
  55856. readonly distance: NodeMaterialConnectionPoint;
  55857. /**
  55858. * Gets the replacement input component
  55859. */
  55860. readonly replacement: NodeMaterialConnectionPoint;
  55861. /**
  55862. * Gets the output component
  55863. */
  55864. readonly output: NodeMaterialConnectionPoint;
  55865. protected _buildBlock(state: NodeMaterialBuildState): this;
  55866. }
  55867. }
  55868. declare module BABYLON {
  55869. /**
  55870. * Block used to posterize a value
  55871. * @see https://en.wikipedia.org/wiki/Posterization
  55872. */
  55873. export class PosterizeBlock extends NodeMaterialBlock {
  55874. /**
  55875. * Creates a new PosterizeBlock
  55876. * @param name defines the block name
  55877. */
  55878. constructor(name: string);
  55879. /**
  55880. * Gets the current class name
  55881. * @returns the class name
  55882. */
  55883. getClassName(): string;
  55884. /**
  55885. * Gets the value input component
  55886. */
  55887. readonly value: NodeMaterialConnectionPoint;
  55888. /**
  55889. * Gets the steps input component
  55890. */
  55891. readonly steps: NodeMaterialConnectionPoint;
  55892. /**
  55893. * Gets the output component
  55894. */
  55895. readonly output: NodeMaterialConnectionPoint;
  55896. protected _buildBlock(state: NodeMaterialBuildState): this;
  55897. }
  55898. }
  55899. declare module BABYLON {
  55900. /**
  55901. * Operations supported by the Wave block
  55902. */
  55903. export enum WaveBlockKind {
  55904. /** SawTooth */
  55905. SawTooth = 0,
  55906. /** Square */
  55907. Square = 1,
  55908. /** Triangle */
  55909. Triangle = 2
  55910. }
  55911. /**
  55912. * Block used to apply wave operation to floats
  55913. */
  55914. export class WaveBlock extends NodeMaterialBlock {
  55915. /**
  55916. * Gets or sets the kibnd of wave to be applied by the block
  55917. */
  55918. kind: WaveBlockKind;
  55919. /**
  55920. * Creates a new WaveBlock
  55921. * @param name defines the block name
  55922. */
  55923. constructor(name: string);
  55924. /**
  55925. * Gets the current class name
  55926. * @returns the class name
  55927. */
  55928. getClassName(): string;
  55929. /**
  55930. * Gets the input component
  55931. */
  55932. readonly input: NodeMaterialConnectionPoint;
  55933. /**
  55934. * Gets the output component
  55935. */
  55936. readonly output: NodeMaterialConnectionPoint;
  55937. protected _buildBlock(state: NodeMaterialBuildState): this;
  55938. serialize(): any;
  55939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /**
  55944. * Class used to store a color step for the GradientBlock
  55945. */
  55946. export class GradientBlockColorStep {
  55947. /**
  55948. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55949. */
  55950. step: number;
  55951. /**
  55952. * Gets or sets the color associated with this step
  55953. */
  55954. color: Color3;
  55955. /**
  55956. * Creates a new GradientBlockColorStep
  55957. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55958. * @param color defines the color associated with this step
  55959. */
  55960. constructor(
  55961. /**
  55962. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55963. */
  55964. step: number,
  55965. /**
  55966. * Gets or sets the color associated with this step
  55967. */
  55968. color: Color3);
  55969. }
  55970. /**
  55971. * Block used to return a color from a gradient based on an input value between 0 and 1
  55972. */
  55973. export class GradientBlock extends NodeMaterialBlock {
  55974. /**
  55975. * Gets or sets the list of color steps
  55976. */
  55977. colorSteps: GradientBlockColorStep[];
  55978. /**
  55979. * Creates a new GradientBlock
  55980. * @param name defines the block name
  55981. */
  55982. constructor(name: string);
  55983. /**
  55984. * Gets the current class name
  55985. * @returns the class name
  55986. */
  55987. getClassName(): string;
  55988. /**
  55989. * Gets the gradient input component
  55990. */
  55991. readonly gradient: NodeMaterialConnectionPoint;
  55992. /**
  55993. * Gets the output component
  55994. */
  55995. readonly output: NodeMaterialConnectionPoint;
  55996. private _writeColorConstant;
  55997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55998. serialize(): any;
  55999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56000. protected _dumpPropertiesCode(): string;
  56001. }
  56002. }
  56003. declare module BABYLON {
  56004. /**
  56005. * Block used to normalize lerp between 2 values
  56006. */
  56007. export class NLerpBlock extends NodeMaterialBlock {
  56008. /**
  56009. * Creates a new NLerpBlock
  56010. * @param name defines the block name
  56011. */
  56012. constructor(name: string);
  56013. /**
  56014. * Gets the current class name
  56015. * @returns the class name
  56016. */
  56017. getClassName(): string;
  56018. /**
  56019. * Gets the left operand input component
  56020. */
  56021. readonly left: NodeMaterialConnectionPoint;
  56022. /**
  56023. * Gets the right operand input component
  56024. */
  56025. readonly right: NodeMaterialConnectionPoint;
  56026. /**
  56027. * Gets the gradient operand input component
  56028. */
  56029. readonly gradient: NodeMaterialConnectionPoint;
  56030. /**
  56031. * Gets the output component
  56032. */
  56033. readonly output: NodeMaterialConnectionPoint;
  56034. protected _buildBlock(state: NodeMaterialBuildState): this;
  56035. }
  56036. }
  56037. declare module BABYLON {
  56038. /**
  56039. * Block used to test if the fragment shader is front facing
  56040. */
  56041. export class FrontFacingBlock extends NodeMaterialBlock {
  56042. /**
  56043. * Creates a new FrontFacingBlock
  56044. * @param name defines the block name
  56045. */
  56046. constructor(name: string);
  56047. /**
  56048. * Gets the current class name
  56049. * @returns the class name
  56050. */
  56051. getClassName(): string;
  56052. /**
  56053. * Gets the world normal component
  56054. */
  56055. readonly worldNormal: NodeMaterialConnectionPoint;
  56056. /**
  56057. * Gets the view direction input component
  56058. */
  56059. readonly viewDirection: NodeMaterialConnectionPoint;
  56060. /**
  56061. * Gets the output component
  56062. */
  56063. readonly output: NodeMaterialConnectionPoint;
  56064. autoConfigure(material: NodeMaterial): void;
  56065. protected _buildBlock(state: NodeMaterialBuildState): this;
  56066. }
  56067. }
  56068. declare module BABYLON {
  56069. /**
  56070. * Effect Render Options
  56071. */
  56072. export interface IEffectRendererOptions {
  56073. /**
  56074. * Defines the vertices positions.
  56075. */
  56076. positions?: number[];
  56077. /**
  56078. * Defines the indices.
  56079. */
  56080. indices?: number[];
  56081. }
  56082. /**
  56083. * Helper class to render one or more effects
  56084. */
  56085. export class EffectRenderer {
  56086. private engine;
  56087. private static _DefaultOptions;
  56088. private _vertexBuffers;
  56089. private _indexBuffer;
  56090. private _ringBufferIndex;
  56091. private _ringScreenBuffer;
  56092. private _fullscreenViewport;
  56093. private _getNextFrameBuffer;
  56094. /**
  56095. * Creates an effect renderer
  56096. * @param engine the engine to use for rendering
  56097. * @param options defines the options of the effect renderer
  56098. */
  56099. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  56100. /**
  56101. * Sets the current viewport in normalized coordinates 0-1
  56102. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56103. */
  56104. setViewport(viewport?: Viewport): void;
  56105. /**
  56106. * Binds the embedded attributes buffer to the effect.
  56107. * @param effect Defines the effect to bind the attributes for
  56108. */
  56109. bindBuffers(effect: Effect): void;
  56110. /**
  56111. * Sets the current effect wrapper to use during draw.
  56112. * The effect needs to be ready before calling this api.
  56113. * This also sets the default full screen position attribute.
  56114. * @param effectWrapper Defines the effect to draw with
  56115. */
  56116. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56117. /**
  56118. * Draws a full screen quad.
  56119. */
  56120. draw(): void;
  56121. /**
  56122. * renders one or more effects to a specified texture
  56123. * @param effectWrappers list of effects to renderer
  56124. * @param outputTexture texture to draw to, if null it will render to the screen
  56125. */
  56126. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56127. /**
  56128. * Disposes of the effect renderer
  56129. */
  56130. dispose(): void;
  56131. }
  56132. /**
  56133. * Options to create an EffectWrapper
  56134. */
  56135. interface EffectWrapperCreationOptions {
  56136. /**
  56137. * Engine to use to create the effect
  56138. */
  56139. engine: ThinEngine;
  56140. /**
  56141. * Fragment shader for the effect
  56142. */
  56143. fragmentShader: string;
  56144. /**
  56145. * Vertex shader for the effect
  56146. */
  56147. vertexShader?: string;
  56148. /**
  56149. * Attributes to use in the shader
  56150. */
  56151. attributeNames?: Array<string>;
  56152. /**
  56153. * Uniforms to use in the shader
  56154. */
  56155. uniformNames?: Array<string>;
  56156. /**
  56157. * Texture sampler names to use in the shader
  56158. */
  56159. samplerNames?: Array<string>;
  56160. /**
  56161. * The friendly name of the effect displayed in Spector.
  56162. */
  56163. name?: string;
  56164. }
  56165. /**
  56166. * Wraps an effect to be used for rendering
  56167. */
  56168. export class EffectWrapper {
  56169. /**
  56170. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56171. */
  56172. onApplyObservable: Observable<{}>;
  56173. /**
  56174. * The underlying effect
  56175. */
  56176. effect: Effect;
  56177. /**
  56178. * Creates an effect to be renderer
  56179. * @param creationOptions options to create the effect
  56180. */
  56181. constructor(creationOptions: EffectWrapperCreationOptions);
  56182. /**
  56183. * Disposes of the effect wrapper
  56184. */
  56185. dispose(): void;
  56186. }
  56187. }
  56188. declare module BABYLON {
  56189. /**
  56190. * Helper class to push actions to a pool of workers.
  56191. */
  56192. export class WorkerPool implements IDisposable {
  56193. private _workerInfos;
  56194. private _pendingActions;
  56195. /**
  56196. * Constructor
  56197. * @param workers Array of workers to use for actions
  56198. */
  56199. constructor(workers: Array<Worker>);
  56200. /**
  56201. * Terminates all workers and clears any pending actions.
  56202. */
  56203. dispose(): void;
  56204. /**
  56205. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56206. * pended until a worker has completed its action.
  56207. * @param action The action to perform. Call onComplete when the action is complete.
  56208. */
  56209. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56210. private _execute;
  56211. }
  56212. }
  56213. declare module BABYLON {
  56214. /**
  56215. * Configuration for Draco compression
  56216. */
  56217. export interface IDracoCompressionConfiguration {
  56218. /**
  56219. * Configuration for the decoder.
  56220. */
  56221. decoder: {
  56222. /**
  56223. * The url to the WebAssembly module.
  56224. */
  56225. wasmUrl?: string;
  56226. /**
  56227. * The url to the WebAssembly binary.
  56228. */
  56229. wasmBinaryUrl?: string;
  56230. /**
  56231. * The url to the fallback JavaScript module.
  56232. */
  56233. fallbackUrl?: string;
  56234. };
  56235. }
  56236. /**
  56237. * Draco compression (https://google.github.io/draco/)
  56238. *
  56239. * This class wraps the Draco module.
  56240. *
  56241. * **Encoder**
  56242. *
  56243. * The encoder is not currently implemented.
  56244. *
  56245. * **Decoder**
  56246. *
  56247. * 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.
  56248. *
  56249. * To update the configuration, use the following code:
  56250. * ```javascript
  56251. * DracoCompression.Configuration = {
  56252. * decoder: {
  56253. * wasmUrl: "<url to the WebAssembly library>",
  56254. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56255. * fallbackUrl: "<url to the fallback JavaScript library>",
  56256. * }
  56257. * };
  56258. * ```
  56259. *
  56260. * 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.
  56261. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56262. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56263. *
  56264. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56265. * ```javascript
  56266. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56267. * ```
  56268. *
  56269. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56270. */
  56271. export class DracoCompression implements IDisposable {
  56272. private _workerPoolPromise?;
  56273. private _decoderModulePromise?;
  56274. /**
  56275. * The configuration. Defaults to the following urls:
  56276. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56277. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56278. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56279. */
  56280. static Configuration: IDracoCompressionConfiguration;
  56281. /**
  56282. * Returns true if the decoder configuration is available.
  56283. */
  56284. static readonly DecoderAvailable: boolean;
  56285. /**
  56286. * Default number of workers to create when creating the draco compression object.
  56287. */
  56288. static DefaultNumWorkers: number;
  56289. private static GetDefaultNumWorkers;
  56290. private static _Default;
  56291. /**
  56292. * Default instance for the draco compression object.
  56293. */
  56294. static readonly Default: DracoCompression;
  56295. /**
  56296. * Constructor
  56297. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56298. */
  56299. constructor(numWorkers?: number);
  56300. /**
  56301. * Stop all async operations and release resources.
  56302. */
  56303. dispose(): void;
  56304. /**
  56305. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56306. * @returns a promise that resolves when ready
  56307. */
  56308. whenReadyAsync(): Promise<void>;
  56309. /**
  56310. * Decode Draco compressed mesh data to vertex data.
  56311. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56312. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56313. * @returns A promise that resolves with the decoded vertex data
  56314. */
  56315. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56316. [kind: string]: number;
  56317. }): Promise<VertexData>;
  56318. }
  56319. }
  56320. declare module BABYLON {
  56321. /**
  56322. * Class for building Constructive Solid Geometry
  56323. */
  56324. export class CSG {
  56325. private polygons;
  56326. /**
  56327. * The world matrix
  56328. */
  56329. matrix: Matrix;
  56330. /**
  56331. * Stores the position
  56332. */
  56333. position: Vector3;
  56334. /**
  56335. * Stores the rotation
  56336. */
  56337. rotation: Vector3;
  56338. /**
  56339. * Stores the rotation quaternion
  56340. */
  56341. rotationQuaternion: Nullable<Quaternion>;
  56342. /**
  56343. * Stores the scaling vector
  56344. */
  56345. scaling: Vector3;
  56346. /**
  56347. * Convert the Mesh to CSG
  56348. * @param mesh The Mesh to convert to CSG
  56349. * @returns A new CSG from the Mesh
  56350. */
  56351. static FromMesh(mesh: Mesh): CSG;
  56352. /**
  56353. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56354. * @param polygons Polygons used to construct a CSG solid
  56355. */
  56356. private static FromPolygons;
  56357. /**
  56358. * Clones, or makes a deep copy, of the CSG
  56359. * @returns A new CSG
  56360. */
  56361. clone(): CSG;
  56362. /**
  56363. * Unions this CSG with another CSG
  56364. * @param csg The CSG to union against this CSG
  56365. * @returns The unioned CSG
  56366. */
  56367. union(csg: CSG): CSG;
  56368. /**
  56369. * Unions this CSG with another CSG in place
  56370. * @param csg The CSG to union against this CSG
  56371. */
  56372. unionInPlace(csg: CSG): void;
  56373. /**
  56374. * Subtracts this CSG with another CSG
  56375. * @param csg The CSG to subtract against this CSG
  56376. * @returns A new CSG
  56377. */
  56378. subtract(csg: CSG): CSG;
  56379. /**
  56380. * Subtracts this CSG with another CSG in place
  56381. * @param csg The CSG to subtact against this CSG
  56382. */
  56383. subtractInPlace(csg: CSG): void;
  56384. /**
  56385. * Intersect this CSG with another CSG
  56386. * @param csg The CSG to intersect against this CSG
  56387. * @returns A new CSG
  56388. */
  56389. intersect(csg: CSG): CSG;
  56390. /**
  56391. * Intersects this CSG with another CSG in place
  56392. * @param csg The CSG to intersect against this CSG
  56393. */
  56394. intersectInPlace(csg: CSG): void;
  56395. /**
  56396. * Return a new CSG solid with solid and empty space switched. This solid is
  56397. * not modified.
  56398. * @returns A new CSG solid with solid and empty space switched
  56399. */
  56400. inverse(): CSG;
  56401. /**
  56402. * Inverses the CSG in place
  56403. */
  56404. inverseInPlace(): void;
  56405. /**
  56406. * This is used to keep meshes transformations so they can be restored
  56407. * when we build back a Babylon Mesh
  56408. * NB : All CSG operations are performed in world coordinates
  56409. * @param csg The CSG to copy the transform attributes from
  56410. * @returns This CSG
  56411. */
  56412. copyTransformAttributes(csg: CSG): CSG;
  56413. /**
  56414. * Build Raw mesh from CSG
  56415. * Coordinates here are in world space
  56416. * @param name The name of the mesh geometry
  56417. * @param scene The Scene
  56418. * @param keepSubMeshes Specifies if the submeshes should be kept
  56419. * @returns A new Mesh
  56420. */
  56421. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56422. /**
  56423. * Build Mesh from CSG taking material and transforms into account
  56424. * @param name The name of the Mesh
  56425. * @param material The material of the Mesh
  56426. * @param scene The Scene
  56427. * @param keepSubMeshes Specifies if submeshes should be kept
  56428. * @returns The new Mesh
  56429. */
  56430. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * Class used to create a trail following a mesh
  56436. */
  56437. export class TrailMesh extends Mesh {
  56438. private _generator;
  56439. private _autoStart;
  56440. private _running;
  56441. private _diameter;
  56442. private _length;
  56443. private _sectionPolygonPointsCount;
  56444. private _sectionVectors;
  56445. private _sectionNormalVectors;
  56446. private _beforeRenderObserver;
  56447. /**
  56448. * @constructor
  56449. * @param name The value used by scene.getMeshByName() to do a lookup.
  56450. * @param generator The mesh to generate a trail.
  56451. * @param scene The scene to add this mesh to.
  56452. * @param diameter Diameter of trailing mesh. Default is 1.
  56453. * @param length Length of trailing mesh. Default is 60.
  56454. * @param autoStart Automatically start trailing mesh. Default true.
  56455. */
  56456. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56457. /**
  56458. * "TrailMesh"
  56459. * @returns "TrailMesh"
  56460. */
  56461. getClassName(): string;
  56462. private _createMesh;
  56463. /**
  56464. * Start trailing mesh.
  56465. */
  56466. start(): void;
  56467. /**
  56468. * Stop trailing mesh.
  56469. */
  56470. stop(): void;
  56471. /**
  56472. * Update trailing mesh geometry.
  56473. */
  56474. update(): void;
  56475. /**
  56476. * Returns a new TrailMesh object.
  56477. * @param name is a string, the name given to the new mesh
  56478. * @param newGenerator use new generator object for cloned trail mesh
  56479. * @returns a new mesh
  56480. */
  56481. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56482. /**
  56483. * Serializes this trail mesh
  56484. * @param serializationObject object to write serialization to
  56485. */
  56486. serialize(serializationObject: any): void;
  56487. /**
  56488. * Parses a serialized trail mesh
  56489. * @param parsedMesh the serialized mesh
  56490. * @param scene the scene to create the trail mesh in
  56491. * @returns the created trail mesh
  56492. */
  56493. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56494. }
  56495. }
  56496. declare module BABYLON {
  56497. /**
  56498. * Class containing static functions to help procedurally build meshes
  56499. */
  56500. export class TiledBoxBuilder {
  56501. /**
  56502. * Creates a box mesh
  56503. * 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)
  56504. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56506. * * 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
  56507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56508. * @param name defines the name of the mesh
  56509. * @param options defines the options used to create the mesh
  56510. * @param scene defines the hosting scene
  56511. * @returns the box mesh
  56512. */
  56513. static CreateTiledBox(name: string, options: {
  56514. pattern?: number;
  56515. width?: number;
  56516. height?: number;
  56517. depth?: number;
  56518. tileSize?: number;
  56519. tileWidth?: number;
  56520. tileHeight?: number;
  56521. alignHorizontal?: number;
  56522. alignVertical?: number;
  56523. faceUV?: Vector4[];
  56524. faceColors?: Color4[];
  56525. sideOrientation?: number;
  56526. updatable?: boolean;
  56527. }, scene?: Nullable<Scene>): Mesh;
  56528. }
  56529. }
  56530. declare module BABYLON {
  56531. /**
  56532. * Class containing static functions to help procedurally build meshes
  56533. */
  56534. export class TorusKnotBuilder {
  56535. /**
  56536. * Creates a torus knot mesh
  56537. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56538. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56539. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56540. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56542. * * 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
  56543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56544. * @param name defines the name of the mesh
  56545. * @param options defines the options used to create the mesh
  56546. * @param scene defines the hosting scene
  56547. * @returns the torus knot mesh
  56548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56549. */
  56550. static CreateTorusKnot(name: string, options: {
  56551. radius?: number;
  56552. tube?: number;
  56553. radialSegments?: number;
  56554. tubularSegments?: number;
  56555. p?: number;
  56556. q?: number;
  56557. updatable?: boolean;
  56558. sideOrientation?: number;
  56559. frontUVs?: Vector4;
  56560. backUVs?: Vector4;
  56561. }, scene: any): Mesh;
  56562. }
  56563. }
  56564. declare module BABYLON {
  56565. /**
  56566. * Polygon
  56567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56568. */
  56569. export class Polygon {
  56570. /**
  56571. * Creates a rectangle
  56572. * @param xmin bottom X coord
  56573. * @param ymin bottom Y coord
  56574. * @param xmax top X coord
  56575. * @param ymax top Y coord
  56576. * @returns points that make the resulting rectation
  56577. */
  56578. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56579. /**
  56580. * Creates a circle
  56581. * @param radius radius of circle
  56582. * @param cx scale in x
  56583. * @param cy scale in y
  56584. * @param numberOfSides number of sides that make up the circle
  56585. * @returns points that make the resulting circle
  56586. */
  56587. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56588. /**
  56589. * Creates a polygon from input string
  56590. * @param input Input polygon data
  56591. * @returns the parsed points
  56592. */
  56593. static Parse(input: string): Vector2[];
  56594. /**
  56595. * Starts building a polygon from x and y coordinates
  56596. * @param x x coordinate
  56597. * @param y y coordinate
  56598. * @returns the started path2
  56599. */
  56600. static StartingAt(x: number, y: number): Path2;
  56601. }
  56602. /**
  56603. * Builds a polygon
  56604. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56605. */
  56606. export class PolygonMeshBuilder {
  56607. private _points;
  56608. private _outlinepoints;
  56609. private _holes;
  56610. private _name;
  56611. private _scene;
  56612. private _epoints;
  56613. private _eholes;
  56614. private _addToepoint;
  56615. /**
  56616. * Babylon reference to the earcut plugin.
  56617. */
  56618. bjsEarcut: any;
  56619. /**
  56620. * Creates a PolygonMeshBuilder
  56621. * @param name name of the builder
  56622. * @param contours Path of the polygon
  56623. * @param scene scene to add to when creating the mesh
  56624. * @param earcutInjection can be used to inject your own earcut reference
  56625. */
  56626. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56627. /**
  56628. * Adds a whole within the polygon
  56629. * @param hole Array of points defining the hole
  56630. * @returns this
  56631. */
  56632. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56633. /**
  56634. * Creates the polygon
  56635. * @param updatable If the mesh should be updatable
  56636. * @param depth The depth of the mesh created
  56637. * @returns the created mesh
  56638. */
  56639. build(updatable?: boolean, depth?: number): Mesh;
  56640. /**
  56641. * Creates the polygon
  56642. * @param depth The depth of the mesh created
  56643. * @returns the created VertexData
  56644. */
  56645. buildVertexData(depth?: number): VertexData;
  56646. /**
  56647. * Adds a side to the polygon
  56648. * @param positions points that make the polygon
  56649. * @param normals normals of the polygon
  56650. * @param uvs uvs of the polygon
  56651. * @param indices indices of the polygon
  56652. * @param bounds bounds of the polygon
  56653. * @param points points of the polygon
  56654. * @param depth depth of the polygon
  56655. * @param flip flip of the polygon
  56656. */
  56657. private addSide;
  56658. }
  56659. }
  56660. declare module BABYLON {
  56661. /**
  56662. * Class containing static functions to help procedurally build meshes
  56663. */
  56664. export class PolygonBuilder {
  56665. /**
  56666. * Creates a polygon mesh
  56667. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56668. * * 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
  56669. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56671. * * 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)
  56672. * * Remember you can only change the shape positions, not their number when updating a polygon
  56673. * @param name defines the name of the mesh
  56674. * @param options defines the options used to create the mesh
  56675. * @param scene defines the hosting scene
  56676. * @param earcutInjection can be used to inject your own earcut reference
  56677. * @returns the polygon mesh
  56678. */
  56679. static CreatePolygon(name: string, options: {
  56680. shape: Vector3[];
  56681. holes?: Vector3[][];
  56682. depth?: number;
  56683. faceUV?: Vector4[];
  56684. faceColors?: Color4[];
  56685. updatable?: boolean;
  56686. sideOrientation?: number;
  56687. frontUVs?: Vector4;
  56688. backUVs?: Vector4;
  56689. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56690. /**
  56691. * Creates an extruded polygon mesh, with depth in the Y direction.
  56692. * * 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)
  56693. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56694. * @param name defines the name of the mesh
  56695. * @param options defines the options used to create the mesh
  56696. * @param scene defines the hosting scene
  56697. * @param earcutInjection can be used to inject your own earcut reference
  56698. * @returns the polygon mesh
  56699. */
  56700. static ExtrudePolygon(name: string, options: {
  56701. shape: Vector3[];
  56702. holes?: Vector3[][];
  56703. depth?: number;
  56704. faceUV?: Vector4[];
  56705. faceColors?: Color4[];
  56706. updatable?: boolean;
  56707. sideOrientation?: number;
  56708. frontUVs?: Vector4;
  56709. backUVs?: Vector4;
  56710. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56711. }
  56712. }
  56713. declare module BABYLON {
  56714. /**
  56715. * Class containing static functions to help procedurally build meshes
  56716. */
  56717. export class LatheBuilder {
  56718. /**
  56719. * Creates lathe mesh.
  56720. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56721. * * 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
  56722. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56723. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56724. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56725. * * 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
  56726. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56727. * * 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
  56728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56729. * * 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
  56730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56732. * @param name defines the name of the mesh
  56733. * @param options defines the options used to create the mesh
  56734. * @param scene defines the hosting scene
  56735. * @returns the lathe mesh
  56736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56737. */
  56738. static CreateLathe(name: string, options: {
  56739. shape: Vector3[];
  56740. radius?: number;
  56741. tessellation?: number;
  56742. clip?: number;
  56743. arc?: number;
  56744. closed?: boolean;
  56745. updatable?: boolean;
  56746. sideOrientation?: number;
  56747. frontUVs?: Vector4;
  56748. backUVs?: Vector4;
  56749. cap?: number;
  56750. invertUV?: boolean;
  56751. }, scene?: Nullable<Scene>): Mesh;
  56752. }
  56753. }
  56754. declare module BABYLON {
  56755. /**
  56756. * Class containing static functions to help procedurally build meshes
  56757. */
  56758. export class TiledPlaneBuilder {
  56759. /**
  56760. * Creates a tiled plane mesh
  56761. * * The parameter `pattern` will, depending on value, do nothing or
  56762. * * * flip (reflect about central vertical) alternate tiles across and up
  56763. * * * flip every tile on alternate rows
  56764. * * * rotate (180 degs) alternate tiles across and up
  56765. * * * rotate every tile on alternate rows
  56766. * * * flip and rotate alternate tiles across and up
  56767. * * * flip and rotate every tile on alternate rows
  56768. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56769. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56770. * * 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
  56771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56772. * * 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)
  56773. * * 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)
  56774. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56775. * @param name defines the name of the mesh
  56776. * @param options defines the options used to create the mesh
  56777. * @param scene defines the hosting scene
  56778. * @returns the box mesh
  56779. */
  56780. static CreateTiledPlane(name: string, options: {
  56781. pattern?: number;
  56782. tileSize?: number;
  56783. tileWidth?: number;
  56784. tileHeight?: number;
  56785. size?: number;
  56786. width?: number;
  56787. height?: number;
  56788. alignHorizontal?: number;
  56789. alignVertical?: number;
  56790. sideOrientation?: number;
  56791. frontUVs?: Vector4;
  56792. backUVs?: Vector4;
  56793. updatable?: boolean;
  56794. }, scene?: Nullable<Scene>): Mesh;
  56795. }
  56796. }
  56797. declare module BABYLON {
  56798. /**
  56799. * Class containing static functions to help procedurally build meshes
  56800. */
  56801. export class TubeBuilder {
  56802. /**
  56803. * Creates a tube mesh.
  56804. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56805. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56806. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56807. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56808. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56809. * * 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)
  56810. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56811. * * 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
  56812. * * 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
  56813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56814. * * 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
  56815. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56817. * @param name defines the name of the mesh
  56818. * @param options defines the options used to create the mesh
  56819. * @param scene defines the hosting scene
  56820. * @returns the tube mesh
  56821. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56822. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56823. */
  56824. static CreateTube(name: string, options: {
  56825. path: Vector3[];
  56826. radius?: number;
  56827. tessellation?: number;
  56828. radiusFunction?: {
  56829. (i: number, distance: number): number;
  56830. };
  56831. cap?: number;
  56832. arc?: number;
  56833. updatable?: boolean;
  56834. sideOrientation?: number;
  56835. frontUVs?: Vector4;
  56836. backUVs?: Vector4;
  56837. instance?: Mesh;
  56838. invertUV?: boolean;
  56839. }, scene?: Nullable<Scene>): Mesh;
  56840. }
  56841. }
  56842. declare module BABYLON {
  56843. /**
  56844. * Class containing static functions to help procedurally build meshes
  56845. */
  56846. export class IcoSphereBuilder {
  56847. /**
  56848. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56849. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56850. * * 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`)
  56851. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56852. * * 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
  56853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56854. * * 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
  56855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56856. * @param name defines the name of the mesh
  56857. * @param options defines the options used to create the mesh
  56858. * @param scene defines the hosting scene
  56859. * @returns the icosahedron mesh
  56860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56861. */
  56862. static CreateIcoSphere(name: string, options: {
  56863. radius?: number;
  56864. radiusX?: number;
  56865. radiusY?: number;
  56866. radiusZ?: number;
  56867. flat?: boolean;
  56868. subdivisions?: number;
  56869. sideOrientation?: number;
  56870. frontUVs?: Vector4;
  56871. backUVs?: Vector4;
  56872. updatable?: boolean;
  56873. }, scene?: Nullable<Scene>): Mesh;
  56874. }
  56875. }
  56876. declare module BABYLON {
  56877. /**
  56878. * Class containing static functions to help procedurally build meshes
  56879. */
  56880. export class DecalBuilder {
  56881. /**
  56882. * Creates a decal mesh.
  56883. * 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
  56884. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56885. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56886. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56887. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56888. * @param name defines the name of the mesh
  56889. * @param sourceMesh defines the mesh where the decal must be applied
  56890. * @param options defines the options used to create the mesh
  56891. * @param scene defines the hosting scene
  56892. * @returns the decal mesh
  56893. * @see https://doc.babylonjs.com/how_to/decals
  56894. */
  56895. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56896. position?: Vector3;
  56897. normal?: Vector3;
  56898. size?: Vector3;
  56899. angle?: number;
  56900. }): Mesh;
  56901. }
  56902. }
  56903. declare module BABYLON {
  56904. /**
  56905. * Class containing static functions to help procedurally build meshes
  56906. */
  56907. export class MeshBuilder {
  56908. /**
  56909. * Creates a box mesh
  56910. * * The parameter `size` sets the size (float) of each box side (default 1)
  56911. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56912. * * 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)
  56913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56915. * * 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
  56916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56918. * @param name defines the name of the mesh
  56919. * @param options defines the options used to create the mesh
  56920. * @param scene defines the hosting scene
  56921. * @returns the box mesh
  56922. */
  56923. static CreateBox(name: string, options: {
  56924. size?: number;
  56925. width?: number;
  56926. height?: number;
  56927. depth?: number;
  56928. faceUV?: Vector4[];
  56929. faceColors?: Color4[];
  56930. sideOrientation?: number;
  56931. frontUVs?: Vector4;
  56932. backUVs?: Vector4;
  56933. updatable?: boolean;
  56934. }, scene?: Nullable<Scene>): Mesh;
  56935. /**
  56936. * Creates a tiled box mesh
  56937. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56939. * @param name defines the name of the mesh
  56940. * @param options defines the options used to create the mesh
  56941. * @param scene defines the hosting scene
  56942. * @returns the tiled box mesh
  56943. */
  56944. static CreateTiledBox(name: string, options: {
  56945. pattern?: number;
  56946. size?: number;
  56947. width?: number;
  56948. height?: number;
  56949. depth: number;
  56950. tileSize?: number;
  56951. tileWidth?: number;
  56952. tileHeight?: number;
  56953. faceUV?: Vector4[];
  56954. faceColors?: Color4[];
  56955. alignHorizontal?: number;
  56956. alignVertical?: number;
  56957. sideOrientation?: number;
  56958. updatable?: boolean;
  56959. }, scene?: Nullable<Scene>): Mesh;
  56960. /**
  56961. * Creates a sphere mesh
  56962. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56963. * * 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`)
  56964. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56965. * * 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
  56966. * * 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)
  56967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56968. * * 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
  56969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56970. * @param name defines the name of the mesh
  56971. * @param options defines the options used to create the mesh
  56972. * @param scene defines the hosting scene
  56973. * @returns the sphere mesh
  56974. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56975. */
  56976. static CreateSphere(name: string, options: {
  56977. segments?: number;
  56978. diameter?: number;
  56979. diameterX?: number;
  56980. diameterY?: number;
  56981. diameterZ?: number;
  56982. arc?: number;
  56983. slice?: number;
  56984. sideOrientation?: number;
  56985. frontUVs?: Vector4;
  56986. backUVs?: Vector4;
  56987. updatable?: boolean;
  56988. }, scene?: Nullable<Scene>): Mesh;
  56989. /**
  56990. * Creates a plane polygonal mesh. By default, this is a disc
  56991. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56992. * * 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
  56993. * * 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
  56994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56995. * * 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
  56996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56997. * @param name defines the name of the mesh
  56998. * @param options defines the options used to create the mesh
  56999. * @param scene defines the hosting scene
  57000. * @returns the plane polygonal mesh
  57001. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57002. */
  57003. static CreateDisc(name: string, options: {
  57004. radius?: number;
  57005. tessellation?: number;
  57006. arc?: number;
  57007. updatable?: boolean;
  57008. sideOrientation?: number;
  57009. frontUVs?: Vector4;
  57010. backUVs?: Vector4;
  57011. }, scene?: Nullable<Scene>): Mesh;
  57012. /**
  57013. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57014. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57015. * * 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`)
  57016. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57017. * * 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
  57018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57019. * * 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
  57020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57021. * @param name defines the name of the mesh
  57022. * @param options defines the options used to create the mesh
  57023. * @param scene defines the hosting scene
  57024. * @returns the icosahedron mesh
  57025. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57026. */
  57027. static CreateIcoSphere(name: string, options: {
  57028. radius?: number;
  57029. radiusX?: number;
  57030. radiusY?: number;
  57031. radiusZ?: number;
  57032. flat?: boolean;
  57033. subdivisions?: number;
  57034. sideOrientation?: number;
  57035. frontUVs?: Vector4;
  57036. backUVs?: Vector4;
  57037. updatable?: boolean;
  57038. }, scene?: Nullable<Scene>): Mesh;
  57039. /**
  57040. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57041. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57042. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57043. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57044. * * 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
  57045. * * 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
  57046. * * 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
  57047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57048. * * 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
  57049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57050. * * 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
  57051. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57052. * * 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
  57053. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57055. * @param name defines the name of the mesh
  57056. * @param options defines the options used to create the mesh
  57057. * @param scene defines the hosting scene
  57058. * @returns the ribbon mesh
  57059. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57061. */
  57062. static CreateRibbon(name: string, options: {
  57063. pathArray: Vector3[][];
  57064. closeArray?: boolean;
  57065. closePath?: boolean;
  57066. offset?: number;
  57067. updatable?: boolean;
  57068. sideOrientation?: number;
  57069. frontUVs?: Vector4;
  57070. backUVs?: Vector4;
  57071. instance?: Mesh;
  57072. invertUV?: boolean;
  57073. uvs?: Vector2[];
  57074. colors?: Color4[];
  57075. }, scene?: Nullable<Scene>): Mesh;
  57076. /**
  57077. * Creates a cylinder or a cone mesh
  57078. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57079. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57080. * * 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.
  57081. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57082. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57083. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57084. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57085. * * 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).
  57086. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57087. * * 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).
  57088. * * 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
  57089. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57090. * * 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
  57091. * * 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.
  57092. * * If `enclose` is false, a ring surface is one element.
  57093. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57094. * * 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
  57095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57096. * * 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
  57097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57098. * @param name defines the name of the mesh
  57099. * @param options defines the options used to create the mesh
  57100. * @param scene defines the hosting scene
  57101. * @returns the cylinder mesh
  57102. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57103. */
  57104. static CreateCylinder(name: string, options: {
  57105. height?: number;
  57106. diameterTop?: number;
  57107. diameterBottom?: number;
  57108. diameter?: number;
  57109. tessellation?: number;
  57110. subdivisions?: number;
  57111. arc?: number;
  57112. faceColors?: Color4[];
  57113. faceUV?: Vector4[];
  57114. updatable?: boolean;
  57115. hasRings?: boolean;
  57116. enclose?: boolean;
  57117. cap?: number;
  57118. sideOrientation?: number;
  57119. frontUVs?: Vector4;
  57120. backUVs?: Vector4;
  57121. }, scene?: Nullable<Scene>): Mesh;
  57122. /**
  57123. * Creates a torus mesh
  57124. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57125. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57126. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57128. * * 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
  57129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57130. * @param name defines the name of the mesh
  57131. * @param options defines the options used to create the mesh
  57132. * @param scene defines the hosting scene
  57133. * @returns the torus mesh
  57134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57135. */
  57136. static CreateTorus(name: string, options: {
  57137. diameter?: number;
  57138. thickness?: number;
  57139. tessellation?: number;
  57140. updatable?: boolean;
  57141. sideOrientation?: number;
  57142. frontUVs?: Vector4;
  57143. backUVs?: Vector4;
  57144. }, scene?: Nullable<Scene>): Mesh;
  57145. /**
  57146. * Creates a torus knot mesh
  57147. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57148. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57149. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57150. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57152. * * 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
  57153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57154. * @param name defines the name of the mesh
  57155. * @param options defines the options used to create the mesh
  57156. * @param scene defines the hosting scene
  57157. * @returns the torus knot mesh
  57158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57159. */
  57160. static CreateTorusKnot(name: string, options: {
  57161. radius?: number;
  57162. tube?: number;
  57163. radialSegments?: number;
  57164. tubularSegments?: number;
  57165. p?: number;
  57166. q?: number;
  57167. updatable?: boolean;
  57168. sideOrientation?: number;
  57169. frontUVs?: Vector4;
  57170. backUVs?: Vector4;
  57171. }, scene?: Nullable<Scene>): Mesh;
  57172. /**
  57173. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57174. * * 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
  57175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57176. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57177. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57178. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57180. * * 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
  57181. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57184. * @param name defines the name of the new line system
  57185. * @param options defines the options used to create the line system
  57186. * @param scene defines the hosting scene
  57187. * @returns a new line system mesh
  57188. */
  57189. static CreateLineSystem(name: string, options: {
  57190. lines: Vector3[][];
  57191. updatable?: boolean;
  57192. instance?: Nullable<LinesMesh>;
  57193. colors?: Nullable<Color4[][]>;
  57194. useVertexAlpha?: boolean;
  57195. }, scene: Nullable<Scene>): LinesMesh;
  57196. /**
  57197. * Creates a line mesh
  57198. * 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
  57199. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57200. * * The parameter `points` is an array successive Vector3
  57201. * * 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
  57202. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57203. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57204. * * When updating an instance, remember that only point positions can change, not the number of points
  57205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57207. * @param name defines the name of the new line system
  57208. * @param options defines the options used to create the line system
  57209. * @param scene defines the hosting scene
  57210. * @returns a new line mesh
  57211. */
  57212. static CreateLines(name: string, options: {
  57213. points: Vector3[];
  57214. updatable?: boolean;
  57215. instance?: Nullable<LinesMesh>;
  57216. colors?: Color4[];
  57217. useVertexAlpha?: boolean;
  57218. }, scene?: Nullable<Scene>): LinesMesh;
  57219. /**
  57220. * Creates a dashed line mesh
  57221. * * 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
  57222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57223. * * The parameter `points` is an array successive Vector3
  57224. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57225. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57226. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57227. * * 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
  57228. * * When updating an instance, remember that only point positions can change, not the number of points
  57229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57230. * @param name defines the name of the mesh
  57231. * @param options defines the options used to create the mesh
  57232. * @param scene defines the hosting scene
  57233. * @returns the dashed line mesh
  57234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57235. */
  57236. static CreateDashedLines(name: string, options: {
  57237. points: Vector3[];
  57238. dashSize?: number;
  57239. gapSize?: number;
  57240. dashNb?: number;
  57241. updatable?: boolean;
  57242. instance?: LinesMesh;
  57243. }, scene?: Nullable<Scene>): LinesMesh;
  57244. /**
  57245. * 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.
  57246. * * 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.
  57247. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57248. * * 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.
  57249. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57250. * * 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
  57251. * * 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
  57252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57254. * * 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
  57255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57257. * @param name defines the name of the mesh
  57258. * @param options defines the options used to create the mesh
  57259. * @param scene defines the hosting scene
  57260. * @returns the extruded shape mesh
  57261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57263. */
  57264. static ExtrudeShape(name: string, options: {
  57265. shape: Vector3[];
  57266. path: Vector3[];
  57267. scale?: number;
  57268. rotation?: number;
  57269. cap?: number;
  57270. updatable?: boolean;
  57271. sideOrientation?: number;
  57272. frontUVs?: Vector4;
  57273. backUVs?: Vector4;
  57274. instance?: Mesh;
  57275. invertUV?: boolean;
  57276. }, scene?: Nullable<Scene>): Mesh;
  57277. /**
  57278. * Creates an custom extruded shape mesh.
  57279. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57280. * * 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.
  57281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57282. * * 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
  57283. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57284. * * 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
  57285. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57286. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57287. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57288. * * 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
  57289. * * 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
  57290. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57292. * * 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
  57293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57295. * @param name defines the name of the mesh
  57296. * @param options defines the options used to create the mesh
  57297. * @param scene defines the hosting scene
  57298. * @returns the custom extruded shape mesh
  57299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57302. */
  57303. static ExtrudeShapeCustom(name: string, options: {
  57304. shape: Vector3[];
  57305. path: Vector3[];
  57306. scaleFunction?: any;
  57307. rotationFunction?: any;
  57308. ribbonCloseArray?: boolean;
  57309. ribbonClosePath?: boolean;
  57310. cap?: number;
  57311. updatable?: boolean;
  57312. sideOrientation?: number;
  57313. frontUVs?: Vector4;
  57314. backUVs?: Vector4;
  57315. instance?: Mesh;
  57316. invertUV?: boolean;
  57317. }, scene?: Nullable<Scene>): Mesh;
  57318. /**
  57319. * Creates lathe mesh.
  57320. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57321. * * 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
  57322. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57323. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57324. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57325. * * 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
  57326. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57327. * * 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
  57328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57329. * * 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
  57330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57332. * @param name defines the name of the mesh
  57333. * @param options defines the options used to create the mesh
  57334. * @param scene defines the hosting scene
  57335. * @returns the lathe mesh
  57336. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57337. */
  57338. static CreateLathe(name: string, options: {
  57339. shape: Vector3[];
  57340. radius?: number;
  57341. tessellation?: number;
  57342. clip?: number;
  57343. arc?: number;
  57344. closed?: boolean;
  57345. updatable?: boolean;
  57346. sideOrientation?: number;
  57347. frontUVs?: Vector4;
  57348. backUVs?: Vector4;
  57349. cap?: number;
  57350. invertUV?: boolean;
  57351. }, scene?: Nullable<Scene>): Mesh;
  57352. /**
  57353. * Creates a tiled plane mesh
  57354. * * You can set a limited pattern arrangement with the tiles
  57355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57356. * * 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
  57357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57358. * @param name defines the name of the mesh
  57359. * @param options defines the options used to create the mesh
  57360. * @param scene defines the hosting scene
  57361. * @returns the plane mesh
  57362. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57363. */
  57364. static CreateTiledPlane(name: string, options: {
  57365. pattern?: number;
  57366. tileSize?: number;
  57367. tileWidth?: number;
  57368. tileHeight?: number;
  57369. size?: number;
  57370. width?: number;
  57371. height?: number;
  57372. alignHorizontal?: number;
  57373. alignVertical?: number;
  57374. sideOrientation?: number;
  57375. frontUVs?: Vector4;
  57376. backUVs?: Vector4;
  57377. updatable?: boolean;
  57378. }, scene?: Nullable<Scene>): Mesh;
  57379. /**
  57380. * Creates a plane mesh
  57381. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57382. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57383. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57385. * * 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
  57386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57387. * @param name defines the name of the mesh
  57388. * @param options defines the options used to create the mesh
  57389. * @param scene defines the hosting scene
  57390. * @returns the plane mesh
  57391. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57392. */
  57393. static CreatePlane(name: string, options: {
  57394. size?: number;
  57395. width?: number;
  57396. height?: number;
  57397. sideOrientation?: number;
  57398. frontUVs?: Vector4;
  57399. backUVs?: Vector4;
  57400. updatable?: boolean;
  57401. sourcePlane?: Plane;
  57402. }, scene?: Nullable<Scene>): Mesh;
  57403. /**
  57404. * Creates a ground mesh
  57405. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57406. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57408. * @param name defines the name of the mesh
  57409. * @param options defines the options used to create the mesh
  57410. * @param scene defines the hosting scene
  57411. * @returns the ground mesh
  57412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57413. */
  57414. static CreateGround(name: string, options: {
  57415. width?: number;
  57416. height?: number;
  57417. subdivisions?: number;
  57418. subdivisionsX?: number;
  57419. subdivisionsY?: number;
  57420. updatable?: boolean;
  57421. }, scene?: Nullable<Scene>): Mesh;
  57422. /**
  57423. * Creates a tiled ground mesh
  57424. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57425. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57426. * * 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
  57427. * * 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
  57428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57429. * @param name defines the name of the mesh
  57430. * @param options defines the options used to create the mesh
  57431. * @param scene defines the hosting scene
  57432. * @returns the tiled ground mesh
  57433. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57434. */
  57435. static CreateTiledGround(name: string, options: {
  57436. xmin: number;
  57437. zmin: number;
  57438. xmax: number;
  57439. zmax: number;
  57440. subdivisions?: {
  57441. w: number;
  57442. h: number;
  57443. };
  57444. precision?: {
  57445. w: number;
  57446. h: number;
  57447. };
  57448. updatable?: boolean;
  57449. }, scene?: Nullable<Scene>): Mesh;
  57450. /**
  57451. * Creates a ground mesh from a height map
  57452. * * The parameter `url` sets the URL of the height map image resource.
  57453. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57454. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57455. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57456. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57457. * * 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.
  57458. * * 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).
  57459. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57461. * @param name defines the name of the mesh
  57462. * @param url defines the url to the height map
  57463. * @param options defines the options used to create the mesh
  57464. * @param scene defines the hosting scene
  57465. * @returns the ground mesh
  57466. * @see https://doc.babylonjs.com/babylon101/height_map
  57467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57468. */
  57469. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57470. width?: number;
  57471. height?: number;
  57472. subdivisions?: number;
  57473. minHeight?: number;
  57474. maxHeight?: number;
  57475. colorFilter?: Color3;
  57476. alphaFilter?: number;
  57477. updatable?: boolean;
  57478. onReady?: (mesh: GroundMesh) => void;
  57479. }, scene?: Nullable<Scene>): GroundMesh;
  57480. /**
  57481. * Creates a polygon mesh
  57482. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57483. * * 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
  57484. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57486. * * 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)
  57487. * * Remember you can only change the shape positions, not their number when updating a polygon
  57488. * @param name defines the name of the mesh
  57489. * @param options defines the options used to create the mesh
  57490. * @param scene defines the hosting scene
  57491. * @param earcutInjection can be used to inject your own earcut reference
  57492. * @returns the polygon mesh
  57493. */
  57494. static CreatePolygon(name: string, options: {
  57495. shape: Vector3[];
  57496. holes?: Vector3[][];
  57497. depth?: number;
  57498. faceUV?: Vector4[];
  57499. faceColors?: Color4[];
  57500. updatable?: boolean;
  57501. sideOrientation?: number;
  57502. frontUVs?: Vector4;
  57503. backUVs?: Vector4;
  57504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57505. /**
  57506. * Creates an extruded polygon mesh, with depth in the Y direction.
  57507. * * 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)
  57508. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57509. * @param name defines the name of the mesh
  57510. * @param options defines the options used to create the mesh
  57511. * @param scene defines the hosting scene
  57512. * @param earcutInjection can be used to inject your own earcut reference
  57513. * @returns the polygon mesh
  57514. */
  57515. static ExtrudePolygon(name: string, options: {
  57516. shape: Vector3[];
  57517. holes?: Vector3[][];
  57518. depth?: number;
  57519. faceUV?: Vector4[];
  57520. faceColors?: Color4[];
  57521. updatable?: boolean;
  57522. sideOrientation?: number;
  57523. frontUVs?: Vector4;
  57524. backUVs?: Vector4;
  57525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57526. /**
  57527. * Creates a tube mesh.
  57528. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57529. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57530. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57531. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57532. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57533. * * 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)
  57534. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57535. * * 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
  57536. * * 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
  57537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57538. * * 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
  57539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57541. * @param name defines the name of the mesh
  57542. * @param options defines the options used to create the mesh
  57543. * @param scene defines the hosting scene
  57544. * @returns the tube mesh
  57545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57546. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57547. */
  57548. static CreateTube(name: string, options: {
  57549. path: Vector3[];
  57550. radius?: number;
  57551. tessellation?: number;
  57552. radiusFunction?: {
  57553. (i: number, distance: number): number;
  57554. };
  57555. cap?: number;
  57556. arc?: number;
  57557. updatable?: boolean;
  57558. sideOrientation?: number;
  57559. frontUVs?: Vector4;
  57560. backUVs?: Vector4;
  57561. instance?: Mesh;
  57562. invertUV?: boolean;
  57563. }, scene?: Nullable<Scene>): Mesh;
  57564. /**
  57565. * Creates a polyhedron mesh
  57566. * * 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
  57567. * * The parameter `size` (positive float, default 1) sets the polygon size
  57568. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57569. * * 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`
  57570. * * 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
  57571. * * 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)`)
  57572. * * 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
  57573. * * 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
  57574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57575. * * 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
  57576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57577. * @param name defines the name of the mesh
  57578. * @param options defines the options used to create the mesh
  57579. * @param scene defines the hosting scene
  57580. * @returns the polyhedron mesh
  57581. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57582. */
  57583. static CreatePolyhedron(name: string, options: {
  57584. type?: number;
  57585. size?: number;
  57586. sizeX?: number;
  57587. sizeY?: number;
  57588. sizeZ?: number;
  57589. custom?: any;
  57590. faceUV?: Vector4[];
  57591. faceColors?: Color4[];
  57592. flat?: boolean;
  57593. updatable?: boolean;
  57594. sideOrientation?: number;
  57595. frontUVs?: Vector4;
  57596. backUVs?: Vector4;
  57597. }, scene?: Nullable<Scene>): Mesh;
  57598. /**
  57599. * Creates a decal mesh.
  57600. * 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
  57601. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57602. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57603. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57604. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57605. * @param name defines the name of the mesh
  57606. * @param sourceMesh defines the mesh where the decal must be applied
  57607. * @param options defines the options used to create the mesh
  57608. * @param scene defines the hosting scene
  57609. * @returns the decal mesh
  57610. * @see https://doc.babylonjs.com/how_to/decals
  57611. */
  57612. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57613. position?: Vector3;
  57614. normal?: Vector3;
  57615. size?: Vector3;
  57616. angle?: number;
  57617. }): Mesh;
  57618. }
  57619. }
  57620. declare module BABYLON {
  57621. /**
  57622. * A simplifier interface for future simplification implementations
  57623. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57624. */
  57625. export interface ISimplifier {
  57626. /**
  57627. * Simplification of a given mesh according to the given settings.
  57628. * Since this requires computation, it is assumed that the function runs async.
  57629. * @param settings The settings of the simplification, including quality and distance
  57630. * @param successCallback A callback that will be called after the mesh was simplified.
  57631. * @param errorCallback in case of an error, this callback will be called. optional.
  57632. */
  57633. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57634. }
  57635. /**
  57636. * Expected simplification settings.
  57637. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57638. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57639. */
  57640. export interface ISimplificationSettings {
  57641. /**
  57642. * Gets or sets the expected quality
  57643. */
  57644. quality: number;
  57645. /**
  57646. * Gets or sets the distance when this optimized version should be used
  57647. */
  57648. distance: number;
  57649. /**
  57650. * Gets an already optimized mesh
  57651. */
  57652. optimizeMesh?: boolean;
  57653. }
  57654. /**
  57655. * Class used to specify simplification options
  57656. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57657. */
  57658. export class SimplificationSettings implements ISimplificationSettings {
  57659. /** expected quality */
  57660. quality: number;
  57661. /** distance when this optimized version should be used */
  57662. distance: number;
  57663. /** already optimized mesh */
  57664. optimizeMesh?: boolean | undefined;
  57665. /**
  57666. * Creates a SimplificationSettings
  57667. * @param quality expected quality
  57668. * @param distance distance when this optimized version should be used
  57669. * @param optimizeMesh already optimized mesh
  57670. */
  57671. constructor(
  57672. /** expected quality */
  57673. quality: number,
  57674. /** distance when this optimized version should be used */
  57675. distance: number,
  57676. /** already optimized mesh */
  57677. optimizeMesh?: boolean | undefined);
  57678. }
  57679. /**
  57680. * Interface used to define a simplification task
  57681. */
  57682. export interface ISimplificationTask {
  57683. /**
  57684. * Array of settings
  57685. */
  57686. settings: Array<ISimplificationSettings>;
  57687. /**
  57688. * Simplification type
  57689. */
  57690. simplificationType: SimplificationType;
  57691. /**
  57692. * Mesh to simplify
  57693. */
  57694. mesh: Mesh;
  57695. /**
  57696. * Callback called on success
  57697. */
  57698. successCallback?: () => void;
  57699. /**
  57700. * Defines if parallel processing can be used
  57701. */
  57702. parallelProcessing: boolean;
  57703. }
  57704. /**
  57705. * Queue used to order the simplification tasks
  57706. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57707. */
  57708. export class SimplificationQueue {
  57709. private _simplificationArray;
  57710. /**
  57711. * Gets a boolean indicating that the process is still running
  57712. */
  57713. running: boolean;
  57714. /**
  57715. * Creates a new queue
  57716. */
  57717. constructor();
  57718. /**
  57719. * Adds a new simplification task
  57720. * @param task defines a task to add
  57721. */
  57722. addTask(task: ISimplificationTask): void;
  57723. /**
  57724. * Execute next task
  57725. */
  57726. executeNext(): void;
  57727. /**
  57728. * Execute a simplification task
  57729. * @param task defines the task to run
  57730. */
  57731. runSimplification(task: ISimplificationTask): void;
  57732. private getSimplifier;
  57733. }
  57734. /**
  57735. * The implemented types of simplification
  57736. * At the moment only Quadratic Error Decimation is implemented
  57737. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57738. */
  57739. export enum SimplificationType {
  57740. /** Quadratic error decimation */
  57741. QUADRATIC = 0
  57742. }
  57743. }
  57744. declare module BABYLON {
  57745. interface Scene {
  57746. /** @hidden (Backing field) */
  57747. _simplificationQueue: SimplificationQueue;
  57748. /**
  57749. * Gets or sets the simplification queue attached to the scene
  57750. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57751. */
  57752. simplificationQueue: SimplificationQueue;
  57753. }
  57754. interface Mesh {
  57755. /**
  57756. * Simplify the mesh according to the given array of settings.
  57757. * Function will return immediately and will simplify async
  57758. * @param settings a collection of simplification settings
  57759. * @param parallelProcessing should all levels calculate parallel or one after the other
  57760. * @param simplificationType the type of simplification to run
  57761. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57762. * @returns the current mesh
  57763. */
  57764. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57765. }
  57766. /**
  57767. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57768. * created in a scene
  57769. */
  57770. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57771. /**
  57772. * The component name helpfull to identify the component in the list of scene components.
  57773. */
  57774. readonly name: string;
  57775. /**
  57776. * The scene the component belongs to.
  57777. */
  57778. scene: Scene;
  57779. /**
  57780. * Creates a new instance of the component for the given scene
  57781. * @param scene Defines the scene to register the component in
  57782. */
  57783. constructor(scene: Scene);
  57784. /**
  57785. * Registers the component in a given scene
  57786. */
  57787. register(): void;
  57788. /**
  57789. * Rebuilds the elements related to this component in case of
  57790. * context lost for instance.
  57791. */
  57792. rebuild(): void;
  57793. /**
  57794. * Disposes the component and the associated ressources
  57795. */
  57796. dispose(): void;
  57797. private _beforeCameraUpdate;
  57798. }
  57799. }
  57800. declare module BABYLON {
  57801. /**
  57802. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57803. */
  57804. export interface INavigationEnginePlugin {
  57805. /**
  57806. * plugin name
  57807. */
  57808. name: string;
  57809. /**
  57810. * Creates a navigation mesh
  57811. * @param meshes array of all the geometry used to compute the navigatio mesh
  57812. * @param parameters bunch of parameters used to filter geometry
  57813. */
  57814. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57815. /**
  57816. * Create a navigation mesh debug mesh
  57817. * @param scene is where the mesh will be added
  57818. * @returns debug display mesh
  57819. */
  57820. createDebugNavMesh(scene: Scene): Mesh;
  57821. /**
  57822. * Get a navigation mesh constrained position, closest to the parameter position
  57823. * @param position world position
  57824. * @returns the closest point to position constrained by the navigation mesh
  57825. */
  57826. getClosestPoint(position: Vector3): Vector3;
  57827. /**
  57828. * Get a navigation mesh constrained position, within a particular radius
  57829. * @param position world position
  57830. * @param maxRadius the maximum distance to the constrained world position
  57831. * @returns the closest point to position constrained by the navigation mesh
  57832. */
  57833. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57834. /**
  57835. * Compute the final position from a segment made of destination-position
  57836. * @param position world position
  57837. * @param destination world position
  57838. * @returns the resulting point along the navmesh
  57839. */
  57840. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57841. /**
  57842. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57843. * @param start world position
  57844. * @param end world position
  57845. * @returns array containing world position composing the path
  57846. */
  57847. computePath(start: Vector3, end: Vector3): Vector3[];
  57848. /**
  57849. * If this plugin is supported
  57850. * @returns true if plugin is supported
  57851. */
  57852. isSupported(): boolean;
  57853. /**
  57854. * Create a new Crowd so you can add agents
  57855. * @param maxAgents the maximum agent count in the crowd
  57856. * @param maxAgentRadius the maximum radius an agent can have
  57857. * @param scene to attach the crowd to
  57858. * @returns the crowd you can add agents to
  57859. */
  57860. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57861. /**
  57862. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57863. * The queries will try to find a solution within those bounds
  57864. * default is (1,1,1)
  57865. * @param extent x,y,z value that define the extent around the queries point of reference
  57866. */
  57867. setDefaultQueryExtent(extent: Vector3): void;
  57868. /**
  57869. * Get the Bounding box extent specified by setDefaultQueryExtent
  57870. * @returns the box extent values
  57871. */
  57872. getDefaultQueryExtent(): Vector3;
  57873. /**
  57874. * Release all resources
  57875. */
  57876. dispose(): void;
  57877. }
  57878. /**
  57879. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57880. */
  57881. export interface ICrowd {
  57882. /**
  57883. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57884. * You can attach anything to that node. The node position is updated in the scene update tick.
  57885. * @param pos world position that will be constrained by the navigation mesh
  57886. * @param parameters agent parameters
  57887. * @param transform hooked to the agent that will be update by the scene
  57888. * @returns agent index
  57889. */
  57890. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57891. /**
  57892. * Returns the agent position in world space
  57893. * @param index agent index returned by addAgent
  57894. * @returns world space position
  57895. */
  57896. getAgentPosition(index: number): Vector3;
  57897. /**
  57898. * Gets the agent velocity in world space
  57899. * @param index agent index returned by addAgent
  57900. * @returns world space velocity
  57901. */
  57902. getAgentVelocity(index: number): Vector3;
  57903. /**
  57904. * remove a particular agent previously created
  57905. * @param index agent index returned by addAgent
  57906. */
  57907. removeAgent(index: number): void;
  57908. /**
  57909. * get the list of all agents attached to this crowd
  57910. * @returns list of agent indices
  57911. */
  57912. getAgents(): number[];
  57913. /**
  57914. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57915. * @param deltaTime in seconds
  57916. */
  57917. update(deltaTime: number): void;
  57918. /**
  57919. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57920. * @param index agent index returned by addAgent
  57921. * @param destination targeted world position
  57922. */
  57923. agentGoto(index: number, destination: Vector3): void;
  57924. /**
  57925. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57926. * The queries will try to find a solution within those bounds
  57927. * default is (1,1,1)
  57928. * @param extent x,y,z value that define the extent around the queries point of reference
  57929. */
  57930. setDefaultQueryExtent(extent: Vector3): void;
  57931. /**
  57932. * Get the Bounding box extent specified by setDefaultQueryExtent
  57933. * @returns the box extent values
  57934. */
  57935. getDefaultQueryExtent(): Vector3;
  57936. /**
  57937. * Release all resources
  57938. */
  57939. dispose(): void;
  57940. }
  57941. /**
  57942. * Configures an agent
  57943. */
  57944. export interface IAgentParameters {
  57945. /**
  57946. * Agent radius. [Limit: >= 0]
  57947. */
  57948. radius: number;
  57949. /**
  57950. * Agent height. [Limit: > 0]
  57951. */
  57952. height: number;
  57953. /**
  57954. * Maximum allowed acceleration. [Limit: >= 0]
  57955. */
  57956. maxAcceleration: number;
  57957. /**
  57958. * Maximum allowed speed. [Limit: >= 0]
  57959. */
  57960. maxSpeed: number;
  57961. /**
  57962. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57963. */
  57964. collisionQueryRange: number;
  57965. /**
  57966. * The path visibility optimization range. [Limit: > 0]
  57967. */
  57968. pathOptimizationRange: number;
  57969. /**
  57970. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57971. */
  57972. separationWeight: number;
  57973. }
  57974. /**
  57975. * Configures the navigation mesh creation
  57976. */
  57977. export interface INavMeshParameters {
  57978. /**
  57979. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57980. */
  57981. cs: number;
  57982. /**
  57983. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57984. */
  57985. ch: number;
  57986. /**
  57987. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57988. */
  57989. walkableSlopeAngle: number;
  57990. /**
  57991. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57992. * be considered walkable. [Limit: >= 3] [Units: vx]
  57993. */
  57994. walkableHeight: number;
  57995. /**
  57996. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57997. */
  57998. walkableClimb: number;
  57999. /**
  58000. * The distance to erode/shrink the walkable area of the heightfield away from
  58001. * obstructions. [Limit: >=0] [Units: vx]
  58002. */
  58003. walkableRadius: number;
  58004. /**
  58005. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58006. */
  58007. maxEdgeLen: number;
  58008. /**
  58009. * The maximum distance a simplfied contour's border edges should deviate
  58010. * the original raw contour. [Limit: >=0] [Units: vx]
  58011. */
  58012. maxSimplificationError: number;
  58013. /**
  58014. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58015. */
  58016. minRegionArea: number;
  58017. /**
  58018. * Any regions with a span count smaller than this value will, if possible,
  58019. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58020. */
  58021. mergeRegionArea: number;
  58022. /**
  58023. * The maximum number of vertices allowed for polygons generated during the
  58024. * contour to polygon conversion process. [Limit: >= 3]
  58025. */
  58026. maxVertsPerPoly: number;
  58027. /**
  58028. * Sets the sampling distance to use when generating the detail mesh.
  58029. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58030. */
  58031. detailSampleDist: number;
  58032. /**
  58033. * The maximum distance the detail mesh surface should deviate from heightfield
  58034. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58035. */
  58036. detailSampleMaxError: number;
  58037. }
  58038. }
  58039. declare module BABYLON {
  58040. /**
  58041. * RecastJS navigation plugin
  58042. */
  58043. export class RecastJSPlugin implements INavigationEnginePlugin {
  58044. /**
  58045. * Reference to the Recast library
  58046. */
  58047. bjsRECAST: any;
  58048. /**
  58049. * plugin name
  58050. */
  58051. name: string;
  58052. /**
  58053. * the first navmesh created. We might extend this to support multiple navmeshes
  58054. */
  58055. navMesh: any;
  58056. /**
  58057. * Initializes the recastJS plugin
  58058. * @param recastInjection can be used to inject your own recast reference
  58059. */
  58060. constructor(recastInjection?: any);
  58061. /**
  58062. * Creates a navigation mesh
  58063. * @param meshes array of all the geometry used to compute the navigatio mesh
  58064. * @param parameters bunch of parameters used to filter geometry
  58065. */
  58066. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58067. /**
  58068. * Create a navigation mesh debug mesh
  58069. * @param scene is where the mesh will be added
  58070. * @returns debug display mesh
  58071. */
  58072. createDebugNavMesh(scene: Scene): Mesh;
  58073. /**
  58074. * Get a navigation mesh constrained position, closest to the parameter position
  58075. * @param position world position
  58076. * @returns the closest point to position constrained by the navigation mesh
  58077. */
  58078. getClosestPoint(position: Vector3): Vector3;
  58079. /**
  58080. * Get a navigation mesh constrained position, within a particular radius
  58081. * @param position world position
  58082. * @param maxRadius the maximum distance to the constrained world position
  58083. * @returns the closest point to position constrained by the navigation mesh
  58084. */
  58085. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58086. /**
  58087. * Compute the final position from a segment made of destination-position
  58088. * @param position world position
  58089. * @param destination world position
  58090. * @returns the resulting point along the navmesh
  58091. */
  58092. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58093. /**
  58094. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58095. * @param start world position
  58096. * @param end world position
  58097. * @returns array containing world position composing the path
  58098. */
  58099. computePath(start: Vector3, end: Vector3): Vector3[];
  58100. /**
  58101. * Create a new Crowd so you can add agents
  58102. * @param maxAgents the maximum agent count in the crowd
  58103. * @param maxAgentRadius the maximum radius an agent can have
  58104. * @param scene to attach the crowd to
  58105. * @returns the crowd you can add agents to
  58106. */
  58107. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58108. /**
  58109. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58110. * The queries will try to find a solution within those bounds
  58111. * default is (1,1,1)
  58112. * @param extent x,y,z value that define the extent around the queries point of reference
  58113. */
  58114. setDefaultQueryExtent(extent: Vector3): void;
  58115. /**
  58116. * Get the Bounding box extent specified by setDefaultQueryExtent
  58117. * @returns the box extent values
  58118. */
  58119. getDefaultQueryExtent(): Vector3;
  58120. /**
  58121. * Disposes
  58122. */
  58123. dispose(): void;
  58124. /**
  58125. * If this plugin is supported
  58126. * @returns true if plugin is supported
  58127. */
  58128. isSupported(): boolean;
  58129. }
  58130. /**
  58131. * Recast detour crowd implementation
  58132. */
  58133. export class RecastJSCrowd implements ICrowd {
  58134. /**
  58135. * Recast/detour plugin
  58136. */
  58137. bjsRECASTPlugin: RecastJSPlugin;
  58138. /**
  58139. * Link to the detour crowd
  58140. */
  58141. recastCrowd: any;
  58142. /**
  58143. * One transform per agent
  58144. */
  58145. transforms: TransformNode[];
  58146. /**
  58147. * All agents created
  58148. */
  58149. agents: number[];
  58150. /**
  58151. * Link to the scene is kept to unregister the crowd from the scene
  58152. */
  58153. private _scene;
  58154. /**
  58155. * Observer for crowd updates
  58156. */
  58157. private _onBeforeAnimationsObserver;
  58158. /**
  58159. * Constructor
  58160. * @param plugin recastJS plugin
  58161. * @param maxAgents the maximum agent count in the crowd
  58162. * @param maxAgentRadius the maximum radius an agent can have
  58163. * @param scene to attach the crowd to
  58164. * @returns the crowd you can add agents to
  58165. */
  58166. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58167. /**
  58168. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58169. * You can attach anything to that node. The node position is updated in the scene update tick.
  58170. * @param pos world position that will be constrained by the navigation mesh
  58171. * @param parameters agent parameters
  58172. * @param transform hooked to the agent that will be update by the scene
  58173. * @returns agent index
  58174. */
  58175. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58176. /**
  58177. * Returns the agent position in world space
  58178. * @param index agent index returned by addAgent
  58179. * @returns world space position
  58180. */
  58181. getAgentPosition(index: number): Vector3;
  58182. /**
  58183. * Returns the agent velocity in world space
  58184. * @param index agent index returned by addAgent
  58185. * @returns world space velocity
  58186. */
  58187. getAgentVelocity(index: number): Vector3;
  58188. /**
  58189. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58190. * @param index agent index returned by addAgent
  58191. * @param destination targeted world position
  58192. */
  58193. agentGoto(index: number, destination: Vector3): void;
  58194. /**
  58195. * remove a particular agent previously created
  58196. * @param index agent index returned by addAgent
  58197. */
  58198. removeAgent(index: number): void;
  58199. /**
  58200. * get the list of all agents attached to this crowd
  58201. * @returns list of agent indices
  58202. */
  58203. getAgents(): number[];
  58204. /**
  58205. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58206. * @param deltaTime in seconds
  58207. */
  58208. update(deltaTime: number): void;
  58209. /**
  58210. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58211. * The queries will try to find a solution within those bounds
  58212. * default is (1,1,1)
  58213. * @param extent x,y,z value that define the extent around the queries point of reference
  58214. */
  58215. setDefaultQueryExtent(extent: Vector3): void;
  58216. /**
  58217. * Get the Bounding box extent specified by setDefaultQueryExtent
  58218. * @returns the box extent values
  58219. */
  58220. getDefaultQueryExtent(): Vector3;
  58221. /**
  58222. * Release all resources
  58223. */
  58224. dispose(): void;
  58225. }
  58226. }
  58227. declare module BABYLON {
  58228. /**
  58229. * Class used to enable access to IndexedDB
  58230. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58231. */
  58232. export class Database implements IOfflineProvider {
  58233. private _callbackManifestChecked;
  58234. private _currentSceneUrl;
  58235. private _db;
  58236. private _enableSceneOffline;
  58237. private _enableTexturesOffline;
  58238. private _manifestVersionFound;
  58239. private _mustUpdateRessources;
  58240. private _hasReachedQuota;
  58241. private _isSupported;
  58242. private _idbFactory;
  58243. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58244. private static IsUASupportingBlobStorage;
  58245. /**
  58246. * Gets a boolean indicating if Database storate is enabled (off by default)
  58247. */
  58248. static IDBStorageEnabled: boolean;
  58249. /**
  58250. * Gets a boolean indicating if scene must be saved in the database
  58251. */
  58252. readonly enableSceneOffline: boolean;
  58253. /**
  58254. * Gets a boolean indicating if textures must be saved in the database
  58255. */
  58256. readonly enableTexturesOffline: boolean;
  58257. /**
  58258. * Creates a new Database
  58259. * @param urlToScene defines the url to load the scene
  58260. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58261. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58262. */
  58263. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58264. private static _ParseURL;
  58265. private static _ReturnFullUrlLocation;
  58266. private _checkManifestFile;
  58267. /**
  58268. * Open the database and make it available
  58269. * @param successCallback defines the callback to call on success
  58270. * @param errorCallback defines the callback to call on error
  58271. */
  58272. open(successCallback: () => void, errorCallback: () => void): void;
  58273. /**
  58274. * Loads an image from the database
  58275. * @param url defines the url to load from
  58276. * @param image defines the target DOM image
  58277. */
  58278. loadImage(url: string, image: HTMLImageElement): void;
  58279. private _loadImageFromDBAsync;
  58280. private _saveImageIntoDBAsync;
  58281. private _checkVersionFromDB;
  58282. private _loadVersionFromDBAsync;
  58283. private _saveVersionIntoDBAsync;
  58284. /**
  58285. * Loads a file from database
  58286. * @param url defines the URL to load from
  58287. * @param sceneLoaded defines a callback to call on success
  58288. * @param progressCallBack defines a callback to call when progress changed
  58289. * @param errorCallback defines a callback to call on error
  58290. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58291. */
  58292. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58293. private _loadFileAsync;
  58294. private _saveFileAsync;
  58295. /**
  58296. * Validates if xhr data is correct
  58297. * @param xhr defines the request to validate
  58298. * @param dataType defines the expected data type
  58299. * @returns true if data is correct
  58300. */
  58301. private static _ValidateXHRData;
  58302. }
  58303. }
  58304. declare module BABYLON {
  58305. /** @hidden */
  58306. export var gpuUpdateParticlesPixelShader: {
  58307. name: string;
  58308. shader: string;
  58309. };
  58310. }
  58311. declare module BABYLON {
  58312. /** @hidden */
  58313. export var gpuUpdateParticlesVertexShader: {
  58314. name: string;
  58315. shader: string;
  58316. };
  58317. }
  58318. declare module BABYLON {
  58319. /** @hidden */
  58320. export var clipPlaneFragmentDeclaration2: {
  58321. name: string;
  58322. shader: string;
  58323. };
  58324. }
  58325. declare module BABYLON {
  58326. /** @hidden */
  58327. export var gpuRenderParticlesPixelShader: {
  58328. name: string;
  58329. shader: string;
  58330. };
  58331. }
  58332. declare module BABYLON {
  58333. /** @hidden */
  58334. export var clipPlaneVertexDeclaration2: {
  58335. name: string;
  58336. shader: string;
  58337. };
  58338. }
  58339. declare module BABYLON {
  58340. /** @hidden */
  58341. export var gpuRenderParticlesVertexShader: {
  58342. name: string;
  58343. shader: string;
  58344. };
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * This represents a GPU particle system in Babylon
  58349. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58350. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58351. */
  58352. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58353. /**
  58354. * The layer mask we are rendering the particles through.
  58355. */
  58356. layerMask: number;
  58357. private _capacity;
  58358. private _activeCount;
  58359. private _currentActiveCount;
  58360. private _accumulatedCount;
  58361. private _renderEffect;
  58362. private _updateEffect;
  58363. private _buffer0;
  58364. private _buffer1;
  58365. private _spriteBuffer;
  58366. private _updateVAO;
  58367. private _renderVAO;
  58368. private _targetIndex;
  58369. private _sourceBuffer;
  58370. private _targetBuffer;
  58371. private _engine;
  58372. private _currentRenderId;
  58373. private _started;
  58374. private _stopped;
  58375. private _timeDelta;
  58376. private _randomTexture;
  58377. private _randomTexture2;
  58378. private _attributesStrideSize;
  58379. private _updateEffectOptions;
  58380. private _randomTextureSize;
  58381. private _actualFrame;
  58382. private readonly _rawTextureWidth;
  58383. /**
  58384. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58385. */
  58386. static readonly IsSupported: boolean;
  58387. /**
  58388. * An event triggered when the system is disposed.
  58389. */
  58390. onDisposeObservable: Observable<GPUParticleSystem>;
  58391. /**
  58392. * Gets the maximum number of particles active at the same time.
  58393. * @returns The max number of active particles.
  58394. */
  58395. getCapacity(): number;
  58396. /**
  58397. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58398. * to override the particles.
  58399. */
  58400. forceDepthWrite: boolean;
  58401. /**
  58402. * Gets or set the number of active particles
  58403. */
  58404. activeParticleCount: number;
  58405. private _preWarmDone;
  58406. /**
  58407. * Is this system ready to be used/rendered
  58408. * @return true if the system is ready
  58409. */
  58410. isReady(): boolean;
  58411. /**
  58412. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58413. * @returns True if it has been started, otherwise false.
  58414. */
  58415. isStarted(): boolean;
  58416. /**
  58417. * Starts the particle system and begins to emit
  58418. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58419. */
  58420. start(delay?: number): void;
  58421. /**
  58422. * Stops the particle system.
  58423. */
  58424. stop(): void;
  58425. /**
  58426. * Remove all active particles
  58427. */
  58428. reset(): void;
  58429. /**
  58430. * Returns the string "GPUParticleSystem"
  58431. * @returns a string containing the class name
  58432. */
  58433. getClassName(): string;
  58434. private _colorGradientsTexture;
  58435. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58436. /**
  58437. * Adds a new color gradient
  58438. * @param gradient defines the gradient to use (between 0 and 1)
  58439. * @param color1 defines the color to affect to the specified gradient
  58440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58441. * @returns the current particle system
  58442. */
  58443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58444. /**
  58445. * Remove a specific color gradient
  58446. * @param gradient defines the gradient to remove
  58447. * @returns the current particle system
  58448. */
  58449. removeColorGradient(gradient: number): GPUParticleSystem;
  58450. private _angularSpeedGradientsTexture;
  58451. private _sizeGradientsTexture;
  58452. private _velocityGradientsTexture;
  58453. private _limitVelocityGradientsTexture;
  58454. private _dragGradientsTexture;
  58455. private _addFactorGradient;
  58456. /**
  58457. * Adds a new size gradient
  58458. * @param gradient defines the gradient to use (between 0 and 1)
  58459. * @param factor defines the size factor to affect to the specified gradient
  58460. * @returns the current particle system
  58461. */
  58462. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58463. /**
  58464. * Remove a specific size gradient
  58465. * @param gradient defines the gradient to remove
  58466. * @returns the current particle system
  58467. */
  58468. removeSizeGradient(gradient: number): GPUParticleSystem;
  58469. /**
  58470. * Adds a new angular speed gradient
  58471. * @param gradient defines the gradient to use (between 0 and 1)
  58472. * @param factor defines the angular speed to affect to the specified gradient
  58473. * @returns the current particle system
  58474. */
  58475. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58476. /**
  58477. * Remove a specific angular speed gradient
  58478. * @param gradient defines the gradient to remove
  58479. * @returns the current particle system
  58480. */
  58481. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58482. /**
  58483. * Adds a new velocity gradient
  58484. * @param gradient defines the gradient to use (between 0 and 1)
  58485. * @param factor defines the velocity to affect to the specified gradient
  58486. * @returns the current particle system
  58487. */
  58488. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58489. /**
  58490. * Remove a specific velocity gradient
  58491. * @param gradient defines the gradient to remove
  58492. * @returns the current particle system
  58493. */
  58494. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58495. /**
  58496. * Adds a new limit velocity gradient
  58497. * @param gradient defines the gradient to use (between 0 and 1)
  58498. * @param factor defines the limit velocity value to affect to the specified gradient
  58499. * @returns the current particle system
  58500. */
  58501. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58502. /**
  58503. * Remove a specific limit velocity gradient
  58504. * @param gradient defines the gradient to remove
  58505. * @returns the current particle system
  58506. */
  58507. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58508. /**
  58509. * Adds a new drag gradient
  58510. * @param gradient defines the gradient to use (between 0 and 1)
  58511. * @param factor defines the drag value to affect to the specified gradient
  58512. * @returns the current particle system
  58513. */
  58514. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58515. /**
  58516. * Remove a specific drag gradient
  58517. * @param gradient defines the gradient to remove
  58518. * @returns the current particle system
  58519. */
  58520. removeDragGradient(gradient: number): GPUParticleSystem;
  58521. /**
  58522. * Not supported by GPUParticleSystem
  58523. * @param gradient defines the gradient to use (between 0 and 1)
  58524. * @param factor defines the emit rate value to affect to the specified gradient
  58525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58526. * @returns the current particle system
  58527. */
  58528. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58529. /**
  58530. * Not supported by GPUParticleSystem
  58531. * @param gradient defines the gradient to remove
  58532. * @returns the current particle system
  58533. */
  58534. removeEmitRateGradient(gradient: number): IParticleSystem;
  58535. /**
  58536. * Not supported by GPUParticleSystem
  58537. * @param gradient defines the gradient to use (between 0 and 1)
  58538. * @param factor defines the start size value to affect to the specified gradient
  58539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58540. * @returns the current particle system
  58541. */
  58542. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58543. /**
  58544. * Not supported by GPUParticleSystem
  58545. * @param gradient defines the gradient to remove
  58546. * @returns the current particle system
  58547. */
  58548. removeStartSizeGradient(gradient: number): IParticleSystem;
  58549. /**
  58550. * Not supported by GPUParticleSystem
  58551. * @param gradient defines the gradient to use (between 0 and 1)
  58552. * @param min defines the color remap minimal range
  58553. * @param max defines the color remap maximal range
  58554. * @returns the current particle system
  58555. */
  58556. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58557. /**
  58558. * Not supported by GPUParticleSystem
  58559. * @param gradient defines the gradient to remove
  58560. * @returns the current particle system
  58561. */
  58562. removeColorRemapGradient(): IParticleSystem;
  58563. /**
  58564. * Not supported by GPUParticleSystem
  58565. * @param gradient defines the gradient to use (between 0 and 1)
  58566. * @param min defines the alpha remap minimal range
  58567. * @param max defines the alpha remap maximal range
  58568. * @returns the current particle system
  58569. */
  58570. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58571. /**
  58572. * Not supported by GPUParticleSystem
  58573. * @param gradient defines the gradient to remove
  58574. * @returns the current particle system
  58575. */
  58576. removeAlphaRemapGradient(): IParticleSystem;
  58577. /**
  58578. * Not supported by GPUParticleSystem
  58579. * @param gradient defines the gradient to use (between 0 and 1)
  58580. * @param color defines the color to affect to the specified gradient
  58581. * @returns the current particle system
  58582. */
  58583. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58584. /**
  58585. * Not supported by GPUParticleSystem
  58586. * @param gradient defines the gradient to remove
  58587. * @returns the current particle system
  58588. */
  58589. removeRampGradient(): IParticleSystem;
  58590. /**
  58591. * Not supported by GPUParticleSystem
  58592. * @returns the list of ramp gradients
  58593. */
  58594. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58595. /**
  58596. * Not supported by GPUParticleSystem
  58597. * Gets or sets a boolean indicating that ramp gradients must be used
  58598. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58599. */
  58600. useRampGradients: boolean;
  58601. /**
  58602. * Not supported by GPUParticleSystem
  58603. * @param gradient defines the gradient to use (between 0 and 1)
  58604. * @param factor defines the life time factor to affect to the specified gradient
  58605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58606. * @returns the current particle system
  58607. */
  58608. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58609. /**
  58610. * Not supported by GPUParticleSystem
  58611. * @param gradient defines the gradient to remove
  58612. * @returns the current particle system
  58613. */
  58614. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58615. /**
  58616. * Instantiates a GPU particle system.
  58617. * 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.
  58618. * @param name The name of the particle system
  58619. * @param options The options used to create the system
  58620. * @param scene The scene the particle system belongs to
  58621. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58622. */
  58623. constructor(name: string, options: Partial<{
  58624. capacity: number;
  58625. randomTextureSize: number;
  58626. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58627. protected _reset(): void;
  58628. private _createUpdateVAO;
  58629. private _createRenderVAO;
  58630. private _initialize;
  58631. /** @hidden */
  58632. _recreateUpdateEffect(): void;
  58633. /** @hidden */
  58634. _recreateRenderEffect(): void;
  58635. /**
  58636. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58637. * @param preWarm defines if we are in the pre-warmimg phase
  58638. */
  58639. animate(preWarm?: boolean): void;
  58640. private _createFactorGradientTexture;
  58641. private _createSizeGradientTexture;
  58642. private _createAngularSpeedGradientTexture;
  58643. private _createVelocityGradientTexture;
  58644. private _createLimitVelocityGradientTexture;
  58645. private _createDragGradientTexture;
  58646. private _createColorGradientTexture;
  58647. /**
  58648. * Renders the particle system in its current state
  58649. * @param preWarm defines if the system should only update the particles but not render them
  58650. * @returns the current number of particles
  58651. */
  58652. render(preWarm?: boolean): number;
  58653. /**
  58654. * Rebuilds the particle system
  58655. */
  58656. rebuild(): void;
  58657. private _releaseBuffers;
  58658. private _releaseVAOs;
  58659. /**
  58660. * Disposes the particle system and free the associated resources
  58661. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58662. */
  58663. dispose(disposeTexture?: boolean): void;
  58664. /**
  58665. * Clones the particle system.
  58666. * @param name The name of the cloned object
  58667. * @param newEmitter The new emitter to use
  58668. * @returns the cloned particle system
  58669. */
  58670. clone(name: string, newEmitter: any): GPUParticleSystem;
  58671. /**
  58672. * Serializes the particle system to a JSON object.
  58673. * @returns the JSON object
  58674. */
  58675. serialize(): any;
  58676. /**
  58677. * Parses a JSON object to create a GPU particle system.
  58678. * @param parsedParticleSystem The JSON object to parse
  58679. * @param scene The scene to create the particle system in
  58680. * @param rootUrl The root url to use to load external dependencies like texture
  58681. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58682. * @returns the parsed GPU particle system
  58683. */
  58684. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58685. }
  58686. }
  58687. declare module BABYLON {
  58688. /**
  58689. * Represents a set of particle systems working together to create a specific effect
  58690. */
  58691. export class ParticleSystemSet implements IDisposable {
  58692. /**
  58693. * Gets or sets base Assets URL
  58694. */
  58695. static BaseAssetsUrl: string;
  58696. private _emitterCreationOptions;
  58697. private _emitterNode;
  58698. /**
  58699. * Gets the particle system list
  58700. */
  58701. systems: IParticleSystem[];
  58702. /**
  58703. * Gets the emitter node used with this set
  58704. */
  58705. readonly emitterNode: Nullable<TransformNode>;
  58706. /**
  58707. * Creates a new emitter mesh as a sphere
  58708. * @param options defines the options used to create the sphere
  58709. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58710. * @param scene defines the hosting scene
  58711. */
  58712. setEmitterAsSphere(options: {
  58713. diameter: number;
  58714. segments: number;
  58715. color: Color3;
  58716. }, renderingGroupId: number, scene: Scene): void;
  58717. /**
  58718. * Starts all particle systems of the set
  58719. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58720. */
  58721. start(emitter?: AbstractMesh): void;
  58722. /**
  58723. * Release all associated resources
  58724. */
  58725. dispose(): void;
  58726. /**
  58727. * Serialize the set into a JSON compatible object
  58728. * @returns a JSON compatible representation of the set
  58729. */
  58730. serialize(): any;
  58731. /**
  58732. * Parse a new ParticleSystemSet from a serialized source
  58733. * @param data defines a JSON compatible representation of the set
  58734. * @param scene defines the hosting scene
  58735. * @param gpu defines if we want GPU particles or CPU particles
  58736. * @returns a new ParticleSystemSet
  58737. */
  58738. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58739. }
  58740. }
  58741. declare module BABYLON {
  58742. /**
  58743. * This class is made for on one-liner static method to help creating particle system set.
  58744. */
  58745. export class ParticleHelper {
  58746. /**
  58747. * Gets or sets base Assets URL
  58748. */
  58749. static BaseAssetsUrl: string;
  58750. /**
  58751. * Create a default particle system that you can tweak
  58752. * @param emitter defines the emitter to use
  58753. * @param capacity defines the system capacity (default is 500 particles)
  58754. * @param scene defines the hosting scene
  58755. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58756. * @returns the new Particle system
  58757. */
  58758. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58759. /**
  58760. * This is the main static method (one-liner) of this helper to create different particle systems
  58761. * @param type This string represents the type to the particle system to create
  58762. * @param scene The scene where the particle system should live
  58763. * @param gpu If the system will use gpu
  58764. * @returns the ParticleSystemSet created
  58765. */
  58766. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58767. /**
  58768. * Static function used to export a particle system to a ParticleSystemSet variable.
  58769. * Please note that the emitter shape is not exported
  58770. * @param systems defines the particle systems to export
  58771. * @returns the created particle system set
  58772. */
  58773. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58774. }
  58775. }
  58776. declare module BABYLON {
  58777. interface Engine {
  58778. /**
  58779. * Create an effect to use with particle systems.
  58780. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58781. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58782. * @param uniformsNames defines a list of attribute names
  58783. * @param samplers defines an array of string used to represent textures
  58784. * @param defines defines the string containing the defines to use to compile the shaders
  58785. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58786. * @param onCompiled defines a function to call when the effect creation is successful
  58787. * @param onError defines a function to call when the effect creation has failed
  58788. * @returns the new Effect
  58789. */
  58790. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58791. }
  58792. interface Mesh {
  58793. /**
  58794. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58795. * @returns an array of IParticleSystem
  58796. */
  58797. getEmittedParticleSystems(): IParticleSystem[];
  58798. /**
  58799. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58800. * @returns an array of IParticleSystem
  58801. */
  58802. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58803. }
  58804. /**
  58805. * @hidden
  58806. */
  58807. export var _IDoNeedToBeInTheBuild: number;
  58808. }
  58809. declare module BABYLON {
  58810. /** Defines the 4 color options */
  58811. export enum PointColor {
  58812. /** color value */
  58813. Color = 2,
  58814. /** uv value */
  58815. UV = 1,
  58816. /** random value */
  58817. Random = 0,
  58818. /** stated value */
  58819. Stated = 3
  58820. }
  58821. /**
  58822. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58823. * 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.
  58824. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58825. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58826. *
  58827. * Full documentation here : TO BE ENTERED
  58828. */
  58829. export class PointsCloudSystem implements IDisposable {
  58830. /**
  58831. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58832. * Example : var p = SPS.particles[i];
  58833. */
  58834. particles: CloudPoint[];
  58835. /**
  58836. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58837. */
  58838. nbParticles: number;
  58839. /**
  58840. * This a counter for your own usage. It's not set by any SPS functions.
  58841. */
  58842. counter: number;
  58843. /**
  58844. * The PCS name. This name is also given to the underlying mesh.
  58845. */
  58846. name: string;
  58847. /**
  58848. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58849. */
  58850. mesh: Mesh;
  58851. /**
  58852. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58853. * Please read :
  58854. */
  58855. vars: any;
  58856. /**
  58857. * @hidden
  58858. */
  58859. _size: number;
  58860. private _scene;
  58861. private _promises;
  58862. private _positions;
  58863. private _indices;
  58864. private _normals;
  58865. private _colors;
  58866. private _uvs;
  58867. private _indices32;
  58868. private _positions32;
  58869. private _colors32;
  58870. private _uvs32;
  58871. private _updatable;
  58872. private _isVisibilityBoxLocked;
  58873. private _alwaysVisible;
  58874. private _groups;
  58875. private _groupCounter;
  58876. private _computeParticleColor;
  58877. private _computeParticleTexture;
  58878. private _computeParticleRotation;
  58879. private _computeBoundingBox;
  58880. private _isReady;
  58881. /**
  58882. * Creates a PCS (Points Cloud System) object
  58883. * @param name (String) is the PCS name, this will be the underlying mesh name
  58884. * @param pointSize (number) is the size for each point
  58885. * @param scene (Scene) is the scene in which the PCS is added
  58886. * @param options defines the options of the PCS e.g.
  58887. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58888. */
  58889. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58890. updatable?: boolean;
  58891. });
  58892. /**
  58893. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58894. * If no points were added to the PCS, the returned mesh is just a single point.
  58895. * @returns a promise for the created mesh
  58896. */
  58897. buildMeshAsync(): Promise<Mesh>;
  58898. /**
  58899. * @hidden
  58900. */
  58901. private _buildMesh;
  58902. private _addParticle;
  58903. private _randomUnitVector;
  58904. private _getColorIndicesForCoord;
  58905. private _setPointsColorOrUV;
  58906. private _colorFromTexture;
  58907. private _calculateDensity;
  58908. /**
  58909. * Adds points to the PCS in random positions within a unit sphere
  58910. * @param nb (positive integer) the number of particles to be created from this model
  58911. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58912. * @returns the number of groups in the system
  58913. */
  58914. addPoints(nb: number, pointFunction?: any): number;
  58915. /**
  58916. * Adds points to the PCS from the surface of the model shape
  58917. * @param mesh is any Mesh object that will be used as a surface model for the points
  58918. * @param nb (positive integer) the number of particles to be created from this model
  58919. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58920. * @param color (color3) to be used when colorWith is stated
  58921. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58922. * @returns the number of groups in the system
  58923. */
  58924. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58925. /**
  58926. * Adds points to the PCS inside the model shape
  58927. * @param mesh is any Mesh object that will be used as a surface model for the points
  58928. * @param nb (positive integer) the number of particles to be created from this model
  58929. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58930. * @param color (color4) to be used when colorWith is stated
  58931. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58932. * @returns the number of groups in the system
  58933. */
  58934. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58935. /**
  58936. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58937. * This method calls `updateParticle()` for each particle of the SPS.
  58938. * For an animated SPS, it is usually called within the render loop.
  58939. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58940. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58941. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58942. * @returns the PCS.
  58943. */
  58944. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58945. /**
  58946. * Disposes the PCS.
  58947. */
  58948. dispose(): void;
  58949. /**
  58950. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58951. * doc :
  58952. * @returns the PCS.
  58953. */
  58954. refreshVisibleSize(): PointsCloudSystem;
  58955. /**
  58956. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58957. * @param size the size (float) of the visibility box
  58958. * note : this doesn't lock the PCS mesh bounding box.
  58959. * doc :
  58960. */
  58961. setVisibilityBox(size: number): void;
  58962. /**
  58963. * Gets whether the PCS is always visible or not
  58964. * doc :
  58965. */
  58966. /**
  58967. * Sets the PCS as always visible or not
  58968. * doc :
  58969. */
  58970. isAlwaysVisible: boolean;
  58971. /**
  58972. * Tells to `setParticles()` to compute the particle rotations or not
  58973. * Default value : false. The PCS is faster when it's set to false
  58974. * Note : particle rotations are only applied to parent particles
  58975. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58976. */
  58977. computeParticleRotation: boolean;
  58978. /**
  58979. * Tells to `setParticles()` to compute the particle colors or not.
  58980. * Default value : true. The PCS is faster when it's set to false.
  58981. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58982. */
  58983. /**
  58984. * Gets if `setParticles()` computes the particle colors or not.
  58985. * Default value : false. The PCS is faster when it's set to false.
  58986. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58987. */
  58988. computeParticleColor: boolean;
  58989. /**
  58990. * Gets if `setParticles()` computes the particle textures or not.
  58991. * Default value : false. The PCS is faster when it's set to false.
  58992. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58993. */
  58994. computeParticleTexture: boolean;
  58995. /**
  58996. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58997. */
  58998. /**
  58999. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59000. */
  59001. computeBoundingBox: boolean;
  59002. /**
  59003. * This function does nothing. It may be overwritten to set all the particle first values.
  59004. * The PCS doesn't call this function, you may have to call it by your own.
  59005. * doc :
  59006. */
  59007. initParticles(): void;
  59008. /**
  59009. * This function does nothing. It may be overwritten to recycle a particle
  59010. * The PCS doesn't call this function, you can to call it
  59011. * doc :
  59012. * @param particle The particle to recycle
  59013. * @returns the recycled particle
  59014. */
  59015. recycleParticle(particle: CloudPoint): CloudPoint;
  59016. /**
  59017. * Updates a particle : this function should be overwritten by the user.
  59018. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59019. * doc :
  59020. * @example : just set a particle position or velocity and recycle conditions
  59021. * @param particle The particle to update
  59022. * @returns the updated particle
  59023. */
  59024. updateParticle(particle: CloudPoint): CloudPoint;
  59025. /**
  59026. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59027. * This does nothing and may be overwritten by the user.
  59028. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59029. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59030. * @param update the boolean update value actually passed to setParticles()
  59031. */
  59032. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59033. /**
  59034. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59035. * This will be passed three parameters.
  59036. * This does nothing and may be overwritten by the user.
  59037. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59038. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59039. * @param update the boolean update value actually passed to setParticles()
  59040. */
  59041. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59042. }
  59043. }
  59044. declare module BABYLON {
  59045. /**
  59046. * Represents one particle of a points cloud system.
  59047. */
  59048. export class CloudPoint {
  59049. /**
  59050. * particle global index
  59051. */
  59052. idx: number;
  59053. /**
  59054. * The color of the particle
  59055. */
  59056. color: Nullable<Color4>;
  59057. /**
  59058. * The world space position of the particle.
  59059. */
  59060. position: Vector3;
  59061. /**
  59062. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  59063. */
  59064. rotation: Vector3;
  59065. /**
  59066. * The world space rotation quaternion of the particle.
  59067. */
  59068. rotationQuaternion: Nullable<Quaternion>;
  59069. /**
  59070. * The uv of the particle.
  59071. */
  59072. uv: Nullable<Vector2>;
  59073. /**
  59074. * The current speed of the particle.
  59075. */
  59076. velocity: Vector3;
  59077. /**
  59078. * The pivot point in the particle local space.
  59079. */
  59080. pivot: Vector3;
  59081. /**
  59082. * Must the particle be translated from its pivot point in its local space ?
  59083. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  59084. * Default : false
  59085. */
  59086. translateFromPivot: boolean;
  59087. /**
  59088. * Index of this particle in the global "positions" array (Internal use)
  59089. * @hidden
  59090. */
  59091. _pos: number;
  59092. /**
  59093. * @hidden Index of this particle in the global "indices" array (Internal use)
  59094. */
  59095. _ind: number;
  59096. /**
  59097. * Group this particle belongs to
  59098. */
  59099. _group: PointsGroup;
  59100. /**
  59101. * Group id of this particle
  59102. */
  59103. groupId: number;
  59104. /**
  59105. * Index of the particle in its group id (Internal use)
  59106. */
  59107. idxInGroup: number;
  59108. /**
  59109. * @hidden Particle BoundingInfo object (Internal use)
  59110. */
  59111. _boundingInfo: BoundingInfo;
  59112. /**
  59113. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  59114. */
  59115. _pcs: PointsCloudSystem;
  59116. /**
  59117. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59118. */
  59119. _stillInvisible: boolean;
  59120. /**
  59121. * @hidden Last computed particle rotation matrix
  59122. */
  59123. _rotationMatrix: number[];
  59124. /**
  59125. * Parent particle Id, if any.
  59126. * Default null.
  59127. */
  59128. parentId: Nullable<number>;
  59129. /**
  59130. * @hidden Internal global position in the PCS.
  59131. */
  59132. _globalPosition: Vector3;
  59133. /**
  59134. * Creates a Point Cloud object.
  59135. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59136. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59137. * @param group (PointsGroup) is the group the particle belongs to
  59138. * @param groupId (integer) is the group identifier in the PCS.
  59139. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59140. * @param pcs defines the PCS it is associated to
  59141. */
  59142. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59143. /**
  59144. * get point size
  59145. */
  59146. /**
  59147. * Set point size
  59148. */
  59149. size: Vector3;
  59150. /**
  59151. * Legacy support, changed quaternion to rotationQuaternion
  59152. */
  59153. /**
  59154. * Legacy support, changed quaternion to rotationQuaternion
  59155. */
  59156. quaternion: Nullable<Quaternion>;
  59157. /**
  59158. * Returns a boolean. True if the particle intersects a mesh, else false
  59159. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59160. * @param target is the object (point or mesh) what the intersection is computed against
  59161. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59162. * @returns true if it intersects
  59163. */
  59164. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59165. /**
  59166. * get the rotation matrix of the particle
  59167. * @hidden
  59168. */
  59169. getRotationMatrix(m: Matrix): void;
  59170. }
  59171. /**
  59172. * Represents a group of points in a points cloud system
  59173. * * PCS internal tool, don't use it manually.
  59174. */
  59175. export class PointsGroup {
  59176. /**
  59177. * The group id
  59178. * @hidden
  59179. */
  59180. groupID: number;
  59181. /**
  59182. * image data for group (internal use)
  59183. * @hidden
  59184. */
  59185. _groupImageData: Nullable<ArrayBufferView>;
  59186. /**
  59187. * Image Width (internal use)
  59188. * @hidden
  59189. */
  59190. _groupImgWidth: number;
  59191. /**
  59192. * Image Height (internal use)
  59193. * @hidden
  59194. */
  59195. _groupImgHeight: number;
  59196. /**
  59197. * Custom position function (internal use)
  59198. * @hidden
  59199. */
  59200. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59201. /**
  59202. * density per facet for surface points
  59203. * @hidden
  59204. */
  59205. _groupDensity: number[];
  59206. /**
  59207. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59208. * PCS internal tool, don't use it manually.
  59209. * @hidden
  59210. */
  59211. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59212. }
  59213. }
  59214. declare module BABYLON {
  59215. interface Scene {
  59216. /** @hidden (Backing field) */
  59217. _physicsEngine: Nullable<IPhysicsEngine>;
  59218. /**
  59219. * Gets the current physics engine
  59220. * @returns a IPhysicsEngine or null if none attached
  59221. */
  59222. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59223. /**
  59224. * Enables physics to the current scene
  59225. * @param gravity defines the scene's gravity for the physics engine
  59226. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59227. * @return a boolean indicating if the physics engine was initialized
  59228. */
  59229. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59230. /**
  59231. * Disables and disposes the physics engine associated with the scene
  59232. */
  59233. disablePhysicsEngine(): void;
  59234. /**
  59235. * Gets a boolean indicating if there is an active physics engine
  59236. * @returns a boolean indicating if there is an active physics engine
  59237. */
  59238. isPhysicsEnabled(): boolean;
  59239. /**
  59240. * Deletes a physics compound impostor
  59241. * @param compound defines the compound to delete
  59242. */
  59243. deleteCompoundImpostor(compound: any): void;
  59244. /**
  59245. * An event triggered when physic simulation is about to be run
  59246. */
  59247. onBeforePhysicsObservable: Observable<Scene>;
  59248. /**
  59249. * An event triggered when physic simulation has been done
  59250. */
  59251. onAfterPhysicsObservable: Observable<Scene>;
  59252. }
  59253. interface AbstractMesh {
  59254. /** @hidden */
  59255. _physicsImpostor: Nullable<PhysicsImpostor>;
  59256. /**
  59257. * Gets or sets impostor used for physic simulation
  59258. * @see http://doc.babylonjs.com/features/physics_engine
  59259. */
  59260. physicsImpostor: Nullable<PhysicsImpostor>;
  59261. /**
  59262. * Gets the current physics impostor
  59263. * @see http://doc.babylonjs.com/features/physics_engine
  59264. * @returns a physics impostor or null
  59265. */
  59266. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59267. /** Apply a physic impulse to the mesh
  59268. * @param force defines the force to apply
  59269. * @param contactPoint defines where to apply the force
  59270. * @returns the current mesh
  59271. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59272. */
  59273. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59274. /**
  59275. * Creates a physic joint between two meshes
  59276. * @param otherMesh defines the other mesh to use
  59277. * @param pivot1 defines the pivot to use on this mesh
  59278. * @param pivot2 defines the pivot to use on the other mesh
  59279. * @param options defines additional options (can be plugin dependent)
  59280. * @returns the current mesh
  59281. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59282. */
  59283. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59284. /** @hidden */
  59285. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59286. }
  59287. /**
  59288. * Defines the physics engine scene component responsible to manage a physics engine
  59289. */
  59290. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59291. /**
  59292. * The component name helpful to identify the component in the list of scene components.
  59293. */
  59294. readonly name: string;
  59295. /**
  59296. * The scene the component belongs to.
  59297. */
  59298. scene: Scene;
  59299. /**
  59300. * Creates a new instance of the component for the given scene
  59301. * @param scene Defines the scene to register the component in
  59302. */
  59303. constructor(scene: Scene);
  59304. /**
  59305. * Registers the component in a given scene
  59306. */
  59307. register(): void;
  59308. /**
  59309. * Rebuilds the elements related to this component in case of
  59310. * context lost for instance.
  59311. */
  59312. rebuild(): void;
  59313. /**
  59314. * Disposes the component and the associated ressources
  59315. */
  59316. dispose(): void;
  59317. }
  59318. }
  59319. declare module BABYLON {
  59320. /**
  59321. * A helper for physics simulations
  59322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59323. */
  59324. export class PhysicsHelper {
  59325. private _scene;
  59326. private _physicsEngine;
  59327. /**
  59328. * Initializes the Physics helper
  59329. * @param scene Babylon.js scene
  59330. */
  59331. constructor(scene: Scene);
  59332. /**
  59333. * Applies a radial explosion impulse
  59334. * @param origin the origin of the explosion
  59335. * @param radiusOrEventOptions the radius or the options of radial explosion
  59336. * @param strength the explosion strength
  59337. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59338. * @returns A physics radial explosion event, or null
  59339. */
  59340. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59341. /**
  59342. * Applies a radial explosion force
  59343. * @param origin the origin of the explosion
  59344. * @param radiusOrEventOptions the radius or the options of radial explosion
  59345. * @param strength the explosion strength
  59346. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59347. * @returns A physics radial explosion event, or null
  59348. */
  59349. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59350. /**
  59351. * Creates a gravitational field
  59352. * @param origin the origin of the explosion
  59353. * @param radiusOrEventOptions the radius or the options of radial explosion
  59354. * @param strength the explosion strength
  59355. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59356. * @returns A physics gravitational field event, or null
  59357. */
  59358. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59359. /**
  59360. * Creates a physics updraft event
  59361. * @param origin the origin of the updraft
  59362. * @param radiusOrEventOptions the radius or the options of the updraft
  59363. * @param strength the strength of the updraft
  59364. * @param height the height of the updraft
  59365. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59366. * @returns A physics updraft event, or null
  59367. */
  59368. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59369. /**
  59370. * Creates a physics vortex event
  59371. * @param origin the of the vortex
  59372. * @param radiusOrEventOptions the radius or the options of the vortex
  59373. * @param strength the strength of the vortex
  59374. * @param height the height of the vortex
  59375. * @returns a Physics vortex event, or null
  59376. * A physics vortex event or null
  59377. */
  59378. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59379. }
  59380. /**
  59381. * Represents a physics radial explosion event
  59382. */
  59383. class PhysicsRadialExplosionEvent {
  59384. private _scene;
  59385. private _options;
  59386. private _sphere;
  59387. private _dataFetched;
  59388. /**
  59389. * Initializes a radial explosioin event
  59390. * @param _scene BabylonJS scene
  59391. * @param _options The options for the vortex event
  59392. */
  59393. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59394. /**
  59395. * Returns the data related to the radial explosion event (sphere).
  59396. * @returns The radial explosion event data
  59397. */
  59398. getData(): PhysicsRadialExplosionEventData;
  59399. /**
  59400. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59401. * @param impostor A physics imposter
  59402. * @param origin the origin of the explosion
  59403. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59404. */
  59405. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59406. /**
  59407. * Triggers affecterd impostors callbacks
  59408. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59409. */
  59410. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59411. /**
  59412. * Disposes the sphere.
  59413. * @param force Specifies if the sphere should be disposed by force
  59414. */
  59415. dispose(force?: boolean): void;
  59416. /*** Helpers ***/
  59417. private _prepareSphere;
  59418. private _intersectsWithSphere;
  59419. }
  59420. /**
  59421. * Represents a gravitational field event
  59422. */
  59423. class PhysicsGravitationalFieldEvent {
  59424. private _physicsHelper;
  59425. private _scene;
  59426. private _origin;
  59427. private _options;
  59428. private _tickCallback;
  59429. private _sphere;
  59430. private _dataFetched;
  59431. /**
  59432. * Initializes the physics gravitational field event
  59433. * @param _physicsHelper A physics helper
  59434. * @param _scene BabylonJS scene
  59435. * @param _origin The origin position of the gravitational field event
  59436. * @param _options The options for the vortex event
  59437. */
  59438. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59439. /**
  59440. * Returns the data related to the gravitational field event (sphere).
  59441. * @returns A gravitational field event
  59442. */
  59443. getData(): PhysicsGravitationalFieldEventData;
  59444. /**
  59445. * Enables the gravitational field.
  59446. */
  59447. enable(): void;
  59448. /**
  59449. * Disables the gravitational field.
  59450. */
  59451. disable(): void;
  59452. /**
  59453. * Disposes the sphere.
  59454. * @param force The force to dispose from the gravitational field event
  59455. */
  59456. dispose(force?: boolean): void;
  59457. private _tick;
  59458. }
  59459. /**
  59460. * Represents a physics updraft event
  59461. */
  59462. class PhysicsUpdraftEvent {
  59463. private _scene;
  59464. private _origin;
  59465. private _options;
  59466. private _physicsEngine;
  59467. private _originTop;
  59468. private _originDirection;
  59469. private _tickCallback;
  59470. private _cylinder;
  59471. private _cylinderPosition;
  59472. private _dataFetched;
  59473. /**
  59474. * Initializes the physics updraft event
  59475. * @param _scene BabylonJS scene
  59476. * @param _origin The origin position of the updraft
  59477. * @param _options The options for the updraft event
  59478. */
  59479. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59480. /**
  59481. * Returns the data related to the updraft event (cylinder).
  59482. * @returns A physics updraft event
  59483. */
  59484. getData(): PhysicsUpdraftEventData;
  59485. /**
  59486. * Enables the updraft.
  59487. */
  59488. enable(): void;
  59489. /**
  59490. * Disables the updraft.
  59491. */
  59492. disable(): void;
  59493. /**
  59494. * Disposes the cylinder.
  59495. * @param force Specifies if the updraft should be disposed by force
  59496. */
  59497. dispose(force?: boolean): void;
  59498. private getImpostorHitData;
  59499. private _tick;
  59500. /*** Helpers ***/
  59501. private _prepareCylinder;
  59502. private _intersectsWithCylinder;
  59503. }
  59504. /**
  59505. * Represents a physics vortex event
  59506. */
  59507. class PhysicsVortexEvent {
  59508. private _scene;
  59509. private _origin;
  59510. private _options;
  59511. private _physicsEngine;
  59512. private _originTop;
  59513. private _tickCallback;
  59514. private _cylinder;
  59515. private _cylinderPosition;
  59516. private _dataFetched;
  59517. /**
  59518. * Initializes the physics vortex event
  59519. * @param _scene The BabylonJS scene
  59520. * @param _origin The origin position of the vortex
  59521. * @param _options The options for the vortex event
  59522. */
  59523. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59524. /**
  59525. * Returns the data related to the vortex event (cylinder).
  59526. * @returns The physics vortex event data
  59527. */
  59528. getData(): PhysicsVortexEventData;
  59529. /**
  59530. * Enables the vortex.
  59531. */
  59532. enable(): void;
  59533. /**
  59534. * Disables the cortex.
  59535. */
  59536. disable(): void;
  59537. /**
  59538. * Disposes the sphere.
  59539. * @param force
  59540. */
  59541. dispose(force?: boolean): void;
  59542. private getImpostorHitData;
  59543. private _tick;
  59544. /*** Helpers ***/
  59545. private _prepareCylinder;
  59546. private _intersectsWithCylinder;
  59547. }
  59548. /**
  59549. * Options fot the radial explosion event
  59550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59551. */
  59552. export class PhysicsRadialExplosionEventOptions {
  59553. /**
  59554. * The radius of the sphere for the radial explosion.
  59555. */
  59556. radius: number;
  59557. /**
  59558. * The strenth of the explosion.
  59559. */
  59560. strength: number;
  59561. /**
  59562. * The strenght of the force in correspondence to the distance of the affected object
  59563. */
  59564. falloff: PhysicsRadialImpulseFalloff;
  59565. /**
  59566. * Sphere options for the radial explosion.
  59567. */
  59568. sphere: {
  59569. segments: number;
  59570. diameter: number;
  59571. };
  59572. /**
  59573. * Sphere options for the radial explosion.
  59574. */
  59575. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59576. }
  59577. /**
  59578. * Options fot the updraft event
  59579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59580. */
  59581. export class PhysicsUpdraftEventOptions {
  59582. /**
  59583. * The radius of the cylinder for the vortex
  59584. */
  59585. radius: number;
  59586. /**
  59587. * The strenth of the updraft.
  59588. */
  59589. strength: number;
  59590. /**
  59591. * The height of the cylinder for the updraft.
  59592. */
  59593. height: number;
  59594. /**
  59595. * The mode for the the updraft.
  59596. */
  59597. updraftMode: PhysicsUpdraftMode;
  59598. }
  59599. /**
  59600. * Options fot the vortex event
  59601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59602. */
  59603. export class PhysicsVortexEventOptions {
  59604. /**
  59605. * The radius of the cylinder for the vortex
  59606. */
  59607. radius: number;
  59608. /**
  59609. * The strenth of the vortex.
  59610. */
  59611. strength: number;
  59612. /**
  59613. * The height of the cylinder for the vortex.
  59614. */
  59615. height: number;
  59616. /**
  59617. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59618. */
  59619. centripetalForceThreshold: number;
  59620. /**
  59621. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59622. */
  59623. centripetalForceMultiplier: number;
  59624. /**
  59625. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59626. */
  59627. centrifugalForceMultiplier: number;
  59628. /**
  59629. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59630. */
  59631. updraftForceMultiplier: number;
  59632. }
  59633. /**
  59634. * The strenght of the force in correspondence to the distance of the affected object
  59635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59636. */
  59637. export enum PhysicsRadialImpulseFalloff {
  59638. /** Defines that impulse is constant in strength across it's whole radius */
  59639. Constant = 0,
  59640. /** Defines that impulse gets weaker if it's further from the origin */
  59641. Linear = 1
  59642. }
  59643. /**
  59644. * The strength of the force in correspondence to the distance of the affected object
  59645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59646. */
  59647. export enum PhysicsUpdraftMode {
  59648. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59649. Center = 0,
  59650. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59651. Perpendicular = 1
  59652. }
  59653. /**
  59654. * Interface for a physics hit data
  59655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59656. */
  59657. export interface PhysicsHitData {
  59658. /**
  59659. * The force applied at the contact point
  59660. */
  59661. force: Vector3;
  59662. /**
  59663. * The contact point
  59664. */
  59665. contactPoint: Vector3;
  59666. /**
  59667. * The distance from the origin to the contact point
  59668. */
  59669. distanceFromOrigin: number;
  59670. }
  59671. /**
  59672. * Interface for radial explosion event data
  59673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59674. */
  59675. export interface PhysicsRadialExplosionEventData {
  59676. /**
  59677. * A sphere used for the radial explosion event
  59678. */
  59679. sphere: Mesh;
  59680. }
  59681. /**
  59682. * Interface for gravitational field event data
  59683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59684. */
  59685. export interface PhysicsGravitationalFieldEventData {
  59686. /**
  59687. * A sphere mesh used for the gravitational field event
  59688. */
  59689. sphere: Mesh;
  59690. }
  59691. /**
  59692. * Interface for updraft event data
  59693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59694. */
  59695. export interface PhysicsUpdraftEventData {
  59696. /**
  59697. * A cylinder used for the updraft event
  59698. */
  59699. cylinder: Mesh;
  59700. }
  59701. /**
  59702. * Interface for vortex event data
  59703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59704. */
  59705. export interface PhysicsVortexEventData {
  59706. /**
  59707. * A cylinder used for the vortex event
  59708. */
  59709. cylinder: Mesh;
  59710. }
  59711. /**
  59712. * Interface for an affected physics impostor
  59713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59714. */
  59715. export interface PhysicsAffectedImpostorWithData {
  59716. /**
  59717. * The impostor affected by the effect
  59718. */
  59719. impostor: PhysicsImpostor;
  59720. /**
  59721. * The data about the hit/horce from the explosion
  59722. */
  59723. hitData: PhysicsHitData;
  59724. }
  59725. }
  59726. declare module BABYLON {
  59727. /** @hidden */
  59728. export var blackAndWhitePixelShader: {
  59729. name: string;
  59730. shader: string;
  59731. };
  59732. }
  59733. declare module BABYLON {
  59734. /**
  59735. * Post process used to render in black and white
  59736. */
  59737. export class BlackAndWhitePostProcess extends PostProcess {
  59738. /**
  59739. * Linear about to convert he result to black and white (default: 1)
  59740. */
  59741. degree: number;
  59742. /**
  59743. * Creates a black and white post process
  59744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59745. * @param name The name of the effect.
  59746. * @param options The required width/height ratio to downsize to before computing the render pass.
  59747. * @param camera The camera to apply the render pass to.
  59748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59749. * @param engine The engine which the post process will be applied. (default: current engine)
  59750. * @param reusable If the post process can be reused on the same frame. (default: false)
  59751. */
  59752. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59753. }
  59754. }
  59755. declare module BABYLON {
  59756. /**
  59757. * This represents a set of one or more post processes in Babylon.
  59758. * A post process can be used to apply a shader to a texture after it is rendered.
  59759. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59760. */
  59761. export class PostProcessRenderEffect {
  59762. private _postProcesses;
  59763. private _getPostProcesses;
  59764. private _singleInstance;
  59765. private _cameras;
  59766. private _indicesForCamera;
  59767. /**
  59768. * Name of the effect
  59769. * @hidden
  59770. */
  59771. _name: string;
  59772. /**
  59773. * Instantiates a post process render effect.
  59774. * A post process can be used to apply a shader to a texture after it is rendered.
  59775. * @param engine The engine the effect is tied to
  59776. * @param name The name of the effect
  59777. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59778. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59779. */
  59780. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59781. /**
  59782. * Checks if all the post processes in the effect are supported.
  59783. */
  59784. readonly isSupported: boolean;
  59785. /**
  59786. * Updates the current state of the effect
  59787. * @hidden
  59788. */
  59789. _update(): void;
  59790. /**
  59791. * Attaches the effect on cameras
  59792. * @param cameras The camera to attach to.
  59793. * @hidden
  59794. */
  59795. _attachCameras(cameras: Camera): void;
  59796. /**
  59797. * Attaches the effect on cameras
  59798. * @param cameras The camera to attach to.
  59799. * @hidden
  59800. */
  59801. _attachCameras(cameras: Camera[]): void;
  59802. /**
  59803. * Detaches the effect on cameras
  59804. * @param cameras The camera to detatch from.
  59805. * @hidden
  59806. */
  59807. _detachCameras(cameras: Camera): void;
  59808. /**
  59809. * Detatches the effect on cameras
  59810. * @param cameras The camera to detatch from.
  59811. * @hidden
  59812. */
  59813. _detachCameras(cameras: Camera[]): void;
  59814. /**
  59815. * Enables the effect on given cameras
  59816. * @param cameras The camera to enable.
  59817. * @hidden
  59818. */
  59819. _enable(cameras: Camera): void;
  59820. /**
  59821. * Enables the effect on given cameras
  59822. * @param cameras The camera to enable.
  59823. * @hidden
  59824. */
  59825. _enable(cameras: Nullable<Camera[]>): void;
  59826. /**
  59827. * Disables the effect on the given cameras
  59828. * @param cameras The camera to disable.
  59829. * @hidden
  59830. */
  59831. _disable(cameras: Camera): void;
  59832. /**
  59833. * Disables the effect on the given cameras
  59834. * @param cameras The camera to disable.
  59835. * @hidden
  59836. */
  59837. _disable(cameras: Nullable<Camera[]>): void;
  59838. /**
  59839. * Gets a list of the post processes contained in the effect.
  59840. * @param camera The camera to get the post processes on.
  59841. * @returns The list of the post processes in the effect.
  59842. */
  59843. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59844. }
  59845. }
  59846. declare module BABYLON {
  59847. /** @hidden */
  59848. export var extractHighlightsPixelShader: {
  59849. name: string;
  59850. shader: string;
  59851. };
  59852. }
  59853. declare module BABYLON {
  59854. /**
  59855. * 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.
  59856. */
  59857. export class ExtractHighlightsPostProcess extends PostProcess {
  59858. /**
  59859. * The luminance threshold, pixels below this value will be set to black.
  59860. */
  59861. threshold: number;
  59862. /** @hidden */
  59863. _exposure: number;
  59864. /**
  59865. * Post process which has the input texture to be used when performing highlight extraction
  59866. * @hidden
  59867. */
  59868. _inputPostProcess: Nullable<PostProcess>;
  59869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59870. }
  59871. }
  59872. declare module BABYLON {
  59873. /** @hidden */
  59874. export var bloomMergePixelShader: {
  59875. name: string;
  59876. shader: string;
  59877. };
  59878. }
  59879. declare module BABYLON {
  59880. /**
  59881. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59882. */
  59883. export class BloomMergePostProcess extends PostProcess {
  59884. /** Weight of the bloom to be added to the original input. */
  59885. weight: number;
  59886. /**
  59887. * Creates a new instance of @see BloomMergePostProcess
  59888. * @param name The name of the effect.
  59889. * @param originalFromInput Post process which's input will be used for the merge.
  59890. * @param blurred Blurred highlights post process which's output will be used.
  59891. * @param weight Weight of the bloom to be added to the original input.
  59892. * @param options The required width/height ratio to downsize to before computing the render pass.
  59893. * @param camera The camera to apply the render pass to.
  59894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59895. * @param engine The engine which the post process will be applied. (default: current engine)
  59896. * @param reusable If the post process can be reused on the same frame. (default: false)
  59897. * @param textureType Type of textures used when performing the post process. (default: 0)
  59898. * @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)
  59899. */
  59900. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59901. /** Weight of the bloom to be added to the original input. */
  59902. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59903. }
  59904. }
  59905. declare module BABYLON {
  59906. /**
  59907. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59908. */
  59909. export class BloomEffect extends PostProcessRenderEffect {
  59910. private bloomScale;
  59911. /**
  59912. * @hidden Internal
  59913. */
  59914. _effects: Array<PostProcess>;
  59915. /**
  59916. * @hidden Internal
  59917. */
  59918. _downscale: ExtractHighlightsPostProcess;
  59919. private _blurX;
  59920. private _blurY;
  59921. private _merge;
  59922. /**
  59923. * The luminance threshold to find bright areas of the image to bloom.
  59924. */
  59925. threshold: number;
  59926. /**
  59927. * The strength of the bloom.
  59928. */
  59929. weight: number;
  59930. /**
  59931. * Specifies the size of the bloom blur kernel, relative to the final output size
  59932. */
  59933. kernel: number;
  59934. /**
  59935. * Creates a new instance of @see BloomEffect
  59936. * @param scene The scene the effect belongs to.
  59937. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59938. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59939. * @param bloomWeight The the strength of bloom.
  59940. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59941. * @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)
  59942. */
  59943. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59944. /**
  59945. * Disposes each of the internal effects for a given camera.
  59946. * @param camera The camera to dispose the effect on.
  59947. */
  59948. disposeEffects(camera: Camera): void;
  59949. /**
  59950. * @hidden Internal
  59951. */
  59952. _updateEffects(): void;
  59953. /**
  59954. * Internal
  59955. * @returns if all the contained post processes are ready.
  59956. * @hidden
  59957. */
  59958. _isReady(): boolean;
  59959. }
  59960. }
  59961. declare module BABYLON {
  59962. /** @hidden */
  59963. export var chromaticAberrationPixelShader: {
  59964. name: string;
  59965. shader: string;
  59966. };
  59967. }
  59968. declare module BABYLON {
  59969. /**
  59970. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59971. */
  59972. export class ChromaticAberrationPostProcess extends PostProcess {
  59973. /**
  59974. * The amount of seperation of rgb channels (default: 30)
  59975. */
  59976. aberrationAmount: number;
  59977. /**
  59978. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59979. */
  59980. radialIntensity: number;
  59981. /**
  59982. * 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))
  59983. */
  59984. direction: Vector2;
  59985. /**
  59986. * 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))
  59987. */
  59988. centerPosition: Vector2;
  59989. /**
  59990. * Creates a new instance ChromaticAberrationPostProcess
  59991. * @param name The name of the effect.
  59992. * @param screenWidth The width of the screen to apply the effect on.
  59993. * @param screenHeight The height of the screen to apply the effect on.
  59994. * @param options The required width/height ratio to downsize to before computing the render pass.
  59995. * @param camera The camera to apply the render pass to.
  59996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59997. * @param engine The engine which the post process will be applied. (default: current engine)
  59998. * @param reusable If the post process can be reused on the same frame. (default: false)
  59999. * @param textureType Type of textures used when performing the post process. (default: 0)
  60000. * @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)
  60001. */
  60002. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60003. }
  60004. }
  60005. declare module BABYLON {
  60006. /** @hidden */
  60007. export var circleOfConfusionPixelShader: {
  60008. name: string;
  60009. shader: string;
  60010. };
  60011. }
  60012. declare module BABYLON {
  60013. /**
  60014. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60015. */
  60016. export class CircleOfConfusionPostProcess extends PostProcess {
  60017. /**
  60018. * 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.
  60019. */
  60020. lensSize: number;
  60021. /**
  60022. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60023. */
  60024. fStop: number;
  60025. /**
  60026. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60027. */
  60028. focusDistance: number;
  60029. /**
  60030. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60031. */
  60032. focalLength: number;
  60033. private _depthTexture;
  60034. /**
  60035. * Creates a new instance CircleOfConfusionPostProcess
  60036. * @param name The name of the effect.
  60037. * @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.
  60038. * @param options The required width/height ratio to downsize to before computing the render pass.
  60039. * @param camera The camera to apply the render pass to.
  60040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60041. * @param engine The engine which the post process will be applied. (default: current engine)
  60042. * @param reusable If the post process can be reused on the same frame. (default: false)
  60043. * @param textureType Type of textures used when performing the post process. (default: 0)
  60044. * @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)
  60045. */
  60046. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60047. /**
  60048. * 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.
  60049. */
  60050. depthTexture: RenderTargetTexture;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. /** @hidden */
  60055. export var colorCorrectionPixelShader: {
  60056. name: string;
  60057. shader: string;
  60058. };
  60059. }
  60060. declare module BABYLON {
  60061. /**
  60062. *
  60063. * This post-process allows the modification of rendered colors by using
  60064. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60065. *
  60066. * The object needs to be provided an url to a texture containing the color
  60067. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60068. * Use an image editing software to tweak the LUT to match your needs.
  60069. *
  60070. * For an example of a color LUT, see here:
  60071. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60072. * For explanations on color grading, see here:
  60073. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60074. *
  60075. */
  60076. export class ColorCorrectionPostProcess extends PostProcess {
  60077. private _colorTableTexture;
  60078. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60079. }
  60080. }
  60081. declare module BABYLON {
  60082. /** @hidden */
  60083. export var convolutionPixelShader: {
  60084. name: string;
  60085. shader: string;
  60086. };
  60087. }
  60088. declare module BABYLON {
  60089. /**
  60090. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60091. * input texture to perform effects such as edge detection or sharpening
  60092. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60093. */
  60094. export class ConvolutionPostProcess extends PostProcess {
  60095. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60096. kernel: number[];
  60097. /**
  60098. * Creates a new instance ConvolutionPostProcess
  60099. * @param name The name of the effect.
  60100. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60101. * @param options The required width/height ratio to downsize to before computing the render pass.
  60102. * @param camera The camera to apply the render pass to.
  60103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60104. * @param engine The engine which the post process will be applied. (default: current engine)
  60105. * @param reusable If the post process can be reused on the same frame. (default: false)
  60106. * @param textureType Type of textures used when performing the post process. (default: 0)
  60107. */
  60108. constructor(name: string,
  60109. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60110. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60111. /**
  60112. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60113. */
  60114. static EdgeDetect0Kernel: number[];
  60115. /**
  60116. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60117. */
  60118. static EdgeDetect1Kernel: number[];
  60119. /**
  60120. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60121. */
  60122. static EdgeDetect2Kernel: number[];
  60123. /**
  60124. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60125. */
  60126. static SharpenKernel: number[];
  60127. /**
  60128. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60129. */
  60130. static EmbossKernel: number[];
  60131. /**
  60132. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60133. */
  60134. static GaussianKernel: number[];
  60135. }
  60136. }
  60137. declare module BABYLON {
  60138. /**
  60139. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60140. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60141. * based on samples that have a large difference in distance than the center pixel.
  60142. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60143. */
  60144. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60145. direction: Vector2;
  60146. /**
  60147. * Creates a new instance CircleOfConfusionPostProcess
  60148. * @param name The name of the effect.
  60149. * @param scene The scene the effect belongs to.
  60150. * @param direction The direction the blur should be applied.
  60151. * @param kernel The size of the kernel used to blur.
  60152. * @param options The required width/height ratio to downsize to before computing the render pass.
  60153. * @param camera The camera to apply the render pass to.
  60154. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60155. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60157. * @param engine The engine which the post process will be applied. (default: current engine)
  60158. * @param reusable If the post process can be reused on the same frame. (default: false)
  60159. * @param textureType Type of textures used when performing the post process. (default: 0)
  60160. * @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)
  60161. */
  60162. 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);
  60163. }
  60164. }
  60165. declare module BABYLON {
  60166. /** @hidden */
  60167. export var depthOfFieldMergePixelShader: {
  60168. name: string;
  60169. shader: string;
  60170. };
  60171. }
  60172. declare module BABYLON {
  60173. /**
  60174. * Options to be set when merging outputs from the default pipeline.
  60175. */
  60176. export class DepthOfFieldMergePostProcessOptions {
  60177. /**
  60178. * The original image to merge on top of
  60179. */
  60180. originalFromInput: PostProcess;
  60181. /**
  60182. * Parameters to perform the merge of the depth of field effect
  60183. */
  60184. depthOfField?: {
  60185. circleOfConfusion: PostProcess;
  60186. blurSteps: Array<PostProcess>;
  60187. };
  60188. /**
  60189. * Parameters to perform the merge of bloom effect
  60190. */
  60191. bloom?: {
  60192. blurred: PostProcess;
  60193. weight: number;
  60194. };
  60195. }
  60196. /**
  60197. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60198. */
  60199. export class DepthOfFieldMergePostProcess extends PostProcess {
  60200. private blurSteps;
  60201. /**
  60202. * Creates a new instance of DepthOfFieldMergePostProcess
  60203. * @param name The name of the effect.
  60204. * @param originalFromInput Post process which's input will be used for the merge.
  60205. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60206. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60207. * @param options The required width/height ratio to downsize to before computing the render pass.
  60208. * @param camera The camera to apply the render pass to.
  60209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60210. * @param engine The engine which the post process will be applied. (default: current engine)
  60211. * @param reusable If the post process can be reused on the same frame. (default: false)
  60212. * @param textureType Type of textures used when performing the post process. (default: 0)
  60213. * @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)
  60214. */
  60215. 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);
  60216. /**
  60217. * Updates the effect with the current post process compile time values and recompiles the shader.
  60218. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60219. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60220. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60221. * @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
  60222. * @param onCompiled Called when the shader has been compiled.
  60223. * @param onError Called if there is an error when compiling a shader.
  60224. */
  60225. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60226. }
  60227. }
  60228. declare module BABYLON {
  60229. /**
  60230. * Specifies the level of max blur that should be applied when using the depth of field effect
  60231. */
  60232. export enum DepthOfFieldEffectBlurLevel {
  60233. /**
  60234. * Subtle blur
  60235. */
  60236. Low = 0,
  60237. /**
  60238. * Medium blur
  60239. */
  60240. Medium = 1,
  60241. /**
  60242. * Large blur
  60243. */
  60244. High = 2
  60245. }
  60246. /**
  60247. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60248. */
  60249. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60250. private _circleOfConfusion;
  60251. /**
  60252. * @hidden Internal, blurs from high to low
  60253. */
  60254. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60255. private _depthOfFieldBlurY;
  60256. private _dofMerge;
  60257. /**
  60258. * @hidden Internal post processes in depth of field effect
  60259. */
  60260. _effects: Array<PostProcess>;
  60261. /**
  60262. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60263. */
  60264. focalLength: number;
  60265. /**
  60266. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60267. */
  60268. fStop: number;
  60269. /**
  60270. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60271. */
  60272. focusDistance: number;
  60273. /**
  60274. * 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.
  60275. */
  60276. lensSize: number;
  60277. /**
  60278. * Creates a new instance DepthOfFieldEffect
  60279. * @param scene The scene the effect belongs to.
  60280. * @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.
  60281. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60282. * @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)
  60283. */
  60284. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60285. /**
  60286. * Get the current class name of the current effet
  60287. * @returns "DepthOfFieldEffect"
  60288. */
  60289. getClassName(): string;
  60290. /**
  60291. * 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.
  60292. */
  60293. depthTexture: RenderTargetTexture;
  60294. /**
  60295. * Disposes each of the internal effects for a given camera.
  60296. * @param camera The camera to dispose the effect on.
  60297. */
  60298. disposeEffects(camera: Camera): void;
  60299. /**
  60300. * @hidden Internal
  60301. */
  60302. _updateEffects(): void;
  60303. /**
  60304. * Internal
  60305. * @returns if all the contained post processes are ready.
  60306. * @hidden
  60307. */
  60308. _isReady(): boolean;
  60309. }
  60310. }
  60311. declare module BABYLON {
  60312. /** @hidden */
  60313. export var displayPassPixelShader: {
  60314. name: string;
  60315. shader: string;
  60316. };
  60317. }
  60318. declare module BABYLON {
  60319. /**
  60320. * DisplayPassPostProcess which produces an output the same as it's input
  60321. */
  60322. export class DisplayPassPostProcess extends PostProcess {
  60323. /**
  60324. * Creates the DisplayPassPostProcess
  60325. * @param name The name of the effect.
  60326. * @param options The required width/height ratio to downsize to before computing the render pass.
  60327. * @param camera The camera to apply the render pass to.
  60328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60329. * @param engine The engine which the post process will be applied. (default: current engine)
  60330. * @param reusable If the post process can be reused on the same frame. (default: false)
  60331. */
  60332. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60333. }
  60334. }
  60335. declare module BABYLON {
  60336. /** @hidden */
  60337. export var filterPixelShader: {
  60338. name: string;
  60339. shader: string;
  60340. };
  60341. }
  60342. declare module BABYLON {
  60343. /**
  60344. * Applies a kernel filter to the image
  60345. */
  60346. export class FilterPostProcess extends PostProcess {
  60347. /** The matrix to be applied to the image */
  60348. kernelMatrix: Matrix;
  60349. /**
  60350. *
  60351. * @param name The name of the effect.
  60352. * @param kernelMatrix The matrix to be applied to the image
  60353. * @param options The required width/height ratio to downsize to before computing the render pass.
  60354. * @param camera The camera to apply the render pass to.
  60355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60356. * @param engine The engine which the post process will be applied. (default: current engine)
  60357. * @param reusable If the post process can be reused on the same frame. (default: false)
  60358. */
  60359. constructor(name: string,
  60360. /** The matrix to be applied to the image */
  60361. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60362. }
  60363. }
  60364. declare module BABYLON {
  60365. /** @hidden */
  60366. export var fxaaPixelShader: {
  60367. name: string;
  60368. shader: string;
  60369. };
  60370. }
  60371. declare module BABYLON {
  60372. /** @hidden */
  60373. export var fxaaVertexShader: {
  60374. name: string;
  60375. shader: string;
  60376. };
  60377. }
  60378. declare module BABYLON {
  60379. /**
  60380. * Fxaa post process
  60381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60382. */
  60383. export class FxaaPostProcess extends PostProcess {
  60384. /** @hidden */
  60385. texelWidth: number;
  60386. /** @hidden */
  60387. texelHeight: number;
  60388. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60389. private _getDefines;
  60390. }
  60391. }
  60392. declare module BABYLON {
  60393. /** @hidden */
  60394. export var grainPixelShader: {
  60395. name: string;
  60396. shader: string;
  60397. };
  60398. }
  60399. declare module BABYLON {
  60400. /**
  60401. * The GrainPostProcess adds noise to the image at mid luminance levels
  60402. */
  60403. export class GrainPostProcess extends PostProcess {
  60404. /**
  60405. * The intensity of the grain added (default: 30)
  60406. */
  60407. intensity: number;
  60408. /**
  60409. * If the grain should be randomized on every frame
  60410. */
  60411. animated: boolean;
  60412. /**
  60413. * Creates a new instance of @see GrainPostProcess
  60414. * @param name The name of the effect.
  60415. * @param options The required width/height ratio to downsize to before computing the render pass.
  60416. * @param camera The camera to apply the render pass to.
  60417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60418. * @param engine The engine which the post process will be applied. (default: current engine)
  60419. * @param reusable If the post process can be reused on the same frame. (default: false)
  60420. * @param textureType Type of textures used when performing the post process. (default: 0)
  60421. * @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)
  60422. */
  60423. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60424. }
  60425. }
  60426. declare module BABYLON {
  60427. /** @hidden */
  60428. export var highlightsPixelShader: {
  60429. name: string;
  60430. shader: string;
  60431. };
  60432. }
  60433. declare module BABYLON {
  60434. /**
  60435. * Extracts highlights from the image
  60436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60437. */
  60438. export class HighlightsPostProcess extends PostProcess {
  60439. /**
  60440. * Extracts highlights from the image
  60441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60442. * @param name The name of the effect.
  60443. * @param options The required width/height ratio to downsize to before computing the render pass.
  60444. * @param camera The camera to apply the render pass to.
  60445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60446. * @param engine The engine which the post process will be applied. (default: current engine)
  60447. * @param reusable If the post process can be reused on the same frame. (default: false)
  60448. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60449. */
  60450. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60451. }
  60452. }
  60453. declare module BABYLON {
  60454. /** @hidden */
  60455. export var mrtFragmentDeclaration: {
  60456. name: string;
  60457. shader: string;
  60458. };
  60459. }
  60460. declare module BABYLON {
  60461. /** @hidden */
  60462. export var geometryPixelShader: {
  60463. name: string;
  60464. shader: string;
  60465. };
  60466. }
  60467. declare module BABYLON {
  60468. /** @hidden */
  60469. export var geometryVertexShader: {
  60470. name: string;
  60471. shader: string;
  60472. };
  60473. }
  60474. declare module BABYLON {
  60475. /** @hidden */
  60476. interface ISavedTransformationMatrix {
  60477. world: Matrix;
  60478. viewProjection: Matrix;
  60479. }
  60480. /**
  60481. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60482. */
  60483. export class GeometryBufferRenderer {
  60484. /**
  60485. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60486. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60487. */
  60488. static readonly POSITION_TEXTURE_TYPE: number;
  60489. /**
  60490. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60491. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60492. */
  60493. static readonly VELOCITY_TEXTURE_TYPE: number;
  60494. /**
  60495. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60496. * in order to compute objects velocities when enableVelocity is set to "true"
  60497. * @hidden
  60498. */
  60499. _previousTransformationMatrices: {
  60500. [index: number]: ISavedTransformationMatrix;
  60501. };
  60502. /**
  60503. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60504. * in order to compute objects velocities when enableVelocity is set to "true"
  60505. * @hidden
  60506. */
  60507. _previousBonesTransformationMatrices: {
  60508. [index: number]: Float32Array;
  60509. };
  60510. /**
  60511. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60512. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60513. */
  60514. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60515. private _scene;
  60516. private _multiRenderTarget;
  60517. private _ratio;
  60518. private _enablePosition;
  60519. private _enableVelocity;
  60520. private _positionIndex;
  60521. private _velocityIndex;
  60522. protected _effect: Effect;
  60523. protected _cachedDefines: string;
  60524. /**
  60525. * Set the render list (meshes to be rendered) used in the G buffer.
  60526. */
  60527. renderList: Mesh[];
  60528. /**
  60529. * Gets wether or not G buffer are supported by the running hardware.
  60530. * This requires draw buffer supports
  60531. */
  60532. readonly isSupported: boolean;
  60533. /**
  60534. * Returns the index of the given texture type in the G-Buffer textures array
  60535. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60536. * @returns the index of the given texture type in the G-Buffer textures array
  60537. */
  60538. getTextureIndex(textureType: number): number;
  60539. /**
  60540. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60541. */
  60542. /**
  60543. * Sets whether or not objects positions are enabled for the G buffer.
  60544. */
  60545. enablePosition: boolean;
  60546. /**
  60547. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60548. */
  60549. /**
  60550. * Sets wether or not objects velocities are enabled for the G buffer.
  60551. */
  60552. enableVelocity: boolean;
  60553. /**
  60554. * Gets the scene associated with the buffer.
  60555. */
  60556. readonly scene: Scene;
  60557. /**
  60558. * Gets the ratio used by the buffer during its creation.
  60559. * How big is the buffer related to the main canvas.
  60560. */
  60561. readonly ratio: number;
  60562. /** @hidden */
  60563. static _SceneComponentInitialization: (scene: Scene) => void;
  60564. /**
  60565. * Creates a new G Buffer for the scene
  60566. * @param scene The scene the buffer belongs to
  60567. * @param ratio How big is the buffer related to the main canvas.
  60568. */
  60569. constructor(scene: Scene, ratio?: number);
  60570. /**
  60571. * Checks wether everything is ready to render a submesh to the G buffer.
  60572. * @param subMesh the submesh to check readiness for
  60573. * @param useInstances is the mesh drawn using instance or not
  60574. * @returns true if ready otherwise false
  60575. */
  60576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60577. /**
  60578. * Gets the current underlying G Buffer.
  60579. * @returns the buffer
  60580. */
  60581. getGBuffer(): MultiRenderTarget;
  60582. /**
  60583. * Gets the number of samples used to render the buffer (anti aliasing).
  60584. */
  60585. /**
  60586. * Sets the number of samples used to render the buffer (anti aliasing).
  60587. */
  60588. samples: number;
  60589. /**
  60590. * Disposes the renderer and frees up associated resources.
  60591. */
  60592. dispose(): void;
  60593. protected _createRenderTargets(): void;
  60594. private _copyBonesTransformationMatrices;
  60595. }
  60596. }
  60597. declare module BABYLON {
  60598. interface Scene {
  60599. /** @hidden (Backing field) */
  60600. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60601. /**
  60602. * Gets or Sets the current geometry buffer associated to the scene.
  60603. */
  60604. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60605. /**
  60606. * Enables a GeometryBufferRender and associates it with the scene
  60607. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60608. * @returns the GeometryBufferRenderer
  60609. */
  60610. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60611. /**
  60612. * Disables the GeometryBufferRender associated with the scene
  60613. */
  60614. disableGeometryBufferRenderer(): void;
  60615. }
  60616. /**
  60617. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60618. * in several rendering techniques.
  60619. */
  60620. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60621. /**
  60622. * The component name helpful to identify the component in the list of scene components.
  60623. */
  60624. readonly name: string;
  60625. /**
  60626. * The scene the component belongs to.
  60627. */
  60628. scene: Scene;
  60629. /**
  60630. * Creates a new instance of the component for the given scene
  60631. * @param scene Defines the scene to register the component in
  60632. */
  60633. constructor(scene: Scene);
  60634. /**
  60635. * Registers the component in a given scene
  60636. */
  60637. register(): void;
  60638. /**
  60639. * Rebuilds the elements related to this component in case of
  60640. * context lost for instance.
  60641. */
  60642. rebuild(): void;
  60643. /**
  60644. * Disposes the component and the associated ressources
  60645. */
  60646. dispose(): void;
  60647. private _gatherRenderTargets;
  60648. }
  60649. }
  60650. declare module BABYLON {
  60651. /** @hidden */
  60652. export var motionBlurPixelShader: {
  60653. name: string;
  60654. shader: string;
  60655. };
  60656. }
  60657. declare module BABYLON {
  60658. /**
  60659. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60660. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60661. * As an example, all you have to do is to create the post-process:
  60662. * var mb = new BABYLON.MotionBlurPostProcess(
  60663. * 'mb', // The name of the effect.
  60664. * scene, // The scene containing the objects to blur according to their velocity.
  60665. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60666. * camera // The camera to apply the render pass to.
  60667. * );
  60668. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60669. */
  60670. export class MotionBlurPostProcess extends PostProcess {
  60671. /**
  60672. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60673. */
  60674. motionStrength: number;
  60675. /**
  60676. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60677. */
  60678. /**
  60679. * Sets the number of iterations to be used for motion blur quality
  60680. */
  60681. motionBlurSamples: number;
  60682. private _motionBlurSamples;
  60683. private _geometryBufferRenderer;
  60684. /**
  60685. * Creates a new instance MotionBlurPostProcess
  60686. * @param name The name of the effect.
  60687. * @param scene The scene containing the objects to blur according to their velocity.
  60688. * @param options The required width/height ratio to downsize to before computing the render pass.
  60689. * @param camera The camera to apply the render pass to.
  60690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60691. * @param engine The engine which the post process will be applied. (default: current engine)
  60692. * @param reusable If the post process can be reused on the same frame. (default: false)
  60693. * @param textureType Type of textures used when performing the post process. (default: 0)
  60694. * @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)
  60695. */
  60696. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60697. /**
  60698. * Excludes the given skinned mesh from computing bones velocities.
  60699. * 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.
  60700. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60701. */
  60702. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60703. /**
  60704. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60705. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60706. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60707. */
  60708. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60709. /**
  60710. * Disposes the post process.
  60711. * @param camera The camera to dispose the post process on.
  60712. */
  60713. dispose(camera?: Camera): void;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /** @hidden */
  60718. export var refractionPixelShader: {
  60719. name: string;
  60720. shader: string;
  60721. };
  60722. }
  60723. declare module BABYLON {
  60724. /**
  60725. * Post process which applies a refractin texture
  60726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60727. */
  60728. export class RefractionPostProcess extends PostProcess {
  60729. /** the base color of the refraction (used to taint the rendering) */
  60730. color: Color3;
  60731. /** simulated refraction depth */
  60732. depth: number;
  60733. /** the coefficient of the base color (0 to remove base color tainting) */
  60734. colorLevel: number;
  60735. private _refTexture;
  60736. private _ownRefractionTexture;
  60737. /**
  60738. * Gets or sets the refraction texture
  60739. * Please note that you are responsible for disposing the texture if you set it manually
  60740. */
  60741. refractionTexture: Texture;
  60742. /**
  60743. * Initializes the RefractionPostProcess
  60744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60745. * @param name The name of the effect.
  60746. * @param refractionTextureUrl Url of the refraction texture to use
  60747. * @param color the base color of the refraction (used to taint the rendering)
  60748. * @param depth simulated refraction depth
  60749. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60750. * @param camera The camera to apply the render pass to.
  60751. * @param options The required width/height ratio to downsize to before computing the render pass.
  60752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60753. * @param engine The engine which the post process will be applied. (default: current engine)
  60754. * @param reusable If the post process can be reused on the same frame. (default: false)
  60755. */
  60756. constructor(name: string, refractionTextureUrl: string,
  60757. /** the base color of the refraction (used to taint the rendering) */
  60758. color: Color3,
  60759. /** simulated refraction depth */
  60760. depth: number,
  60761. /** the coefficient of the base color (0 to remove base color tainting) */
  60762. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60763. /**
  60764. * Disposes of the post process
  60765. * @param camera Camera to dispose post process on
  60766. */
  60767. dispose(camera: Camera): void;
  60768. }
  60769. }
  60770. declare module BABYLON {
  60771. /** @hidden */
  60772. export var sharpenPixelShader: {
  60773. name: string;
  60774. shader: string;
  60775. };
  60776. }
  60777. declare module BABYLON {
  60778. /**
  60779. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60780. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60781. */
  60782. export class SharpenPostProcess extends PostProcess {
  60783. /**
  60784. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60785. */
  60786. colorAmount: number;
  60787. /**
  60788. * How much sharpness should be applied (default: 0.3)
  60789. */
  60790. edgeAmount: number;
  60791. /**
  60792. * Creates a new instance ConvolutionPostProcess
  60793. * @param name The name of the effect.
  60794. * @param options The required width/height ratio to downsize to before computing the render pass.
  60795. * @param camera The camera to apply the render pass to.
  60796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60797. * @param engine The engine which the post process will be applied. (default: current engine)
  60798. * @param reusable If the post process can be reused on the same frame. (default: false)
  60799. * @param textureType Type of textures used when performing the post process. (default: 0)
  60800. * @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)
  60801. */
  60802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * PostProcessRenderPipeline
  60808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60809. */
  60810. export class PostProcessRenderPipeline {
  60811. private engine;
  60812. private _renderEffects;
  60813. private _renderEffectsForIsolatedPass;
  60814. /**
  60815. * List of inspectable custom properties (used by the Inspector)
  60816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60817. */
  60818. inspectableCustomProperties: IInspectable[];
  60819. /**
  60820. * @hidden
  60821. */
  60822. protected _cameras: Camera[];
  60823. /** @hidden */
  60824. _name: string;
  60825. /**
  60826. * Gets pipeline name
  60827. */
  60828. readonly name: string;
  60829. /** Gets the list of attached cameras */
  60830. readonly cameras: Camera[];
  60831. /**
  60832. * Initializes a PostProcessRenderPipeline
  60833. * @param engine engine to add the pipeline to
  60834. * @param name name of the pipeline
  60835. */
  60836. constructor(engine: Engine, name: string);
  60837. /**
  60838. * Gets the class name
  60839. * @returns "PostProcessRenderPipeline"
  60840. */
  60841. getClassName(): string;
  60842. /**
  60843. * If all the render effects in the pipeline are supported
  60844. */
  60845. readonly isSupported: boolean;
  60846. /**
  60847. * Adds an effect to the pipeline
  60848. * @param renderEffect the effect to add
  60849. */
  60850. addEffect(renderEffect: PostProcessRenderEffect): void;
  60851. /** @hidden */
  60852. _rebuild(): void;
  60853. /** @hidden */
  60854. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60855. /** @hidden */
  60856. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60857. /** @hidden */
  60858. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60859. /** @hidden */
  60860. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60861. /** @hidden */
  60862. _attachCameras(cameras: Camera, unique: boolean): void;
  60863. /** @hidden */
  60864. _attachCameras(cameras: Camera[], unique: boolean): void;
  60865. /** @hidden */
  60866. _detachCameras(cameras: Camera): void;
  60867. /** @hidden */
  60868. _detachCameras(cameras: Nullable<Camera[]>): void;
  60869. /** @hidden */
  60870. _update(): void;
  60871. /** @hidden */
  60872. _reset(): void;
  60873. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60874. /**
  60875. * Disposes of the pipeline
  60876. */
  60877. dispose(): void;
  60878. }
  60879. }
  60880. declare module BABYLON {
  60881. /**
  60882. * PostProcessRenderPipelineManager class
  60883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60884. */
  60885. export class PostProcessRenderPipelineManager {
  60886. private _renderPipelines;
  60887. /**
  60888. * Initializes a PostProcessRenderPipelineManager
  60889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60890. */
  60891. constructor();
  60892. /**
  60893. * Gets the list of supported render pipelines
  60894. */
  60895. readonly supportedPipelines: PostProcessRenderPipeline[];
  60896. /**
  60897. * Adds a pipeline to the manager
  60898. * @param renderPipeline The pipeline to add
  60899. */
  60900. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60901. /**
  60902. * Attaches a camera to the pipeline
  60903. * @param renderPipelineName The name of the pipeline to attach to
  60904. * @param cameras the camera to attach
  60905. * @param unique if the camera can be attached multiple times to the pipeline
  60906. */
  60907. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60908. /**
  60909. * Detaches a camera from the pipeline
  60910. * @param renderPipelineName The name of the pipeline to detach from
  60911. * @param cameras the camera to detach
  60912. */
  60913. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60914. /**
  60915. * Enables an effect by name on a pipeline
  60916. * @param renderPipelineName the name of the pipeline to enable the effect in
  60917. * @param renderEffectName the name of the effect to enable
  60918. * @param cameras the cameras that the effect should be enabled on
  60919. */
  60920. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60921. /**
  60922. * Disables an effect by name on a pipeline
  60923. * @param renderPipelineName the name of the pipeline to disable the effect in
  60924. * @param renderEffectName the name of the effect to disable
  60925. * @param cameras the cameras that the effect should be disabled on
  60926. */
  60927. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60928. /**
  60929. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60930. */
  60931. update(): void;
  60932. /** @hidden */
  60933. _rebuild(): void;
  60934. /**
  60935. * Disposes of the manager and pipelines
  60936. */
  60937. dispose(): void;
  60938. }
  60939. }
  60940. declare module BABYLON {
  60941. interface Scene {
  60942. /** @hidden (Backing field) */
  60943. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60944. /**
  60945. * Gets the postprocess render pipeline manager
  60946. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60947. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60948. */
  60949. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60950. }
  60951. /**
  60952. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60953. */
  60954. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60955. /**
  60956. * The component name helpfull to identify the component in the list of scene components.
  60957. */
  60958. readonly name: string;
  60959. /**
  60960. * The scene the component belongs to.
  60961. */
  60962. scene: Scene;
  60963. /**
  60964. * Creates a new instance of the component for the given scene
  60965. * @param scene Defines the scene to register the component in
  60966. */
  60967. constructor(scene: Scene);
  60968. /**
  60969. * Registers the component in a given scene
  60970. */
  60971. register(): void;
  60972. /**
  60973. * Rebuilds the elements related to this component in case of
  60974. * context lost for instance.
  60975. */
  60976. rebuild(): void;
  60977. /**
  60978. * Disposes the component and the associated ressources
  60979. */
  60980. dispose(): void;
  60981. private _gatherRenderTargets;
  60982. }
  60983. }
  60984. declare module BABYLON {
  60985. /**
  60986. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60987. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60988. */
  60989. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60990. private _scene;
  60991. private _camerasToBeAttached;
  60992. /**
  60993. * ID of the sharpen post process,
  60994. */
  60995. private readonly SharpenPostProcessId;
  60996. /**
  60997. * @ignore
  60998. * ID of the image processing post process;
  60999. */
  61000. readonly ImageProcessingPostProcessId: string;
  61001. /**
  61002. * @ignore
  61003. * ID of the Fast Approximate Anti-Aliasing post process;
  61004. */
  61005. readonly FxaaPostProcessId: string;
  61006. /**
  61007. * ID of the chromatic aberration post process,
  61008. */
  61009. private readonly ChromaticAberrationPostProcessId;
  61010. /**
  61011. * ID of the grain post process
  61012. */
  61013. private readonly GrainPostProcessId;
  61014. /**
  61015. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61016. */
  61017. sharpen: SharpenPostProcess;
  61018. private _sharpenEffect;
  61019. private bloom;
  61020. /**
  61021. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61022. */
  61023. depthOfField: DepthOfFieldEffect;
  61024. /**
  61025. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61026. */
  61027. fxaa: FxaaPostProcess;
  61028. /**
  61029. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61030. */
  61031. imageProcessing: ImageProcessingPostProcess;
  61032. /**
  61033. * Chromatic aberration post process which will shift rgb colors in the image
  61034. */
  61035. chromaticAberration: ChromaticAberrationPostProcess;
  61036. private _chromaticAberrationEffect;
  61037. /**
  61038. * Grain post process which add noise to the image
  61039. */
  61040. grain: GrainPostProcess;
  61041. private _grainEffect;
  61042. /**
  61043. * Glow post process which adds a glow to emissive areas of the image
  61044. */
  61045. private _glowLayer;
  61046. /**
  61047. * Animations which can be used to tweak settings over a period of time
  61048. */
  61049. animations: Animation[];
  61050. private _imageProcessingConfigurationObserver;
  61051. private _sharpenEnabled;
  61052. private _bloomEnabled;
  61053. private _depthOfFieldEnabled;
  61054. private _depthOfFieldBlurLevel;
  61055. private _fxaaEnabled;
  61056. private _imageProcessingEnabled;
  61057. private _defaultPipelineTextureType;
  61058. private _bloomScale;
  61059. private _chromaticAberrationEnabled;
  61060. private _grainEnabled;
  61061. private _buildAllowed;
  61062. /**
  61063. * Gets active scene
  61064. */
  61065. readonly scene: Scene;
  61066. /**
  61067. * Enable or disable the sharpen process from the pipeline
  61068. */
  61069. sharpenEnabled: boolean;
  61070. private _resizeObserver;
  61071. private _hardwareScaleLevel;
  61072. private _bloomKernel;
  61073. /**
  61074. * Specifies the size of the bloom blur kernel, relative to the final output size
  61075. */
  61076. bloomKernel: number;
  61077. /**
  61078. * Specifies the weight of the bloom in the final rendering
  61079. */
  61080. private _bloomWeight;
  61081. /**
  61082. * Specifies the luma threshold for the area that will be blurred by the bloom
  61083. */
  61084. private _bloomThreshold;
  61085. private _hdr;
  61086. /**
  61087. * The strength of the bloom.
  61088. */
  61089. bloomWeight: number;
  61090. /**
  61091. * The strength of the bloom.
  61092. */
  61093. bloomThreshold: number;
  61094. /**
  61095. * The scale of the bloom, lower value will provide better performance.
  61096. */
  61097. bloomScale: number;
  61098. /**
  61099. * Enable or disable the bloom from the pipeline
  61100. */
  61101. bloomEnabled: boolean;
  61102. private _rebuildBloom;
  61103. /**
  61104. * If the depth of field is enabled.
  61105. */
  61106. depthOfFieldEnabled: boolean;
  61107. /**
  61108. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61109. */
  61110. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61111. /**
  61112. * If the anti aliasing is enabled.
  61113. */
  61114. fxaaEnabled: boolean;
  61115. private _samples;
  61116. /**
  61117. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61118. */
  61119. samples: number;
  61120. /**
  61121. * If image processing is enabled.
  61122. */
  61123. imageProcessingEnabled: boolean;
  61124. /**
  61125. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61126. */
  61127. glowLayerEnabled: boolean;
  61128. /**
  61129. * Gets the glow layer (or null if not defined)
  61130. */
  61131. readonly glowLayer: Nullable<GlowLayer>;
  61132. /**
  61133. * Enable or disable the chromaticAberration process from the pipeline
  61134. */
  61135. chromaticAberrationEnabled: boolean;
  61136. /**
  61137. * Enable or disable the grain process from the pipeline
  61138. */
  61139. grainEnabled: boolean;
  61140. /**
  61141. * @constructor
  61142. * @param name - The rendering pipeline name (default: "")
  61143. * @param hdr - If high dynamic range textures should be used (default: true)
  61144. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61145. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61146. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61147. */
  61148. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61149. /**
  61150. * Get the class name
  61151. * @returns "DefaultRenderingPipeline"
  61152. */
  61153. getClassName(): string;
  61154. /**
  61155. * Force the compilation of the entire pipeline.
  61156. */
  61157. prepare(): void;
  61158. private _hasCleared;
  61159. private _prevPostProcess;
  61160. private _prevPrevPostProcess;
  61161. private _setAutoClearAndTextureSharing;
  61162. private _depthOfFieldSceneObserver;
  61163. private _buildPipeline;
  61164. private _disposePostProcesses;
  61165. /**
  61166. * Adds a camera to the pipeline
  61167. * @param camera the camera to be added
  61168. */
  61169. addCamera(camera: Camera): void;
  61170. /**
  61171. * Removes a camera from the pipeline
  61172. * @param camera the camera to remove
  61173. */
  61174. removeCamera(camera: Camera): void;
  61175. /**
  61176. * Dispose of the pipeline and stop all post processes
  61177. */
  61178. dispose(): void;
  61179. /**
  61180. * Serialize the rendering pipeline (Used when exporting)
  61181. * @returns the serialized object
  61182. */
  61183. serialize(): any;
  61184. /**
  61185. * Parse the serialized pipeline
  61186. * @param source Source pipeline.
  61187. * @param scene The scene to load the pipeline to.
  61188. * @param rootUrl The URL of the serialized pipeline.
  61189. * @returns An instantiated pipeline from the serialized object.
  61190. */
  61191. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61192. }
  61193. }
  61194. declare module BABYLON {
  61195. /** @hidden */
  61196. export var lensHighlightsPixelShader: {
  61197. name: string;
  61198. shader: string;
  61199. };
  61200. }
  61201. declare module BABYLON {
  61202. /** @hidden */
  61203. export var depthOfFieldPixelShader: {
  61204. name: string;
  61205. shader: string;
  61206. };
  61207. }
  61208. declare module BABYLON {
  61209. /**
  61210. * BABYLON.JS Chromatic Aberration GLSL Shader
  61211. * Author: Olivier Guyot
  61212. * Separates very slightly R, G and B colors on the edges of the screen
  61213. * Inspired by Francois Tarlier & Martins Upitis
  61214. */
  61215. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61216. /**
  61217. * @ignore
  61218. * The chromatic aberration PostProcess id in the pipeline
  61219. */
  61220. LensChromaticAberrationEffect: string;
  61221. /**
  61222. * @ignore
  61223. * The highlights enhancing PostProcess id in the pipeline
  61224. */
  61225. HighlightsEnhancingEffect: string;
  61226. /**
  61227. * @ignore
  61228. * The depth-of-field PostProcess id in the pipeline
  61229. */
  61230. LensDepthOfFieldEffect: string;
  61231. private _scene;
  61232. private _depthTexture;
  61233. private _grainTexture;
  61234. private _chromaticAberrationPostProcess;
  61235. private _highlightsPostProcess;
  61236. private _depthOfFieldPostProcess;
  61237. private _edgeBlur;
  61238. private _grainAmount;
  61239. private _chromaticAberration;
  61240. private _distortion;
  61241. private _highlightsGain;
  61242. private _highlightsThreshold;
  61243. private _dofDistance;
  61244. private _dofAperture;
  61245. private _dofDarken;
  61246. private _dofPentagon;
  61247. private _blurNoise;
  61248. /**
  61249. * @constructor
  61250. *
  61251. * Effect parameters are as follow:
  61252. * {
  61253. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61254. * edge_blur: number; // from 0 to x (1 for realism)
  61255. * distortion: number; // from 0 to x (1 for realism)
  61256. * grain_amount: number; // from 0 to 1
  61257. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61258. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61259. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61260. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61261. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61262. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61263. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61264. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61265. * }
  61266. * Note: if an effect parameter is unset, effect is disabled
  61267. *
  61268. * @param name The rendering pipeline name
  61269. * @param parameters - An object containing all parameters (see above)
  61270. * @param scene The scene linked to this pipeline
  61271. * @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)
  61272. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61273. */
  61274. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61275. /**
  61276. * Get the class name
  61277. * @returns "LensRenderingPipeline"
  61278. */
  61279. getClassName(): string;
  61280. /**
  61281. * Gets associated scene
  61282. */
  61283. readonly scene: Scene;
  61284. /**
  61285. * Gets or sets the edge blur
  61286. */
  61287. edgeBlur: number;
  61288. /**
  61289. * Gets or sets the grain amount
  61290. */
  61291. grainAmount: number;
  61292. /**
  61293. * Gets or sets the chromatic aberration amount
  61294. */
  61295. chromaticAberration: number;
  61296. /**
  61297. * Gets or sets the depth of field aperture
  61298. */
  61299. dofAperture: number;
  61300. /**
  61301. * Gets or sets the edge distortion
  61302. */
  61303. edgeDistortion: number;
  61304. /**
  61305. * Gets or sets the depth of field distortion
  61306. */
  61307. dofDistortion: number;
  61308. /**
  61309. * Gets or sets the darken out of focus amount
  61310. */
  61311. darkenOutOfFocus: number;
  61312. /**
  61313. * Gets or sets a boolean indicating if blur noise is enabled
  61314. */
  61315. blurNoise: boolean;
  61316. /**
  61317. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61318. */
  61319. pentagonBokeh: boolean;
  61320. /**
  61321. * Gets or sets the highlight grain amount
  61322. */
  61323. highlightsGain: number;
  61324. /**
  61325. * Gets or sets the highlight threshold
  61326. */
  61327. highlightsThreshold: number;
  61328. /**
  61329. * Sets the amount of blur at the edges
  61330. * @param amount blur amount
  61331. */
  61332. setEdgeBlur(amount: number): void;
  61333. /**
  61334. * Sets edge blur to 0
  61335. */
  61336. disableEdgeBlur(): void;
  61337. /**
  61338. * Sets the amout of grain
  61339. * @param amount Amount of grain
  61340. */
  61341. setGrainAmount(amount: number): void;
  61342. /**
  61343. * Set grain amount to 0
  61344. */
  61345. disableGrain(): void;
  61346. /**
  61347. * Sets the chromatic aberration amount
  61348. * @param amount amount of chromatic aberration
  61349. */
  61350. setChromaticAberration(amount: number): void;
  61351. /**
  61352. * Sets chromatic aberration amount to 0
  61353. */
  61354. disableChromaticAberration(): void;
  61355. /**
  61356. * Sets the EdgeDistortion amount
  61357. * @param amount amount of EdgeDistortion
  61358. */
  61359. setEdgeDistortion(amount: number): void;
  61360. /**
  61361. * Sets edge distortion to 0
  61362. */
  61363. disableEdgeDistortion(): void;
  61364. /**
  61365. * Sets the FocusDistance amount
  61366. * @param amount amount of FocusDistance
  61367. */
  61368. setFocusDistance(amount: number): void;
  61369. /**
  61370. * Disables depth of field
  61371. */
  61372. disableDepthOfField(): void;
  61373. /**
  61374. * Sets the Aperture amount
  61375. * @param amount amount of Aperture
  61376. */
  61377. setAperture(amount: number): void;
  61378. /**
  61379. * Sets the DarkenOutOfFocus amount
  61380. * @param amount amount of DarkenOutOfFocus
  61381. */
  61382. setDarkenOutOfFocus(amount: number): void;
  61383. private _pentagonBokehIsEnabled;
  61384. /**
  61385. * Creates a pentagon bokeh effect
  61386. */
  61387. enablePentagonBokeh(): void;
  61388. /**
  61389. * Disables the pentagon bokeh effect
  61390. */
  61391. disablePentagonBokeh(): void;
  61392. /**
  61393. * Enables noise blur
  61394. */
  61395. enableNoiseBlur(): void;
  61396. /**
  61397. * Disables noise blur
  61398. */
  61399. disableNoiseBlur(): void;
  61400. /**
  61401. * Sets the HighlightsGain amount
  61402. * @param amount amount of HighlightsGain
  61403. */
  61404. setHighlightsGain(amount: number): void;
  61405. /**
  61406. * Sets the HighlightsThreshold amount
  61407. * @param amount amount of HighlightsThreshold
  61408. */
  61409. setHighlightsThreshold(amount: number): void;
  61410. /**
  61411. * Disables highlights
  61412. */
  61413. disableHighlights(): void;
  61414. /**
  61415. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61416. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61417. */
  61418. dispose(disableDepthRender?: boolean): void;
  61419. private _createChromaticAberrationPostProcess;
  61420. private _createHighlightsPostProcess;
  61421. private _createDepthOfFieldPostProcess;
  61422. private _createGrainTexture;
  61423. }
  61424. }
  61425. declare module BABYLON {
  61426. /** @hidden */
  61427. export var ssao2PixelShader: {
  61428. name: string;
  61429. shader: string;
  61430. };
  61431. }
  61432. declare module BABYLON {
  61433. /** @hidden */
  61434. export var ssaoCombinePixelShader: {
  61435. name: string;
  61436. shader: string;
  61437. };
  61438. }
  61439. declare module BABYLON {
  61440. /**
  61441. * Render pipeline to produce ssao effect
  61442. */
  61443. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61444. /**
  61445. * @ignore
  61446. * The PassPostProcess id in the pipeline that contains the original scene color
  61447. */
  61448. SSAOOriginalSceneColorEffect: string;
  61449. /**
  61450. * @ignore
  61451. * The SSAO PostProcess id in the pipeline
  61452. */
  61453. SSAORenderEffect: string;
  61454. /**
  61455. * @ignore
  61456. * The horizontal blur PostProcess id in the pipeline
  61457. */
  61458. SSAOBlurHRenderEffect: string;
  61459. /**
  61460. * @ignore
  61461. * The vertical blur PostProcess id in the pipeline
  61462. */
  61463. SSAOBlurVRenderEffect: string;
  61464. /**
  61465. * @ignore
  61466. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61467. */
  61468. SSAOCombineRenderEffect: string;
  61469. /**
  61470. * The output strength of the SSAO post-process. Default value is 1.0.
  61471. */
  61472. totalStrength: number;
  61473. /**
  61474. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61475. */
  61476. maxZ: number;
  61477. /**
  61478. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61479. */
  61480. minZAspect: number;
  61481. private _samples;
  61482. /**
  61483. * Number of samples used for the SSAO calculations. Default value is 8
  61484. */
  61485. samples: number;
  61486. private _textureSamples;
  61487. /**
  61488. * Number of samples to use for antialiasing
  61489. */
  61490. textureSamples: number;
  61491. /**
  61492. * Ratio object used for SSAO ratio and blur ratio
  61493. */
  61494. private _ratio;
  61495. /**
  61496. * Dynamically generated sphere sampler.
  61497. */
  61498. private _sampleSphere;
  61499. /**
  61500. * Blur filter offsets
  61501. */
  61502. private _samplerOffsets;
  61503. private _expensiveBlur;
  61504. /**
  61505. * If bilateral blur should be used
  61506. */
  61507. expensiveBlur: boolean;
  61508. /**
  61509. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61510. */
  61511. radius: number;
  61512. /**
  61513. * The base color of the SSAO post-process
  61514. * The final result is "base + ssao" between [0, 1]
  61515. */
  61516. base: number;
  61517. /**
  61518. * Support test.
  61519. */
  61520. static readonly IsSupported: boolean;
  61521. private _scene;
  61522. private _depthTexture;
  61523. private _normalTexture;
  61524. private _randomTexture;
  61525. private _originalColorPostProcess;
  61526. private _ssaoPostProcess;
  61527. private _blurHPostProcess;
  61528. private _blurVPostProcess;
  61529. private _ssaoCombinePostProcess;
  61530. private _firstUpdate;
  61531. /**
  61532. * Gets active scene
  61533. */
  61534. readonly scene: Scene;
  61535. /**
  61536. * @constructor
  61537. * @param name The rendering pipeline name
  61538. * @param scene The scene linked to this pipeline
  61539. * @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 }
  61540. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61541. */
  61542. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61543. /**
  61544. * Get the class name
  61545. * @returns "SSAO2RenderingPipeline"
  61546. */
  61547. getClassName(): string;
  61548. /**
  61549. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61550. */
  61551. dispose(disableGeometryBufferRenderer?: boolean): void;
  61552. private _createBlurPostProcess;
  61553. /** @hidden */
  61554. _rebuild(): void;
  61555. private _bits;
  61556. private _radicalInverse_VdC;
  61557. private _hammersley;
  61558. private _hemisphereSample_uniform;
  61559. private _generateHemisphere;
  61560. private _createSSAOPostProcess;
  61561. private _createSSAOCombinePostProcess;
  61562. private _createRandomTexture;
  61563. /**
  61564. * Serialize the rendering pipeline (Used when exporting)
  61565. * @returns the serialized object
  61566. */
  61567. serialize(): any;
  61568. /**
  61569. * Parse the serialized pipeline
  61570. * @param source Source pipeline.
  61571. * @param scene The scene to load the pipeline to.
  61572. * @param rootUrl The URL of the serialized pipeline.
  61573. * @returns An instantiated pipeline from the serialized object.
  61574. */
  61575. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61576. }
  61577. }
  61578. declare module BABYLON {
  61579. /** @hidden */
  61580. export var ssaoPixelShader: {
  61581. name: string;
  61582. shader: string;
  61583. };
  61584. }
  61585. declare module BABYLON {
  61586. /**
  61587. * Render pipeline to produce ssao effect
  61588. */
  61589. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61590. /**
  61591. * @ignore
  61592. * The PassPostProcess id in the pipeline that contains the original scene color
  61593. */
  61594. SSAOOriginalSceneColorEffect: string;
  61595. /**
  61596. * @ignore
  61597. * The SSAO PostProcess id in the pipeline
  61598. */
  61599. SSAORenderEffect: string;
  61600. /**
  61601. * @ignore
  61602. * The horizontal blur PostProcess id in the pipeline
  61603. */
  61604. SSAOBlurHRenderEffect: string;
  61605. /**
  61606. * @ignore
  61607. * The vertical blur PostProcess id in the pipeline
  61608. */
  61609. SSAOBlurVRenderEffect: string;
  61610. /**
  61611. * @ignore
  61612. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61613. */
  61614. SSAOCombineRenderEffect: string;
  61615. /**
  61616. * The output strength of the SSAO post-process. Default value is 1.0.
  61617. */
  61618. totalStrength: number;
  61619. /**
  61620. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61621. */
  61622. radius: number;
  61623. /**
  61624. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61625. * Must not be equal to fallOff and superior to fallOff.
  61626. * Default value is 0.0075
  61627. */
  61628. area: number;
  61629. /**
  61630. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61631. * Must not be equal to area and inferior to area.
  61632. * Default value is 0.000001
  61633. */
  61634. fallOff: number;
  61635. /**
  61636. * The base color of the SSAO post-process
  61637. * The final result is "base + ssao" between [0, 1]
  61638. */
  61639. base: number;
  61640. private _scene;
  61641. private _depthTexture;
  61642. private _randomTexture;
  61643. private _originalColorPostProcess;
  61644. private _ssaoPostProcess;
  61645. private _blurHPostProcess;
  61646. private _blurVPostProcess;
  61647. private _ssaoCombinePostProcess;
  61648. private _firstUpdate;
  61649. /**
  61650. * Gets active scene
  61651. */
  61652. readonly scene: Scene;
  61653. /**
  61654. * @constructor
  61655. * @param name - The rendering pipeline name
  61656. * @param scene - The scene linked to this pipeline
  61657. * @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 }
  61658. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61659. */
  61660. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61661. /**
  61662. * Get the class name
  61663. * @returns "SSAORenderingPipeline"
  61664. */
  61665. getClassName(): string;
  61666. /**
  61667. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61668. */
  61669. dispose(disableDepthRender?: boolean): void;
  61670. private _createBlurPostProcess;
  61671. /** @hidden */
  61672. _rebuild(): void;
  61673. private _createSSAOPostProcess;
  61674. private _createSSAOCombinePostProcess;
  61675. private _createRandomTexture;
  61676. }
  61677. }
  61678. declare module BABYLON {
  61679. /** @hidden */
  61680. export var standardPixelShader: {
  61681. name: string;
  61682. shader: string;
  61683. };
  61684. }
  61685. declare module BABYLON {
  61686. /**
  61687. * Standard rendering pipeline
  61688. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61689. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61690. */
  61691. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61692. /**
  61693. * Public members
  61694. */
  61695. /**
  61696. * Post-process which contains the original scene color before the pipeline applies all the effects
  61697. */
  61698. originalPostProcess: Nullable<PostProcess>;
  61699. /**
  61700. * Post-process used to down scale an image x4
  61701. */
  61702. downSampleX4PostProcess: Nullable<PostProcess>;
  61703. /**
  61704. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61705. */
  61706. brightPassPostProcess: Nullable<PostProcess>;
  61707. /**
  61708. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61709. */
  61710. blurHPostProcesses: PostProcess[];
  61711. /**
  61712. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61713. */
  61714. blurVPostProcesses: PostProcess[];
  61715. /**
  61716. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61717. */
  61718. textureAdderPostProcess: Nullable<PostProcess>;
  61719. /**
  61720. * Post-process used to create volumetric lighting effect
  61721. */
  61722. volumetricLightPostProcess: Nullable<PostProcess>;
  61723. /**
  61724. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61725. */
  61726. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61727. /**
  61728. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61729. */
  61730. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61731. /**
  61732. * Post-process used to merge the volumetric light effect and the real scene color
  61733. */
  61734. volumetricLightMergePostProces: Nullable<PostProcess>;
  61735. /**
  61736. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61737. */
  61738. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61739. /**
  61740. * Base post-process used to calculate the average luminance of the final image for HDR
  61741. */
  61742. luminancePostProcess: Nullable<PostProcess>;
  61743. /**
  61744. * Post-processes used to create down sample post-processes in order to get
  61745. * the average luminance of the final image for HDR
  61746. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61747. */
  61748. luminanceDownSamplePostProcesses: PostProcess[];
  61749. /**
  61750. * Post-process used to create a HDR effect (light adaptation)
  61751. */
  61752. hdrPostProcess: Nullable<PostProcess>;
  61753. /**
  61754. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61755. */
  61756. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61757. /**
  61758. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61759. */
  61760. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61761. /**
  61762. * Post-process used to merge the final HDR post-process and the real scene color
  61763. */
  61764. hdrFinalPostProcess: Nullable<PostProcess>;
  61765. /**
  61766. * Post-process used to create a lens flare effect
  61767. */
  61768. lensFlarePostProcess: Nullable<PostProcess>;
  61769. /**
  61770. * Post-process that merges the result of the lens flare post-process and the real scene color
  61771. */
  61772. lensFlareComposePostProcess: Nullable<PostProcess>;
  61773. /**
  61774. * Post-process used to create a motion blur effect
  61775. */
  61776. motionBlurPostProcess: Nullable<PostProcess>;
  61777. /**
  61778. * Post-process used to create a depth of field effect
  61779. */
  61780. depthOfFieldPostProcess: Nullable<PostProcess>;
  61781. /**
  61782. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61783. */
  61784. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61785. /**
  61786. * Represents the brightness threshold in order to configure the illuminated surfaces
  61787. */
  61788. brightThreshold: number;
  61789. /**
  61790. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61791. */
  61792. blurWidth: number;
  61793. /**
  61794. * Sets if the blur for highlighted surfaces must be only horizontal
  61795. */
  61796. horizontalBlur: boolean;
  61797. /**
  61798. * Gets the overall exposure used by the pipeline
  61799. */
  61800. /**
  61801. * Sets the overall exposure used by the pipeline
  61802. */
  61803. exposure: number;
  61804. /**
  61805. * Texture used typically to simulate "dirty" on camera lens
  61806. */
  61807. lensTexture: Nullable<Texture>;
  61808. /**
  61809. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61810. */
  61811. volumetricLightCoefficient: number;
  61812. /**
  61813. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61814. */
  61815. volumetricLightPower: number;
  61816. /**
  61817. * Used the set the blur intensity to smooth the volumetric lights
  61818. */
  61819. volumetricLightBlurScale: number;
  61820. /**
  61821. * Light (spot or directional) used to generate the volumetric lights rays
  61822. * The source light must have a shadow generate so the pipeline can get its
  61823. * depth map
  61824. */
  61825. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61826. /**
  61827. * For eye adaptation, represents the minimum luminance the eye can see
  61828. */
  61829. hdrMinimumLuminance: number;
  61830. /**
  61831. * For eye adaptation, represents the decrease luminance speed
  61832. */
  61833. hdrDecreaseRate: number;
  61834. /**
  61835. * For eye adaptation, represents the increase luminance speed
  61836. */
  61837. hdrIncreaseRate: number;
  61838. /**
  61839. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61840. */
  61841. /**
  61842. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61843. */
  61844. hdrAutoExposure: boolean;
  61845. /**
  61846. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61847. */
  61848. lensColorTexture: Nullable<Texture>;
  61849. /**
  61850. * The overall strengh for the lens flare effect
  61851. */
  61852. lensFlareStrength: number;
  61853. /**
  61854. * Dispersion coefficient for lens flare ghosts
  61855. */
  61856. lensFlareGhostDispersal: number;
  61857. /**
  61858. * Main lens flare halo width
  61859. */
  61860. lensFlareHaloWidth: number;
  61861. /**
  61862. * Based on the lens distortion effect, defines how much the lens flare result
  61863. * is distorted
  61864. */
  61865. lensFlareDistortionStrength: number;
  61866. /**
  61867. * Configures the blur intensity used for for lens flare (halo)
  61868. */
  61869. lensFlareBlurWidth: number;
  61870. /**
  61871. * Lens star texture must be used to simulate rays on the flares and is available
  61872. * in the documentation
  61873. */
  61874. lensStarTexture: Nullable<Texture>;
  61875. /**
  61876. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61877. * flare effect by taking account of the dirt texture
  61878. */
  61879. lensFlareDirtTexture: Nullable<Texture>;
  61880. /**
  61881. * Represents the focal length for the depth of field effect
  61882. */
  61883. depthOfFieldDistance: number;
  61884. /**
  61885. * Represents the blur intensity for the blurred part of the depth of field effect
  61886. */
  61887. depthOfFieldBlurWidth: number;
  61888. /**
  61889. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61890. */
  61891. /**
  61892. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61893. */
  61894. motionStrength: number;
  61895. /**
  61896. * Gets wether or not the motion blur post-process is object based or screen based.
  61897. */
  61898. /**
  61899. * Sets wether or not the motion blur post-process should be object based or screen based
  61900. */
  61901. objectBasedMotionBlur: boolean;
  61902. /**
  61903. * List of animations for the pipeline (IAnimatable implementation)
  61904. */
  61905. animations: Animation[];
  61906. /**
  61907. * Private members
  61908. */
  61909. private _scene;
  61910. private _currentDepthOfFieldSource;
  61911. private _basePostProcess;
  61912. private _fixedExposure;
  61913. private _currentExposure;
  61914. private _hdrAutoExposure;
  61915. private _hdrCurrentLuminance;
  61916. private _motionStrength;
  61917. private _isObjectBasedMotionBlur;
  61918. private _floatTextureType;
  61919. private _camerasToBeAttached;
  61920. private _ratio;
  61921. private _bloomEnabled;
  61922. private _depthOfFieldEnabled;
  61923. private _vlsEnabled;
  61924. private _lensFlareEnabled;
  61925. private _hdrEnabled;
  61926. private _motionBlurEnabled;
  61927. private _fxaaEnabled;
  61928. private _motionBlurSamples;
  61929. private _volumetricLightStepsCount;
  61930. private _samples;
  61931. /**
  61932. * @ignore
  61933. * Specifies if the bloom pipeline is enabled
  61934. */
  61935. BloomEnabled: boolean;
  61936. /**
  61937. * @ignore
  61938. * Specifies if the depth of field pipeline is enabed
  61939. */
  61940. DepthOfFieldEnabled: boolean;
  61941. /**
  61942. * @ignore
  61943. * Specifies if the lens flare pipeline is enabed
  61944. */
  61945. LensFlareEnabled: boolean;
  61946. /**
  61947. * @ignore
  61948. * Specifies if the HDR pipeline is enabled
  61949. */
  61950. HDREnabled: boolean;
  61951. /**
  61952. * @ignore
  61953. * Specifies if the volumetric lights scattering effect is enabled
  61954. */
  61955. VLSEnabled: boolean;
  61956. /**
  61957. * @ignore
  61958. * Specifies if the motion blur effect is enabled
  61959. */
  61960. MotionBlurEnabled: boolean;
  61961. /**
  61962. * Specifies if anti-aliasing is enabled
  61963. */
  61964. fxaaEnabled: boolean;
  61965. /**
  61966. * Specifies the number of steps used to calculate the volumetric lights
  61967. * Typically in interval [50, 200]
  61968. */
  61969. volumetricLightStepsCount: number;
  61970. /**
  61971. * Specifies the number of samples used for the motion blur effect
  61972. * Typically in interval [16, 64]
  61973. */
  61974. motionBlurSamples: number;
  61975. /**
  61976. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61977. */
  61978. samples: number;
  61979. /**
  61980. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61981. * @constructor
  61982. * @param name The rendering pipeline name
  61983. * @param scene The scene linked to this pipeline
  61984. * @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)
  61985. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61986. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61987. */
  61988. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61989. private _buildPipeline;
  61990. private _createDownSampleX4PostProcess;
  61991. private _createBrightPassPostProcess;
  61992. private _createBlurPostProcesses;
  61993. private _createTextureAdderPostProcess;
  61994. private _createVolumetricLightPostProcess;
  61995. private _createLuminancePostProcesses;
  61996. private _createHdrPostProcess;
  61997. private _createLensFlarePostProcess;
  61998. private _createDepthOfFieldPostProcess;
  61999. private _createMotionBlurPostProcess;
  62000. private _getDepthTexture;
  62001. private _disposePostProcesses;
  62002. /**
  62003. * Dispose of the pipeline and stop all post processes
  62004. */
  62005. dispose(): void;
  62006. /**
  62007. * Serialize the rendering pipeline (Used when exporting)
  62008. * @returns the serialized object
  62009. */
  62010. serialize(): any;
  62011. /**
  62012. * Parse the serialized pipeline
  62013. * @param source Source pipeline.
  62014. * @param scene The scene to load the pipeline to.
  62015. * @param rootUrl The URL of the serialized pipeline.
  62016. * @returns An instantiated pipeline from the serialized object.
  62017. */
  62018. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62019. /**
  62020. * Luminance steps
  62021. */
  62022. static LuminanceSteps: number;
  62023. }
  62024. }
  62025. declare module BABYLON {
  62026. /** @hidden */
  62027. export var tonemapPixelShader: {
  62028. name: string;
  62029. shader: string;
  62030. };
  62031. }
  62032. declare module BABYLON {
  62033. /** Defines operator used for tonemapping */
  62034. export enum TonemappingOperator {
  62035. /** Hable */
  62036. Hable = 0,
  62037. /** Reinhard */
  62038. Reinhard = 1,
  62039. /** HejiDawson */
  62040. HejiDawson = 2,
  62041. /** Photographic */
  62042. Photographic = 3
  62043. }
  62044. /**
  62045. * Defines a post process to apply tone mapping
  62046. */
  62047. export class TonemapPostProcess extends PostProcess {
  62048. private _operator;
  62049. /** Defines the required exposure adjustement */
  62050. exposureAdjustment: number;
  62051. /**
  62052. * Creates a new TonemapPostProcess
  62053. * @param name defines the name of the postprocess
  62054. * @param _operator defines the operator to use
  62055. * @param exposureAdjustment defines the required exposure adjustement
  62056. * @param camera defines the camera to use (can be null)
  62057. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62058. * @param engine defines the hosting engine (can be ignore if camera is set)
  62059. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62060. */
  62061. constructor(name: string, _operator: TonemappingOperator,
  62062. /** Defines the required exposure adjustement */
  62063. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /** @hidden */
  62068. export var depthVertexShader: {
  62069. name: string;
  62070. shader: string;
  62071. };
  62072. }
  62073. declare module BABYLON {
  62074. /** @hidden */
  62075. export var volumetricLightScatteringPixelShader: {
  62076. name: string;
  62077. shader: string;
  62078. };
  62079. }
  62080. declare module BABYLON {
  62081. /** @hidden */
  62082. export var volumetricLightScatteringPassVertexShader: {
  62083. name: string;
  62084. shader: string;
  62085. };
  62086. }
  62087. declare module BABYLON {
  62088. /** @hidden */
  62089. export var volumetricLightScatteringPassPixelShader: {
  62090. name: string;
  62091. shader: string;
  62092. };
  62093. }
  62094. declare module BABYLON {
  62095. /**
  62096. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62097. */
  62098. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62099. private _volumetricLightScatteringPass;
  62100. private _volumetricLightScatteringRTT;
  62101. private _viewPort;
  62102. private _screenCoordinates;
  62103. private _cachedDefines;
  62104. /**
  62105. * If not undefined, the mesh position is computed from the attached node position
  62106. */
  62107. attachedNode: {
  62108. position: Vector3;
  62109. };
  62110. /**
  62111. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62112. */
  62113. customMeshPosition: Vector3;
  62114. /**
  62115. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62116. */
  62117. useCustomMeshPosition: boolean;
  62118. /**
  62119. * If the post-process should inverse the light scattering direction
  62120. */
  62121. invert: boolean;
  62122. /**
  62123. * The internal mesh used by the post-process
  62124. */
  62125. mesh: Mesh;
  62126. /**
  62127. * @hidden
  62128. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62129. */
  62130. useDiffuseColor: boolean;
  62131. /**
  62132. * Array containing the excluded meshes not rendered in the internal pass
  62133. */
  62134. excludedMeshes: AbstractMesh[];
  62135. /**
  62136. * Controls the overall intensity of the post-process
  62137. */
  62138. exposure: number;
  62139. /**
  62140. * Dissipates each sample's contribution in range [0, 1]
  62141. */
  62142. decay: number;
  62143. /**
  62144. * Controls the overall intensity of each sample
  62145. */
  62146. weight: number;
  62147. /**
  62148. * Controls the density of each sample
  62149. */
  62150. density: number;
  62151. /**
  62152. * @constructor
  62153. * @param name The post-process name
  62154. * @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)
  62155. * @param camera The camera that the post-process will be attached to
  62156. * @param mesh The mesh used to create the light scattering
  62157. * @param samples The post-process quality, default 100
  62158. * @param samplingModeThe post-process filtering mode
  62159. * @param engine The babylon engine
  62160. * @param reusable If the post-process is reusable
  62161. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62162. */
  62163. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62164. /**
  62165. * Returns the string "VolumetricLightScatteringPostProcess"
  62166. * @returns "VolumetricLightScatteringPostProcess"
  62167. */
  62168. getClassName(): string;
  62169. private _isReady;
  62170. /**
  62171. * Sets the new light position for light scattering effect
  62172. * @param position The new custom light position
  62173. */
  62174. setCustomMeshPosition(position: Vector3): void;
  62175. /**
  62176. * Returns the light position for light scattering effect
  62177. * @return Vector3 The custom light position
  62178. */
  62179. getCustomMeshPosition(): Vector3;
  62180. /**
  62181. * Disposes the internal assets and detaches the post-process from the camera
  62182. */
  62183. dispose(camera: Camera): void;
  62184. /**
  62185. * Returns the render target texture used by the post-process
  62186. * @return the render target texture used by the post-process
  62187. */
  62188. getPass(): RenderTargetTexture;
  62189. private _meshExcluded;
  62190. private _createPass;
  62191. private _updateMeshScreenCoordinates;
  62192. /**
  62193. * Creates a default mesh for the Volumeric Light Scattering post-process
  62194. * @param name The mesh name
  62195. * @param scene The scene where to create the mesh
  62196. * @return the default mesh
  62197. */
  62198. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62199. }
  62200. }
  62201. declare module BABYLON {
  62202. interface Scene {
  62203. /** @hidden (Backing field) */
  62204. _boundingBoxRenderer: BoundingBoxRenderer;
  62205. /** @hidden (Backing field) */
  62206. _forceShowBoundingBoxes: boolean;
  62207. /**
  62208. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62209. */
  62210. forceShowBoundingBoxes: boolean;
  62211. /**
  62212. * Gets the bounding box renderer associated with the scene
  62213. * @returns a BoundingBoxRenderer
  62214. */
  62215. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62216. }
  62217. interface AbstractMesh {
  62218. /** @hidden (Backing field) */
  62219. _showBoundingBox: boolean;
  62220. /**
  62221. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62222. */
  62223. showBoundingBox: boolean;
  62224. }
  62225. /**
  62226. * Component responsible of rendering the bounding box of the meshes in a scene.
  62227. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62228. */
  62229. export class BoundingBoxRenderer implements ISceneComponent {
  62230. /**
  62231. * The component name helpfull to identify the component in the list of scene components.
  62232. */
  62233. readonly name: string;
  62234. /**
  62235. * The scene the component belongs to.
  62236. */
  62237. scene: Scene;
  62238. /**
  62239. * Color of the bounding box lines placed in front of an object
  62240. */
  62241. frontColor: Color3;
  62242. /**
  62243. * Color of the bounding box lines placed behind an object
  62244. */
  62245. backColor: Color3;
  62246. /**
  62247. * Defines if the renderer should show the back lines or not
  62248. */
  62249. showBackLines: boolean;
  62250. /**
  62251. * @hidden
  62252. */
  62253. renderList: SmartArray<BoundingBox>;
  62254. private _colorShader;
  62255. private _vertexBuffers;
  62256. private _indexBuffer;
  62257. private _fillIndexBuffer;
  62258. private _fillIndexData;
  62259. /**
  62260. * Instantiates a new bounding box renderer in a scene.
  62261. * @param scene the scene the renderer renders in
  62262. */
  62263. constructor(scene: Scene);
  62264. /**
  62265. * Registers the component in a given scene
  62266. */
  62267. register(): void;
  62268. private _evaluateSubMesh;
  62269. private _activeMesh;
  62270. private _prepareRessources;
  62271. private _createIndexBuffer;
  62272. /**
  62273. * Rebuilds the elements related to this component in case of
  62274. * context lost for instance.
  62275. */
  62276. rebuild(): void;
  62277. /**
  62278. * @hidden
  62279. */
  62280. reset(): void;
  62281. /**
  62282. * Render the bounding boxes of a specific rendering group
  62283. * @param renderingGroupId defines the rendering group to render
  62284. */
  62285. render(renderingGroupId: number): void;
  62286. /**
  62287. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62288. * @param mesh Define the mesh to render the occlusion bounding box for
  62289. */
  62290. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62291. /**
  62292. * Dispose and release the resources attached to this renderer.
  62293. */
  62294. dispose(): void;
  62295. }
  62296. }
  62297. declare module BABYLON {
  62298. /** @hidden */
  62299. export var depthPixelShader: {
  62300. name: string;
  62301. shader: string;
  62302. };
  62303. }
  62304. declare module BABYLON {
  62305. /**
  62306. * This represents a depth renderer in Babylon.
  62307. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62308. */
  62309. export class DepthRenderer {
  62310. private _scene;
  62311. private _depthMap;
  62312. private _effect;
  62313. private readonly _storeNonLinearDepth;
  62314. private readonly _clearColor;
  62315. /** Get if the depth renderer is using packed depth or not */
  62316. readonly isPacked: boolean;
  62317. private _cachedDefines;
  62318. private _camera;
  62319. /**
  62320. * Specifiess that the depth renderer will only be used within
  62321. * the camera it is created for.
  62322. * This can help forcing its rendering during the camera processing.
  62323. */
  62324. useOnlyInActiveCamera: boolean;
  62325. /** @hidden */
  62326. static _SceneComponentInitialization: (scene: Scene) => void;
  62327. /**
  62328. * Instantiates a depth renderer
  62329. * @param scene The scene the renderer belongs to
  62330. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62331. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62332. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62333. */
  62334. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62335. /**
  62336. * Creates the depth rendering effect and checks if the effect is ready.
  62337. * @param subMesh The submesh to be used to render the depth map of
  62338. * @param useInstances If multiple world instances should be used
  62339. * @returns if the depth renderer is ready to render the depth map
  62340. */
  62341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62342. /**
  62343. * Gets the texture which the depth map will be written to.
  62344. * @returns The depth map texture
  62345. */
  62346. getDepthMap(): RenderTargetTexture;
  62347. /**
  62348. * Disposes of the depth renderer.
  62349. */
  62350. dispose(): void;
  62351. }
  62352. }
  62353. declare module BABYLON {
  62354. interface Scene {
  62355. /** @hidden (Backing field) */
  62356. _depthRenderer: {
  62357. [id: string]: DepthRenderer;
  62358. };
  62359. /**
  62360. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62361. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62362. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62363. * @returns the created depth renderer
  62364. */
  62365. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62366. /**
  62367. * Disables a depth renderer for a given camera
  62368. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62369. */
  62370. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62371. }
  62372. /**
  62373. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62374. * in several rendering techniques.
  62375. */
  62376. export class DepthRendererSceneComponent implements ISceneComponent {
  62377. /**
  62378. * The component name helpfull to identify the component in the list of scene components.
  62379. */
  62380. readonly name: string;
  62381. /**
  62382. * The scene the component belongs to.
  62383. */
  62384. scene: Scene;
  62385. /**
  62386. * Creates a new instance of the component for the given scene
  62387. * @param scene Defines the scene to register the component in
  62388. */
  62389. constructor(scene: Scene);
  62390. /**
  62391. * Registers the component in a given scene
  62392. */
  62393. register(): void;
  62394. /**
  62395. * Rebuilds the elements related to this component in case of
  62396. * context lost for instance.
  62397. */
  62398. rebuild(): void;
  62399. /**
  62400. * Disposes the component and the associated ressources
  62401. */
  62402. dispose(): void;
  62403. private _gatherRenderTargets;
  62404. private _gatherActiveCameraRenderTargets;
  62405. }
  62406. }
  62407. declare module BABYLON {
  62408. /** @hidden */
  62409. export var outlinePixelShader: {
  62410. name: string;
  62411. shader: string;
  62412. };
  62413. }
  62414. declare module BABYLON {
  62415. /** @hidden */
  62416. export var outlineVertexShader: {
  62417. name: string;
  62418. shader: string;
  62419. };
  62420. }
  62421. declare module BABYLON {
  62422. interface Scene {
  62423. /** @hidden */
  62424. _outlineRenderer: OutlineRenderer;
  62425. /**
  62426. * Gets the outline renderer associated with the scene
  62427. * @returns a OutlineRenderer
  62428. */
  62429. getOutlineRenderer(): OutlineRenderer;
  62430. }
  62431. interface AbstractMesh {
  62432. /** @hidden (Backing field) */
  62433. _renderOutline: boolean;
  62434. /**
  62435. * Gets or sets a boolean indicating if the outline must be rendered as well
  62436. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62437. */
  62438. renderOutline: boolean;
  62439. /** @hidden (Backing field) */
  62440. _renderOverlay: boolean;
  62441. /**
  62442. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62443. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62444. */
  62445. renderOverlay: boolean;
  62446. }
  62447. /**
  62448. * This class is responsible to draw bothe outline/overlay of meshes.
  62449. * It should not be used directly but through the available method on mesh.
  62450. */
  62451. export class OutlineRenderer implements ISceneComponent {
  62452. /**
  62453. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62454. */
  62455. private static _StencilReference;
  62456. /**
  62457. * The name of the component. Each component must have a unique name.
  62458. */
  62459. name: string;
  62460. /**
  62461. * The scene the component belongs to.
  62462. */
  62463. scene: Scene;
  62464. /**
  62465. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62466. */
  62467. zOffset: number;
  62468. private _engine;
  62469. private _effect;
  62470. private _cachedDefines;
  62471. private _savedDepthWrite;
  62472. /**
  62473. * Instantiates a new outline renderer. (There could be only one per scene).
  62474. * @param scene Defines the scene it belongs to
  62475. */
  62476. constructor(scene: Scene);
  62477. /**
  62478. * Register the component to one instance of a scene.
  62479. */
  62480. register(): void;
  62481. /**
  62482. * Rebuilds the elements related to this component in case of
  62483. * context lost for instance.
  62484. */
  62485. rebuild(): void;
  62486. /**
  62487. * Disposes the component and the associated ressources.
  62488. */
  62489. dispose(): void;
  62490. /**
  62491. * Renders the outline in the canvas.
  62492. * @param subMesh Defines the sumesh to render
  62493. * @param batch Defines the batch of meshes in case of instances
  62494. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62495. */
  62496. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62497. /**
  62498. * Returns whether or not the outline renderer is ready for a given submesh.
  62499. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62500. * @param subMesh Defines the submesh to check readyness for
  62501. * @param useInstances Defines wheter wee are trying to render instances or not
  62502. * @returns true if ready otherwise false
  62503. */
  62504. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62505. private _beforeRenderingMesh;
  62506. private _afterRenderingMesh;
  62507. }
  62508. }
  62509. declare module BABYLON {
  62510. /**
  62511. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62512. * @see http://doc.babylonjs.com/babylon101/sprites
  62513. */
  62514. export class SpritePackedManager extends SpriteManager {
  62515. /** defines the packed manager's name */
  62516. name: string;
  62517. /**
  62518. * Creates a new sprite manager from a packed sprite sheet
  62519. * @param name defines the manager's name
  62520. * @param imgUrl defines the sprite sheet url
  62521. * @param capacity defines the maximum allowed number of sprites
  62522. * @param scene defines the hosting scene
  62523. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62524. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62525. * @param samplingMode defines the smapling mode to use with spritesheet
  62526. * @param fromPacked set to true; do not alter
  62527. */
  62528. constructor(
  62529. /** defines the packed manager's name */
  62530. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62531. }
  62532. }
  62533. declare module BABYLON {
  62534. /**
  62535. * Defines the list of states available for a task inside a AssetsManager
  62536. */
  62537. export enum AssetTaskState {
  62538. /**
  62539. * Initialization
  62540. */
  62541. INIT = 0,
  62542. /**
  62543. * Running
  62544. */
  62545. RUNNING = 1,
  62546. /**
  62547. * Done
  62548. */
  62549. DONE = 2,
  62550. /**
  62551. * Error
  62552. */
  62553. ERROR = 3
  62554. }
  62555. /**
  62556. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62557. */
  62558. export abstract class AbstractAssetTask {
  62559. /**
  62560. * Task name
  62561. */ name: string;
  62562. /**
  62563. * Callback called when the task is successful
  62564. */
  62565. onSuccess: (task: any) => void;
  62566. /**
  62567. * Callback called when the task is not successful
  62568. */
  62569. onError: (task: any, message?: string, exception?: any) => void;
  62570. /**
  62571. * Creates a new AssetsManager
  62572. * @param name defines the name of the task
  62573. */
  62574. constructor(
  62575. /**
  62576. * Task name
  62577. */ name: string);
  62578. private _isCompleted;
  62579. private _taskState;
  62580. private _errorObject;
  62581. /**
  62582. * Get if the task is completed
  62583. */
  62584. readonly isCompleted: boolean;
  62585. /**
  62586. * Gets the current state of the task
  62587. */
  62588. readonly taskState: AssetTaskState;
  62589. /**
  62590. * Gets the current error object (if task is in error)
  62591. */
  62592. readonly errorObject: {
  62593. message?: string;
  62594. exception?: any;
  62595. };
  62596. /**
  62597. * Internal only
  62598. * @hidden
  62599. */
  62600. _setErrorObject(message?: string, exception?: any): void;
  62601. /**
  62602. * Execute the current task
  62603. * @param scene defines the scene where you want your assets to be loaded
  62604. * @param onSuccess is a callback called when the task is successfully executed
  62605. * @param onError is a callback called if an error occurs
  62606. */
  62607. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62608. /**
  62609. * Execute the current task
  62610. * @param scene defines the scene where you want your assets to be loaded
  62611. * @param onSuccess is a callback called when the task is successfully executed
  62612. * @param onError is a callback called if an error occurs
  62613. */
  62614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62615. /**
  62616. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62617. * This can be used with failed tasks that have the reason for failure fixed.
  62618. */
  62619. reset(): void;
  62620. private onErrorCallback;
  62621. private onDoneCallback;
  62622. }
  62623. /**
  62624. * Define the interface used by progress events raised during assets loading
  62625. */
  62626. export interface IAssetsProgressEvent {
  62627. /**
  62628. * Defines the number of remaining tasks to process
  62629. */
  62630. remainingCount: number;
  62631. /**
  62632. * Defines the total number of tasks
  62633. */
  62634. totalCount: number;
  62635. /**
  62636. * Defines the task that was just processed
  62637. */
  62638. task: AbstractAssetTask;
  62639. }
  62640. /**
  62641. * Class used to share progress information about assets loading
  62642. */
  62643. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62644. /**
  62645. * Defines the number of remaining tasks to process
  62646. */
  62647. remainingCount: number;
  62648. /**
  62649. * Defines the total number of tasks
  62650. */
  62651. totalCount: number;
  62652. /**
  62653. * Defines the task that was just processed
  62654. */
  62655. task: AbstractAssetTask;
  62656. /**
  62657. * Creates a AssetsProgressEvent
  62658. * @param remainingCount defines the number of remaining tasks to process
  62659. * @param totalCount defines the total number of tasks
  62660. * @param task defines the task that was just processed
  62661. */
  62662. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62663. }
  62664. /**
  62665. * Define a task used by AssetsManager to load meshes
  62666. */
  62667. export class MeshAssetTask extends AbstractAssetTask {
  62668. /**
  62669. * Defines the name of the task
  62670. */
  62671. name: string;
  62672. /**
  62673. * Defines the list of mesh's names you want to load
  62674. */
  62675. meshesNames: any;
  62676. /**
  62677. * Defines the root url to use as a base to load your meshes and associated resources
  62678. */
  62679. rootUrl: string;
  62680. /**
  62681. * Defines the filename of the scene to load from
  62682. */
  62683. sceneFilename: string;
  62684. /**
  62685. * Gets the list of loaded meshes
  62686. */
  62687. loadedMeshes: Array<AbstractMesh>;
  62688. /**
  62689. * Gets the list of loaded particle systems
  62690. */
  62691. loadedParticleSystems: Array<IParticleSystem>;
  62692. /**
  62693. * Gets the list of loaded skeletons
  62694. */
  62695. loadedSkeletons: Array<Skeleton>;
  62696. /**
  62697. * Gets the list of loaded animation groups
  62698. */
  62699. loadedAnimationGroups: Array<AnimationGroup>;
  62700. /**
  62701. * Callback called when the task is successful
  62702. */
  62703. onSuccess: (task: MeshAssetTask) => void;
  62704. /**
  62705. * Callback called when the task is successful
  62706. */
  62707. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62708. /**
  62709. * Creates a new MeshAssetTask
  62710. * @param name defines the name of the task
  62711. * @param meshesNames defines the list of mesh's names you want to load
  62712. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62713. * @param sceneFilename defines the filename of the scene to load from
  62714. */
  62715. constructor(
  62716. /**
  62717. * Defines the name of the task
  62718. */
  62719. name: string,
  62720. /**
  62721. * Defines the list of mesh's names you want to load
  62722. */
  62723. meshesNames: any,
  62724. /**
  62725. * Defines the root url to use as a base to load your meshes and associated resources
  62726. */
  62727. rootUrl: string,
  62728. /**
  62729. * Defines the filename of the scene to load from
  62730. */
  62731. sceneFilename: string);
  62732. /**
  62733. * Execute the current task
  62734. * @param scene defines the scene where you want your assets to be loaded
  62735. * @param onSuccess is a callback called when the task is successfully executed
  62736. * @param onError is a callback called if an error occurs
  62737. */
  62738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62739. }
  62740. /**
  62741. * Define a task used by AssetsManager to load text content
  62742. */
  62743. export class TextFileAssetTask extends AbstractAssetTask {
  62744. /**
  62745. * Defines the name of the task
  62746. */
  62747. name: string;
  62748. /**
  62749. * Defines the location of the file to load
  62750. */
  62751. url: string;
  62752. /**
  62753. * Gets the loaded text string
  62754. */
  62755. text: string;
  62756. /**
  62757. * Callback called when the task is successful
  62758. */
  62759. onSuccess: (task: TextFileAssetTask) => void;
  62760. /**
  62761. * Callback called when the task is successful
  62762. */
  62763. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62764. /**
  62765. * Creates a new TextFileAssetTask object
  62766. * @param name defines the name of the task
  62767. * @param url defines the location of the file to load
  62768. */
  62769. constructor(
  62770. /**
  62771. * Defines the name of the task
  62772. */
  62773. name: string,
  62774. /**
  62775. * Defines the location of the file to load
  62776. */
  62777. url: string);
  62778. /**
  62779. * Execute the current task
  62780. * @param scene defines the scene where you want your assets to be loaded
  62781. * @param onSuccess is a callback called when the task is successfully executed
  62782. * @param onError is a callback called if an error occurs
  62783. */
  62784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62785. }
  62786. /**
  62787. * Define a task used by AssetsManager to load binary data
  62788. */
  62789. export class BinaryFileAssetTask extends AbstractAssetTask {
  62790. /**
  62791. * Defines the name of the task
  62792. */
  62793. name: string;
  62794. /**
  62795. * Defines the location of the file to load
  62796. */
  62797. url: string;
  62798. /**
  62799. * Gets the lodaded data (as an array buffer)
  62800. */
  62801. data: ArrayBuffer;
  62802. /**
  62803. * Callback called when the task is successful
  62804. */
  62805. onSuccess: (task: BinaryFileAssetTask) => void;
  62806. /**
  62807. * Callback called when the task is successful
  62808. */
  62809. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62810. /**
  62811. * Creates a new BinaryFileAssetTask object
  62812. * @param name defines the name of the new task
  62813. * @param url defines the location of the file to load
  62814. */
  62815. constructor(
  62816. /**
  62817. * Defines the name of the task
  62818. */
  62819. name: string,
  62820. /**
  62821. * Defines the location of the file to load
  62822. */
  62823. url: string);
  62824. /**
  62825. * Execute the current task
  62826. * @param scene defines the scene where you want your assets to be loaded
  62827. * @param onSuccess is a callback called when the task is successfully executed
  62828. * @param onError is a callback called if an error occurs
  62829. */
  62830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62831. }
  62832. /**
  62833. * Define a task used by AssetsManager to load images
  62834. */
  62835. export class ImageAssetTask extends AbstractAssetTask {
  62836. /**
  62837. * Defines the name of the task
  62838. */
  62839. name: string;
  62840. /**
  62841. * Defines the location of the image to load
  62842. */
  62843. url: string;
  62844. /**
  62845. * Gets the loaded images
  62846. */
  62847. image: HTMLImageElement;
  62848. /**
  62849. * Callback called when the task is successful
  62850. */
  62851. onSuccess: (task: ImageAssetTask) => void;
  62852. /**
  62853. * Callback called when the task is successful
  62854. */
  62855. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62856. /**
  62857. * Creates a new ImageAssetTask
  62858. * @param name defines the name of the task
  62859. * @param url defines the location of the image to load
  62860. */
  62861. constructor(
  62862. /**
  62863. * Defines the name of the task
  62864. */
  62865. name: string,
  62866. /**
  62867. * Defines the location of the image to load
  62868. */
  62869. url: string);
  62870. /**
  62871. * Execute the current task
  62872. * @param scene defines the scene where you want your assets to be loaded
  62873. * @param onSuccess is a callback called when the task is successfully executed
  62874. * @param onError is a callback called if an error occurs
  62875. */
  62876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62877. }
  62878. /**
  62879. * Defines the interface used by texture loading tasks
  62880. */
  62881. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62882. /**
  62883. * Gets the loaded texture
  62884. */
  62885. texture: TEX;
  62886. }
  62887. /**
  62888. * Define a task used by AssetsManager to load 2D textures
  62889. */
  62890. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62891. /**
  62892. * Defines the name of the task
  62893. */
  62894. name: string;
  62895. /**
  62896. * Defines the location of the file to load
  62897. */
  62898. url: string;
  62899. /**
  62900. * Defines if mipmap should not be generated (default is false)
  62901. */
  62902. noMipmap?: boolean | undefined;
  62903. /**
  62904. * Defines if texture must be inverted on Y axis (default is false)
  62905. */
  62906. invertY?: boolean | undefined;
  62907. /**
  62908. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62909. */
  62910. samplingMode: number;
  62911. /**
  62912. * Gets the loaded texture
  62913. */
  62914. texture: Texture;
  62915. /**
  62916. * Callback called when the task is successful
  62917. */
  62918. onSuccess: (task: TextureAssetTask) => void;
  62919. /**
  62920. * Callback called when the task is successful
  62921. */
  62922. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62923. /**
  62924. * Creates a new TextureAssetTask object
  62925. * @param name defines the name of the task
  62926. * @param url defines the location of the file to load
  62927. * @param noMipmap defines if mipmap should not be generated (default is false)
  62928. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62929. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62930. */
  62931. constructor(
  62932. /**
  62933. * Defines the name of the task
  62934. */
  62935. name: string,
  62936. /**
  62937. * Defines the location of the file to load
  62938. */
  62939. url: string,
  62940. /**
  62941. * Defines if mipmap should not be generated (default is false)
  62942. */
  62943. noMipmap?: boolean | undefined,
  62944. /**
  62945. * Defines if texture must be inverted on Y axis (default is false)
  62946. */
  62947. invertY?: boolean | undefined,
  62948. /**
  62949. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62950. */
  62951. samplingMode?: number);
  62952. /**
  62953. * Execute the current task
  62954. * @param scene defines the scene where you want your assets to be loaded
  62955. * @param onSuccess is a callback called when the task is successfully executed
  62956. * @param onError is a callback called if an error occurs
  62957. */
  62958. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62959. }
  62960. /**
  62961. * Define a task used by AssetsManager to load cube textures
  62962. */
  62963. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62964. /**
  62965. * Defines the name of the task
  62966. */
  62967. name: string;
  62968. /**
  62969. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62970. */
  62971. url: string;
  62972. /**
  62973. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62974. */
  62975. extensions?: string[] | undefined;
  62976. /**
  62977. * Defines if mipmaps should not be generated (default is false)
  62978. */
  62979. noMipmap?: boolean | undefined;
  62980. /**
  62981. * Defines the explicit list of files (undefined by default)
  62982. */
  62983. files?: string[] | undefined;
  62984. /**
  62985. * Gets the loaded texture
  62986. */
  62987. texture: CubeTexture;
  62988. /**
  62989. * Callback called when the task is successful
  62990. */
  62991. onSuccess: (task: CubeTextureAssetTask) => void;
  62992. /**
  62993. * Callback called when the task is successful
  62994. */
  62995. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62996. /**
  62997. * Creates a new CubeTextureAssetTask
  62998. * @param name defines the name of the task
  62999. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63000. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63001. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63002. * @param files defines the explicit list of files (undefined by default)
  63003. */
  63004. constructor(
  63005. /**
  63006. * Defines the name of the task
  63007. */
  63008. name: string,
  63009. /**
  63010. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63011. */
  63012. url: string,
  63013. /**
  63014. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63015. */
  63016. extensions?: string[] | undefined,
  63017. /**
  63018. * Defines if mipmaps should not be generated (default is false)
  63019. */
  63020. noMipmap?: boolean | undefined,
  63021. /**
  63022. * Defines the explicit list of files (undefined by default)
  63023. */
  63024. files?: string[] | undefined);
  63025. /**
  63026. * Execute the current task
  63027. * @param scene defines the scene where you want your assets to be loaded
  63028. * @param onSuccess is a callback called when the task is successfully executed
  63029. * @param onError is a callback called if an error occurs
  63030. */
  63031. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63032. }
  63033. /**
  63034. * Define a task used by AssetsManager to load HDR cube textures
  63035. */
  63036. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63037. /**
  63038. * Defines the name of the task
  63039. */
  63040. name: string;
  63041. /**
  63042. * Defines the location of the file to load
  63043. */
  63044. url: string;
  63045. /**
  63046. * Defines the desired size (the more it increases the longer the generation will be)
  63047. */
  63048. size: number;
  63049. /**
  63050. * Defines if mipmaps should not be generated (default is false)
  63051. */
  63052. noMipmap: boolean;
  63053. /**
  63054. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63055. */
  63056. generateHarmonics: boolean;
  63057. /**
  63058. * 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)
  63059. */
  63060. gammaSpace: boolean;
  63061. /**
  63062. * Internal Use Only
  63063. */
  63064. reserved: boolean;
  63065. /**
  63066. * Gets the loaded texture
  63067. */
  63068. texture: HDRCubeTexture;
  63069. /**
  63070. * Callback called when the task is successful
  63071. */
  63072. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63073. /**
  63074. * Callback called when the task is successful
  63075. */
  63076. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63077. /**
  63078. * Creates a new HDRCubeTextureAssetTask object
  63079. * @param name defines the name of the task
  63080. * @param url defines the location of the file to load
  63081. * @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.
  63082. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63083. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63084. * @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)
  63085. * @param reserved Internal use only
  63086. */
  63087. constructor(
  63088. /**
  63089. * Defines the name of the task
  63090. */
  63091. name: string,
  63092. /**
  63093. * Defines the location of the file to load
  63094. */
  63095. url: string,
  63096. /**
  63097. * Defines the desired size (the more it increases the longer the generation will be)
  63098. */
  63099. size: number,
  63100. /**
  63101. * Defines if mipmaps should not be generated (default is false)
  63102. */
  63103. noMipmap?: boolean,
  63104. /**
  63105. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63106. */
  63107. generateHarmonics?: boolean,
  63108. /**
  63109. * 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)
  63110. */
  63111. gammaSpace?: boolean,
  63112. /**
  63113. * Internal Use Only
  63114. */
  63115. reserved?: boolean);
  63116. /**
  63117. * Execute the current task
  63118. * @param scene defines the scene where you want your assets to be loaded
  63119. * @param onSuccess is a callback called when the task is successfully executed
  63120. * @param onError is a callback called if an error occurs
  63121. */
  63122. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63123. }
  63124. /**
  63125. * Define a task used by AssetsManager to load Equirectangular cube textures
  63126. */
  63127. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63128. /**
  63129. * Defines the name of the task
  63130. */
  63131. name: string;
  63132. /**
  63133. * Defines the location of the file to load
  63134. */
  63135. url: string;
  63136. /**
  63137. * Defines the desired size (the more it increases the longer the generation will be)
  63138. */
  63139. size: number;
  63140. /**
  63141. * Defines if mipmaps should not be generated (default is false)
  63142. */
  63143. noMipmap: boolean;
  63144. /**
  63145. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63146. * but the standard material would require them in Gamma space) (default is true)
  63147. */
  63148. gammaSpace: boolean;
  63149. /**
  63150. * Gets the loaded texture
  63151. */
  63152. texture: EquiRectangularCubeTexture;
  63153. /**
  63154. * Callback called when the task is successful
  63155. */
  63156. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63157. /**
  63158. * Callback called when the task is successful
  63159. */
  63160. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63161. /**
  63162. * Creates a new EquiRectangularCubeTextureAssetTask object
  63163. * @param name defines the name of the task
  63164. * @param url defines the location of the file to load
  63165. * @param size defines the desired size (the more it increases the longer the generation will be)
  63166. * If the size is omitted this implies you are using a preprocessed cubemap.
  63167. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63168. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63169. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63170. * (default is true)
  63171. */
  63172. constructor(
  63173. /**
  63174. * Defines the name of the task
  63175. */
  63176. name: string,
  63177. /**
  63178. * Defines the location of the file to load
  63179. */
  63180. url: string,
  63181. /**
  63182. * Defines the desired size (the more it increases the longer the generation will be)
  63183. */
  63184. size: number,
  63185. /**
  63186. * Defines if mipmaps should not be generated (default is false)
  63187. */
  63188. noMipmap?: boolean,
  63189. /**
  63190. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63191. * but the standard material would require them in Gamma space) (default is true)
  63192. */
  63193. gammaSpace?: boolean);
  63194. /**
  63195. * Execute the current task
  63196. * @param scene defines the scene where you want your assets to be loaded
  63197. * @param onSuccess is a callback called when the task is successfully executed
  63198. * @param onError is a callback called if an error occurs
  63199. */
  63200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63201. }
  63202. /**
  63203. * This class can be used to easily import assets into a scene
  63204. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63205. */
  63206. export class AssetsManager {
  63207. private _scene;
  63208. private _isLoading;
  63209. protected _tasks: AbstractAssetTask[];
  63210. protected _waitingTasksCount: number;
  63211. protected _totalTasksCount: number;
  63212. /**
  63213. * Callback called when all tasks are processed
  63214. */
  63215. onFinish: (tasks: AbstractAssetTask[]) => void;
  63216. /**
  63217. * Callback called when a task is successful
  63218. */
  63219. onTaskSuccess: (task: AbstractAssetTask) => void;
  63220. /**
  63221. * Callback called when a task had an error
  63222. */
  63223. onTaskError: (task: AbstractAssetTask) => void;
  63224. /**
  63225. * Callback called when a task is done (whatever the result is)
  63226. */
  63227. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63228. /**
  63229. * Observable called when all tasks are processed
  63230. */
  63231. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63232. /**
  63233. * Observable called when a task had an error
  63234. */
  63235. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63236. /**
  63237. * Observable called when all tasks were executed
  63238. */
  63239. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63240. /**
  63241. * Observable called when a task is done (whatever the result is)
  63242. */
  63243. onProgressObservable: Observable<IAssetsProgressEvent>;
  63244. /**
  63245. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63247. */
  63248. useDefaultLoadingScreen: boolean;
  63249. /**
  63250. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63251. * when all assets have been downloaded.
  63252. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63253. */
  63254. autoHideLoadingUI: boolean;
  63255. /**
  63256. * Creates a new AssetsManager
  63257. * @param scene defines the scene to work on
  63258. */
  63259. constructor(scene: Scene);
  63260. /**
  63261. * Add a MeshAssetTask to the list of active tasks
  63262. * @param taskName defines the name of the new task
  63263. * @param meshesNames defines the name of meshes to load
  63264. * @param rootUrl defines the root url to use to locate files
  63265. * @param sceneFilename defines the filename of the scene file
  63266. * @returns a new MeshAssetTask object
  63267. */
  63268. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63269. /**
  63270. * Add a TextFileAssetTask to the list of active tasks
  63271. * @param taskName defines the name of the new task
  63272. * @param url defines the url of the file to load
  63273. * @returns a new TextFileAssetTask object
  63274. */
  63275. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63276. /**
  63277. * Add a BinaryFileAssetTask to the list of active tasks
  63278. * @param taskName defines the name of the new task
  63279. * @param url defines the url of the file to load
  63280. * @returns a new BinaryFileAssetTask object
  63281. */
  63282. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63283. /**
  63284. * Add a ImageAssetTask to the list of active tasks
  63285. * @param taskName defines the name of the new task
  63286. * @param url defines the url of the file to load
  63287. * @returns a new ImageAssetTask object
  63288. */
  63289. addImageTask(taskName: string, url: string): ImageAssetTask;
  63290. /**
  63291. * Add a TextureAssetTask to the list of active tasks
  63292. * @param taskName defines the name of the new task
  63293. * @param url defines the url of the file to load
  63294. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63295. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63296. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63297. * @returns a new TextureAssetTask object
  63298. */
  63299. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63300. /**
  63301. * Add a CubeTextureAssetTask to the list of active tasks
  63302. * @param taskName defines the name of the new task
  63303. * @param url defines the url of the file to load
  63304. * @param extensions defines the extension to use to load the cube map (can be null)
  63305. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63306. * @param files defines the list of files to load (can be null)
  63307. * @returns a new CubeTextureAssetTask object
  63308. */
  63309. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63310. /**
  63311. *
  63312. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63313. * @param taskName defines the name of the new task
  63314. * @param url defines the url of the file to load
  63315. * @param size defines the size you want for the cubemap (can be null)
  63316. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63317. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63318. * @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)
  63319. * @param reserved Internal use only
  63320. * @returns a new HDRCubeTextureAssetTask object
  63321. */
  63322. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63323. /**
  63324. *
  63325. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63326. * @param taskName defines the name of the new task
  63327. * @param url defines the url of the file to load
  63328. * @param size defines the size you want for the cubemap (can be null)
  63329. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63330. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63331. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63332. * @returns a new EquiRectangularCubeTextureAssetTask object
  63333. */
  63334. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63335. /**
  63336. * Remove a task from the assets manager.
  63337. * @param task the task to remove
  63338. */
  63339. removeTask(task: AbstractAssetTask): void;
  63340. private _decreaseWaitingTasksCount;
  63341. private _runTask;
  63342. /**
  63343. * Reset the AssetsManager and remove all tasks
  63344. * @return the current instance of the AssetsManager
  63345. */
  63346. reset(): AssetsManager;
  63347. /**
  63348. * Start the loading process
  63349. * @return the current instance of the AssetsManager
  63350. */
  63351. load(): AssetsManager;
  63352. /**
  63353. * Start the loading process as an async operation
  63354. * @return a promise returning the list of failed tasks
  63355. */
  63356. loadAsync(): Promise<void>;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * Wrapper class for promise with external resolve and reject.
  63362. */
  63363. export class Deferred<T> {
  63364. /**
  63365. * The promise associated with this deferred object.
  63366. */
  63367. readonly promise: Promise<T>;
  63368. private _resolve;
  63369. private _reject;
  63370. /**
  63371. * The resolve method of the promise associated with this deferred object.
  63372. */
  63373. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63374. /**
  63375. * The reject method of the promise associated with this deferred object.
  63376. */
  63377. readonly reject: (reason?: any) => void;
  63378. /**
  63379. * Constructor for this deferred object.
  63380. */
  63381. constructor();
  63382. }
  63383. }
  63384. declare module BABYLON {
  63385. /**
  63386. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63387. */
  63388. export class MeshExploder {
  63389. private _centerMesh;
  63390. private _meshes;
  63391. private _meshesOrigins;
  63392. private _toCenterVectors;
  63393. private _scaledDirection;
  63394. private _newPosition;
  63395. private _centerPosition;
  63396. /**
  63397. * Explodes meshes from a center mesh.
  63398. * @param meshes The meshes to explode.
  63399. * @param centerMesh The mesh to be center of explosion.
  63400. */
  63401. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63402. private _setCenterMesh;
  63403. /**
  63404. * Get class name
  63405. * @returns "MeshExploder"
  63406. */
  63407. getClassName(): string;
  63408. /**
  63409. * "Exploded meshes"
  63410. * @returns Array of meshes with the centerMesh at index 0.
  63411. */
  63412. getMeshes(): Array<Mesh>;
  63413. /**
  63414. * Explodes meshes giving a specific direction
  63415. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63416. */
  63417. explode(direction?: number): void;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * Class used to help managing file picking and drag'n'drop
  63423. */
  63424. export class FilesInput {
  63425. /**
  63426. * List of files ready to be loaded
  63427. */
  63428. static readonly FilesToLoad: {
  63429. [key: string]: File;
  63430. };
  63431. /**
  63432. * Callback called when a file is processed
  63433. */
  63434. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63435. private _engine;
  63436. private _currentScene;
  63437. private _sceneLoadedCallback;
  63438. private _progressCallback;
  63439. private _additionalRenderLoopLogicCallback;
  63440. private _textureLoadingCallback;
  63441. private _startingProcessingFilesCallback;
  63442. private _onReloadCallback;
  63443. private _errorCallback;
  63444. private _elementToMonitor;
  63445. private _sceneFileToLoad;
  63446. private _filesToLoad;
  63447. /**
  63448. * Creates a new FilesInput
  63449. * @param engine defines the rendering engine
  63450. * @param scene defines the hosting scene
  63451. * @param sceneLoadedCallback callback called when scene is loaded
  63452. * @param progressCallback callback called to track progress
  63453. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63454. * @param textureLoadingCallback callback called when a texture is loading
  63455. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63456. * @param onReloadCallback callback called when a reload is requested
  63457. * @param errorCallback callback call if an error occurs
  63458. */
  63459. 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);
  63460. private _dragEnterHandler;
  63461. private _dragOverHandler;
  63462. private _dropHandler;
  63463. /**
  63464. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63465. * @param elementToMonitor defines the DOM element to track
  63466. */
  63467. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63468. /**
  63469. * Release all associated resources
  63470. */
  63471. dispose(): void;
  63472. private renderFunction;
  63473. private drag;
  63474. private drop;
  63475. private _traverseFolder;
  63476. private _processFiles;
  63477. /**
  63478. * Load files from a drop event
  63479. * @param event defines the drop event to use as source
  63480. */
  63481. loadFiles(event: any): void;
  63482. private _processReload;
  63483. /**
  63484. * Reload the current scene from the loaded files
  63485. */
  63486. reload(): void;
  63487. }
  63488. }
  63489. declare module BABYLON {
  63490. /**
  63491. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63493. */
  63494. export class SceneOptimization {
  63495. /**
  63496. * Defines the priority of this optimization (0 by default which means first in the list)
  63497. */
  63498. priority: number;
  63499. /**
  63500. * Gets a string describing the action executed by the current optimization
  63501. * @returns description string
  63502. */
  63503. getDescription(): string;
  63504. /**
  63505. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63506. * @param scene defines the current scene where to apply this optimization
  63507. * @param optimizer defines the current optimizer
  63508. * @returns true if everything that can be done was applied
  63509. */
  63510. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63511. /**
  63512. * Creates the SceneOptimization object
  63513. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63514. * @param desc defines the description associated with the optimization
  63515. */
  63516. constructor(
  63517. /**
  63518. * Defines the priority of this optimization (0 by default which means first in the list)
  63519. */
  63520. priority?: number);
  63521. }
  63522. /**
  63523. * Defines an optimization used to reduce the size of render target textures
  63524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63525. */
  63526. export class TextureOptimization extends SceneOptimization {
  63527. /**
  63528. * Defines the priority of this optimization (0 by default which means first in the list)
  63529. */
  63530. priority: number;
  63531. /**
  63532. * 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
  63533. */
  63534. maximumSize: number;
  63535. /**
  63536. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63537. */
  63538. step: number;
  63539. /**
  63540. * Gets a string describing the action executed by the current optimization
  63541. * @returns description string
  63542. */
  63543. getDescription(): string;
  63544. /**
  63545. * Creates the TextureOptimization object
  63546. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63547. * @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
  63548. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63549. */
  63550. constructor(
  63551. /**
  63552. * Defines the priority of this optimization (0 by default which means first in the list)
  63553. */
  63554. priority?: number,
  63555. /**
  63556. * 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
  63557. */
  63558. maximumSize?: number,
  63559. /**
  63560. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63561. */
  63562. step?: number);
  63563. /**
  63564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63565. * @param scene defines the current scene where to apply this optimization
  63566. * @param optimizer defines the current optimizer
  63567. * @returns true if everything that can be done was applied
  63568. */
  63569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63570. }
  63571. /**
  63572. * Defines an optimization used to increase or decrease the rendering resolution
  63573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63574. */
  63575. export class HardwareScalingOptimization extends SceneOptimization {
  63576. /**
  63577. * Defines the priority of this optimization (0 by default which means first in the list)
  63578. */
  63579. priority: number;
  63580. /**
  63581. * Defines the maximum scale to use (2 by default)
  63582. */
  63583. maximumScale: number;
  63584. /**
  63585. * Defines the step to use between two passes (0.5 by default)
  63586. */
  63587. step: number;
  63588. private _currentScale;
  63589. private _directionOffset;
  63590. /**
  63591. * Gets a string describing the action executed by the current optimization
  63592. * @return description string
  63593. */
  63594. getDescription(): string;
  63595. /**
  63596. * Creates the HardwareScalingOptimization object
  63597. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63598. * @param maximumScale defines the maximum scale to use (2 by default)
  63599. * @param step defines the step to use between two passes (0.5 by default)
  63600. */
  63601. constructor(
  63602. /**
  63603. * Defines the priority of this optimization (0 by default which means first in the list)
  63604. */
  63605. priority?: number,
  63606. /**
  63607. * Defines the maximum scale to use (2 by default)
  63608. */
  63609. maximumScale?: number,
  63610. /**
  63611. * Defines the step to use between two passes (0.5 by default)
  63612. */
  63613. step?: number);
  63614. /**
  63615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63616. * @param scene defines the current scene where to apply this optimization
  63617. * @param optimizer defines the current optimizer
  63618. * @returns true if everything that can be done was applied
  63619. */
  63620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63621. }
  63622. /**
  63623. * Defines an optimization used to remove shadows
  63624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63625. */
  63626. export class ShadowsOptimization extends SceneOptimization {
  63627. /**
  63628. * Gets a string describing the action executed by the current optimization
  63629. * @return description string
  63630. */
  63631. getDescription(): string;
  63632. /**
  63633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63634. * @param scene defines the current scene where to apply this optimization
  63635. * @param optimizer defines the current optimizer
  63636. * @returns true if everything that can be done was applied
  63637. */
  63638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63639. }
  63640. /**
  63641. * Defines an optimization used to turn post-processes off
  63642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63643. */
  63644. export class PostProcessesOptimization extends SceneOptimization {
  63645. /**
  63646. * Gets a string describing the action executed by the current optimization
  63647. * @return description string
  63648. */
  63649. getDescription(): string;
  63650. /**
  63651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63652. * @param scene defines the current scene where to apply this optimization
  63653. * @param optimizer defines the current optimizer
  63654. * @returns true if everything that can be done was applied
  63655. */
  63656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63657. }
  63658. /**
  63659. * Defines an optimization used to turn lens flares off
  63660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63661. */
  63662. export class LensFlaresOptimization extends SceneOptimization {
  63663. /**
  63664. * Gets a string describing the action executed by the current optimization
  63665. * @return description string
  63666. */
  63667. getDescription(): string;
  63668. /**
  63669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63670. * @param scene defines the current scene where to apply this optimization
  63671. * @param optimizer defines the current optimizer
  63672. * @returns true if everything that can be done was applied
  63673. */
  63674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63675. }
  63676. /**
  63677. * Defines an optimization based on user defined callback.
  63678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63679. */
  63680. export class CustomOptimization extends SceneOptimization {
  63681. /**
  63682. * Callback called to apply the custom optimization.
  63683. */
  63684. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63685. /**
  63686. * Callback called to get custom description
  63687. */
  63688. onGetDescription: () => string;
  63689. /**
  63690. * Gets a string describing the action executed by the current optimization
  63691. * @returns description string
  63692. */
  63693. getDescription(): string;
  63694. /**
  63695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63696. * @param scene defines the current scene where to apply this optimization
  63697. * @param optimizer defines the current optimizer
  63698. * @returns true if everything that can be done was applied
  63699. */
  63700. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63701. }
  63702. /**
  63703. * Defines an optimization used to turn particles off
  63704. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63705. */
  63706. export class ParticlesOptimization extends SceneOptimization {
  63707. /**
  63708. * Gets a string describing the action executed by the current optimization
  63709. * @return description string
  63710. */
  63711. getDescription(): string;
  63712. /**
  63713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63714. * @param scene defines the current scene where to apply this optimization
  63715. * @param optimizer defines the current optimizer
  63716. * @returns true if everything that can be done was applied
  63717. */
  63718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63719. }
  63720. /**
  63721. * Defines an optimization used to turn render targets off
  63722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63723. */
  63724. export class RenderTargetsOptimization extends SceneOptimization {
  63725. /**
  63726. * Gets a string describing the action executed by the current optimization
  63727. * @return description string
  63728. */
  63729. getDescription(): string;
  63730. /**
  63731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63732. * @param scene defines the current scene where to apply this optimization
  63733. * @param optimizer defines the current optimizer
  63734. * @returns true if everything that can be done was applied
  63735. */
  63736. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63737. }
  63738. /**
  63739. * Defines an optimization used to merge meshes with compatible materials
  63740. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63741. */
  63742. export class MergeMeshesOptimization extends SceneOptimization {
  63743. private static _UpdateSelectionTree;
  63744. /**
  63745. * Gets or sets a boolean which defines if optimization octree has to be updated
  63746. */
  63747. /**
  63748. * Gets or sets a boolean which defines if optimization octree has to be updated
  63749. */
  63750. static UpdateSelectionTree: boolean;
  63751. /**
  63752. * Gets a string describing the action executed by the current optimization
  63753. * @return description string
  63754. */
  63755. getDescription(): string;
  63756. private _canBeMerged;
  63757. /**
  63758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63759. * @param scene defines the current scene where to apply this optimization
  63760. * @param optimizer defines the current optimizer
  63761. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63762. * @returns true if everything that can be done was applied
  63763. */
  63764. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63765. }
  63766. /**
  63767. * Defines a list of options used by SceneOptimizer
  63768. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63769. */
  63770. export class SceneOptimizerOptions {
  63771. /**
  63772. * Defines the target frame rate to reach (60 by default)
  63773. */
  63774. targetFrameRate: number;
  63775. /**
  63776. * Defines the interval between two checkes (2000ms by default)
  63777. */
  63778. trackerDuration: number;
  63779. /**
  63780. * Gets the list of optimizations to apply
  63781. */
  63782. optimizations: SceneOptimization[];
  63783. /**
  63784. * Creates a new list of options used by SceneOptimizer
  63785. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63786. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63787. */
  63788. constructor(
  63789. /**
  63790. * Defines the target frame rate to reach (60 by default)
  63791. */
  63792. targetFrameRate?: number,
  63793. /**
  63794. * Defines the interval between two checkes (2000ms by default)
  63795. */
  63796. trackerDuration?: number);
  63797. /**
  63798. * Add a new optimization
  63799. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63800. * @returns the current SceneOptimizerOptions
  63801. */
  63802. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63803. /**
  63804. * Add a new custom optimization
  63805. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63806. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63808. * @returns the current SceneOptimizerOptions
  63809. */
  63810. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63811. /**
  63812. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63813. * @param targetFrameRate defines the target frame rate (60 by default)
  63814. * @returns a SceneOptimizerOptions object
  63815. */
  63816. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63817. /**
  63818. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63819. * @param targetFrameRate defines the target frame rate (60 by default)
  63820. * @returns a SceneOptimizerOptions object
  63821. */
  63822. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63823. /**
  63824. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63825. * @param targetFrameRate defines the target frame rate (60 by default)
  63826. * @returns a SceneOptimizerOptions object
  63827. */
  63828. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63829. }
  63830. /**
  63831. * Class used to run optimizations in order to reach a target frame rate
  63832. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63833. */
  63834. export class SceneOptimizer implements IDisposable {
  63835. private _isRunning;
  63836. private _options;
  63837. private _scene;
  63838. private _currentPriorityLevel;
  63839. private _targetFrameRate;
  63840. private _trackerDuration;
  63841. private _currentFrameRate;
  63842. private _sceneDisposeObserver;
  63843. private _improvementMode;
  63844. /**
  63845. * Defines an observable called when the optimizer reaches the target frame rate
  63846. */
  63847. onSuccessObservable: Observable<SceneOptimizer>;
  63848. /**
  63849. * Defines an observable called when the optimizer enables an optimization
  63850. */
  63851. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63852. /**
  63853. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63854. */
  63855. onFailureObservable: Observable<SceneOptimizer>;
  63856. /**
  63857. * Gets a boolean indicating if the optimizer is in improvement mode
  63858. */
  63859. readonly isInImprovementMode: boolean;
  63860. /**
  63861. * Gets the current priority level (0 at start)
  63862. */
  63863. readonly currentPriorityLevel: number;
  63864. /**
  63865. * Gets the current frame rate checked by the SceneOptimizer
  63866. */
  63867. readonly currentFrameRate: number;
  63868. /**
  63869. * Gets or sets the current target frame rate (60 by default)
  63870. */
  63871. /**
  63872. * Gets or sets the current target frame rate (60 by default)
  63873. */
  63874. targetFrameRate: number;
  63875. /**
  63876. * Gets or sets the current interval between two checks (every 2000ms by default)
  63877. */
  63878. /**
  63879. * Gets or sets the current interval between two checks (every 2000ms by default)
  63880. */
  63881. trackerDuration: number;
  63882. /**
  63883. * Gets the list of active optimizations
  63884. */
  63885. readonly optimizations: SceneOptimization[];
  63886. /**
  63887. * Creates a new SceneOptimizer
  63888. * @param scene defines the scene to work on
  63889. * @param options defines the options to use with the SceneOptimizer
  63890. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63891. * @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)
  63892. */
  63893. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63894. /**
  63895. * Stops the current optimizer
  63896. */
  63897. stop(): void;
  63898. /**
  63899. * Reset the optimizer to initial step (current priority level = 0)
  63900. */
  63901. reset(): void;
  63902. /**
  63903. * Start the optimizer. By default it will try to reach a specific framerate
  63904. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63905. */
  63906. start(): void;
  63907. private _checkCurrentState;
  63908. /**
  63909. * Release all resources
  63910. */
  63911. dispose(): void;
  63912. /**
  63913. * Helper function to create a SceneOptimizer with one single line of code
  63914. * @param scene defines the scene to work on
  63915. * @param options defines the options to use with the SceneOptimizer
  63916. * @param onSuccess defines a callback to call on success
  63917. * @param onFailure defines a callback to call on failure
  63918. * @returns the new SceneOptimizer object
  63919. */
  63920. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Class used to serialize a scene into a string
  63926. */
  63927. export class SceneSerializer {
  63928. /**
  63929. * Clear cache used by a previous serialization
  63930. */
  63931. static ClearCache(): void;
  63932. /**
  63933. * Serialize a scene into a JSON compatible object
  63934. * @param scene defines the scene to serialize
  63935. * @returns a JSON compatible object
  63936. */
  63937. static Serialize(scene: Scene): any;
  63938. /**
  63939. * Serialize a mesh into a JSON compatible object
  63940. * @param toSerialize defines the mesh to serialize
  63941. * @param withParents defines if parents must be serialized as well
  63942. * @param withChildren defines if children must be serialized as well
  63943. * @returns a JSON compatible object
  63944. */
  63945. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63946. }
  63947. }
  63948. declare module BABYLON {
  63949. /**
  63950. * Class used to host texture specific utilities
  63951. */
  63952. export class TextureTools {
  63953. /**
  63954. * Uses the GPU to create a copy texture rescaled at a given size
  63955. * @param texture Texture to copy from
  63956. * @param width defines the desired width
  63957. * @param height defines the desired height
  63958. * @param useBilinearMode defines if bilinear mode has to be used
  63959. * @return the generated texture
  63960. */
  63961. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63962. }
  63963. }
  63964. declare module BABYLON {
  63965. /**
  63966. * This represents the different options available for the video capture.
  63967. */
  63968. export interface VideoRecorderOptions {
  63969. /** Defines the mime type of the video. */
  63970. mimeType: string;
  63971. /** Defines the FPS the video should be recorded at. */
  63972. fps: number;
  63973. /** Defines the chunk size for the recording data. */
  63974. recordChunckSize: number;
  63975. /** The audio tracks to attach to the recording. */
  63976. audioTracks?: MediaStreamTrack[];
  63977. }
  63978. /**
  63979. * This can help with recording videos from BabylonJS.
  63980. * This is based on the available WebRTC functionalities of the browser.
  63981. *
  63982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63983. */
  63984. export class VideoRecorder {
  63985. private static readonly _defaultOptions;
  63986. /**
  63987. * Returns whether or not the VideoRecorder is available in your browser.
  63988. * @param engine Defines the Babylon Engine.
  63989. * @returns true if supported otherwise false.
  63990. */
  63991. static IsSupported(engine: Engine): boolean;
  63992. private readonly _options;
  63993. private _canvas;
  63994. private _mediaRecorder;
  63995. private _recordedChunks;
  63996. private _fileName;
  63997. private _resolve;
  63998. private _reject;
  63999. /**
  64000. * True when a recording is already in progress.
  64001. */
  64002. readonly isRecording: boolean;
  64003. /**
  64004. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64005. * @param engine Defines the BabylonJS Engine you wish to record.
  64006. * @param options Defines options that can be used to customize the capture.
  64007. */
  64008. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64009. /**
  64010. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64011. */
  64012. stopRecording(): void;
  64013. /**
  64014. * Starts recording the canvas for a max duration specified in parameters.
  64015. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64016. * If null no automatic download will start and you can rely on the promise to get the data back.
  64017. * @param maxDuration Defines the maximum recording time in seconds.
  64018. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64019. * @return A promise callback at the end of the recording with the video data in Blob.
  64020. */
  64021. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64022. /**
  64023. * Releases internal resources used during the recording.
  64024. */
  64025. dispose(): void;
  64026. private _handleDataAvailable;
  64027. private _handleError;
  64028. private _handleStop;
  64029. }
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * Class containing a set of static utilities functions for screenshots
  64034. */
  64035. export class ScreenshotTools {
  64036. /**
  64037. * Captures a screenshot of the current rendering
  64038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64039. * @param engine defines the rendering engine
  64040. * @param camera defines the source camera
  64041. * @param size This parameter can be set to a single number or to an object with the
  64042. * following (optional) properties: precision, width, height. If a single number is passed,
  64043. * it will be used for both width and height. If an object is passed, the screenshot size
  64044. * will be derived from the parameters. The precision property is a multiplier allowing
  64045. * rendering at a higher or lower resolution
  64046. * @param successCallback defines the callback receives a single parameter which contains the
  64047. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64048. * src parameter of an <img> to display it
  64049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64050. * Check your browser for supported MIME types
  64051. */
  64052. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64053. /**
  64054. * Captures a screenshot of the current rendering
  64055. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64056. * @param engine defines the rendering engine
  64057. * @param camera defines the source camera
  64058. * @param size This parameter can be set to a single number or to an object with the
  64059. * following (optional) properties: precision, width, height. If a single number is passed,
  64060. * it will be used for both width and height. If an object is passed, the screenshot size
  64061. * will be derived from the parameters. The precision property is a multiplier allowing
  64062. * rendering at a higher or lower resolution
  64063. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64064. * Check your browser for supported MIME types
  64065. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64066. * to the src parameter of an <img> to display it
  64067. */
  64068. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64069. /**
  64070. * Generates an image screenshot from the specified camera.
  64071. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64072. * @param engine The engine to use for rendering
  64073. * @param camera The camera to use for rendering
  64074. * @param size This parameter can be set to a single number or to an object with the
  64075. * following (optional) properties: precision, width, height. If a single number is passed,
  64076. * it will be used for both width and height. If an object is passed, the screenshot size
  64077. * will be derived from the parameters. The precision property is a multiplier allowing
  64078. * rendering at a higher or lower resolution
  64079. * @param successCallback The callback receives a single parameter which contains the
  64080. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64081. * src parameter of an <img> to display it
  64082. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64083. * Check your browser for supported MIME types
  64084. * @param samples Texture samples (default: 1)
  64085. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64086. * @param fileName A name for for the downloaded file.
  64087. */
  64088. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64089. /**
  64090. * Generates an image screenshot from the specified camera.
  64091. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64092. * @param engine The engine to use for rendering
  64093. * @param camera The camera to use for rendering
  64094. * @param size This parameter can be set to a single number or to an object with the
  64095. * following (optional) properties: precision, width, height. If a single number is passed,
  64096. * it will be used for both width and height. If an object is passed, the screenshot size
  64097. * will be derived from the parameters. The precision property is a multiplier allowing
  64098. * rendering at a higher or lower resolution
  64099. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64100. * Check your browser for supported MIME types
  64101. * @param samples Texture samples (default: 1)
  64102. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64103. * @param fileName A name for for the downloaded file.
  64104. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64105. * to the src parameter of an <img> to display it
  64106. */
  64107. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64108. /**
  64109. * Gets height and width for screenshot size
  64110. * @private
  64111. */
  64112. private static _getScreenshotSize;
  64113. }
  64114. }
  64115. declare module BABYLON {
  64116. /**
  64117. * Interface for a data buffer
  64118. */
  64119. export interface IDataBuffer {
  64120. /**
  64121. * Reads bytes from the data buffer.
  64122. * @param byteOffset The byte offset to read
  64123. * @param byteLength The byte length to read
  64124. * @returns A promise that resolves when the bytes are read
  64125. */
  64126. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64127. /**
  64128. * The byte length of the buffer.
  64129. */
  64130. readonly byteLength: number;
  64131. }
  64132. /**
  64133. * Utility class for reading from a data buffer
  64134. */
  64135. export class DataReader {
  64136. /**
  64137. * The data buffer associated with this data reader.
  64138. */
  64139. readonly buffer: IDataBuffer;
  64140. /**
  64141. * The current byte offset from the beginning of the data buffer.
  64142. */
  64143. byteOffset: number;
  64144. private _dataView;
  64145. private _dataByteOffset;
  64146. /**
  64147. * Constructor
  64148. * @param buffer The buffer to read
  64149. */
  64150. constructor(buffer: IDataBuffer);
  64151. /**
  64152. * Loads the given byte length.
  64153. * @param byteLength The byte length to load
  64154. * @returns A promise that resolves when the load is complete
  64155. */
  64156. loadAsync(byteLength: number): Promise<void>;
  64157. /**
  64158. * Read a unsigned 32-bit integer from the currently loaded data range.
  64159. * @returns The 32-bit integer read
  64160. */
  64161. readUint32(): number;
  64162. /**
  64163. * Read a byte array from the currently loaded data range.
  64164. * @param byteLength The byte length to read
  64165. * @returns The byte array read
  64166. */
  64167. readUint8Array(byteLength: number): Uint8Array;
  64168. /**
  64169. * Read a string from the currently loaded data range.
  64170. * @param byteLength The byte length to read
  64171. * @returns The string read
  64172. */
  64173. readString(byteLength: number): string;
  64174. /**
  64175. * Skips the given byte length the currently loaded data range.
  64176. * @param byteLength The byte length to skip
  64177. */
  64178. skipBytes(byteLength: number): void;
  64179. }
  64180. }
  64181. declare module BABYLON {
  64182. /**
  64183. * A cursor which tracks a point on a path
  64184. */
  64185. export class PathCursor {
  64186. private path;
  64187. /**
  64188. * Stores path cursor callbacks for when an onchange event is triggered
  64189. */
  64190. private _onchange;
  64191. /**
  64192. * The value of the path cursor
  64193. */
  64194. value: number;
  64195. /**
  64196. * The animation array of the path cursor
  64197. */
  64198. animations: Animation[];
  64199. /**
  64200. * Initializes the path cursor
  64201. * @param path The path to track
  64202. */
  64203. constructor(path: Path2);
  64204. /**
  64205. * Gets the cursor point on the path
  64206. * @returns A point on the path cursor at the cursor location
  64207. */
  64208. getPoint(): Vector3;
  64209. /**
  64210. * Moves the cursor ahead by the step amount
  64211. * @param step The amount to move the cursor forward
  64212. * @returns This path cursor
  64213. */
  64214. moveAhead(step?: number): PathCursor;
  64215. /**
  64216. * Moves the cursor behind by the step amount
  64217. * @param step The amount to move the cursor back
  64218. * @returns This path cursor
  64219. */
  64220. moveBack(step?: number): PathCursor;
  64221. /**
  64222. * Moves the cursor by the step amount
  64223. * If the step amount is greater than one, an exception is thrown
  64224. * @param step The amount to move the cursor
  64225. * @returns This path cursor
  64226. */
  64227. move(step: number): PathCursor;
  64228. /**
  64229. * Ensures that the value is limited between zero and one
  64230. * @returns This path cursor
  64231. */
  64232. private ensureLimits;
  64233. /**
  64234. * Runs onchange callbacks on change (used by the animation engine)
  64235. * @returns This path cursor
  64236. */
  64237. private raiseOnChange;
  64238. /**
  64239. * Executes a function on change
  64240. * @param f A path cursor onchange callback
  64241. * @returns This path cursor
  64242. */
  64243. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64244. }
  64245. }
  64246. declare module BABYLON {
  64247. /** @hidden */
  64248. export var blurPixelShader: {
  64249. name: string;
  64250. shader: string;
  64251. };
  64252. }
  64253. declare module BABYLON {
  64254. /** @hidden */
  64255. export var pointCloudVertexDeclaration: {
  64256. name: string;
  64257. shader: string;
  64258. };
  64259. }
  64260. // Mixins
  64261. interface Window {
  64262. mozIndexedDB: IDBFactory;
  64263. webkitIndexedDB: IDBFactory;
  64264. msIndexedDB: IDBFactory;
  64265. webkitURL: typeof URL;
  64266. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64267. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64268. WebGLRenderingContext: WebGLRenderingContext;
  64269. MSGesture: MSGesture;
  64270. CANNON: any;
  64271. AudioContext: AudioContext;
  64272. webkitAudioContext: AudioContext;
  64273. PointerEvent: any;
  64274. Math: Math;
  64275. Uint8Array: Uint8ArrayConstructor;
  64276. Float32Array: Float32ArrayConstructor;
  64277. mozURL: typeof URL;
  64278. msURL: typeof URL;
  64279. VRFrameData: any; // WebVR, from specs 1.1
  64280. DracoDecoderModule: any;
  64281. setImmediate(handler: (...args: any[]) => void): number;
  64282. }
  64283. interface HTMLCanvasElement {
  64284. requestPointerLock(): void;
  64285. msRequestPointerLock?(): void;
  64286. mozRequestPointerLock?(): void;
  64287. webkitRequestPointerLock?(): void;
  64288. /** Track wether a record is in progress */
  64289. isRecording: boolean;
  64290. /** Capture Stream method defined by some browsers */
  64291. captureStream(fps?: number): MediaStream;
  64292. }
  64293. interface CanvasRenderingContext2D {
  64294. msImageSmoothingEnabled: boolean;
  64295. }
  64296. interface MouseEvent {
  64297. mozMovementX: number;
  64298. mozMovementY: number;
  64299. webkitMovementX: number;
  64300. webkitMovementY: number;
  64301. msMovementX: number;
  64302. msMovementY: number;
  64303. }
  64304. interface Navigator {
  64305. mozGetVRDevices: (any: any) => any;
  64306. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64307. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64308. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64309. webkitGetGamepads(): Gamepad[];
  64310. msGetGamepads(): Gamepad[];
  64311. webkitGamepads(): Gamepad[];
  64312. }
  64313. interface HTMLVideoElement {
  64314. mozSrcObject: any;
  64315. }
  64316. interface Math {
  64317. fround(x: number): number;
  64318. imul(a: number, b: number): number;
  64319. }
  64320. interface WebGLRenderingContext {
  64321. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64322. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64323. vertexAttribDivisor(index: number, divisor: number): void;
  64324. createVertexArray(): any;
  64325. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64326. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64327. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64328. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64329. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64330. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64331. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64332. // Queries
  64333. createQuery(): WebGLQuery;
  64334. deleteQuery(query: WebGLQuery): void;
  64335. beginQuery(target: number, query: WebGLQuery): void;
  64336. endQuery(target: number): void;
  64337. getQueryParameter(query: WebGLQuery, pname: number): any;
  64338. getQuery(target: number, pname: number): any;
  64339. MAX_SAMPLES: number;
  64340. RGBA8: number;
  64341. READ_FRAMEBUFFER: number;
  64342. DRAW_FRAMEBUFFER: number;
  64343. UNIFORM_BUFFER: number;
  64344. HALF_FLOAT_OES: number;
  64345. RGBA16F: number;
  64346. RGBA32F: number;
  64347. R32F: number;
  64348. RG32F: number;
  64349. RGB32F: number;
  64350. R16F: number;
  64351. RG16F: number;
  64352. RGB16F: number;
  64353. RED: number;
  64354. RG: number;
  64355. R8: number;
  64356. RG8: number;
  64357. UNSIGNED_INT_24_8: number;
  64358. DEPTH24_STENCIL8: number;
  64359. MIN: number;
  64360. MAX: number;
  64361. /* Multiple Render Targets */
  64362. drawBuffers(buffers: number[]): void;
  64363. readBuffer(src: number): void;
  64364. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64365. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64366. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64367. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64368. // Occlusion Query
  64369. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64370. ANY_SAMPLES_PASSED: number;
  64371. QUERY_RESULT_AVAILABLE: number;
  64372. QUERY_RESULT: number;
  64373. }
  64374. interface WebGLProgram {
  64375. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64376. }
  64377. interface EXT_disjoint_timer_query {
  64378. QUERY_COUNTER_BITS_EXT: number;
  64379. TIME_ELAPSED_EXT: number;
  64380. TIMESTAMP_EXT: number;
  64381. GPU_DISJOINT_EXT: number;
  64382. QUERY_RESULT_EXT: number;
  64383. QUERY_RESULT_AVAILABLE_EXT: number;
  64384. queryCounterEXT(query: WebGLQuery, target: number): void;
  64385. createQueryEXT(): WebGLQuery;
  64386. beginQueryEXT(target: number, query: WebGLQuery): void;
  64387. endQueryEXT(target: number): void;
  64388. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64389. deleteQueryEXT(query: WebGLQuery): void;
  64390. }
  64391. interface WebGLUniformLocation {
  64392. _currentState: any;
  64393. }
  64394. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64395. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64396. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64397. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64398. interface WebGLRenderingContext {
  64399. readonly RASTERIZER_DISCARD: number;
  64400. readonly DEPTH_COMPONENT24: number;
  64401. readonly TEXTURE_3D: number;
  64402. readonly TEXTURE_2D_ARRAY: number;
  64403. readonly TEXTURE_COMPARE_FUNC: number;
  64404. readonly TEXTURE_COMPARE_MODE: number;
  64405. readonly COMPARE_REF_TO_TEXTURE: number;
  64406. readonly TEXTURE_WRAP_R: number;
  64407. readonly HALF_FLOAT: number;
  64408. readonly RGB8: number;
  64409. readonly RED_INTEGER: number;
  64410. readonly RG_INTEGER: number;
  64411. readonly RGB_INTEGER: number;
  64412. readonly RGBA_INTEGER: number;
  64413. readonly R8_SNORM: number;
  64414. readonly RG8_SNORM: number;
  64415. readonly RGB8_SNORM: number;
  64416. readonly RGBA8_SNORM: number;
  64417. readonly R8I: number;
  64418. readonly RG8I: number;
  64419. readonly RGB8I: number;
  64420. readonly RGBA8I: number;
  64421. readonly R8UI: number;
  64422. readonly RG8UI: number;
  64423. readonly RGB8UI: number;
  64424. readonly RGBA8UI: number;
  64425. readonly R16I: number;
  64426. readonly RG16I: number;
  64427. readonly RGB16I: number;
  64428. readonly RGBA16I: number;
  64429. readonly R16UI: number;
  64430. readonly RG16UI: number;
  64431. readonly RGB16UI: number;
  64432. readonly RGBA16UI: number;
  64433. readonly R32I: number;
  64434. readonly RG32I: number;
  64435. readonly RGB32I: number;
  64436. readonly RGBA32I: number;
  64437. readonly R32UI: number;
  64438. readonly RG32UI: number;
  64439. readonly RGB32UI: number;
  64440. readonly RGBA32UI: number;
  64441. readonly RGB10_A2UI: number;
  64442. readonly R11F_G11F_B10F: number;
  64443. readonly RGB9_E5: number;
  64444. readonly RGB10_A2: number;
  64445. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64446. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64447. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64448. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64449. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64450. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64451. 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;
  64452. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64453. readonly TRANSFORM_FEEDBACK: number;
  64454. readonly INTERLEAVED_ATTRIBS: number;
  64455. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64456. createTransformFeedback(): WebGLTransformFeedback;
  64457. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64458. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64459. beginTransformFeedback(primitiveMode: number): void;
  64460. endTransformFeedback(): void;
  64461. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64462. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64463. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64464. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64465. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64466. }
  64467. interface ImageBitmap {
  64468. readonly width: number;
  64469. readonly height: number;
  64470. close(): void;
  64471. }
  64472. interface WebGLQuery extends WebGLObject {
  64473. }
  64474. declare var WebGLQuery: {
  64475. prototype: WebGLQuery;
  64476. new(): WebGLQuery;
  64477. };
  64478. interface WebGLSampler extends WebGLObject {
  64479. }
  64480. declare var WebGLSampler: {
  64481. prototype: WebGLSampler;
  64482. new(): WebGLSampler;
  64483. };
  64484. interface WebGLSync extends WebGLObject {
  64485. }
  64486. declare var WebGLSync: {
  64487. prototype: WebGLSync;
  64488. new(): WebGLSync;
  64489. };
  64490. interface WebGLTransformFeedback extends WebGLObject {
  64491. }
  64492. declare var WebGLTransformFeedback: {
  64493. prototype: WebGLTransformFeedback;
  64494. new(): WebGLTransformFeedback;
  64495. };
  64496. interface WebGLVertexArrayObject extends WebGLObject {
  64497. }
  64498. declare var WebGLVertexArrayObject: {
  64499. prototype: WebGLVertexArrayObject;
  64500. new(): WebGLVertexArrayObject;
  64501. };
  64502. // Type definitions for WebVR API
  64503. // Project: https://w3c.github.io/webvr/
  64504. // Definitions by: six a <https://github.com/lostfictions>
  64505. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64506. interface VRDisplay extends EventTarget {
  64507. /**
  64508. * Dictionary of capabilities describing the VRDisplay.
  64509. */
  64510. readonly capabilities: VRDisplayCapabilities;
  64511. /**
  64512. * z-depth defining the far plane of the eye view frustum
  64513. * enables mapping of values in the render target depth
  64514. * attachment to scene coordinates. Initially set to 10000.0.
  64515. */
  64516. depthFar: number;
  64517. /**
  64518. * z-depth defining the near plane of the eye view frustum
  64519. * enables mapping of values in the render target depth
  64520. * attachment to scene coordinates. Initially set to 0.01.
  64521. */
  64522. depthNear: number;
  64523. /**
  64524. * An identifier for this distinct VRDisplay. Used as an
  64525. * association point in the Gamepad API.
  64526. */
  64527. readonly displayId: number;
  64528. /**
  64529. * A display name, a user-readable name identifying it.
  64530. */
  64531. readonly displayName: string;
  64532. readonly isConnected: boolean;
  64533. readonly isPresenting: boolean;
  64534. /**
  64535. * If this VRDisplay supports room-scale experiences, the optional
  64536. * stage attribute contains details on the room-scale parameters.
  64537. */
  64538. readonly stageParameters: VRStageParameters | null;
  64539. /**
  64540. * Passing the value returned by `requestAnimationFrame` to
  64541. * `cancelAnimationFrame` will unregister the callback.
  64542. * @param handle Define the hanle of the request to cancel
  64543. */
  64544. cancelAnimationFrame(handle: number): void;
  64545. /**
  64546. * Stops presenting to the VRDisplay.
  64547. * @returns a promise to know when it stopped
  64548. */
  64549. exitPresent(): Promise<void>;
  64550. /**
  64551. * Return the current VREyeParameters for the given eye.
  64552. * @param whichEye Define the eye we want the parameter for
  64553. * @returns the eye parameters
  64554. */
  64555. getEyeParameters(whichEye: string): VREyeParameters;
  64556. /**
  64557. * Populates the passed VRFrameData with the information required to render
  64558. * the current frame.
  64559. * @param frameData Define the data structure to populate
  64560. * @returns true if ok otherwise false
  64561. */
  64562. getFrameData(frameData: VRFrameData): boolean;
  64563. /**
  64564. * Get the layers currently being presented.
  64565. * @returns the list of VR layers
  64566. */
  64567. getLayers(): VRLayer[];
  64568. /**
  64569. * Return a VRPose containing the future predicted pose of the VRDisplay
  64570. * when the current frame will be presented. The value returned will not
  64571. * change until JavaScript has returned control to the browser.
  64572. *
  64573. * The VRPose will contain the position, orientation, velocity,
  64574. * and acceleration of each of these properties.
  64575. * @returns the pose object
  64576. */
  64577. getPose(): VRPose;
  64578. /**
  64579. * Return the current instantaneous pose of the VRDisplay, with no
  64580. * prediction applied.
  64581. * @returns the current instantaneous pose
  64582. */
  64583. getImmediatePose(): VRPose;
  64584. /**
  64585. * The callback passed to `requestAnimationFrame` will be called
  64586. * any time a new frame should be rendered. When the VRDisplay is
  64587. * presenting the callback will be called at the native refresh
  64588. * rate of the HMD. When not presenting this function acts
  64589. * identically to how window.requestAnimationFrame acts. Content should
  64590. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64591. * asynchronously from other displays and at differing refresh rates.
  64592. * @param callback Define the eaction to run next frame
  64593. * @returns the request handle it
  64594. */
  64595. requestAnimationFrame(callback: FrameRequestCallback): number;
  64596. /**
  64597. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64598. * Repeat calls while already presenting will update the VRLayers being displayed.
  64599. * @param layers Define the list of layer to present
  64600. * @returns a promise to know when the request has been fulfilled
  64601. */
  64602. requestPresent(layers: VRLayer[]): Promise<void>;
  64603. /**
  64604. * Reset the pose for this display, treating its current position and
  64605. * orientation as the "origin/zero" values. VRPose.position,
  64606. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64607. * updated when calling resetPose(). This should be called in only
  64608. * sitting-space experiences.
  64609. */
  64610. resetPose(): void;
  64611. /**
  64612. * The VRLayer provided to the VRDisplay will be captured and presented
  64613. * in the HMD. Calling this function has the same effect on the source
  64614. * canvas as any other operation that uses its source image, and canvases
  64615. * created without preserveDrawingBuffer set to true will be cleared.
  64616. * @param pose Define the pose to submit
  64617. */
  64618. submitFrame(pose?: VRPose): void;
  64619. }
  64620. declare var VRDisplay: {
  64621. prototype: VRDisplay;
  64622. new(): VRDisplay;
  64623. };
  64624. interface VRLayer {
  64625. leftBounds?: number[] | Float32Array | null;
  64626. rightBounds?: number[] | Float32Array | null;
  64627. source?: HTMLCanvasElement | null;
  64628. }
  64629. interface VRDisplayCapabilities {
  64630. readonly canPresent: boolean;
  64631. readonly hasExternalDisplay: boolean;
  64632. readonly hasOrientation: boolean;
  64633. readonly hasPosition: boolean;
  64634. readonly maxLayers: number;
  64635. }
  64636. interface VREyeParameters {
  64637. /** @deprecated */
  64638. readonly fieldOfView: VRFieldOfView;
  64639. readonly offset: Float32Array;
  64640. readonly renderHeight: number;
  64641. readonly renderWidth: number;
  64642. }
  64643. interface VRFieldOfView {
  64644. readonly downDegrees: number;
  64645. readonly leftDegrees: number;
  64646. readonly rightDegrees: number;
  64647. readonly upDegrees: number;
  64648. }
  64649. interface VRFrameData {
  64650. readonly leftProjectionMatrix: Float32Array;
  64651. readonly leftViewMatrix: Float32Array;
  64652. readonly pose: VRPose;
  64653. readonly rightProjectionMatrix: Float32Array;
  64654. readonly rightViewMatrix: Float32Array;
  64655. readonly timestamp: number;
  64656. }
  64657. interface VRPose {
  64658. readonly angularAcceleration: Float32Array | null;
  64659. readonly angularVelocity: Float32Array | null;
  64660. readonly linearAcceleration: Float32Array | null;
  64661. readonly linearVelocity: Float32Array | null;
  64662. readonly orientation: Float32Array | null;
  64663. readonly position: Float32Array | null;
  64664. readonly timestamp: number;
  64665. }
  64666. interface VRStageParameters {
  64667. sittingToStandingTransform?: Float32Array;
  64668. sizeX?: number;
  64669. sizeY?: number;
  64670. }
  64671. interface Navigator {
  64672. getVRDisplays(): Promise<VRDisplay[]>;
  64673. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64674. }
  64675. interface Window {
  64676. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64677. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64678. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64679. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64680. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64681. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64682. }
  64683. interface Gamepad {
  64684. readonly displayId: number;
  64685. }
  64686. type XRSessionMode =
  64687. | "inline"
  64688. | "immersive-vr"
  64689. | "immersive-ar";
  64690. type XRReferenceSpaceType =
  64691. | "viewer"
  64692. | "local"
  64693. | "local-floor"
  64694. | "bounded-floor"
  64695. | "unbounded";
  64696. type XREnvironmentBlendMode =
  64697. | "opaque"
  64698. | "additive"
  64699. | "alpha-blend";
  64700. type XRVisibilityState =
  64701. | "visible"
  64702. | "visible-blurred"
  64703. | "hidden";
  64704. type XRHandedness =
  64705. | "none"
  64706. | "left"
  64707. | "right";
  64708. type XRTargetRayMode =
  64709. | "gaze"
  64710. | "tracked-pointer"
  64711. | "screen";
  64712. type XREye =
  64713. | "none"
  64714. | "left"
  64715. | "right";
  64716. interface XRSpace extends EventTarget {
  64717. }
  64718. interface XRRenderState {
  64719. depthNear?: number;
  64720. depthFar?: number;
  64721. inlineVerticalFieldOfView?: number;
  64722. baseLayer?: XRWebGLLayer;
  64723. }
  64724. interface XRInputSource {
  64725. handedness: XRHandedness;
  64726. targetRayMode: XRTargetRayMode;
  64727. targetRaySpace: XRSpace;
  64728. gripSpace: XRSpace | undefined;
  64729. gamepad: Gamepad | undefined;
  64730. profiles: Array<string>;
  64731. }
  64732. interface XRSession {
  64733. addEventListener: Function;
  64734. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64735. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64736. requestAnimationFrame: Function;
  64737. end(): Promise<void>;
  64738. renderState: XRRenderState;
  64739. inputSources: Array<XRInputSource>;
  64740. }
  64741. interface XRReferenceSpace extends XRSpace {
  64742. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64743. onreset: any;
  64744. }
  64745. interface XRFrame {
  64746. session: XRSession;
  64747. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64748. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64749. }
  64750. interface XRViewerPose extends XRPose {
  64751. views: Array<XRView>;
  64752. }
  64753. interface XRPose {
  64754. transform: XRRigidTransform;
  64755. emulatedPosition: boolean;
  64756. }
  64757. declare var XRWebGLLayer: {
  64758. prototype: XRWebGLLayer;
  64759. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64760. };
  64761. interface XRWebGLLayer {
  64762. framebuffer: WebGLFramebuffer;
  64763. framebufferWidth: number;
  64764. framebufferHeight: number;
  64765. getViewport: Function;
  64766. }
  64767. interface XRRigidTransform {
  64768. position: DOMPointReadOnly;
  64769. orientation: DOMPointReadOnly;
  64770. matrix: Float32Array;
  64771. inverse: XRRigidTransform;
  64772. }
  64773. interface XRView {
  64774. eye: XREye;
  64775. projectionMatrix: Float32Array;
  64776. transform: XRRigidTransform;
  64777. }
  64778. interface XRInputSourceChangeEvent {
  64779. session: XRSession;
  64780. removed: Array<XRInputSource>;
  64781. added: Array<XRInputSource>;
  64782. }
  64783. /**
  64784. * @ignore
  64785. */
  64786. declare module BABYLON.GLTF2.Exporter {
  64787. }
  64788. /**
  64789. * @ignore
  64790. */
  64791. declare module BABYLON.GLTF1 {
  64792. }
  64793. declare module BABYLON.GUI {
  64794. /**
  64795. * Class used to specific a value and its associated unit
  64796. */
  64797. export class ValueAndUnit {
  64798. /** defines the unit to store */
  64799. unit: number;
  64800. /** defines a boolean indicating if the value can be negative */
  64801. negativeValueAllowed: boolean;
  64802. private _value;
  64803. private _originalUnit;
  64804. /**
  64805. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64806. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64807. */
  64808. ignoreAdaptiveScaling: boolean;
  64809. /**
  64810. * Creates a new ValueAndUnit
  64811. * @param value defines the value to store
  64812. * @param unit defines the unit to store
  64813. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64814. */
  64815. constructor(value: number,
  64816. /** defines the unit to store */
  64817. unit?: number,
  64818. /** defines a boolean indicating if the value can be negative */
  64819. negativeValueAllowed?: boolean);
  64820. /** Gets a boolean indicating if the value is a percentage */
  64821. readonly isPercentage: boolean;
  64822. /** Gets a boolean indicating if the value is store as pixel */
  64823. readonly isPixel: boolean;
  64824. /** Gets direct internal value */
  64825. readonly internalValue: number;
  64826. /**
  64827. * Gets value as pixel
  64828. * @param host defines the root host
  64829. * @param refValue defines the reference value for percentages
  64830. * @returns the value as pixel
  64831. */
  64832. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64833. /**
  64834. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64835. * @param value defines the value to store
  64836. * @param unit defines the unit to store
  64837. * @returns the current ValueAndUnit
  64838. */
  64839. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64840. /**
  64841. * Gets the value accordingly to its unit
  64842. * @param host defines the root host
  64843. * @returns the value
  64844. */
  64845. getValue(host: AdvancedDynamicTexture): number;
  64846. /**
  64847. * Gets a string representation of the value
  64848. * @param host defines the root host
  64849. * @param decimals defines an optional number of decimals to display
  64850. * @returns a string
  64851. */
  64852. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64853. /**
  64854. * Store a value parsed from a string
  64855. * @param source defines the source string
  64856. * @returns true if the value was successfully parsed
  64857. */
  64858. fromString(source: string | number): boolean;
  64859. private static _Regex;
  64860. private static _UNITMODE_PERCENTAGE;
  64861. private static _UNITMODE_PIXEL;
  64862. /** UNITMODE_PERCENTAGE */
  64863. static readonly UNITMODE_PERCENTAGE: number;
  64864. /** UNITMODE_PIXEL */
  64865. static readonly UNITMODE_PIXEL: number;
  64866. }
  64867. }
  64868. declare module BABYLON.GUI {
  64869. /**
  64870. * Define a style used by control to automatically setup properties based on a template.
  64871. * Only support font related properties so far
  64872. */
  64873. export class Style implements BABYLON.IDisposable {
  64874. private _fontFamily;
  64875. private _fontStyle;
  64876. private _fontWeight;
  64877. /** @hidden */
  64878. _host: AdvancedDynamicTexture;
  64879. /** @hidden */
  64880. _fontSize: ValueAndUnit;
  64881. /**
  64882. * BABYLON.Observable raised when the style values are changed
  64883. */
  64884. onChangedObservable: BABYLON.Observable<Style>;
  64885. /**
  64886. * Creates a new style object
  64887. * @param host defines the AdvancedDynamicTexture which hosts this style
  64888. */
  64889. constructor(host: AdvancedDynamicTexture);
  64890. /**
  64891. * Gets or sets the font size
  64892. */
  64893. fontSize: string | number;
  64894. /**
  64895. * Gets or sets the font family
  64896. */
  64897. fontFamily: string;
  64898. /**
  64899. * Gets or sets the font style
  64900. */
  64901. fontStyle: string;
  64902. /** Gets or sets font weight */
  64903. fontWeight: string;
  64904. /** Dispose all associated resources */
  64905. dispose(): void;
  64906. }
  64907. }
  64908. declare module BABYLON.GUI {
  64909. /**
  64910. * Class used to transport BABYLON.Vector2 information for pointer events
  64911. */
  64912. export class Vector2WithInfo extends BABYLON.Vector2 {
  64913. /** defines the current mouse button index */
  64914. buttonIndex: number;
  64915. /**
  64916. * Creates a new Vector2WithInfo
  64917. * @param source defines the vector2 data to transport
  64918. * @param buttonIndex defines the current mouse button index
  64919. */
  64920. constructor(source: BABYLON.Vector2,
  64921. /** defines the current mouse button index */
  64922. buttonIndex?: number);
  64923. }
  64924. /** Class used to provide 2D matrix features */
  64925. export class Matrix2D {
  64926. /** Gets the internal array of 6 floats used to store matrix data */
  64927. m: Float32Array;
  64928. /**
  64929. * Creates a new matrix
  64930. * @param m00 defines value for (0, 0)
  64931. * @param m01 defines value for (0, 1)
  64932. * @param m10 defines value for (1, 0)
  64933. * @param m11 defines value for (1, 1)
  64934. * @param m20 defines value for (2, 0)
  64935. * @param m21 defines value for (2, 1)
  64936. */
  64937. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64938. /**
  64939. * Fills the matrix from direct values
  64940. * @param m00 defines value for (0, 0)
  64941. * @param m01 defines value for (0, 1)
  64942. * @param m10 defines value for (1, 0)
  64943. * @param m11 defines value for (1, 1)
  64944. * @param m20 defines value for (2, 0)
  64945. * @param m21 defines value for (2, 1)
  64946. * @returns the current modified matrix
  64947. */
  64948. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64949. /**
  64950. * Gets matrix determinant
  64951. * @returns the determinant
  64952. */
  64953. determinant(): number;
  64954. /**
  64955. * Inverses the matrix and stores it in a target matrix
  64956. * @param result defines the target matrix
  64957. * @returns the current matrix
  64958. */
  64959. invertToRef(result: Matrix2D): Matrix2D;
  64960. /**
  64961. * Multiplies the current matrix with another one
  64962. * @param other defines the second operand
  64963. * @param result defines the target matrix
  64964. * @returns the current matrix
  64965. */
  64966. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64967. /**
  64968. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64969. * @param x defines the x coordinate to transform
  64970. * @param y defines the x coordinate to transform
  64971. * @param result defines the target vector2
  64972. * @returns the current matrix
  64973. */
  64974. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64975. /**
  64976. * Creates an identity matrix
  64977. * @returns a new matrix
  64978. */
  64979. static Identity(): Matrix2D;
  64980. /**
  64981. * Creates a translation matrix and stores it in a target matrix
  64982. * @param x defines the x coordinate of the translation
  64983. * @param y defines the y coordinate of the translation
  64984. * @param result defines the target matrix
  64985. */
  64986. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64987. /**
  64988. * Creates a scaling matrix and stores it in a target matrix
  64989. * @param x defines the x coordinate of the scaling
  64990. * @param y defines the y coordinate of the scaling
  64991. * @param result defines the target matrix
  64992. */
  64993. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64994. /**
  64995. * Creates a rotation matrix and stores it in a target matrix
  64996. * @param angle defines the rotation angle
  64997. * @param result defines the target matrix
  64998. */
  64999. static RotationToRef(angle: number, result: Matrix2D): void;
  65000. private static _TempPreTranslationMatrix;
  65001. private static _TempPostTranslationMatrix;
  65002. private static _TempRotationMatrix;
  65003. private static _TempScalingMatrix;
  65004. private static _TempCompose0;
  65005. private static _TempCompose1;
  65006. private static _TempCompose2;
  65007. /**
  65008. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  65009. * @param tx defines the x coordinate of the translation
  65010. * @param ty defines the y coordinate of the translation
  65011. * @param angle defines the rotation angle
  65012. * @param scaleX defines the x coordinate of the scaling
  65013. * @param scaleY defines the y coordinate of the scaling
  65014. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  65015. * @param result defines the target matrix
  65016. */
  65017. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  65018. }
  65019. }
  65020. declare module BABYLON.GUI {
  65021. /**
  65022. * Class used to store 2D control sizes
  65023. */
  65024. export class Measure {
  65025. /** defines left coordinate */
  65026. left: number;
  65027. /** defines top coordinate */
  65028. top: number;
  65029. /** defines width dimension */
  65030. width: number;
  65031. /** defines height dimension */
  65032. height: number;
  65033. /**
  65034. * Creates a new measure
  65035. * @param left defines left coordinate
  65036. * @param top defines top coordinate
  65037. * @param width defines width dimension
  65038. * @param height defines height dimension
  65039. */
  65040. constructor(
  65041. /** defines left coordinate */
  65042. left: number,
  65043. /** defines top coordinate */
  65044. top: number,
  65045. /** defines width dimension */
  65046. width: number,
  65047. /** defines height dimension */
  65048. height: number);
  65049. /**
  65050. * Copy from another measure
  65051. * @param other defines the other measure to copy from
  65052. */
  65053. copyFrom(other: Measure): void;
  65054. /**
  65055. * Copy from a group of 4 floats
  65056. * @param left defines left coordinate
  65057. * @param top defines top coordinate
  65058. * @param width defines width dimension
  65059. * @param height defines height dimension
  65060. */
  65061. copyFromFloats(left: number, top: number, width: number, height: number): void;
  65062. /**
  65063. * Computes the axis aligned bounding box measure for two given measures
  65064. * @param a Input measure
  65065. * @param b Input measure
  65066. * @param result the resulting bounding measure
  65067. */
  65068. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  65069. /**
  65070. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  65071. * @param transform the matrix to transform the measure before computing the AABB
  65072. * @param result the resulting AABB
  65073. */
  65074. transformToRef(transform: Matrix2D, result: Measure): void;
  65075. /**
  65076. * Check equality between this measure and another one
  65077. * @param other defines the other measures
  65078. * @returns true if both measures are equals
  65079. */
  65080. isEqualsTo(other: Measure): boolean;
  65081. /**
  65082. * Creates an empty measure
  65083. * @returns a new measure
  65084. */
  65085. static Empty(): Measure;
  65086. }
  65087. }
  65088. declare module BABYLON.GUI {
  65089. /**
  65090. * Interface used to define a control that can receive focus
  65091. */
  65092. export interface IFocusableControl {
  65093. /**
  65094. * Function called when the control receives the focus
  65095. */
  65096. onFocus(): void;
  65097. /**
  65098. * Function called when the control loses the focus
  65099. */
  65100. onBlur(): void;
  65101. /**
  65102. * Function called to let the control handle keyboard events
  65103. * @param evt defines the current keyboard event
  65104. */
  65105. processKeyboard(evt: KeyboardEvent): void;
  65106. /**
  65107. * Function called to get the list of controls that should not steal the focus from this control
  65108. * @returns an array of controls
  65109. */
  65110. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65111. }
  65112. /**
  65113. * Class used to create texture to support 2D GUI elements
  65114. * @see http://doc.babylonjs.com/how_to/gui
  65115. */
  65116. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  65117. private _isDirty;
  65118. private _renderObserver;
  65119. private _resizeObserver;
  65120. private _preKeyboardObserver;
  65121. private _pointerMoveObserver;
  65122. private _pointerObserver;
  65123. private _canvasPointerOutObserver;
  65124. private _background;
  65125. /** @hidden */
  65126. _rootContainer: Container;
  65127. /** @hidden */
  65128. _lastPickedControl: Control;
  65129. /** @hidden */
  65130. _lastControlOver: {
  65131. [pointerId: number]: Control;
  65132. };
  65133. /** @hidden */
  65134. _lastControlDown: {
  65135. [pointerId: number]: Control;
  65136. };
  65137. /** @hidden */
  65138. _capturingControl: {
  65139. [pointerId: number]: Control;
  65140. };
  65141. /** @hidden */
  65142. _shouldBlockPointer: boolean;
  65143. /** @hidden */
  65144. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  65145. /** @hidden */
  65146. _linkedControls: Control[];
  65147. private _isFullscreen;
  65148. private _fullscreenViewport;
  65149. private _idealWidth;
  65150. private _idealHeight;
  65151. private _useSmallestIdeal;
  65152. private _renderAtIdealSize;
  65153. private _focusedControl;
  65154. private _blockNextFocusCheck;
  65155. private _renderScale;
  65156. private _rootElement;
  65157. private _cursorChanged;
  65158. /**
  65159. * Define type to string to ensure compatibility across browsers
  65160. * Safari doesn't support DataTransfer constructor
  65161. */
  65162. private _clipboardData;
  65163. /**
  65164. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  65165. */
  65166. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  65167. /**
  65168. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  65169. */
  65170. onControlPickedObservable: BABYLON.Observable<Control>;
  65171. /**
  65172. * BABYLON.Observable event triggered before layout is evaluated
  65173. */
  65174. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65175. /**
  65176. * BABYLON.Observable event triggered after the layout was evaluated
  65177. */
  65178. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65179. /**
  65180. * BABYLON.Observable event triggered before the texture is rendered
  65181. */
  65182. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65183. /**
  65184. * BABYLON.Observable event triggered after the texture was rendered
  65185. */
  65186. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65187. /**
  65188. * Gets or sets a boolean defining if alpha is stored as premultiplied
  65189. */
  65190. premulAlpha: boolean;
  65191. /**
  65192. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  65193. * Useful when you want more antialiasing
  65194. */
  65195. renderScale: number;
  65196. /** Gets or sets the background color */
  65197. background: string;
  65198. /**
  65199. * Gets or sets the ideal width used to design controls.
  65200. * The GUI will then rescale everything accordingly
  65201. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65202. */
  65203. idealWidth: number;
  65204. /**
  65205. * Gets or sets the ideal height used to design controls.
  65206. * The GUI will then rescale everything accordingly
  65207. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65208. */
  65209. idealHeight: number;
  65210. /**
  65211. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  65212. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65213. */
  65214. useSmallestIdeal: boolean;
  65215. /**
  65216. * Gets or sets a boolean indicating if adaptive scaling must be used
  65217. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65218. */
  65219. renderAtIdealSize: boolean;
  65220. /**
  65221. * Gets the underlying layer used to render the texture when in fullscreen mode
  65222. */
  65223. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  65224. /**
  65225. * Gets the root container control
  65226. */
  65227. readonly rootContainer: Container;
  65228. /**
  65229. * Returns an array containing the root container.
  65230. * This is mostly used to let the Inspector introspects the ADT
  65231. * @returns an array containing the rootContainer
  65232. */
  65233. getChildren(): Array<Container>;
  65234. /**
  65235. * Will return all controls that are inside this texture
  65236. * @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
  65237. * @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
  65238. * @return all child controls
  65239. */
  65240. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65241. /**
  65242. * Gets or sets the current focused control
  65243. */
  65244. focusedControl: BABYLON.Nullable<IFocusableControl>;
  65245. /**
  65246. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  65247. */
  65248. isForeground: boolean;
  65249. /**
  65250. * Gets or set information about clipboardData
  65251. */
  65252. clipboardData: string;
  65253. /**
  65254. * Creates a new AdvancedDynamicTexture
  65255. * @param name defines the name of the texture
  65256. * @param width defines the width of the texture
  65257. * @param height defines the height of the texture
  65258. * @param scene defines the hosting scene
  65259. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  65260. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  65261. */
  65262. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  65263. /**
  65264. * Get the current class name of the texture useful for serialization or dynamic coding.
  65265. * @returns "AdvancedDynamicTexture"
  65266. */
  65267. getClassName(): string;
  65268. /**
  65269. * Function used to execute a function on all controls
  65270. * @param func defines the function to execute
  65271. * @param container defines the container where controls belong. If null the root container will be used
  65272. */
  65273. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  65274. private _useInvalidateRectOptimization;
  65275. /**
  65276. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  65277. */
  65278. useInvalidateRectOptimization: boolean;
  65279. private _invalidatedRectangle;
  65280. /**
  65281. * Invalidates a rectangle area on the gui texture
  65282. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  65283. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  65284. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  65285. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  65286. */
  65287. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  65288. /**
  65289. * Marks the texture as dirty forcing a complete update
  65290. */
  65291. markAsDirty(): void;
  65292. /**
  65293. * Helper function used to create a new style
  65294. * @returns a new style
  65295. * @see http://doc.babylonjs.com/how_to/gui#styles
  65296. */
  65297. createStyle(): Style;
  65298. /**
  65299. * Adds a new control to the root container
  65300. * @param control defines the control to add
  65301. * @returns the current texture
  65302. */
  65303. addControl(control: Control): AdvancedDynamicTexture;
  65304. /**
  65305. * Removes a control from the root container
  65306. * @param control defines the control to remove
  65307. * @returns the current texture
  65308. */
  65309. removeControl(control: Control): AdvancedDynamicTexture;
  65310. /**
  65311. * Release all resources
  65312. */
  65313. dispose(): void;
  65314. private _onResize;
  65315. /** @hidden */
  65316. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  65317. /**
  65318. * Get screen coordinates for a vector3
  65319. * @param position defines the position to project
  65320. * @param worldMatrix defines the world matrix to use
  65321. * @returns the projected position
  65322. */
  65323. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  65324. private _checkUpdate;
  65325. private _clearMeasure;
  65326. private _render;
  65327. /** @hidden */
  65328. _changeCursor(cursor: string): void;
  65329. /** @hidden */
  65330. _registerLastControlDown(control: Control, pointerId: number): void;
  65331. private _doPicking;
  65332. /** @hidden */
  65333. _cleanControlAfterRemovalFromList(list: {
  65334. [pointerId: number]: Control;
  65335. }, control: Control): void;
  65336. /** @hidden */
  65337. _cleanControlAfterRemoval(control: Control): void;
  65338. /** Attach to all scene events required to support pointer events */
  65339. attach(): void;
  65340. /** @hidden */
  65341. private onClipboardCopy;
  65342. /** @hidden */
  65343. private onClipboardCut;
  65344. /** @hidden */
  65345. private onClipboardPaste;
  65346. /**
  65347. * Register the clipboard Events onto the canvas
  65348. */
  65349. registerClipboardEvents(): void;
  65350. /**
  65351. * Unregister the clipboard Events from the canvas
  65352. */
  65353. unRegisterClipboardEvents(): void;
  65354. /**
  65355. * Connect the texture to a hosting mesh to enable interactions
  65356. * @param mesh defines the mesh to attach to
  65357. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  65358. */
  65359. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  65360. /**
  65361. * Move the focus to a specific control
  65362. * @param control defines the control which will receive the focus
  65363. */
  65364. moveFocusToControl(control: IFocusableControl): void;
  65365. private _manageFocus;
  65366. private _attachToOnPointerOut;
  65367. /**
  65368. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  65369. * @param mesh defines the mesh which will receive the texture
  65370. * @param width defines the texture width (1024 by default)
  65371. * @param height defines the texture height (1024 by default)
  65372. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  65373. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  65374. * @returns a new AdvancedDynamicTexture
  65375. */
  65376. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  65377. /**
  65378. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  65379. * In this mode the texture will rely on a layer for its rendering.
  65380. * This allows it to be treated like any other layer.
  65381. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  65382. * LayerMask is set through advancedTexture.layer.layerMask
  65383. * @param name defines name for the texture
  65384. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  65385. * @param scene defines the hsoting scene
  65386. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  65387. * @returns a new AdvancedDynamicTexture
  65388. */
  65389. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  65390. }
  65391. }
  65392. declare module BABYLON.GUI {
  65393. /**
  65394. * Root class used for all 2D controls
  65395. * @see http://doc.babylonjs.com/how_to/gui#controls
  65396. */
  65397. export class Control {
  65398. /** defines the name of the control */
  65399. name?: string | undefined;
  65400. /**
  65401. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  65402. */
  65403. static AllowAlphaInheritance: boolean;
  65404. private _alpha;
  65405. private _alphaSet;
  65406. private _zIndex;
  65407. /** @hidden */
  65408. _host: AdvancedDynamicTexture;
  65409. /** Gets or sets the control parent */
  65410. parent: BABYLON.Nullable<Container>;
  65411. /** @hidden */
  65412. _currentMeasure: Measure;
  65413. private _fontFamily;
  65414. private _fontStyle;
  65415. private _fontWeight;
  65416. private _fontSize;
  65417. private _font;
  65418. /** @hidden */
  65419. _width: ValueAndUnit;
  65420. /** @hidden */
  65421. _height: ValueAndUnit;
  65422. /** @hidden */
  65423. protected _fontOffset: {
  65424. ascent: number;
  65425. height: number;
  65426. descent: number;
  65427. };
  65428. private _color;
  65429. private _style;
  65430. private _styleObserver;
  65431. /** @hidden */
  65432. protected _horizontalAlignment: number;
  65433. /** @hidden */
  65434. protected _verticalAlignment: number;
  65435. /** @hidden */
  65436. protected _isDirty: boolean;
  65437. /** @hidden */
  65438. protected _wasDirty: boolean;
  65439. /** @hidden */
  65440. _tempParentMeasure: Measure;
  65441. /** @hidden */
  65442. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65443. /** @hidden */
  65444. protected _cachedParentMeasure: Measure;
  65445. private _paddingLeft;
  65446. private _paddingRight;
  65447. private _paddingTop;
  65448. private _paddingBottom;
  65449. /** @hidden */
  65450. _left: ValueAndUnit;
  65451. /** @hidden */
  65452. _top: ValueAndUnit;
  65453. private _scaleX;
  65454. private _scaleY;
  65455. private _rotation;
  65456. private _transformCenterX;
  65457. private _transformCenterY;
  65458. /** @hidden */
  65459. _transformMatrix: Matrix2D;
  65460. /** @hidden */
  65461. protected _invertTransformMatrix: Matrix2D;
  65462. /** @hidden */
  65463. protected _transformedPosition: BABYLON.Vector2;
  65464. private _isMatrixDirty;
  65465. private _cachedOffsetX;
  65466. private _cachedOffsetY;
  65467. private _isVisible;
  65468. private _isHighlighted;
  65469. /** @hidden */
  65470. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65471. private _fontSet;
  65472. private _dummyVector2;
  65473. private _downCount;
  65474. private _enterCount;
  65475. private _doNotRender;
  65476. private _downPointerIds;
  65477. protected _isEnabled: boolean;
  65478. protected _disabledColor: string;
  65479. /** @hidden */
  65480. protected _rebuildLayout: boolean;
  65481. /** @hidden */
  65482. _isClipped: boolean;
  65483. /** @hidden */
  65484. _tag: any;
  65485. /**
  65486. * 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
  65487. */
  65488. uniqueId: number;
  65489. /**
  65490. * Gets or sets an object used to store user defined information for the node
  65491. */
  65492. metadata: any;
  65493. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65494. isHitTestVisible: boolean;
  65495. /** Gets or sets a boolean indicating if the control can block pointer events */
  65496. isPointerBlocker: boolean;
  65497. /** Gets or sets a boolean indicating if the control can be focusable */
  65498. isFocusInvisible: boolean;
  65499. /**
  65500. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65501. * 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
  65502. */
  65503. clipChildren: boolean;
  65504. /**
  65505. * Gets or sets a boolean indicating that control content must be clipped
  65506. * 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
  65507. */
  65508. clipContent: boolean;
  65509. /**
  65510. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65511. */
  65512. useBitmapCache: boolean;
  65513. private _cacheData;
  65514. private _shadowOffsetX;
  65515. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65516. shadowOffsetX: number;
  65517. private _shadowOffsetY;
  65518. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65519. shadowOffsetY: number;
  65520. private _shadowBlur;
  65521. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65522. shadowBlur: number;
  65523. private _shadowColor;
  65524. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65525. shadowColor: string;
  65526. /** Gets or sets the cursor to use when the control is hovered */
  65527. hoverCursor: string;
  65528. /** @hidden */
  65529. protected _linkOffsetX: ValueAndUnit;
  65530. /** @hidden */
  65531. protected _linkOffsetY: ValueAndUnit;
  65532. /** Gets the control type name */
  65533. readonly typeName: string;
  65534. /**
  65535. * Get the current class name of the control.
  65536. * @returns current class name
  65537. */
  65538. getClassName(): string;
  65539. /**
  65540. * An event triggered when the pointer move over the control.
  65541. */
  65542. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65543. /**
  65544. * An event triggered when the pointer move out of the control.
  65545. */
  65546. onPointerOutObservable: BABYLON.Observable<Control>;
  65547. /**
  65548. * An event triggered when the pointer taps the control
  65549. */
  65550. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65551. /**
  65552. * An event triggered when pointer up
  65553. */
  65554. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65555. /**
  65556. * An event triggered when a control is clicked on
  65557. */
  65558. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65559. /**
  65560. * An event triggered when pointer enters the control
  65561. */
  65562. onPointerEnterObservable: BABYLON.Observable<Control>;
  65563. /**
  65564. * An event triggered when the control is marked as dirty
  65565. */
  65566. onDirtyObservable: BABYLON.Observable<Control>;
  65567. /**
  65568. * An event triggered before drawing the control
  65569. */
  65570. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65571. /**
  65572. * An event triggered after the control was drawn
  65573. */
  65574. onAfterDrawObservable: BABYLON.Observable<Control>;
  65575. /**
  65576. * Get the hosting AdvancedDynamicTexture
  65577. */
  65578. readonly host: AdvancedDynamicTexture;
  65579. /** Gets or set information about font offsets (used to render and align text) */
  65580. fontOffset: {
  65581. ascent: number;
  65582. height: number;
  65583. descent: number;
  65584. };
  65585. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65586. alpha: number;
  65587. /**
  65588. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65589. */
  65590. isHighlighted: boolean;
  65591. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65592. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65593. */
  65594. scaleX: number;
  65595. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65596. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65597. */
  65598. scaleY: number;
  65599. /** Gets or sets the rotation angle (0 by default)
  65600. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65601. */
  65602. rotation: number;
  65603. /** Gets or sets the transformation center on Y axis (0 by default)
  65604. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65605. */
  65606. transformCenterY: number;
  65607. /** Gets or sets the transformation center on X axis (0 by default)
  65608. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65609. */
  65610. transformCenterX: number;
  65611. /**
  65612. * Gets or sets the horizontal alignment
  65613. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65614. */
  65615. horizontalAlignment: number;
  65616. /**
  65617. * Gets or sets the vertical alignment
  65618. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65619. */
  65620. verticalAlignment: number;
  65621. /**
  65622. * Gets or sets control width
  65623. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65624. */
  65625. width: string | number;
  65626. /**
  65627. * Gets or sets the control width in pixel
  65628. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65629. */
  65630. widthInPixels: number;
  65631. /**
  65632. * Gets or sets control height
  65633. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65634. */
  65635. height: string | number;
  65636. /**
  65637. * Gets or sets control height in pixel
  65638. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65639. */
  65640. heightInPixels: number;
  65641. /** Gets or set font family */
  65642. fontFamily: string;
  65643. /** Gets or sets font style */
  65644. fontStyle: string;
  65645. /** Gets or sets font weight */
  65646. fontWeight: string;
  65647. /**
  65648. * Gets or sets style
  65649. * @see http://doc.babylonjs.com/how_to/gui#styles
  65650. */
  65651. style: BABYLON.Nullable<Style>;
  65652. /** @hidden */
  65653. readonly _isFontSizeInPercentage: boolean;
  65654. /** Gets or sets font size in pixels */
  65655. fontSizeInPixels: number;
  65656. /** Gets or sets font size */
  65657. fontSize: string | number;
  65658. /** Gets or sets foreground color */
  65659. color: string;
  65660. /** Gets or sets z index which is used to reorder controls on the z axis */
  65661. zIndex: number;
  65662. /** Gets or sets a boolean indicating if the control can be rendered */
  65663. notRenderable: boolean;
  65664. /** Gets or sets a boolean indicating if the control is visible */
  65665. isVisible: boolean;
  65666. /** Gets a boolean indicating that the control needs to update its rendering */
  65667. readonly isDirty: boolean;
  65668. /**
  65669. * Gets the current linked mesh (or null if none)
  65670. */
  65671. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65672. /**
  65673. * Gets or sets a value indicating the padding to use on the left of the control
  65674. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65675. */
  65676. paddingLeft: string | number;
  65677. /**
  65678. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65679. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65680. */
  65681. paddingLeftInPixels: number;
  65682. /**
  65683. * Gets or sets a value indicating the padding to use on the right of the control
  65684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65685. */
  65686. paddingRight: string | number;
  65687. /**
  65688. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65689. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65690. */
  65691. paddingRightInPixels: number;
  65692. /**
  65693. * Gets or sets a value indicating the padding to use on the top of the control
  65694. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65695. */
  65696. paddingTop: string | number;
  65697. /**
  65698. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65699. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65700. */
  65701. paddingTopInPixels: number;
  65702. /**
  65703. * Gets or sets a value indicating the padding to use on the bottom of the control
  65704. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65705. */
  65706. paddingBottom: string | number;
  65707. /**
  65708. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65709. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65710. */
  65711. paddingBottomInPixels: number;
  65712. /**
  65713. * Gets or sets a value indicating the left coordinate of the control
  65714. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65715. */
  65716. left: string | number;
  65717. /**
  65718. * Gets or sets a value indicating the left coordinate in pixels of the control
  65719. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65720. */
  65721. leftInPixels: number;
  65722. /**
  65723. * Gets or sets a value indicating the top coordinate of the control
  65724. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65725. */
  65726. top: string | number;
  65727. /**
  65728. * Gets or sets a value indicating the top coordinate in pixels of the control
  65729. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65730. */
  65731. topInPixels: number;
  65732. /**
  65733. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65734. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65735. */
  65736. linkOffsetX: string | number;
  65737. /**
  65738. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65739. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65740. */
  65741. linkOffsetXInPixels: number;
  65742. /**
  65743. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65744. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65745. */
  65746. linkOffsetY: string | number;
  65747. /**
  65748. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65749. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65750. */
  65751. linkOffsetYInPixels: number;
  65752. /** Gets the center coordinate on X axis */
  65753. readonly centerX: number;
  65754. /** Gets the center coordinate on Y axis */
  65755. readonly centerY: number;
  65756. /** Gets or sets if control is Enabled*/
  65757. isEnabled: boolean;
  65758. /** Gets or sets background color of control if it's disabled*/
  65759. disabledColor: string;
  65760. /**
  65761. * Creates a new control
  65762. * @param name defines the name of the control
  65763. */
  65764. constructor(
  65765. /** defines the name of the control */
  65766. name?: string | undefined);
  65767. /** @hidden */
  65768. protected _getTypeName(): string;
  65769. /**
  65770. * Gets the first ascendant in the hierarchy of the given type
  65771. * @param className defines the required type
  65772. * @returns the ascendant or null if not found
  65773. */
  65774. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65775. /** @hidden */
  65776. _resetFontCache(): void;
  65777. /**
  65778. * Determines if a container is an ascendant of the current control
  65779. * @param container defines the container to look for
  65780. * @returns true if the container is one of the ascendant of the control
  65781. */
  65782. isAscendant(container: Control): boolean;
  65783. /**
  65784. * Gets coordinates in local control space
  65785. * @param globalCoordinates defines the coordinates to transform
  65786. * @returns the new coordinates in local space
  65787. */
  65788. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65789. /**
  65790. * Gets coordinates in local control space
  65791. * @param globalCoordinates defines the coordinates to transform
  65792. * @param result defines the target vector2 where to store the result
  65793. * @returns the current control
  65794. */
  65795. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65796. /**
  65797. * Gets coordinates in parent local control space
  65798. * @param globalCoordinates defines the coordinates to transform
  65799. * @returns the new coordinates in parent local space
  65800. */
  65801. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65802. /**
  65803. * Move the current control to a vector3 position projected onto the screen.
  65804. * @param position defines the target position
  65805. * @param scene defines the hosting scene
  65806. */
  65807. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65808. /** @hidden */
  65809. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65810. /**
  65811. * Will return all controls that have this control as ascendant
  65812. * @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
  65813. * @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
  65814. * @return all child controls
  65815. */
  65816. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65817. /**
  65818. * Link current control with a target mesh
  65819. * @param mesh defines the mesh to link with
  65820. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65821. */
  65822. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65823. /** @hidden */
  65824. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65825. /** @hidden */
  65826. _offsetLeft(offset: number): void;
  65827. /** @hidden */
  65828. _offsetTop(offset: number): void;
  65829. /** @hidden */
  65830. _markMatrixAsDirty(): void;
  65831. /** @hidden */
  65832. _flagDescendantsAsMatrixDirty(): void;
  65833. /** @hidden */
  65834. _intersectsRect(rect: Measure): boolean;
  65835. /** @hidden */
  65836. protected invalidateRect(): void;
  65837. /** @hidden */
  65838. _markAsDirty(force?: boolean): void;
  65839. /** @hidden */
  65840. _markAllAsDirty(): void;
  65841. /** @hidden */
  65842. _link(host: AdvancedDynamicTexture): void;
  65843. /** @hidden */
  65844. protected _transform(context?: CanvasRenderingContext2D): void;
  65845. /** @hidden */
  65846. _renderHighlight(context: CanvasRenderingContext2D): void;
  65847. /** @hidden */
  65848. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65849. /** @hidden */
  65850. protected _applyStates(context: CanvasRenderingContext2D): void;
  65851. /** @hidden */
  65852. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65853. /** @hidden */
  65854. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65855. protected _evaluateClippingState(parentMeasure: Measure): void;
  65856. /** @hidden */
  65857. _measure(): void;
  65858. /** @hidden */
  65859. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65860. /** @hidden */
  65861. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65862. /** @hidden */
  65863. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65864. /** @hidden */
  65865. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65866. private static _ClipMeasure;
  65867. private _tmpMeasureA;
  65868. private _clip;
  65869. /** @hidden */
  65870. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65871. /** @hidden */
  65872. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65873. /**
  65874. * Tests if a given coordinates belong to the current control
  65875. * @param x defines x coordinate to test
  65876. * @param y defines y coordinate to test
  65877. * @returns true if the coordinates are inside the control
  65878. */
  65879. contains(x: number, y: number): boolean;
  65880. /** @hidden */
  65881. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65882. /** @hidden */
  65883. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65884. /** @hidden */
  65885. _onPointerEnter(target: Control): boolean;
  65886. /** @hidden */
  65887. _onPointerOut(target: Control, force?: boolean): void;
  65888. /** @hidden */
  65889. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65890. /** @hidden */
  65891. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65892. /** @hidden */
  65893. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65894. /** @hidden */
  65895. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65896. private _prepareFont;
  65897. /** Releases associated resources */
  65898. dispose(): void;
  65899. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65900. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65901. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65902. private static _VERTICAL_ALIGNMENT_TOP;
  65903. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65904. private static _VERTICAL_ALIGNMENT_CENTER;
  65905. /** HORIZONTAL_ALIGNMENT_LEFT */
  65906. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65907. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65908. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65909. /** HORIZONTAL_ALIGNMENT_CENTER */
  65910. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65911. /** VERTICAL_ALIGNMENT_TOP */
  65912. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65913. /** VERTICAL_ALIGNMENT_BOTTOM */
  65914. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65915. /** VERTICAL_ALIGNMENT_CENTER */
  65916. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65917. private static _FontHeightSizes;
  65918. /** @hidden */
  65919. static _GetFontOffset(font: string): {
  65920. ascent: number;
  65921. height: number;
  65922. descent: number;
  65923. };
  65924. /**
  65925. * Creates a stack panel that can be used to render headers
  65926. * @param control defines the control to associate with the header
  65927. * @param text defines the text of the header
  65928. * @param size defines the size of the header
  65929. * @param options defines options used to configure the header
  65930. * @returns a new StackPanel
  65931. * @ignore
  65932. * @hidden
  65933. */
  65934. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65935. isHorizontal: boolean;
  65936. controlFirst: boolean;
  65937. }) => any;
  65938. /** @hidden */
  65939. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65940. }
  65941. }
  65942. declare module BABYLON.GUI {
  65943. /**
  65944. * Root class for 2D containers
  65945. * @see http://doc.babylonjs.com/how_to/gui#containers
  65946. */
  65947. export class Container extends Control {
  65948. name?: string | undefined;
  65949. /** @hidden */
  65950. protected _children: Control[];
  65951. /** @hidden */
  65952. protected _measureForChildren: Measure;
  65953. /** @hidden */
  65954. protected _background: string;
  65955. /** @hidden */
  65956. protected _adaptWidthToChildren: boolean;
  65957. /** @hidden */
  65958. protected _adaptHeightToChildren: boolean;
  65959. /**
  65960. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65961. */
  65962. logLayoutCycleErrors: boolean;
  65963. /**
  65964. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65965. */
  65966. maxLayoutCycle: number;
  65967. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65968. adaptHeightToChildren: boolean;
  65969. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65970. adaptWidthToChildren: boolean;
  65971. /** Gets or sets background color */
  65972. background: string;
  65973. /** Gets the list of children */
  65974. readonly children: Control[];
  65975. /**
  65976. * Creates a new Container
  65977. * @param name defines the name of the container
  65978. */
  65979. constructor(name?: string | undefined);
  65980. protected _getTypeName(): string;
  65981. _flagDescendantsAsMatrixDirty(): void;
  65982. /**
  65983. * Gets a child using its name
  65984. * @param name defines the child name to look for
  65985. * @returns the child control if found
  65986. */
  65987. getChildByName(name: string): BABYLON.Nullable<Control>;
  65988. /**
  65989. * Gets a child using its type and its name
  65990. * @param name defines the child name to look for
  65991. * @param type defines the child type to look for
  65992. * @returns the child control if found
  65993. */
  65994. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65995. /**
  65996. * Search for a specific control in children
  65997. * @param control defines the control to look for
  65998. * @returns true if the control is in child list
  65999. */
  66000. containsControl(control: Control): boolean;
  66001. /**
  66002. * Adds a new control to the current container
  66003. * @param control defines the control to add
  66004. * @returns the current container
  66005. */
  66006. addControl(control: BABYLON.Nullable<Control>): Container;
  66007. /**
  66008. * Removes all controls from the current container
  66009. * @returns the current container
  66010. */
  66011. clearControls(): Container;
  66012. /**
  66013. * Removes a control from the current container
  66014. * @param control defines the control to remove
  66015. * @returns the current container
  66016. */
  66017. removeControl(control: Control): Container;
  66018. /** @hidden */
  66019. _reOrderControl(control: Control): void;
  66020. /** @hidden */
  66021. _offsetLeft(offset: number): void;
  66022. /** @hidden */
  66023. _offsetTop(offset: number): void;
  66024. /** @hidden */
  66025. _markAllAsDirty(): void;
  66026. /** @hidden */
  66027. protected _localDraw(context: CanvasRenderingContext2D): void;
  66028. /** @hidden */
  66029. _link(host: AdvancedDynamicTexture): void;
  66030. /** @hidden */
  66031. protected _beforeLayout(): void;
  66032. /** @hidden */
  66033. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66034. /** @hidden */
  66035. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66036. protected _postMeasure(): void;
  66037. /** @hidden */
  66038. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  66039. /** @hidden */
  66040. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66041. /** @hidden */
  66042. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66043. /** @hidden */
  66044. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66045. /** Releases associated resources */
  66046. dispose(): void;
  66047. }
  66048. }
  66049. declare module BABYLON.GUI {
  66050. /** Class used to create rectangle container */
  66051. export class Rectangle extends Container {
  66052. name?: string | undefined;
  66053. private _thickness;
  66054. private _cornerRadius;
  66055. /** Gets or sets border thickness */
  66056. thickness: number;
  66057. /** Gets or sets the corner radius angle */
  66058. cornerRadius: number;
  66059. /**
  66060. * Creates a new Rectangle
  66061. * @param name defines the control name
  66062. */
  66063. constructor(name?: string | undefined);
  66064. protected _getTypeName(): string;
  66065. protected _localDraw(context: CanvasRenderingContext2D): void;
  66066. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66067. private _drawRoundedRect;
  66068. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66069. }
  66070. }
  66071. declare module BABYLON.GUI {
  66072. /**
  66073. * Enum that determines the text-wrapping mode to use.
  66074. */
  66075. export enum TextWrapping {
  66076. /**
  66077. * Clip the text when it's larger than Control.width; this is the default mode.
  66078. */
  66079. Clip = 0,
  66080. /**
  66081. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  66082. */
  66083. WordWrap = 1,
  66084. /**
  66085. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  66086. */
  66087. Ellipsis = 2
  66088. }
  66089. /**
  66090. * Class used to create text block control
  66091. */
  66092. export class TextBlock extends Control {
  66093. /**
  66094. * Defines the name of the control
  66095. */
  66096. name?: string | undefined;
  66097. private _text;
  66098. private _textWrapping;
  66099. private _textHorizontalAlignment;
  66100. private _textVerticalAlignment;
  66101. private _lines;
  66102. private _resizeToFit;
  66103. private _lineSpacing;
  66104. private _outlineWidth;
  66105. private _outlineColor;
  66106. /**
  66107. * An event triggered after the text is changed
  66108. */
  66109. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  66110. /**
  66111. * An event triggered after the text was broken up into lines
  66112. */
  66113. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  66114. /**
  66115. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  66116. */
  66117. readonly lines: any[];
  66118. /**
  66119. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66120. */
  66121. /**
  66122. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66123. */
  66124. resizeToFit: boolean;
  66125. /**
  66126. * Gets or sets a boolean indicating if text must be wrapped
  66127. */
  66128. /**
  66129. * Gets or sets a boolean indicating if text must be wrapped
  66130. */
  66131. textWrapping: TextWrapping | boolean;
  66132. /**
  66133. * Gets or sets text to display
  66134. */
  66135. /**
  66136. * Gets or sets text to display
  66137. */
  66138. text: string;
  66139. /**
  66140. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66141. */
  66142. /**
  66143. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66144. */
  66145. textHorizontalAlignment: number;
  66146. /**
  66147. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66148. */
  66149. /**
  66150. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66151. */
  66152. textVerticalAlignment: number;
  66153. /**
  66154. * Gets or sets line spacing value
  66155. */
  66156. /**
  66157. * Gets or sets line spacing value
  66158. */
  66159. lineSpacing: string | number;
  66160. /**
  66161. * Gets or sets outlineWidth of the text to display
  66162. */
  66163. /**
  66164. * Gets or sets outlineWidth of the text to display
  66165. */
  66166. outlineWidth: number;
  66167. /**
  66168. * Gets or sets outlineColor of the text to display
  66169. */
  66170. /**
  66171. * Gets or sets outlineColor of the text to display
  66172. */
  66173. outlineColor: string;
  66174. /**
  66175. * Creates a new TextBlock object
  66176. * @param name defines the name of the control
  66177. * @param text defines the text to display (emptry string by default)
  66178. */
  66179. constructor(
  66180. /**
  66181. * Defines the name of the control
  66182. */
  66183. name?: string | undefined, text?: string);
  66184. protected _getTypeName(): string;
  66185. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66186. private _drawText;
  66187. /** @hidden */
  66188. _draw(context: CanvasRenderingContext2D): void;
  66189. protected _applyStates(context: CanvasRenderingContext2D): void;
  66190. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  66191. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  66192. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  66193. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  66194. protected _renderLines(context: CanvasRenderingContext2D): void;
  66195. /**
  66196. * Given a width constraint applied on the text block, find the expected height
  66197. * @returns expected height
  66198. */
  66199. computeExpectedHeight(): number;
  66200. dispose(): void;
  66201. }
  66202. }
  66203. declare module BABYLON.GUI {
  66204. /**
  66205. * Class used to create 2D images
  66206. */
  66207. export class Image extends Control {
  66208. name?: string | undefined;
  66209. private _workingCanvas;
  66210. private _domImage;
  66211. private _imageWidth;
  66212. private _imageHeight;
  66213. private _loaded;
  66214. private _stretch;
  66215. private _source;
  66216. private _autoScale;
  66217. private _sourceLeft;
  66218. private _sourceTop;
  66219. private _sourceWidth;
  66220. private _sourceHeight;
  66221. private _cellWidth;
  66222. private _cellHeight;
  66223. private _cellId;
  66224. private _populateNinePatchSlicesFromImage;
  66225. private _sliceLeft;
  66226. private _sliceRight;
  66227. private _sliceTop;
  66228. private _sliceBottom;
  66229. private _detectPointerOnOpaqueOnly;
  66230. /**
  66231. * BABYLON.Observable notified when the content is loaded
  66232. */
  66233. onImageLoadedObservable: BABYLON.Observable<Image>;
  66234. /**
  66235. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  66236. */
  66237. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  66238. /**
  66239. * Gets a boolean indicating that the content is loaded
  66240. */
  66241. readonly isLoaded: boolean;
  66242. /**
  66243. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  66244. */
  66245. populateNinePatchSlicesFromImage: boolean;
  66246. /**
  66247. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  66248. * Beware using this as this will comsume more memory as the image has to be stored twice
  66249. */
  66250. detectPointerOnOpaqueOnly: boolean;
  66251. /**
  66252. * Gets or sets the left value for slicing (9-patch)
  66253. */
  66254. sliceLeft: number;
  66255. /**
  66256. * Gets or sets the right value for slicing (9-patch)
  66257. */
  66258. sliceRight: number;
  66259. /**
  66260. * Gets or sets the top value for slicing (9-patch)
  66261. */
  66262. sliceTop: number;
  66263. /**
  66264. * Gets or sets the bottom value for slicing (9-patch)
  66265. */
  66266. sliceBottom: number;
  66267. /**
  66268. * Gets or sets the left coordinate in the source image
  66269. */
  66270. sourceLeft: number;
  66271. /**
  66272. * Gets or sets the top coordinate in the source image
  66273. */
  66274. sourceTop: number;
  66275. /**
  66276. * Gets or sets the width to capture in the source image
  66277. */
  66278. sourceWidth: number;
  66279. /**
  66280. * Gets or sets the height to capture in the source image
  66281. */
  66282. sourceHeight: number;
  66283. /**
  66284. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  66285. * @see http://doc.babylonjs.com/how_to/gui#image
  66286. */
  66287. autoScale: boolean;
  66288. /** Gets or sets the streching mode used by the image */
  66289. stretch: number;
  66290. /**
  66291. * Gets or sets the internal DOM image used to render the control
  66292. */
  66293. domImage: HTMLImageElement;
  66294. private _onImageLoaded;
  66295. private _extractNinePatchSliceDataFromImage;
  66296. /**
  66297. * Gets or sets image source url
  66298. */
  66299. source: BABYLON.Nullable<string>;
  66300. /**
  66301. * Checks for svg document with icon id present
  66302. */
  66303. private _svgCheck;
  66304. /**
  66305. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  66306. * given external svg file and icon id
  66307. */
  66308. private _getSVGAttribs;
  66309. /**
  66310. * Gets or sets the cell width to use when animation sheet is enabled
  66311. * @see http://doc.babylonjs.com/how_to/gui#image
  66312. */
  66313. cellWidth: number;
  66314. /**
  66315. * Gets or sets the cell height to use when animation sheet is enabled
  66316. * @see http://doc.babylonjs.com/how_to/gui#image
  66317. */
  66318. cellHeight: number;
  66319. /**
  66320. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  66321. * @see http://doc.babylonjs.com/how_to/gui#image
  66322. */
  66323. cellId: number;
  66324. /**
  66325. * Creates a new Image
  66326. * @param name defines the control name
  66327. * @param url defines the image url
  66328. */
  66329. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  66330. /**
  66331. * Tests if a given coordinates belong to the current control
  66332. * @param x defines x coordinate to test
  66333. * @param y defines y coordinate to test
  66334. * @returns true if the coordinates are inside the control
  66335. */
  66336. contains(x: number, y: number): boolean;
  66337. protected _getTypeName(): string;
  66338. /** Force the control to synchronize with its content */
  66339. synchronizeSizeWithContent(): void;
  66340. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66341. private _prepareWorkingCanvasForOpaqueDetection;
  66342. private _drawImage;
  66343. _draw(context: CanvasRenderingContext2D): void;
  66344. private _renderCornerPatch;
  66345. private _renderNinePatch;
  66346. dispose(): void;
  66347. /** STRETCH_NONE */
  66348. static readonly STRETCH_NONE: number;
  66349. /** STRETCH_FILL */
  66350. static readonly STRETCH_FILL: number;
  66351. /** STRETCH_UNIFORM */
  66352. static readonly STRETCH_UNIFORM: number;
  66353. /** STRETCH_EXTEND */
  66354. static readonly STRETCH_EXTEND: number;
  66355. /** NINE_PATCH */
  66356. static readonly STRETCH_NINE_PATCH: number;
  66357. }
  66358. }
  66359. declare module BABYLON.GUI {
  66360. /**
  66361. * Class used to create 2D buttons
  66362. */
  66363. export class Button extends Rectangle {
  66364. name?: string | undefined;
  66365. /**
  66366. * Function called to generate a pointer enter animation
  66367. */
  66368. pointerEnterAnimation: () => void;
  66369. /**
  66370. * Function called to generate a pointer out animation
  66371. */
  66372. pointerOutAnimation: () => void;
  66373. /**
  66374. * Function called to generate a pointer down animation
  66375. */
  66376. pointerDownAnimation: () => void;
  66377. /**
  66378. * Function called to generate a pointer up animation
  66379. */
  66380. pointerUpAnimation: () => void;
  66381. /**
  66382. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  66383. */
  66384. delegatePickingToChildren: boolean;
  66385. private _image;
  66386. /**
  66387. * Returns the image part of the button (if any)
  66388. */
  66389. readonly image: BABYLON.Nullable<Image>;
  66390. private _textBlock;
  66391. /**
  66392. * Returns the image part of the button (if any)
  66393. */
  66394. readonly textBlock: BABYLON.Nullable<TextBlock>;
  66395. /**
  66396. * Creates a new Button
  66397. * @param name defines the name of the button
  66398. */
  66399. constructor(name?: string | undefined);
  66400. protected _getTypeName(): string;
  66401. /** @hidden */
  66402. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66403. /** @hidden */
  66404. _onPointerEnter(target: Control): boolean;
  66405. /** @hidden */
  66406. _onPointerOut(target: Control, force?: boolean): void;
  66407. /** @hidden */
  66408. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66409. /** @hidden */
  66410. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66411. /**
  66412. * Creates a new button made with an image and a text
  66413. * @param name defines the name of the button
  66414. * @param text defines the text of the button
  66415. * @param imageUrl defines the url of the image
  66416. * @returns a new Button
  66417. */
  66418. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  66419. /**
  66420. * Creates a new button made with an image
  66421. * @param name defines the name of the button
  66422. * @param imageUrl defines the url of the image
  66423. * @returns a new Button
  66424. */
  66425. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66426. /**
  66427. * Creates a new button made with a text
  66428. * @param name defines the name of the button
  66429. * @param text defines the text of the button
  66430. * @returns a new Button
  66431. */
  66432. static CreateSimpleButton(name: string, text: string): Button;
  66433. /**
  66434. * Creates a new button made with an image and a centered text
  66435. * @param name defines the name of the button
  66436. * @param text defines the text of the button
  66437. * @param imageUrl defines the url of the image
  66438. * @returns a new Button
  66439. */
  66440. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66441. }
  66442. }
  66443. declare module BABYLON.GUI {
  66444. /**
  66445. * Class used to create a 2D stack panel container
  66446. */
  66447. export class StackPanel extends Container {
  66448. name?: string | undefined;
  66449. private _isVertical;
  66450. private _manualWidth;
  66451. private _manualHeight;
  66452. private _doNotTrackManualChanges;
  66453. /**
  66454. * Gets or sets a boolean indicating that layou warnings should be ignored
  66455. */
  66456. ignoreLayoutWarnings: boolean;
  66457. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66458. isVertical: boolean;
  66459. /**
  66460. * Gets or sets panel width.
  66461. * This value should not be set when in horizontal mode as it will be computed automatically
  66462. */
  66463. width: string | number;
  66464. /**
  66465. * Gets or sets panel height.
  66466. * This value should not be set when in vertical mode as it will be computed automatically
  66467. */
  66468. height: string | number;
  66469. /**
  66470. * Creates a new StackPanel
  66471. * @param name defines control name
  66472. */
  66473. constructor(name?: string | undefined);
  66474. protected _getTypeName(): string;
  66475. /** @hidden */
  66476. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66477. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66478. protected _postMeasure(): void;
  66479. }
  66480. }
  66481. declare module BABYLON.GUI {
  66482. /**
  66483. * Class used to represent a 2D checkbox
  66484. */
  66485. export class Checkbox extends Control {
  66486. name?: string | undefined;
  66487. private _isChecked;
  66488. private _background;
  66489. private _checkSizeRatio;
  66490. private _thickness;
  66491. /** Gets or sets border thickness */
  66492. thickness: number;
  66493. /**
  66494. * BABYLON.Observable raised when isChecked property changes
  66495. */
  66496. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66497. /** Gets or sets a value indicating the ratio between overall size and check size */
  66498. checkSizeRatio: number;
  66499. /** Gets or sets background color */
  66500. background: string;
  66501. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66502. isChecked: boolean;
  66503. /**
  66504. * Creates a new CheckBox
  66505. * @param name defines the control name
  66506. */
  66507. constructor(name?: string | undefined);
  66508. protected _getTypeName(): string;
  66509. /** @hidden */
  66510. _draw(context: CanvasRenderingContext2D): void;
  66511. /** @hidden */
  66512. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66513. /**
  66514. * Utility function to easily create a checkbox with a header
  66515. * @param title defines the label to use for the header
  66516. * @param onValueChanged defines the callback to call when value changes
  66517. * @returns a StackPanel containing the checkbox and a textBlock
  66518. */
  66519. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66520. }
  66521. }
  66522. declare module BABYLON.GUI {
  66523. /**
  66524. * Class used to store key control properties
  66525. */
  66526. export class KeyPropertySet {
  66527. /** Width */
  66528. width?: string;
  66529. /** Height */
  66530. height?: string;
  66531. /** Left padding */
  66532. paddingLeft?: string;
  66533. /** Right padding */
  66534. paddingRight?: string;
  66535. /** Top padding */
  66536. paddingTop?: string;
  66537. /** Bottom padding */
  66538. paddingBottom?: string;
  66539. /** Foreground color */
  66540. color?: string;
  66541. /** Background color */
  66542. background?: string;
  66543. }
  66544. /**
  66545. * Class used to create virtual keyboard
  66546. */
  66547. export class VirtualKeyboard extends StackPanel {
  66548. /** BABYLON.Observable raised when a key is pressed */
  66549. onKeyPressObservable: BABYLON.Observable<string>;
  66550. /** Gets or sets default key button width */
  66551. defaultButtonWidth: string;
  66552. /** Gets or sets default key button height */
  66553. defaultButtonHeight: string;
  66554. /** Gets or sets default key button left padding */
  66555. defaultButtonPaddingLeft: string;
  66556. /** Gets or sets default key button right padding */
  66557. defaultButtonPaddingRight: string;
  66558. /** Gets or sets default key button top padding */
  66559. defaultButtonPaddingTop: string;
  66560. /** Gets or sets default key button bottom padding */
  66561. defaultButtonPaddingBottom: string;
  66562. /** Gets or sets default key button foreground color */
  66563. defaultButtonColor: string;
  66564. /** Gets or sets default key button background color */
  66565. defaultButtonBackground: string;
  66566. /** Gets or sets shift button foreground color */
  66567. shiftButtonColor: string;
  66568. /** Gets or sets shift button thickness*/
  66569. selectedShiftThickness: number;
  66570. /** Gets shift key state */
  66571. shiftState: number;
  66572. protected _getTypeName(): string;
  66573. private _createKey;
  66574. /**
  66575. * Adds a new row of keys
  66576. * @param keys defines the list of keys to add
  66577. * @param propertySets defines the associated property sets
  66578. */
  66579. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66580. /**
  66581. * Set the shift key to a specific state
  66582. * @param shiftState defines the new shift state
  66583. */
  66584. applyShiftState(shiftState: number): void;
  66585. private _currentlyConnectedInputText;
  66586. private _connectedInputTexts;
  66587. private _onKeyPressObserver;
  66588. /** Gets the input text control currently attached to the keyboard */
  66589. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66590. /**
  66591. * Connects the keyboard with an input text control
  66592. *
  66593. * @param input defines the target control
  66594. */
  66595. connect(input: InputText): void;
  66596. /**
  66597. * Disconnects the keyboard from connected InputText controls
  66598. *
  66599. * @param input optionally defines a target control, otherwise all are disconnected
  66600. */
  66601. disconnect(input?: InputText): void;
  66602. private _removeConnectedInputObservables;
  66603. /**
  66604. * Release all resources
  66605. */
  66606. dispose(): void;
  66607. /**
  66608. * Creates a new keyboard using a default layout
  66609. *
  66610. * @param name defines control name
  66611. * @returns a new VirtualKeyboard
  66612. */
  66613. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66614. }
  66615. }
  66616. declare module BABYLON.GUI {
  66617. /**
  66618. * Class used to create input text control
  66619. */
  66620. export class InputText extends Control implements IFocusableControl {
  66621. name?: string | undefined;
  66622. private _text;
  66623. private _placeholderText;
  66624. private _background;
  66625. private _focusedBackground;
  66626. private _focusedColor;
  66627. private _placeholderColor;
  66628. private _thickness;
  66629. private _margin;
  66630. private _autoStretchWidth;
  66631. private _maxWidth;
  66632. private _isFocused;
  66633. private _blinkTimeout;
  66634. private _blinkIsEven;
  66635. private _cursorOffset;
  66636. private _scrollLeft;
  66637. private _textWidth;
  66638. private _clickedCoordinate;
  66639. private _deadKey;
  66640. private _addKey;
  66641. private _currentKey;
  66642. private _isTextHighlightOn;
  66643. private _textHighlightColor;
  66644. private _highligherOpacity;
  66645. private _highlightedText;
  66646. private _startHighlightIndex;
  66647. private _endHighlightIndex;
  66648. private _cursorIndex;
  66649. private _onFocusSelectAll;
  66650. private _isPointerDown;
  66651. private _onClipboardObserver;
  66652. private _onPointerDblTapObserver;
  66653. /** @hidden */
  66654. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66655. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66656. promptMessage: string;
  66657. /** Force disable prompt on mobile device */
  66658. disableMobilePrompt: boolean;
  66659. /** BABYLON.Observable raised when the text changes */
  66660. onTextChangedObservable: BABYLON.Observable<InputText>;
  66661. /** BABYLON.Observable raised just before an entered character is to be added */
  66662. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66663. /** BABYLON.Observable raised when the control gets the focus */
  66664. onFocusObservable: BABYLON.Observable<InputText>;
  66665. /** BABYLON.Observable raised when the control loses the focus */
  66666. onBlurObservable: BABYLON.Observable<InputText>;
  66667. /**Observable raised when the text is highlighted */
  66668. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66669. /**Observable raised when copy event is triggered */
  66670. onTextCopyObservable: BABYLON.Observable<InputText>;
  66671. /** BABYLON.Observable raised when cut event is triggered */
  66672. onTextCutObservable: BABYLON.Observable<InputText>;
  66673. /** BABYLON.Observable raised when paste event is triggered */
  66674. onTextPasteObservable: BABYLON.Observable<InputText>;
  66675. /** BABYLON.Observable raised when a key event was processed */
  66676. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66677. /** Gets or sets the maximum width allowed by the control */
  66678. maxWidth: string | number;
  66679. /** Gets the maximum width allowed by the control in pixels */
  66680. readonly maxWidthInPixels: number;
  66681. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66682. highligherOpacity: number;
  66683. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66684. onFocusSelectAll: boolean;
  66685. /** Gets or sets the text hightlight color */
  66686. textHighlightColor: string;
  66687. /** Gets or sets control margin */
  66688. margin: string;
  66689. /** Gets control margin in pixels */
  66690. readonly marginInPixels: number;
  66691. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66692. autoStretchWidth: boolean;
  66693. /** Gets or sets border thickness */
  66694. thickness: number;
  66695. /** Gets or sets the background color when focused */
  66696. focusedBackground: string;
  66697. /** Gets or sets the background color when focused */
  66698. focusedColor: string;
  66699. /** Gets or sets the background color */
  66700. background: string;
  66701. /** Gets or sets the placeholder color */
  66702. placeholderColor: string;
  66703. /** Gets or sets the text displayed when the control is empty */
  66704. placeholderText: string;
  66705. /** Gets or sets the dead key flag */
  66706. deadKey: boolean;
  66707. /** Gets or sets the highlight text */
  66708. highlightedText: string;
  66709. /** Gets or sets if the current key should be added */
  66710. addKey: boolean;
  66711. /** Gets or sets the value of the current key being entered */
  66712. currentKey: string;
  66713. /** Gets or sets the text displayed in the control */
  66714. text: string;
  66715. /** Gets or sets control width */
  66716. width: string | number;
  66717. /**
  66718. * Creates a new InputText
  66719. * @param name defines the control name
  66720. * @param text defines the text of the control
  66721. */
  66722. constructor(name?: string | undefined, text?: string);
  66723. /** @hidden */
  66724. onBlur(): void;
  66725. /** @hidden */
  66726. onFocus(): void;
  66727. protected _getTypeName(): string;
  66728. /**
  66729. * Function called to get the list of controls that should not steal the focus from this control
  66730. * @returns an array of controls
  66731. */
  66732. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66733. /** @hidden */
  66734. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66735. /** @hidden */
  66736. private _updateValueFromCursorIndex;
  66737. /** @hidden */
  66738. private _processDblClick;
  66739. /** @hidden */
  66740. private _selectAllText;
  66741. /**
  66742. * Handles the keyboard event
  66743. * @param evt Defines the KeyboardEvent
  66744. */
  66745. processKeyboard(evt: KeyboardEvent): void;
  66746. /** @hidden */
  66747. private _onCopyText;
  66748. /** @hidden */
  66749. private _onCutText;
  66750. /** @hidden */
  66751. private _onPasteText;
  66752. _draw(context: CanvasRenderingContext2D): void;
  66753. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66754. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66755. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66756. protected _beforeRenderText(text: string): string;
  66757. dispose(): void;
  66758. }
  66759. }
  66760. declare module BABYLON.GUI {
  66761. /**
  66762. * Class used to create a 2D grid container
  66763. */
  66764. export class Grid extends Container {
  66765. name?: string | undefined;
  66766. private _rowDefinitions;
  66767. private _columnDefinitions;
  66768. private _cells;
  66769. private _childControls;
  66770. /**
  66771. * Gets the number of columns
  66772. */
  66773. readonly columnCount: number;
  66774. /**
  66775. * Gets the number of rows
  66776. */
  66777. readonly rowCount: number;
  66778. /** Gets the list of children */
  66779. readonly children: Control[];
  66780. /** Gets the list of cells (e.g. the containers) */
  66781. readonly cells: {
  66782. [key: string]: Container;
  66783. };
  66784. /**
  66785. * Gets the definition of a specific row
  66786. * @param index defines the index of the row
  66787. * @returns the row definition
  66788. */
  66789. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66790. /**
  66791. * Gets the definition of a specific column
  66792. * @param index defines the index of the column
  66793. * @returns the column definition
  66794. */
  66795. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66796. /**
  66797. * Adds a new row to the grid
  66798. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66799. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66800. * @returns the current grid
  66801. */
  66802. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66803. /**
  66804. * Adds a new column to the grid
  66805. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66806. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66807. * @returns the current grid
  66808. */
  66809. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66810. /**
  66811. * Update a row definition
  66812. * @param index defines the index of the row to update
  66813. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66814. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66815. * @returns the current grid
  66816. */
  66817. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66818. /**
  66819. * Update a column definition
  66820. * @param index defines the index of the column to update
  66821. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66822. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66823. * @returns the current grid
  66824. */
  66825. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66826. /**
  66827. * Gets the list of children stored in a specific cell
  66828. * @param row defines the row to check
  66829. * @param column defines the column to check
  66830. * @returns the list of controls
  66831. */
  66832. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66833. /**
  66834. * Gets a string representing the child cell info (row x column)
  66835. * @param child defines the control to get info from
  66836. * @returns a string containing the child cell info (row x column)
  66837. */
  66838. getChildCellInfo(child: Control): string;
  66839. private _removeCell;
  66840. private _offsetCell;
  66841. /**
  66842. * Remove a column definition at specified index
  66843. * @param index defines the index of the column to remove
  66844. * @returns the current grid
  66845. */
  66846. removeColumnDefinition(index: number): Grid;
  66847. /**
  66848. * Remove a row definition at specified index
  66849. * @param index defines the index of the row to remove
  66850. * @returns the current grid
  66851. */
  66852. removeRowDefinition(index: number): Grid;
  66853. /**
  66854. * Adds a new control to the current grid
  66855. * @param control defines the control to add
  66856. * @param row defines the row where to add the control (0 by default)
  66857. * @param column defines the column where to add the control (0 by default)
  66858. * @returns the current grid
  66859. */
  66860. addControl(control: Control, row?: number, column?: number): Grid;
  66861. /**
  66862. * Removes a control from the current container
  66863. * @param control defines the control to remove
  66864. * @returns the current container
  66865. */
  66866. removeControl(control: Control): Container;
  66867. /**
  66868. * Creates a new Grid
  66869. * @param name defines control name
  66870. */
  66871. constructor(name?: string | undefined);
  66872. protected _getTypeName(): string;
  66873. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66874. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66875. _flagDescendantsAsMatrixDirty(): void;
  66876. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66877. /** Releases associated resources */
  66878. dispose(): void;
  66879. }
  66880. }
  66881. declare module BABYLON.GUI {
  66882. /** Class used to create color pickers */
  66883. export class ColorPicker extends Control {
  66884. name?: string | undefined;
  66885. private static _Epsilon;
  66886. private _colorWheelCanvas;
  66887. private _value;
  66888. private _tmpColor;
  66889. private _pointerStartedOnSquare;
  66890. private _pointerStartedOnWheel;
  66891. private _squareLeft;
  66892. private _squareTop;
  66893. private _squareSize;
  66894. private _h;
  66895. private _s;
  66896. private _v;
  66897. private _lastPointerDownID;
  66898. /**
  66899. * BABYLON.Observable raised when the value changes
  66900. */
  66901. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66902. /** Gets or sets the color of the color picker */
  66903. value: BABYLON.Color3;
  66904. /**
  66905. * Gets or sets control width
  66906. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66907. */
  66908. width: string | number;
  66909. /**
  66910. * Gets or sets control height
  66911. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66912. */
  66913. /** Gets or sets control height */
  66914. height: string | number;
  66915. /** Gets or sets control size */
  66916. size: string | number;
  66917. /**
  66918. * Creates a new ColorPicker
  66919. * @param name defines the control name
  66920. */
  66921. constructor(name?: string | undefined);
  66922. protected _getTypeName(): string;
  66923. /** @hidden */
  66924. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66925. private _updateSquareProps;
  66926. private _drawGradientSquare;
  66927. private _drawCircle;
  66928. private _createColorWheelCanvas;
  66929. /** @hidden */
  66930. _draw(context: CanvasRenderingContext2D): void;
  66931. private _pointerIsDown;
  66932. private _updateValueFromPointer;
  66933. private _isPointOnSquare;
  66934. private _isPointOnWheel;
  66935. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66936. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66937. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66938. /**
  66939. * This function expands the color picker by creating a color picker dialog with manual
  66940. * color value input and the ability to save colors into an array to be used later in
  66941. * subsequent launches of the dialogue.
  66942. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66943. * @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.
  66944. * @returns picked color as a hex string and the saved colors array as hex strings.
  66945. */
  66946. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66947. pickerWidth?: string;
  66948. pickerHeight?: string;
  66949. headerHeight?: string;
  66950. lastColor?: string;
  66951. swatchLimit?: number;
  66952. numSwatchesPerLine?: number;
  66953. savedColors?: Array<string>;
  66954. }): Promise<{
  66955. savedColors?: string[];
  66956. pickedColor: string;
  66957. }>;
  66958. }
  66959. }
  66960. declare module BABYLON.GUI {
  66961. /** Class used to create 2D ellipse containers */
  66962. export class Ellipse extends Container {
  66963. name?: string | undefined;
  66964. private _thickness;
  66965. /** Gets or sets border thickness */
  66966. thickness: number;
  66967. /**
  66968. * Creates a new Ellipse
  66969. * @param name defines the control name
  66970. */
  66971. constructor(name?: string | undefined);
  66972. protected _getTypeName(): string;
  66973. protected _localDraw(context: CanvasRenderingContext2D): void;
  66974. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66975. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66976. }
  66977. }
  66978. declare module BABYLON.GUI {
  66979. /**
  66980. * Class used to create a password control
  66981. */
  66982. export class InputPassword extends InputText {
  66983. protected _beforeRenderText(text: string): string;
  66984. }
  66985. }
  66986. declare module BABYLON.GUI {
  66987. /** Class used to render 2D lines */
  66988. export class Line extends Control {
  66989. name?: string | undefined;
  66990. private _lineWidth;
  66991. private _x1;
  66992. private _y1;
  66993. private _x2;
  66994. private _y2;
  66995. private _dash;
  66996. private _connectedControl;
  66997. private _connectedControlDirtyObserver;
  66998. /** Gets or sets the dash pattern */
  66999. dash: Array<number>;
  67000. /** Gets or sets the control connected with the line end */
  67001. connectedControl: Control;
  67002. /** Gets or sets start coordinates on X axis */
  67003. x1: string | number;
  67004. /** Gets or sets start coordinates on Y axis */
  67005. y1: string | number;
  67006. /** Gets or sets end coordinates on X axis */
  67007. x2: string | number;
  67008. /** Gets or sets end coordinates on Y axis */
  67009. y2: string | number;
  67010. /** Gets or sets line width */
  67011. lineWidth: number;
  67012. /** Gets or sets horizontal alignment */
  67013. horizontalAlignment: number;
  67014. /** Gets or sets vertical alignment */
  67015. verticalAlignment: number;
  67016. private readonly _effectiveX2;
  67017. private readonly _effectiveY2;
  67018. /**
  67019. * Creates a new Line
  67020. * @param name defines the control name
  67021. */
  67022. constructor(name?: string | undefined);
  67023. protected _getTypeName(): string;
  67024. _draw(context: CanvasRenderingContext2D): void;
  67025. _measure(): void;
  67026. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67027. /**
  67028. * Move one end of the line given 3D cartesian coordinates.
  67029. * @param position Targeted world position
  67030. * @param scene BABYLON.Scene
  67031. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67032. */
  67033. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  67034. /**
  67035. * Move one end of the line to a position in screen absolute space.
  67036. * @param projectedPosition Position in screen absolute space (X, Y)
  67037. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67038. */
  67039. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  67040. }
  67041. }
  67042. declare module BABYLON.GUI {
  67043. /**
  67044. * Class used to store a point for a MultiLine object.
  67045. * The point can be pure 2D coordinates, a mesh or a control
  67046. */
  67047. export class MultiLinePoint {
  67048. private _multiLine;
  67049. private _x;
  67050. private _y;
  67051. private _control;
  67052. private _mesh;
  67053. private _controlObserver;
  67054. private _meshObserver;
  67055. /** @hidden */
  67056. _point: BABYLON.Vector2;
  67057. /**
  67058. * Creates a new MultiLinePoint
  67059. * @param multiLine defines the source MultiLine object
  67060. */
  67061. constructor(multiLine: MultiLine);
  67062. /** Gets or sets x coordinate */
  67063. x: string | number;
  67064. /** Gets or sets y coordinate */
  67065. y: string | number;
  67066. /** Gets or sets the control associated with this point */
  67067. control: BABYLON.Nullable<Control>;
  67068. /** Gets or sets the mesh associated with this point */
  67069. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67070. /** Resets links */
  67071. resetLinks(): void;
  67072. /**
  67073. * Gets a translation vector
  67074. * @returns the translation vector
  67075. */
  67076. translate(): BABYLON.Vector2;
  67077. private _translatePoint;
  67078. /** Release associated resources */
  67079. dispose(): void;
  67080. }
  67081. }
  67082. declare module BABYLON.GUI {
  67083. /**
  67084. * Class used to create multi line control
  67085. */
  67086. export class MultiLine extends Control {
  67087. name?: string | undefined;
  67088. private _lineWidth;
  67089. private _dash;
  67090. private _points;
  67091. private _minX;
  67092. private _minY;
  67093. private _maxX;
  67094. private _maxY;
  67095. /**
  67096. * Creates a new MultiLine
  67097. * @param name defines the control name
  67098. */
  67099. constructor(name?: string | undefined);
  67100. /** Gets or sets dash pattern */
  67101. dash: Array<number>;
  67102. /**
  67103. * Gets point stored at specified index
  67104. * @param index defines the index to look for
  67105. * @returns the requested point if found
  67106. */
  67107. getAt(index: number): MultiLinePoint;
  67108. /** Function called when a point is updated */
  67109. onPointUpdate: () => void;
  67110. /**
  67111. * Adds new points to the point collection
  67112. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  67113. * @returns the list of created MultiLinePoint
  67114. */
  67115. add(...items: (AbstractMesh | Control | {
  67116. x: string | number;
  67117. y: string | number;
  67118. })[]): MultiLinePoint[];
  67119. /**
  67120. * Adds a new point to the point collection
  67121. * @param item defines the item (mesh, control or 2d coordiantes) to add
  67122. * @returns the created MultiLinePoint
  67123. */
  67124. push(item?: (AbstractMesh | Control | {
  67125. x: string | number;
  67126. y: string | number;
  67127. })): MultiLinePoint;
  67128. /**
  67129. * Remove a specific value or point from the active point collection
  67130. * @param value defines the value or point to remove
  67131. */
  67132. remove(value: number | MultiLinePoint): void;
  67133. /**
  67134. * Resets this object to initial state (no point)
  67135. */
  67136. reset(): void;
  67137. /**
  67138. * Resets all links
  67139. */
  67140. resetLinks(): void;
  67141. /** Gets or sets line width */
  67142. lineWidth: number;
  67143. horizontalAlignment: number;
  67144. verticalAlignment: number;
  67145. protected _getTypeName(): string;
  67146. _draw(context: CanvasRenderingContext2D): void;
  67147. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67148. _measure(): void;
  67149. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67150. dispose(): void;
  67151. }
  67152. }
  67153. declare module BABYLON.GUI {
  67154. /**
  67155. * Class used to create radio button controls
  67156. */
  67157. export class RadioButton extends Control {
  67158. name?: string | undefined;
  67159. private _isChecked;
  67160. private _background;
  67161. private _checkSizeRatio;
  67162. private _thickness;
  67163. /** Gets or sets border thickness */
  67164. thickness: number;
  67165. /** Gets or sets group name */
  67166. group: string;
  67167. /** BABYLON.Observable raised when isChecked is changed */
  67168. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67169. /** Gets or sets a value indicating the ratio between overall size and check size */
  67170. checkSizeRatio: number;
  67171. /** Gets or sets background color */
  67172. background: string;
  67173. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67174. isChecked: boolean;
  67175. /**
  67176. * Creates a new RadioButton
  67177. * @param name defines the control name
  67178. */
  67179. constructor(name?: string | undefined);
  67180. protected _getTypeName(): string;
  67181. _draw(context: CanvasRenderingContext2D): void;
  67182. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67183. /**
  67184. * Utility function to easily create a radio button with a header
  67185. * @param title defines the label to use for the header
  67186. * @param group defines the group to use for the radio button
  67187. * @param isChecked defines the initial state of the radio button
  67188. * @param onValueChanged defines the callback to call when value changes
  67189. * @returns a StackPanel containing the radio button and a textBlock
  67190. */
  67191. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  67192. }
  67193. }
  67194. declare module BABYLON.GUI {
  67195. /**
  67196. * Class used to create slider controls
  67197. */
  67198. export class BaseSlider extends Control {
  67199. name?: string | undefined;
  67200. protected _thumbWidth: ValueAndUnit;
  67201. private _minimum;
  67202. private _maximum;
  67203. private _value;
  67204. private _isVertical;
  67205. protected _barOffset: ValueAndUnit;
  67206. private _isThumbClamped;
  67207. protected _displayThumb: boolean;
  67208. private _step;
  67209. private _lastPointerDownID;
  67210. protected _effectiveBarOffset: number;
  67211. protected _renderLeft: number;
  67212. protected _renderTop: number;
  67213. protected _renderWidth: number;
  67214. protected _renderHeight: number;
  67215. protected _backgroundBoxLength: number;
  67216. protected _backgroundBoxThickness: number;
  67217. protected _effectiveThumbThickness: number;
  67218. /** BABYLON.Observable raised when the sldier value changes */
  67219. onValueChangedObservable: BABYLON.Observable<number>;
  67220. /** Gets or sets a boolean indicating if the thumb must be rendered */
  67221. displayThumb: boolean;
  67222. /** Gets or sets a step to apply to values (0 by default) */
  67223. step: number;
  67224. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  67225. barOffset: string | number;
  67226. /** Gets main bar offset in pixels*/
  67227. readonly barOffsetInPixels: number;
  67228. /** Gets or sets thumb width */
  67229. thumbWidth: string | number;
  67230. /** Gets thumb width in pixels */
  67231. readonly thumbWidthInPixels: number;
  67232. /** Gets or sets minimum value */
  67233. minimum: number;
  67234. /** Gets or sets maximum value */
  67235. maximum: number;
  67236. /** Gets or sets current value */
  67237. value: number;
  67238. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  67239. isVertical: boolean;
  67240. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  67241. isThumbClamped: boolean;
  67242. /**
  67243. * Creates a new BaseSlider
  67244. * @param name defines the control name
  67245. */
  67246. constructor(name?: string | undefined);
  67247. protected _getTypeName(): string;
  67248. protected _getThumbPosition(): number;
  67249. protected _getThumbThickness(type: string): number;
  67250. protected _prepareRenderingData(type: string): void;
  67251. private _pointerIsDown;
  67252. /** @hidden */
  67253. protected _updateValueFromPointer(x: number, y: number): void;
  67254. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67255. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67256. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67257. }
  67258. }
  67259. declare module BABYLON.GUI {
  67260. /**
  67261. * Class used to create slider controls
  67262. */
  67263. export class Slider extends BaseSlider {
  67264. name?: string | undefined;
  67265. private _background;
  67266. private _borderColor;
  67267. private _isThumbCircle;
  67268. protected _displayValueBar: boolean;
  67269. /** Gets or sets a boolean indicating if the value bar must be rendered */
  67270. displayValueBar: boolean;
  67271. /** Gets or sets border color */
  67272. borderColor: string;
  67273. /** Gets or sets background color */
  67274. background: string;
  67275. /** Gets or sets a boolean indicating if the thumb should be round or square */
  67276. isThumbCircle: boolean;
  67277. /**
  67278. * Creates a new Slider
  67279. * @param name defines the control name
  67280. */
  67281. constructor(name?: string | undefined);
  67282. protected _getTypeName(): string;
  67283. _draw(context: CanvasRenderingContext2D): void;
  67284. }
  67285. }
  67286. declare module BABYLON.GUI {
  67287. /** Class used to create a RadioGroup
  67288. * which contains groups of radio buttons
  67289. */
  67290. export class SelectorGroup {
  67291. /** name of SelectorGroup */
  67292. name: string;
  67293. private _groupPanel;
  67294. private _selectors;
  67295. private _groupHeader;
  67296. /**
  67297. * Creates a new SelectorGroup
  67298. * @param name of group, used as a group heading
  67299. */
  67300. constructor(
  67301. /** name of SelectorGroup */
  67302. name: string);
  67303. /** Gets the groupPanel of the SelectorGroup */
  67304. readonly groupPanel: StackPanel;
  67305. /** Gets the selectors array */
  67306. readonly selectors: StackPanel[];
  67307. /** Gets and sets the group header */
  67308. header: string;
  67309. /** @hidden */
  67310. private _addGroupHeader;
  67311. /** @hidden*/
  67312. _getSelector(selectorNb: number): StackPanel | undefined;
  67313. /** Removes the selector at the given position
  67314. * @param selectorNb the position of the selector within the group
  67315. */
  67316. removeSelector(selectorNb: number): void;
  67317. }
  67318. /** Class used to create a CheckboxGroup
  67319. * which contains groups of checkbox buttons
  67320. */
  67321. export class CheckboxGroup extends SelectorGroup {
  67322. /** Adds a checkbox as a control
  67323. * @param text is the label for the selector
  67324. * @param func is the function called when the Selector is checked
  67325. * @param checked is true when Selector is checked
  67326. */
  67327. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  67328. /** @hidden */
  67329. _setSelectorLabel(selectorNb: number, label: string): void;
  67330. /** @hidden */
  67331. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67332. /** @hidden */
  67333. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67334. /** @hidden */
  67335. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67336. }
  67337. /** Class used to create a RadioGroup
  67338. * which contains groups of radio buttons
  67339. */
  67340. export class RadioGroup extends SelectorGroup {
  67341. private _selectNb;
  67342. /** Adds a radio button as a control
  67343. * @param label is the label for the selector
  67344. * @param func is the function called when the Selector is checked
  67345. * @param checked is true when Selector is checked
  67346. */
  67347. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  67348. /** @hidden */
  67349. _setSelectorLabel(selectorNb: number, label: string): void;
  67350. /** @hidden */
  67351. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67352. /** @hidden */
  67353. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67354. /** @hidden */
  67355. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67356. }
  67357. /** Class used to create a SliderGroup
  67358. * which contains groups of slider buttons
  67359. */
  67360. export class SliderGroup extends SelectorGroup {
  67361. /**
  67362. * Adds a slider to the SelectorGroup
  67363. * @param label is the label for the SliderBar
  67364. * @param func is the function called when the Slider moves
  67365. * @param unit is a string describing the units used, eg degrees or metres
  67366. * @param min is the minimum value for the Slider
  67367. * @param max is the maximum value for the Slider
  67368. * @param value is the start value for the Slider between min and max
  67369. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  67370. */
  67371. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  67372. /** @hidden */
  67373. _setSelectorLabel(selectorNb: number, label: string): void;
  67374. /** @hidden */
  67375. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67376. /** @hidden */
  67377. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67378. /** @hidden */
  67379. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67380. }
  67381. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  67382. * @see http://doc.babylonjs.com/how_to/selector
  67383. */
  67384. export class SelectionPanel extends Rectangle {
  67385. /** name of SelectionPanel */
  67386. name: string;
  67387. /** an array of SelectionGroups */
  67388. groups: SelectorGroup[];
  67389. private _panel;
  67390. private _buttonColor;
  67391. private _buttonBackground;
  67392. private _headerColor;
  67393. private _barColor;
  67394. private _barHeight;
  67395. private _spacerHeight;
  67396. private _labelColor;
  67397. private _groups;
  67398. private _bars;
  67399. /**
  67400. * Creates a new SelectionPanel
  67401. * @param name of SelectionPanel
  67402. * @param groups is an array of SelectionGroups
  67403. */
  67404. constructor(
  67405. /** name of SelectionPanel */
  67406. name: string,
  67407. /** an array of SelectionGroups */
  67408. groups?: SelectorGroup[]);
  67409. protected _getTypeName(): string;
  67410. /** Gets or sets the headerColor */
  67411. headerColor: string;
  67412. private _setHeaderColor;
  67413. /** Gets or sets the button color */
  67414. buttonColor: string;
  67415. private _setbuttonColor;
  67416. /** Gets or sets the label color */
  67417. labelColor: string;
  67418. private _setLabelColor;
  67419. /** Gets or sets the button background */
  67420. buttonBackground: string;
  67421. private _setButtonBackground;
  67422. /** Gets or sets the color of separator bar */
  67423. barColor: string;
  67424. private _setBarColor;
  67425. /** Gets or sets the height of separator bar */
  67426. barHeight: string;
  67427. private _setBarHeight;
  67428. /** Gets or sets the height of spacers*/
  67429. spacerHeight: string;
  67430. private _setSpacerHeight;
  67431. /** Adds a bar between groups */
  67432. private _addSpacer;
  67433. /** Add a group to the selection panel
  67434. * @param group is the selector group to add
  67435. */
  67436. addGroup(group: SelectorGroup): void;
  67437. /** Remove the group from the given position
  67438. * @param groupNb is the position of the group in the list
  67439. */
  67440. removeGroup(groupNb: number): void;
  67441. /** Change a group header label
  67442. * @param label is the new group header label
  67443. * @param groupNb is the number of the group to relabel
  67444. * */
  67445. setHeaderName(label: string, groupNb: number): void;
  67446. /** Change selector label to the one given
  67447. * @param label is the new selector label
  67448. * @param groupNb is the number of the groupcontaining the selector
  67449. * @param selectorNb is the number of the selector within a group to relabel
  67450. * */
  67451. relabel(label: string, groupNb: number, selectorNb: number): void;
  67452. /** For a given group position remove the selector at the given position
  67453. * @param groupNb is the number of the group to remove the selector from
  67454. * @param selectorNb is the number of the selector within the group
  67455. */
  67456. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67457. /** For a given group position of correct type add a checkbox button
  67458. * @param groupNb is the number of the group to remove the selector from
  67459. * @param label is the label for the selector
  67460. * @param func is the function called when the Selector is checked
  67461. * @param checked is true when Selector is checked
  67462. */
  67463. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67464. /** For a given group position of correct type add a radio button
  67465. * @param groupNb is the number of the group to remove the selector from
  67466. * @param label is the label for the selector
  67467. * @param func is the function called when the Selector is checked
  67468. * @param checked is true when Selector is checked
  67469. */
  67470. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67471. /**
  67472. * For a given slider group add a slider
  67473. * @param groupNb is the number of the group to add the slider to
  67474. * @param label is the label for the Slider
  67475. * @param func is the function called when the Slider moves
  67476. * @param unit is a string describing the units used, eg degrees or metres
  67477. * @param min is the minimum value for the Slider
  67478. * @param max is the maximum value for the Slider
  67479. * @param value is the start value for the Slider between min and max
  67480. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67481. */
  67482. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67483. }
  67484. }
  67485. declare module BABYLON.GUI {
  67486. /**
  67487. * Class used to hold a the container for ScrollViewer
  67488. * @hidden
  67489. */
  67490. export class _ScrollViewerWindow extends Container {
  67491. parentClientWidth: number;
  67492. parentClientHeight: number;
  67493. /**
  67494. * Creates a new ScrollViewerWindow
  67495. * @param name of ScrollViewerWindow
  67496. */
  67497. constructor(name?: string);
  67498. protected _getTypeName(): string;
  67499. /** @hidden */
  67500. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67501. protected _postMeasure(): void;
  67502. }
  67503. }
  67504. declare module BABYLON.GUI {
  67505. /**
  67506. * Class used to create slider controls
  67507. */
  67508. export class ScrollBar extends BaseSlider {
  67509. name?: string | undefined;
  67510. private _background;
  67511. private _borderColor;
  67512. private _thumbMeasure;
  67513. /** Gets or sets border color */
  67514. borderColor: string;
  67515. /** Gets or sets background color */
  67516. background: string;
  67517. /**
  67518. * Creates a new Slider
  67519. * @param name defines the control name
  67520. */
  67521. constructor(name?: string | undefined);
  67522. protected _getTypeName(): string;
  67523. protected _getThumbThickness(): number;
  67524. _draw(context: CanvasRenderingContext2D): void;
  67525. private _first;
  67526. private _originX;
  67527. private _originY;
  67528. /** @hidden */
  67529. protected _updateValueFromPointer(x: number, y: number): void;
  67530. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67531. }
  67532. }
  67533. declare module BABYLON.GUI {
  67534. /**
  67535. * Class used to hold a viewer window and sliders in a grid
  67536. */
  67537. export class ScrollViewer extends Rectangle {
  67538. private _grid;
  67539. private _horizontalBarSpace;
  67540. private _verticalBarSpace;
  67541. private _dragSpace;
  67542. private _horizontalBar;
  67543. private _verticalBar;
  67544. private _barColor;
  67545. private _barBackground;
  67546. private _barSize;
  67547. private _endLeft;
  67548. private _endTop;
  67549. private _window;
  67550. private _pointerIsOver;
  67551. private _wheelPrecision;
  67552. private _onPointerObserver;
  67553. private _clientWidth;
  67554. private _clientHeight;
  67555. /**
  67556. * Gets the horizontal scrollbar
  67557. */
  67558. readonly horizontalBar: ScrollBar;
  67559. /**
  67560. * Gets the vertical scrollbar
  67561. */
  67562. readonly verticalBar: ScrollBar;
  67563. /**
  67564. * Adds a new control to the current container
  67565. * @param control defines the control to add
  67566. * @returns the current container
  67567. */
  67568. addControl(control: BABYLON.Nullable<Control>): Container;
  67569. /**
  67570. * Removes a control from the current container
  67571. * @param control defines the control to remove
  67572. * @returns the current container
  67573. */
  67574. removeControl(control: Control): Container;
  67575. /** Gets the list of children */
  67576. readonly children: Control[];
  67577. _flagDescendantsAsMatrixDirty(): void;
  67578. /**
  67579. * Creates a new ScrollViewer
  67580. * @param name of ScrollViewer
  67581. */
  67582. constructor(name?: string);
  67583. /** Reset the scroll viewer window to initial size */
  67584. resetWindow(): void;
  67585. protected _getTypeName(): string;
  67586. private _buildClientSizes;
  67587. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67588. protected _postMeasure(): void;
  67589. /**
  67590. * Gets or sets the mouse wheel precision
  67591. * from 0 to 1 with a default value of 0.05
  67592. * */
  67593. wheelPrecision: number;
  67594. /** Gets or sets the bar color */
  67595. barColor: string;
  67596. /** Gets or sets the size of the bar */
  67597. barSize: number;
  67598. /** Gets or sets the bar background */
  67599. barBackground: string;
  67600. /** @hidden */
  67601. private _updateScroller;
  67602. _link(host: AdvancedDynamicTexture): void;
  67603. /** @hidden */
  67604. private _attachWheel;
  67605. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67606. /** Releases associated resources */
  67607. dispose(): void;
  67608. }
  67609. }
  67610. declare module BABYLON.GUI {
  67611. /** Class used to render a grid */
  67612. export class DisplayGrid extends Control {
  67613. name?: string | undefined;
  67614. private _cellWidth;
  67615. private _cellHeight;
  67616. private _minorLineTickness;
  67617. private _minorLineColor;
  67618. private _majorLineTickness;
  67619. private _majorLineColor;
  67620. private _majorLineFrequency;
  67621. private _background;
  67622. private _displayMajorLines;
  67623. private _displayMinorLines;
  67624. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67625. displayMinorLines: boolean;
  67626. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67627. displayMajorLines: boolean;
  67628. /** Gets or sets background color (Black by default) */
  67629. background: string;
  67630. /** Gets or sets the width of each cell (20 by default) */
  67631. cellWidth: number;
  67632. /** Gets or sets the height of each cell (20 by default) */
  67633. cellHeight: number;
  67634. /** Gets or sets the tickness of minor lines (1 by default) */
  67635. minorLineTickness: number;
  67636. /** Gets or sets the color of minor lines (DarkGray by default) */
  67637. minorLineColor: string;
  67638. /** Gets or sets the tickness of major lines (2 by default) */
  67639. majorLineTickness: number;
  67640. /** Gets or sets the color of major lines (White by default) */
  67641. majorLineColor: string;
  67642. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67643. majorLineFrequency: number;
  67644. /**
  67645. * Creates a new GridDisplayRectangle
  67646. * @param name defines the control name
  67647. */
  67648. constructor(name?: string | undefined);
  67649. _draw(context: CanvasRenderingContext2D): void;
  67650. protected _getTypeName(): string;
  67651. }
  67652. }
  67653. declare module BABYLON.GUI {
  67654. /**
  67655. * Class used to create slider controls based on images
  67656. */
  67657. export class ImageBasedSlider extends BaseSlider {
  67658. name?: string | undefined;
  67659. private _backgroundImage;
  67660. private _thumbImage;
  67661. private _valueBarImage;
  67662. private _tempMeasure;
  67663. displayThumb: boolean;
  67664. /**
  67665. * Gets or sets the image used to render the background
  67666. */
  67667. backgroundImage: Image;
  67668. /**
  67669. * Gets or sets the image used to render the value bar
  67670. */
  67671. valueBarImage: Image;
  67672. /**
  67673. * Gets or sets the image used to render the thumb
  67674. */
  67675. thumbImage: Image;
  67676. /**
  67677. * Creates a new ImageBasedSlider
  67678. * @param name defines the control name
  67679. */
  67680. constructor(name?: string | undefined);
  67681. protected _getTypeName(): string;
  67682. _draw(context: CanvasRenderingContext2D): void;
  67683. }
  67684. }
  67685. declare module BABYLON.GUI {
  67686. /**
  67687. * Forcing an export so that this code will execute
  67688. * @hidden
  67689. */
  67690. const name = "Statics";
  67691. }
  67692. declare module BABYLON.GUI {
  67693. /**
  67694. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67695. */
  67696. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67697. /**
  67698. * Define the instrumented AdvancedDynamicTexture.
  67699. */
  67700. texture: AdvancedDynamicTexture;
  67701. private _captureRenderTime;
  67702. private _renderTime;
  67703. private _captureLayoutTime;
  67704. private _layoutTime;
  67705. private _onBeginRenderObserver;
  67706. private _onEndRenderObserver;
  67707. private _onBeginLayoutObserver;
  67708. private _onEndLayoutObserver;
  67709. /**
  67710. * Gets the perf counter used to capture render time
  67711. */
  67712. readonly renderTimeCounter: BABYLON.PerfCounter;
  67713. /**
  67714. * Gets the perf counter used to capture layout time
  67715. */
  67716. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67717. /**
  67718. * Enable or disable the render time capture
  67719. */
  67720. captureRenderTime: boolean;
  67721. /**
  67722. * Enable or disable the layout time capture
  67723. */
  67724. captureLayoutTime: boolean;
  67725. /**
  67726. * Instantiates a new advanced dynamic texture instrumentation.
  67727. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67728. * @param texture Defines the AdvancedDynamicTexture to instrument
  67729. */
  67730. constructor(
  67731. /**
  67732. * Define the instrumented AdvancedDynamicTexture.
  67733. */
  67734. texture: AdvancedDynamicTexture);
  67735. /**
  67736. * Dispose and release associated resources.
  67737. */
  67738. dispose(): void;
  67739. }
  67740. }
  67741. declare module BABYLON.GUI {
  67742. /**
  67743. * Class used to load GUI via XML.
  67744. */
  67745. export class XmlLoader {
  67746. private _nodes;
  67747. private _nodeTypes;
  67748. private _isLoaded;
  67749. private _objectAttributes;
  67750. private _parentClass;
  67751. /**
  67752. * Create a new xml loader
  67753. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67754. */
  67755. constructor(parentClass?: null);
  67756. private _getChainElement;
  67757. private _getClassAttribute;
  67758. private _createGuiElement;
  67759. private _parseGrid;
  67760. private _parseElement;
  67761. private _prepareSourceElement;
  67762. private _parseElementsFromSource;
  67763. private _parseXml;
  67764. /**
  67765. * Gets if the loading has finished.
  67766. * @returns whether the loading has finished or not
  67767. */
  67768. isLoaded(): boolean;
  67769. /**
  67770. * Gets a loaded node / control by id.
  67771. * @param id the Controls id set in the xml
  67772. * @returns element of type Control
  67773. */
  67774. getNodeById(id: string): any;
  67775. /**
  67776. * Gets all loaded nodes / controls
  67777. * @returns Array of controls
  67778. */
  67779. getNodes(): any;
  67780. /**
  67781. * Initiates the xml layout loading
  67782. * @param xmlFile defines the xml layout to load
  67783. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67784. * @param callback defines the callback called on layout load.
  67785. */
  67786. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67787. }
  67788. }
  67789. declare module BABYLON.GUI {
  67790. /**
  67791. * Class used to create containers for controls
  67792. */
  67793. export class Container3D extends Control3D {
  67794. private _blockLayout;
  67795. /**
  67796. * Gets the list of child controls
  67797. */
  67798. protected _children: Control3D[];
  67799. /**
  67800. * Gets the list of child controls
  67801. */
  67802. readonly children: Array<Control3D>;
  67803. /**
  67804. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67805. * This is helpful to optimize layout operation when adding multiple children in a row
  67806. */
  67807. blockLayout: boolean;
  67808. /**
  67809. * Creates a new container
  67810. * @param name defines the container name
  67811. */
  67812. constructor(name?: string);
  67813. /**
  67814. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67815. * @returns the current container
  67816. */
  67817. updateLayout(): Container3D;
  67818. /**
  67819. * Gets a boolean indicating if the given control is in the children of this control
  67820. * @param control defines the control to check
  67821. * @returns true if the control is in the child list
  67822. */
  67823. containsControl(control: Control3D): boolean;
  67824. /**
  67825. * Adds a control to the children of this control
  67826. * @param control defines the control to add
  67827. * @returns the current container
  67828. */
  67829. addControl(control: Control3D): Container3D;
  67830. /**
  67831. * This function will be called everytime a new control is added
  67832. */
  67833. protected _arrangeChildren(): void;
  67834. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67835. /**
  67836. * Removes a control from the children of this control
  67837. * @param control defines the control to remove
  67838. * @returns the current container
  67839. */
  67840. removeControl(control: Control3D): Container3D;
  67841. protected _getTypeName(): string;
  67842. /**
  67843. * Releases all associated resources
  67844. */
  67845. dispose(): void;
  67846. /** Control rotation will remain unchanged */
  67847. static readonly UNSET_ORIENTATION: number;
  67848. /** Control will rotate to make it look at sphere central axis */
  67849. static readonly FACEORIGIN_ORIENTATION: number;
  67850. /** Control will rotate to make it look back at sphere central axis */
  67851. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67852. /** Control will rotate to look at z axis (0, 0, 1) */
  67853. static readonly FACEFORWARD_ORIENTATION: number;
  67854. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67855. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67856. }
  67857. }
  67858. declare module BABYLON.GUI {
  67859. /**
  67860. * Class used to manage 3D user interface
  67861. * @see http://doc.babylonjs.com/how_to/gui3d
  67862. */
  67863. export class GUI3DManager implements BABYLON.IDisposable {
  67864. private _scene;
  67865. private _sceneDisposeObserver;
  67866. private _utilityLayer;
  67867. private _rootContainer;
  67868. private _pointerObserver;
  67869. private _pointerOutObserver;
  67870. /** @hidden */
  67871. _lastPickedControl: Control3D;
  67872. /** @hidden */
  67873. _lastControlOver: {
  67874. [pointerId: number]: Control3D;
  67875. };
  67876. /** @hidden */
  67877. _lastControlDown: {
  67878. [pointerId: number]: Control3D;
  67879. };
  67880. /**
  67881. * BABYLON.Observable raised when the point picked by the pointer events changed
  67882. */
  67883. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67884. /** @hidden */
  67885. _sharedMaterials: {
  67886. [key: string]: BABYLON.Material;
  67887. };
  67888. /** Gets the hosting scene */
  67889. readonly scene: BABYLON.Scene;
  67890. /** Gets associated utility layer */
  67891. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67892. /**
  67893. * Creates a new GUI3DManager
  67894. * @param scene
  67895. */
  67896. constructor(scene?: BABYLON.Scene);
  67897. private _handlePointerOut;
  67898. private _doPicking;
  67899. /**
  67900. * Gets the root container
  67901. */
  67902. readonly rootContainer: Container3D;
  67903. /**
  67904. * Gets a boolean indicating if the given control is in the root child list
  67905. * @param control defines the control to check
  67906. * @returns true if the control is in the root child list
  67907. */
  67908. containsControl(control: Control3D): boolean;
  67909. /**
  67910. * Adds a control to the root child list
  67911. * @param control defines the control to add
  67912. * @returns the current manager
  67913. */
  67914. addControl(control: Control3D): GUI3DManager;
  67915. /**
  67916. * Removes a control from the root child list
  67917. * @param control defines the control to remove
  67918. * @returns the current container
  67919. */
  67920. removeControl(control: Control3D): GUI3DManager;
  67921. /**
  67922. * Releases all associated resources
  67923. */
  67924. dispose(): void;
  67925. }
  67926. }
  67927. declare module BABYLON.GUI {
  67928. /**
  67929. * Class used to transport BABYLON.Vector3 information for pointer events
  67930. */
  67931. export class Vector3WithInfo extends BABYLON.Vector3 {
  67932. /** defines the current mouse button index */
  67933. buttonIndex: number;
  67934. /**
  67935. * Creates a new Vector3WithInfo
  67936. * @param source defines the vector3 data to transport
  67937. * @param buttonIndex defines the current mouse button index
  67938. */
  67939. constructor(source: BABYLON.Vector3,
  67940. /** defines the current mouse button index */
  67941. buttonIndex?: number);
  67942. }
  67943. }
  67944. declare module BABYLON.GUI {
  67945. /**
  67946. * Class used as base class for controls
  67947. */
  67948. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67949. /** Defines the control name */
  67950. name?: string | undefined;
  67951. /** @hidden */
  67952. _host: GUI3DManager;
  67953. private _node;
  67954. private _downCount;
  67955. private _enterCount;
  67956. private _downPointerIds;
  67957. private _isVisible;
  67958. /** Gets or sets the control position in world space */
  67959. position: BABYLON.Vector3;
  67960. /** Gets or sets the control scaling in world space */
  67961. scaling: BABYLON.Vector3;
  67962. /** Callback used to start pointer enter animation */
  67963. pointerEnterAnimation: () => void;
  67964. /** Callback used to start pointer out animation */
  67965. pointerOutAnimation: () => void;
  67966. /** Callback used to start pointer down animation */
  67967. pointerDownAnimation: () => void;
  67968. /** Callback used to start pointer up animation */
  67969. pointerUpAnimation: () => void;
  67970. /**
  67971. * An event triggered when the pointer move over the control
  67972. */
  67973. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67974. /**
  67975. * An event triggered when the pointer move out of the control
  67976. */
  67977. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67978. /**
  67979. * An event triggered when the pointer taps the control
  67980. */
  67981. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67982. /**
  67983. * An event triggered when pointer is up
  67984. */
  67985. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67986. /**
  67987. * An event triggered when a control is clicked on (with a mouse)
  67988. */
  67989. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67990. /**
  67991. * An event triggered when pointer enters the control
  67992. */
  67993. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67994. /**
  67995. * Gets or sets the parent container
  67996. */
  67997. parent: BABYLON.Nullable<Container3D>;
  67998. private _behaviors;
  67999. /**
  68000. * Gets the list of attached behaviors
  68001. * @see http://doc.babylonjs.com/features/behaviour
  68002. */
  68003. readonly behaviors: BABYLON.Behavior<Control3D>[];
  68004. /**
  68005. * Attach a behavior to the control
  68006. * @see http://doc.babylonjs.com/features/behaviour
  68007. * @param behavior defines the behavior to attach
  68008. * @returns the current control
  68009. */
  68010. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68011. /**
  68012. * Remove an attached behavior
  68013. * @see http://doc.babylonjs.com/features/behaviour
  68014. * @param behavior defines the behavior to attach
  68015. * @returns the current control
  68016. */
  68017. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68018. /**
  68019. * Gets an attached behavior by name
  68020. * @param name defines the name of the behavior to look for
  68021. * @see http://doc.babylonjs.com/features/behaviour
  68022. * @returns null if behavior was not found else the requested behavior
  68023. */
  68024. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  68025. /** Gets or sets a boolean indicating if the control is visible */
  68026. isVisible: boolean;
  68027. /**
  68028. * Creates a new control
  68029. * @param name defines the control name
  68030. */
  68031. constructor(
  68032. /** Defines the control name */
  68033. name?: string | undefined);
  68034. /**
  68035. * Gets a string representing the class name
  68036. */
  68037. readonly typeName: string;
  68038. /**
  68039. * Get the current class name of the control.
  68040. * @returns current class name
  68041. */
  68042. getClassName(): string;
  68043. protected _getTypeName(): string;
  68044. /**
  68045. * Gets the transform node used by this control
  68046. */
  68047. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  68048. /**
  68049. * Gets the mesh used to render this control
  68050. */
  68051. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68052. /**
  68053. * Link the control as child of the given node
  68054. * @param node defines the node to link to. Use null to unlink the control
  68055. * @returns the current control
  68056. */
  68057. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  68058. /** @hidden **/
  68059. _prepareNode(scene: BABYLON.Scene): void;
  68060. /**
  68061. * Node creation.
  68062. * Can be overriden by children
  68063. * @param scene defines the scene where the node must be attached
  68064. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  68065. */
  68066. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68067. /**
  68068. * Affect a material to the given mesh
  68069. * @param mesh defines the mesh which will represent the control
  68070. */
  68071. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68072. /** @hidden */
  68073. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  68074. /** @hidden */
  68075. _onPointerEnter(target: Control3D): boolean;
  68076. /** @hidden */
  68077. _onPointerOut(target: Control3D): void;
  68078. /** @hidden */
  68079. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68080. /** @hidden */
  68081. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68082. /** @hidden */
  68083. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68084. /** @hidden */
  68085. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68086. /** @hidden */
  68087. _disposeNode(): void;
  68088. /**
  68089. * Releases all associated resources
  68090. */
  68091. dispose(): void;
  68092. }
  68093. }
  68094. declare module BABYLON.GUI {
  68095. /**
  68096. * Class used as a root to all buttons
  68097. */
  68098. export class AbstractButton3D extends Control3D {
  68099. /**
  68100. * Creates a new button
  68101. * @param name defines the control name
  68102. */
  68103. constructor(name?: string);
  68104. protected _getTypeName(): string;
  68105. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68106. }
  68107. }
  68108. declare module BABYLON.GUI {
  68109. /**
  68110. * Class used to create a button in 3D
  68111. */
  68112. export class Button3D extends AbstractButton3D {
  68113. /** @hidden */
  68114. protected _currentMaterial: BABYLON.Material;
  68115. private _facadeTexture;
  68116. private _content;
  68117. private _contentResolution;
  68118. private _contentScaleRatio;
  68119. /**
  68120. * Gets or sets the texture resolution used to render content (512 by default)
  68121. */
  68122. contentResolution: BABYLON.int;
  68123. /**
  68124. * Gets or sets the texture scale ratio used to render content (2 by default)
  68125. */
  68126. contentScaleRatio: number;
  68127. protected _disposeFacadeTexture(): void;
  68128. protected _resetContent(): void;
  68129. /**
  68130. * Creates a new button
  68131. * @param name defines the control name
  68132. */
  68133. constructor(name?: string);
  68134. /**
  68135. * Gets or sets the GUI 2D content used to display the button's facade
  68136. */
  68137. content: Control;
  68138. /**
  68139. * Apply the facade texture (created from the content property).
  68140. * This function can be overloaded by child classes
  68141. * @param facadeTexture defines the AdvancedDynamicTexture to use
  68142. */
  68143. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68144. protected _getTypeName(): string;
  68145. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68146. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68147. /**
  68148. * Releases all associated resources
  68149. */
  68150. dispose(): void;
  68151. }
  68152. }
  68153. declare module BABYLON.GUI {
  68154. /**
  68155. * Abstract class used to create a container panel deployed on the surface of a volume
  68156. */
  68157. export abstract class VolumeBasedPanel extends Container3D {
  68158. private _columns;
  68159. private _rows;
  68160. private _rowThenColum;
  68161. private _orientation;
  68162. protected _cellWidth: number;
  68163. protected _cellHeight: number;
  68164. /**
  68165. * Gets or sets the distance between elements
  68166. */
  68167. margin: number;
  68168. /**
  68169. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  68170. * | Value | Type | Description |
  68171. * | ----- | ----------------------------------- | ----------- |
  68172. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  68173. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  68174. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  68175. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  68176. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  68177. */
  68178. orientation: number;
  68179. /**
  68180. * Gets or sets the number of columns requested (10 by default).
  68181. * The panel will automatically compute the number of rows based on number of child controls.
  68182. */
  68183. columns: BABYLON.int;
  68184. /**
  68185. * Gets or sets a the number of rows requested.
  68186. * The panel will automatically compute the number of columns based on number of child controls.
  68187. */
  68188. rows: BABYLON.int;
  68189. /**
  68190. * Creates new VolumeBasedPanel
  68191. */
  68192. constructor();
  68193. protected _arrangeChildren(): void;
  68194. /** Child classes must implement this function to provide correct control positioning */
  68195. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68196. /** Child classes can implement this function to provide additional processing */
  68197. protected _finalProcessing(): void;
  68198. }
  68199. }
  68200. declare module BABYLON.GUI {
  68201. /**
  68202. * Class used to create a container panel deployed on the surface of a cylinder
  68203. */
  68204. export class CylinderPanel extends VolumeBasedPanel {
  68205. private _radius;
  68206. /**
  68207. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  68208. */
  68209. radius: BABYLON.float;
  68210. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68211. private _cylindricalMapping;
  68212. }
  68213. }
  68214. declare module BABYLON.GUI {
  68215. /** @hidden */
  68216. export var fluentVertexShader: {
  68217. name: string;
  68218. shader: string;
  68219. };
  68220. }
  68221. declare module BABYLON.GUI {
  68222. /** @hidden */
  68223. export var fluentPixelShader: {
  68224. name: string;
  68225. shader: string;
  68226. };
  68227. }
  68228. declare module BABYLON.GUI {
  68229. /** @hidden */
  68230. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  68231. INNERGLOW: boolean;
  68232. BORDER: boolean;
  68233. HOVERLIGHT: boolean;
  68234. TEXTURE: boolean;
  68235. constructor();
  68236. }
  68237. /**
  68238. * Class used to render controls with fluent desgin
  68239. */
  68240. export class FluentMaterial extends BABYLON.PushMaterial {
  68241. /**
  68242. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  68243. */
  68244. innerGlowColorIntensity: number;
  68245. /**
  68246. * Gets or sets the inner glow color (white by default)
  68247. */
  68248. innerGlowColor: BABYLON.Color3;
  68249. /**
  68250. * Gets or sets alpha value (default is 1.0)
  68251. */
  68252. alpha: number;
  68253. /**
  68254. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  68255. */
  68256. albedoColor: BABYLON.Color3;
  68257. /**
  68258. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  68259. */
  68260. renderBorders: boolean;
  68261. /**
  68262. * Gets or sets border width (default is 0.5)
  68263. */
  68264. borderWidth: number;
  68265. /**
  68266. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  68267. */
  68268. edgeSmoothingValue: number;
  68269. /**
  68270. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  68271. */
  68272. borderMinValue: number;
  68273. /**
  68274. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  68275. */
  68276. renderHoverLight: boolean;
  68277. /**
  68278. * Gets or sets the radius used to render the hover light (default is 1.0)
  68279. */
  68280. hoverRadius: number;
  68281. /**
  68282. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  68283. */
  68284. hoverColor: BABYLON.Color4;
  68285. /**
  68286. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  68287. */
  68288. hoverPosition: BABYLON.Vector3;
  68289. private _albedoTexture;
  68290. /** Gets or sets the texture to use for albedo color */
  68291. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68292. /**
  68293. * Creates a new Fluent material
  68294. * @param name defines the name of the material
  68295. * @param scene defines the hosting scene
  68296. */
  68297. constructor(name: string, scene: BABYLON.Scene);
  68298. needAlphaBlending(): boolean;
  68299. needAlphaTesting(): boolean;
  68300. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68301. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68302. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68303. getActiveTextures(): BABYLON.BaseTexture[];
  68304. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68305. dispose(forceDisposeEffect?: boolean): void;
  68306. clone(name: string): FluentMaterial;
  68307. serialize(): any;
  68308. getClassName(): string;
  68309. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  68310. }
  68311. }
  68312. declare module BABYLON.GUI {
  68313. /**
  68314. * Class used to create a holographic button in 3D
  68315. */
  68316. export class HolographicButton extends Button3D {
  68317. private _backPlate;
  68318. private _textPlate;
  68319. private _frontPlate;
  68320. private _text;
  68321. private _imageUrl;
  68322. private _shareMaterials;
  68323. private _frontMaterial;
  68324. private _backMaterial;
  68325. private _plateMaterial;
  68326. private _pickedPointObserver;
  68327. private _tooltipFade;
  68328. private _tooltipTextBlock;
  68329. private _tooltipTexture;
  68330. private _tooltipMesh;
  68331. private _tooltipHoverObserver;
  68332. private _tooltipOutObserver;
  68333. private _disposeTooltip;
  68334. /**
  68335. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  68336. */
  68337. tooltipText: BABYLON.Nullable<string>;
  68338. /**
  68339. * Gets or sets text for the button
  68340. */
  68341. text: string;
  68342. /**
  68343. * Gets or sets the image url for the button
  68344. */
  68345. imageUrl: string;
  68346. /**
  68347. * Gets the back material used by this button
  68348. */
  68349. readonly backMaterial: FluentMaterial;
  68350. /**
  68351. * Gets the front material used by this button
  68352. */
  68353. readonly frontMaterial: FluentMaterial;
  68354. /**
  68355. * Gets the plate material used by this button
  68356. */
  68357. readonly plateMaterial: BABYLON.StandardMaterial;
  68358. /**
  68359. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  68360. */
  68361. readonly shareMaterials: boolean;
  68362. /**
  68363. * Creates a new button
  68364. * @param name defines the control name
  68365. */
  68366. constructor(name?: string, shareMaterials?: boolean);
  68367. protected _getTypeName(): string;
  68368. private _rebuildContent;
  68369. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68370. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68371. private _createBackMaterial;
  68372. private _createFrontMaterial;
  68373. private _createPlateMaterial;
  68374. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  68375. /**
  68376. * Releases all associated resources
  68377. */
  68378. dispose(): void;
  68379. }
  68380. }
  68381. declare module BABYLON.GUI {
  68382. /**
  68383. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  68384. */
  68385. export class MeshButton3D extends Button3D {
  68386. /** @hidden */
  68387. protected _currentMesh: BABYLON.Mesh;
  68388. /**
  68389. * Creates a new 3D button based on a mesh
  68390. * @param mesh mesh to become a 3D button
  68391. * @param name defines the control name
  68392. */
  68393. constructor(mesh: BABYLON.Mesh, name?: string);
  68394. protected _getTypeName(): string;
  68395. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68396. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68397. }
  68398. }
  68399. declare module BABYLON.GUI {
  68400. /**
  68401. * Class used to create a container panel deployed on the surface of a plane
  68402. */
  68403. export class PlanePanel extends VolumeBasedPanel {
  68404. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68405. }
  68406. }
  68407. declare module BABYLON.GUI {
  68408. /**
  68409. * Class used to create a container panel where items get randomized planar mapping
  68410. */
  68411. export class ScatterPanel extends VolumeBasedPanel {
  68412. private _iteration;
  68413. /**
  68414. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  68415. */
  68416. iteration: BABYLON.float;
  68417. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68418. private _scatterMapping;
  68419. protected _finalProcessing(): void;
  68420. }
  68421. }
  68422. declare module BABYLON.GUI {
  68423. /**
  68424. * Class used to create a container panel deployed on the surface of a sphere
  68425. */
  68426. export class SpherePanel extends VolumeBasedPanel {
  68427. private _radius;
  68428. /**
  68429. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68430. */
  68431. radius: BABYLON.float;
  68432. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68433. private _sphericalMapping;
  68434. }
  68435. }
  68436. declare module BABYLON.GUI {
  68437. /**
  68438. * Class used to create a stack panel in 3D on XY plane
  68439. */
  68440. export class StackPanel3D extends Container3D {
  68441. private _isVertical;
  68442. /**
  68443. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68444. */
  68445. isVertical: boolean;
  68446. /**
  68447. * Gets or sets the distance between elements
  68448. */
  68449. margin: number;
  68450. /**
  68451. * Creates new StackPanel
  68452. * @param isVertical
  68453. */
  68454. constructor(isVertical?: boolean);
  68455. protected _arrangeChildren(): void;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /**
  68460. * Mode that determines the coordinate system to use.
  68461. */
  68462. export enum GLTFLoaderCoordinateSystemMode {
  68463. /**
  68464. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68465. */
  68466. AUTO = 0,
  68467. /**
  68468. * Sets the useRightHandedSystem flag on the scene.
  68469. */
  68470. FORCE_RIGHT_HANDED = 1
  68471. }
  68472. /**
  68473. * Mode that determines what animations will start.
  68474. */
  68475. export enum GLTFLoaderAnimationStartMode {
  68476. /**
  68477. * No animation will start.
  68478. */
  68479. NONE = 0,
  68480. /**
  68481. * The first animation will start.
  68482. */
  68483. FIRST = 1,
  68484. /**
  68485. * All animations will start.
  68486. */
  68487. ALL = 2
  68488. }
  68489. /**
  68490. * Interface that contains the data for the glTF asset.
  68491. */
  68492. export interface IGLTFLoaderData {
  68493. /**
  68494. * The object that represents the glTF JSON.
  68495. */
  68496. json: Object;
  68497. /**
  68498. * The BIN chunk of a binary glTF.
  68499. */
  68500. bin: Nullable<IDataBuffer>;
  68501. }
  68502. /**
  68503. * Interface for extending the loader.
  68504. */
  68505. export interface IGLTFLoaderExtension {
  68506. /**
  68507. * The name of this extension.
  68508. */
  68509. readonly name: string;
  68510. /**
  68511. * Defines whether this extension is enabled.
  68512. */
  68513. enabled: boolean;
  68514. /**
  68515. * Defines the order of this extension.
  68516. * The loader sorts the extensions using these values when loading.
  68517. */
  68518. order?: number;
  68519. }
  68520. /**
  68521. * Loader state.
  68522. */
  68523. export enum GLTFLoaderState {
  68524. /**
  68525. * The asset is loading.
  68526. */
  68527. LOADING = 0,
  68528. /**
  68529. * The asset is ready for rendering.
  68530. */
  68531. READY = 1,
  68532. /**
  68533. * The asset is completely loaded.
  68534. */
  68535. COMPLETE = 2
  68536. }
  68537. /** @hidden */
  68538. export interface IGLTFLoader extends IDisposable {
  68539. readonly state: Nullable<GLTFLoaderState>;
  68540. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68541. meshes: AbstractMesh[];
  68542. particleSystems: IParticleSystem[];
  68543. skeletons: Skeleton[];
  68544. animationGroups: AnimationGroup[];
  68545. }>;
  68546. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68547. }
  68548. /**
  68549. * File loader for loading glTF files into a scene.
  68550. */
  68551. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68552. /** @hidden */
  68553. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68554. /** @hidden */
  68555. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68556. /**
  68557. * Raised when the asset has been parsed
  68558. */
  68559. onParsedObservable: Observable<IGLTFLoaderData>;
  68560. private _onParsedObserver;
  68561. /**
  68562. * Raised when the asset has been parsed
  68563. */
  68564. onParsed: (loaderData: IGLTFLoaderData) => void;
  68565. /**
  68566. * 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.
  68567. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68568. * Defaults to true.
  68569. * @hidden
  68570. */
  68571. static IncrementalLoading: boolean;
  68572. /**
  68573. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68574. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68575. * @hidden
  68576. */
  68577. static HomogeneousCoordinates: boolean;
  68578. /**
  68579. * The coordinate system mode. Defaults to AUTO.
  68580. */
  68581. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68582. /**
  68583. * The animation start mode. Defaults to FIRST.
  68584. */
  68585. animationStartMode: GLTFLoaderAnimationStartMode;
  68586. /**
  68587. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68588. */
  68589. compileMaterials: boolean;
  68590. /**
  68591. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68592. */
  68593. useClipPlane: boolean;
  68594. /**
  68595. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68596. */
  68597. compileShadowGenerators: boolean;
  68598. /**
  68599. * Defines if the Alpha blended materials are only applied as coverage.
  68600. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68601. * If true, no extra effects are applied to transparent pixels.
  68602. */
  68603. transparencyAsCoverage: boolean;
  68604. /**
  68605. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68606. * Enabling will disable offline support and glTF validator.
  68607. * Defaults to false.
  68608. */
  68609. useRangeRequests: boolean;
  68610. /**
  68611. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68612. */
  68613. createInstances: boolean;
  68614. /**
  68615. * Function called before loading a url referenced by the asset.
  68616. */
  68617. preprocessUrlAsync: (url: string) => Promise<string>;
  68618. /**
  68619. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68620. */
  68621. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68622. private _onMeshLoadedObserver;
  68623. /**
  68624. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68625. */
  68626. onMeshLoaded: (mesh: AbstractMesh) => void;
  68627. /**
  68628. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68629. */
  68630. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68631. private _onTextureLoadedObserver;
  68632. /**
  68633. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68634. */
  68635. onTextureLoaded: (texture: BaseTexture) => void;
  68636. /**
  68637. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68638. */
  68639. readonly onMaterialLoadedObservable: Observable<Material>;
  68640. private _onMaterialLoadedObserver;
  68641. /**
  68642. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68643. */
  68644. onMaterialLoaded: (material: Material) => void;
  68645. /**
  68646. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68647. */
  68648. readonly onCameraLoadedObservable: Observable<Camera>;
  68649. private _onCameraLoadedObserver;
  68650. /**
  68651. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68652. */
  68653. onCameraLoaded: (camera: Camera) => void;
  68654. /**
  68655. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68656. * For assets with LODs, raised when all of the LODs are complete.
  68657. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68658. */
  68659. readonly onCompleteObservable: Observable<void>;
  68660. private _onCompleteObserver;
  68661. /**
  68662. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68663. * For assets with LODs, raised when all of the LODs are complete.
  68664. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68665. */
  68666. onComplete: () => void;
  68667. /**
  68668. * Observable raised when an error occurs.
  68669. */
  68670. readonly onErrorObservable: Observable<any>;
  68671. private _onErrorObserver;
  68672. /**
  68673. * Callback raised when an error occurs.
  68674. */
  68675. onError: (reason: any) => void;
  68676. /**
  68677. * Observable raised after the loader is disposed.
  68678. */
  68679. readonly onDisposeObservable: Observable<void>;
  68680. private _onDisposeObserver;
  68681. /**
  68682. * Callback raised after the loader is disposed.
  68683. */
  68684. onDispose: () => void;
  68685. /**
  68686. * Observable raised after a loader extension is created.
  68687. * Set additional options for a loader extension in this event.
  68688. */
  68689. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68690. private _onExtensionLoadedObserver;
  68691. /**
  68692. * Callback raised after a loader extension is created.
  68693. */
  68694. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68695. /**
  68696. * Defines if the loader logging is enabled.
  68697. */
  68698. loggingEnabled: boolean;
  68699. /**
  68700. * Defines if the loader should capture performance counters.
  68701. */
  68702. capturePerformanceCounters: boolean;
  68703. /**
  68704. * Defines if the loader should validate the asset.
  68705. */
  68706. validate: boolean;
  68707. /**
  68708. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68709. */
  68710. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68711. private _onValidatedObserver;
  68712. /**
  68713. * Callback raised after a loader extension is created.
  68714. */
  68715. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68716. private _loader;
  68717. /**
  68718. * Name of the loader ("gltf")
  68719. */
  68720. name: string;
  68721. /** @hidden */
  68722. extensions: ISceneLoaderPluginExtensions;
  68723. /**
  68724. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68725. */
  68726. dispose(): void;
  68727. /** @hidden */
  68728. _clear(): void;
  68729. /** @hidden */
  68730. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68731. /** @hidden */
  68732. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68733. /** @hidden */
  68734. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68735. meshes: AbstractMesh[];
  68736. particleSystems: IParticleSystem[];
  68737. skeletons: Skeleton[];
  68738. animationGroups: AnimationGroup[];
  68739. }>;
  68740. /** @hidden */
  68741. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68742. /** @hidden */
  68743. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68744. /** @hidden */
  68745. canDirectLoad(data: string): boolean;
  68746. /** @hidden */
  68747. directLoad(scene: Scene, data: string): any;
  68748. /**
  68749. * The callback that allows custom handling of the root url based on the response url.
  68750. * @param rootUrl the original root url
  68751. * @param responseURL the response url if available
  68752. * @returns the new root url
  68753. */
  68754. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68755. /** @hidden */
  68756. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68757. /**
  68758. * The loader state or null if the loader is not active.
  68759. */
  68760. readonly loaderState: Nullable<GLTFLoaderState>;
  68761. /**
  68762. * Returns a promise that resolves when the asset is completely loaded.
  68763. * @returns a promise that resolves when the asset is completely loaded.
  68764. */
  68765. whenCompleteAsync(): Promise<void>;
  68766. private _validateAsync;
  68767. private _getLoader;
  68768. private _parseJson;
  68769. private _unpackBinaryAsync;
  68770. private _unpackBinaryV1Async;
  68771. private _unpackBinaryV2Async;
  68772. private static _parseVersion;
  68773. private static _compareVersion;
  68774. private static readonly _logSpaces;
  68775. private _logIndentLevel;
  68776. private _loggingEnabled;
  68777. /** @hidden */
  68778. _log: (message: string) => void;
  68779. /** @hidden */
  68780. _logOpen(message: string): void;
  68781. /** @hidden */
  68782. _logClose(): void;
  68783. private _logEnabled;
  68784. private _logDisabled;
  68785. private _capturePerformanceCounters;
  68786. /** @hidden */
  68787. _startPerformanceCounter: (counterName: string) => void;
  68788. /** @hidden */
  68789. _endPerformanceCounter: (counterName: string) => void;
  68790. private _startPerformanceCounterEnabled;
  68791. private _startPerformanceCounterDisabled;
  68792. private _endPerformanceCounterEnabled;
  68793. private _endPerformanceCounterDisabled;
  68794. }
  68795. }
  68796. declare module BABYLON.GLTF1 {
  68797. /**
  68798. * Enums
  68799. * @hidden
  68800. */
  68801. export enum EComponentType {
  68802. BYTE = 5120,
  68803. UNSIGNED_BYTE = 5121,
  68804. SHORT = 5122,
  68805. UNSIGNED_SHORT = 5123,
  68806. FLOAT = 5126
  68807. }
  68808. /** @hidden */
  68809. export enum EShaderType {
  68810. FRAGMENT = 35632,
  68811. VERTEX = 35633
  68812. }
  68813. /** @hidden */
  68814. export enum EParameterType {
  68815. BYTE = 5120,
  68816. UNSIGNED_BYTE = 5121,
  68817. SHORT = 5122,
  68818. UNSIGNED_SHORT = 5123,
  68819. INT = 5124,
  68820. UNSIGNED_INT = 5125,
  68821. FLOAT = 5126,
  68822. FLOAT_VEC2 = 35664,
  68823. FLOAT_VEC3 = 35665,
  68824. FLOAT_VEC4 = 35666,
  68825. INT_VEC2 = 35667,
  68826. INT_VEC3 = 35668,
  68827. INT_VEC4 = 35669,
  68828. BOOL = 35670,
  68829. BOOL_VEC2 = 35671,
  68830. BOOL_VEC3 = 35672,
  68831. BOOL_VEC4 = 35673,
  68832. FLOAT_MAT2 = 35674,
  68833. FLOAT_MAT3 = 35675,
  68834. FLOAT_MAT4 = 35676,
  68835. SAMPLER_2D = 35678
  68836. }
  68837. /** @hidden */
  68838. export enum ETextureWrapMode {
  68839. CLAMP_TO_EDGE = 33071,
  68840. MIRRORED_REPEAT = 33648,
  68841. REPEAT = 10497
  68842. }
  68843. /** @hidden */
  68844. export enum ETextureFilterType {
  68845. NEAREST = 9728,
  68846. LINEAR = 9728,
  68847. NEAREST_MIPMAP_NEAREST = 9984,
  68848. LINEAR_MIPMAP_NEAREST = 9985,
  68849. NEAREST_MIPMAP_LINEAR = 9986,
  68850. LINEAR_MIPMAP_LINEAR = 9987
  68851. }
  68852. /** @hidden */
  68853. export enum ETextureFormat {
  68854. ALPHA = 6406,
  68855. RGB = 6407,
  68856. RGBA = 6408,
  68857. LUMINANCE = 6409,
  68858. LUMINANCE_ALPHA = 6410
  68859. }
  68860. /** @hidden */
  68861. export enum ECullingType {
  68862. FRONT = 1028,
  68863. BACK = 1029,
  68864. FRONT_AND_BACK = 1032
  68865. }
  68866. /** @hidden */
  68867. export enum EBlendingFunction {
  68868. ZERO = 0,
  68869. ONE = 1,
  68870. SRC_COLOR = 768,
  68871. ONE_MINUS_SRC_COLOR = 769,
  68872. DST_COLOR = 774,
  68873. ONE_MINUS_DST_COLOR = 775,
  68874. SRC_ALPHA = 770,
  68875. ONE_MINUS_SRC_ALPHA = 771,
  68876. DST_ALPHA = 772,
  68877. ONE_MINUS_DST_ALPHA = 773,
  68878. CONSTANT_COLOR = 32769,
  68879. ONE_MINUS_CONSTANT_COLOR = 32770,
  68880. CONSTANT_ALPHA = 32771,
  68881. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68882. SRC_ALPHA_SATURATE = 776
  68883. }
  68884. /** @hidden */
  68885. export interface IGLTFProperty {
  68886. extensions?: {
  68887. [key: string]: any;
  68888. };
  68889. extras?: Object;
  68890. }
  68891. /** @hidden */
  68892. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68893. name?: string;
  68894. }
  68895. /** @hidden */
  68896. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68897. bufferView: string;
  68898. byteOffset: number;
  68899. byteStride: number;
  68900. count: number;
  68901. type: string;
  68902. componentType: EComponentType;
  68903. max?: number[];
  68904. min?: number[];
  68905. name?: string;
  68906. }
  68907. /** @hidden */
  68908. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68909. buffer: string;
  68910. byteOffset: number;
  68911. byteLength: number;
  68912. byteStride: number;
  68913. target?: number;
  68914. }
  68915. /** @hidden */
  68916. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68917. uri: string;
  68918. byteLength?: number;
  68919. type?: string;
  68920. }
  68921. /** @hidden */
  68922. export interface IGLTFShader extends IGLTFChildRootProperty {
  68923. uri: string;
  68924. type: EShaderType;
  68925. }
  68926. /** @hidden */
  68927. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68928. attributes: string[];
  68929. fragmentShader: string;
  68930. vertexShader: string;
  68931. }
  68932. /** @hidden */
  68933. export interface IGLTFTechniqueParameter {
  68934. type: number;
  68935. count?: number;
  68936. semantic?: string;
  68937. node?: string;
  68938. value?: number | boolean | string | Array<any>;
  68939. source?: string;
  68940. babylonValue?: any;
  68941. }
  68942. /** @hidden */
  68943. export interface IGLTFTechniqueCommonProfile {
  68944. lightingModel: string;
  68945. texcoordBindings: Object;
  68946. parameters?: Array<any>;
  68947. }
  68948. /** @hidden */
  68949. export interface IGLTFTechniqueStatesFunctions {
  68950. blendColor?: number[];
  68951. blendEquationSeparate?: number[];
  68952. blendFuncSeparate?: number[];
  68953. colorMask: boolean[];
  68954. cullFace: number[];
  68955. }
  68956. /** @hidden */
  68957. export interface IGLTFTechniqueStates {
  68958. enable: number[];
  68959. functions: IGLTFTechniqueStatesFunctions;
  68960. }
  68961. /** @hidden */
  68962. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68963. parameters: {
  68964. [key: string]: IGLTFTechniqueParameter;
  68965. };
  68966. program: string;
  68967. attributes: {
  68968. [key: string]: string;
  68969. };
  68970. uniforms: {
  68971. [key: string]: string;
  68972. };
  68973. states: IGLTFTechniqueStates;
  68974. }
  68975. /** @hidden */
  68976. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68977. technique?: string;
  68978. values: string[];
  68979. }
  68980. /** @hidden */
  68981. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68982. attributes: {
  68983. [key: string]: string;
  68984. };
  68985. indices: string;
  68986. material: string;
  68987. mode?: number;
  68988. }
  68989. /** @hidden */
  68990. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68991. primitives: IGLTFMeshPrimitive[];
  68992. }
  68993. /** @hidden */
  68994. export interface IGLTFImage extends IGLTFChildRootProperty {
  68995. uri: string;
  68996. }
  68997. /** @hidden */
  68998. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68999. magFilter?: number;
  69000. minFilter?: number;
  69001. wrapS?: number;
  69002. wrapT?: number;
  69003. }
  69004. /** @hidden */
  69005. export interface IGLTFTexture extends IGLTFChildRootProperty {
  69006. sampler: string;
  69007. source: string;
  69008. format?: ETextureFormat;
  69009. internalFormat?: ETextureFormat;
  69010. target?: number;
  69011. type?: number;
  69012. babylonTexture?: Texture;
  69013. }
  69014. /** @hidden */
  69015. export interface IGLTFAmbienLight {
  69016. color?: number[];
  69017. }
  69018. /** @hidden */
  69019. export interface IGLTFDirectionalLight {
  69020. color?: number[];
  69021. }
  69022. /** @hidden */
  69023. export interface IGLTFPointLight {
  69024. color?: number[];
  69025. constantAttenuation?: number;
  69026. linearAttenuation?: number;
  69027. quadraticAttenuation?: number;
  69028. }
  69029. /** @hidden */
  69030. export interface IGLTFSpotLight {
  69031. color?: number[];
  69032. constantAttenuation?: number;
  69033. fallOfAngle?: number;
  69034. fallOffExponent?: number;
  69035. linearAttenuation?: number;
  69036. quadraticAttenuation?: number;
  69037. }
  69038. /** @hidden */
  69039. export interface IGLTFLight extends IGLTFChildRootProperty {
  69040. type: string;
  69041. }
  69042. /** @hidden */
  69043. export interface IGLTFCameraOrthographic {
  69044. xmag: number;
  69045. ymag: number;
  69046. zfar: number;
  69047. znear: number;
  69048. }
  69049. /** @hidden */
  69050. export interface IGLTFCameraPerspective {
  69051. aspectRatio: number;
  69052. yfov: number;
  69053. zfar: number;
  69054. znear: number;
  69055. }
  69056. /** @hidden */
  69057. export interface IGLTFCamera extends IGLTFChildRootProperty {
  69058. type: string;
  69059. }
  69060. /** @hidden */
  69061. export interface IGLTFAnimationChannelTarget {
  69062. id: string;
  69063. path: string;
  69064. }
  69065. /** @hidden */
  69066. export interface IGLTFAnimationChannel {
  69067. sampler: string;
  69068. target: IGLTFAnimationChannelTarget;
  69069. }
  69070. /** @hidden */
  69071. export interface IGLTFAnimationSampler {
  69072. input: string;
  69073. output: string;
  69074. interpolation?: string;
  69075. }
  69076. /** @hidden */
  69077. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  69078. channels?: IGLTFAnimationChannel[];
  69079. parameters?: {
  69080. [key: string]: string;
  69081. };
  69082. samplers?: {
  69083. [key: string]: IGLTFAnimationSampler;
  69084. };
  69085. }
  69086. /** @hidden */
  69087. export interface IGLTFNodeInstanceSkin {
  69088. skeletons: string[];
  69089. skin: string;
  69090. meshes: string[];
  69091. }
  69092. /** @hidden */
  69093. export interface IGLTFSkins extends IGLTFChildRootProperty {
  69094. bindShapeMatrix: number[];
  69095. inverseBindMatrices: string;
  69096. jointNames: string[];
  69097. babylonSkeleton?: Skeleton;
  69098. }
  69099. /** @hidden */
  69100. export interface IGLTFNode extends IGLTFChildRootProperty {
  69101. camera?: string;
  69102. children: string[];
  69103. skin?: string;
  69104. jointName?: string;
  69105. light?: string;
  69106. matrix: number[];
  69107. mesh?: string;
  69108. meshes?: string[];
  69109. rotation?: number[];
  69110. scale?: number[];
  69111. translation?: number[];
  69112. babylonNode?: Node;
  69113. }
  69114. /** @hidden */
  69115. export interface IGLTFScene extends IGLTFChildRootProperty {
  69116. nodes: string[];
  69117. }
  69118. /** @hidden */
  69119. export interface IGLTFRuntime {
  69120. extensions: {
  69121. [key: string]: any;
  69122. };
  69123. accessors: {
  69124. [key: string]: IGLTFAccessor;
  69125. };
  69126. buffers: {
  69127. [key: string]: IGLTFBuffer;
  69128. };
  69129. bufferViews: {
  69130. [key: string]: IGLTFBufferView;
  69131. };
  69132. meshes: {
  69133. [key: string]: IGLTFMesh;
  69134. };
  69135. lights: {
  69136. [key: string]: IGLTFLight;
  69137. };
  69138. cameras: {
  69139. [key: string]: IGLTFCamera;
  69140. };
  69141. nodes: {
  69142. [key: string]: IGLTFNode;
  69143. };
  69144. images: {
  69145. [key: string]: IGLTFImage;
  69146. };
  69147. textures: {
  69148. [key: string]: IGLTFTexture;
  69149. };
  69150. shaders: {
  69151. [key: string]: IGLTFShader;
  69152. };
  69153. programs: {
  69154. [key: string]: IGLTFProgram;
  69155. };
  69156. samplers: {
  69157. [key: string]: IGLTFSampler;
  69158. };
  69159. techniques: {
  69160. [key: string]: IGLTFTechnique;
  69161. };
  69162. materials: {
  69163. [key: string]: IGLTFMaterial;
  69164. };
  69165. animations: {
  69166. [key: string]: IGLTFAnimation;
  69167. };
  69168. skins: {
  69169. [key: string]: IGLTFSkins;
  69170. };
  69171. currentScene?: Object;
  69172. scenes: {
  69173. [key: string]: IGLTFScene;
  69174. };
  69175. extensionsUsed: string[];
  69176. extensionsRequired?: string[];
  69177. buffersCount: number;
  69178. shaderscount: number;
  69179. scene: Scene;
  69180. rootUrl: string;
  69181. loadedBufferCount: number;
  69182. loadedBufferViews: {
  69183. [name: string]: ArrayBufferView;
  69184. };
  69185. loadedShaderCount: number;
  69186. importOnlyMeshes: boolean;
  69187. importMeshesNames?: string[];
  69188. dummyNodes: Node[];
  69189. }
  69190. /** @hidden */
  69191. export interface INodeToRoot {
  69192. bone: Bone;
  69193. node: IGLTFNode;
  69194. id: string;
  69195. }
  69196. /** @hidden */
  69197. export interface IJointNode {
  69198. node: IGLTFNode;
  69199. id: string;
  69200. }
  69201. }
  69202. declare module BABYLON.GLTF1 {
  69203. /**
  69204. * Utils functions for GLTF
  69205. * @hidden
  69206. */
  69207. export class GLTFUtils {
  69208. /**
  69209. * Sets the given "parameter" matrix
  69210. * @param scene: the Scene object
  69211. * @param source: the source node where to pick the matrix
  69212. * @param parameter: the GLTF technique parameter
  69213. * @param uniformName: the name of the shader's uniform
  69214. * @param shaderMaterial: the shader material
  69215. */
  69216. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  69217. /**
  69218. * Sets the given "parameter" matrix
  69219. * @param shaderMaterial: the shader material
  69220. * @param uniform: the name of the shader's uniform
  69221. * @param value: the value of the uniform
  69222. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  69223. */
  69224. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  69225. /**
  69226. * Returns the wrap mode of the texture
  69227. * @param mode: the mode value
  69228. */
  69229. static GetWrapMode(mode: number): number;
  69230. /**
  69231. * Returns the byte stride giving an accessor
  69232. * @param accessor: the GLTF accessor objet
  69233. */
  69234. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  69235. /**
  69236. * Returns the texture filter mode giving a mode value
  69237. * @param mode: the filter mode value
  69238. */
  69239. static GetTextureFilterMode(mode: number): ETextureFilterType;
  69240. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  69241. /**
  69242. * Returns a buffer from its accessor
  69243. * @param gltfRuntime: the GLTF runtime
  69244. * @param accessor: the GLTF accessor
  69245. */
  69246. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  69247. /**
  69248. * Decodes a buffer view into a string
  69249. * @param view: the buffer view
  69250. */
  69251. static DecodeBufferToText(view: ArrayBufferView): string;
  69252. /**
  69253. * Returns the default material of gltf. Related to
  69254. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  69255. * @param scene: the Babylon.js scene
  69256. */
  69257. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  69258. private static _DefaultMaterial;
  69259. }
  69260. }
  69261. declare module BABYLON.GLTF1 {
  69262. /**
  69263. * Implementation of the base glTF spec
  69264. * @hidden
  69265. */
  69266. export class GLTFLoaderBase {
  69267. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  69268. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69269. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  69270. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69271. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  69272. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69273. }
  69274. /**
  69275. * glTF V1 Loader
  69276. * @hidden
  69277. */
  69278. export class GLTFLoader implements IGLTFLoader {
  69279. static Extensions: {
  69280. [name: string]: GLTFLoaderExtension;
  69281. };
  69282. static RegisterExtension(extension: GLTFLoaderExtension): void;
  69283. state: Nullable<GLTFLoaderState>;
  69284. dispose(): void;
  69285. private _importMeshAsync;
  69286. /**
  69287. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  69288. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69289. * @param scene the scene the meshes should be added to
  69290. * @param data gltf data containing information of the meshes in a loaded file
  69291. * @param rootUrl root url to load from
  69292. * @param onProgress event that fires when loading progress has occured
  69293. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69294. */
  69295. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  69296. meshes: AbstractMesh[];
  69297. particleSystems: IParticleSystem[];
  69298. skeletons: Skeleton[];
  69299. animationGroups: AnimationGroup[];
  69300. }>;
  69301. private _loadAsync;
  69302. /**
  69303. * Imports all objects from a loaded gltf file and adds them to the scene
  69304. * @param scene the scene the objects should be added to
  69305. * @param data gltf data containing information of the meshes in a loaded file
  69306. * @param rootUrl root url to load from
  69307. * @param onProgress event that fires when loading progress has occured
  69308. * @returns a promise which completes when objects have been loaded to the scene
  69309. */
  69310. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69311. private _loadShadersAsync;
  69312. private _loadBuffersAsync;
  69313. private _createNodes;
  69314. }
  69315. /** @hidden */
  69316. export abstract class GLTFLoaderExtension {
  69317. private _name;
  69318. constructor(name: string);
  69319. readonly name: string;
  69320. /**
  69321. * Defines an override for loading the runtime
  69322. * Return true to stop further extensions from loading the runtime
  69323. */
  69324. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69325. /**
  69326. * Defines an onverride for creating gltf runtime
  69327. * Return true to stop further extensions from creating the runtime
  69328. */
  69329. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69330. /**
  69331. * Defines an override for loading buffers
  69332. * Return true to stop further extensions from loading this buffer
  69333. */
  69334. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69335. /**
  69336. * Defines an override for loading texture buffers
  69337. * Return true to stop further extensions from loading this texture data
  69338. */
  69339. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69340. /**
  69341. * Defines an override for creating textures
  69342. * Return true to stop further extensions from loading this texture
  69343. */
  69344. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69345. /**
  69346. * Defines an override for loading shader strings
  69347. * Return true to stop further extensions from loading this shader data
  69348. */
  69349. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69350. /**
  69351. * Defines an override for loading materials
  69352. * Return true to stop further extensions from loading this material
  69353. */
  69354. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69355. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69356. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69357. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69358. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69359. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69360. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69361. private static LoadTextureBufferAsync;
  69362. private static CreateTextureAsync;
  69363. private static ApplyExtensions;
  69364. }
  69365. }
  69366. declare module BABYLON.GLTF1 {
  69367. /** @hidden */
  69368. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69369. private _bin;
  69370. constructor();
  69371. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69372. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69373. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69374. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69375. }
  69376. }
  69377. declare module BABYLON.GLTF1 {
  69378. /** @hidden */
  69379. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69380. constructor();
  69381. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69382. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69383. private _loadTexture;
  69384. }
  69385. }
  69386. declare module BABYLON.GLTF2.Loader {
  69387. /**
  69388. * Loader interface with an index field.
  69389. */
  69390. export interface IArrayItem {
  69391. /**
  69392. * The index of this item in the array.
  69393. */
  69394. index: number;
  69395. }
  69396. /**
  69397. * Loader interface with additional members.
  69398. */
  69399. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69400. /** @hidden */
  69401. _data?: Promise<ArrayBufferView>;
  69402. /** @hidden */
  69403. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69404. }
  69405. /**
  69406. * Loader interface with additional members.
  69407. */
  69408. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69409. }
  69410. /** @hidden */
  69411. export interface _IAnimationSamplerData {
  69412. input: Float32Array;
  69413. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69414. output: Float32Array;
  69415. }
  69416. /**
  69417. * Loader interface with additional members.
  69418. */
  69419. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69420. /** @hidden */
  69421. _data?: Promise<_IAnimationSamplerData>;
  69422. }
  69423. /**
  69424. * Loader interface with additional members.
  69425. */
  69426. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69427. channels: IAnimationChannel[];
  69428. samplers: IAnimationSampler[];
  69429. /** @hidden */
  69430. _babylonAnimationGroup?: AnimationGroup;
  69431. }
  69432. /**
  69433. * Loader interface with additional members.
  69434. */
  69435. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69436. /** @hidden */
  69437. _data?: Promise<ArrayBufferView>;
  69438. }
  69439. /**
  69440. * Loader interface with additional members.
  69441. */
  69442. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69443. /** @hidden */
  69444. _data?: Promise<ArrayBufferView>;
  69445. /** @hidden */
  69446. _babylonBuffer?: Promise<Buffer>;
  69447. }
  69448. /**
  69449. * Loader interface with additional members.
  69450. */
  69451. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69452. }
  69453. /**
  69454. * Loader interface with additional members.
  69455. */
  69456. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69457. /** @hidden */
  69458. _data?: Promise<ArrayBufferView>;
  69459. }
  69460. /**
  69461. * Loader interface with additional members.
  69462. */
  69463. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69464. }
  69465. /**
  69466. * Loader interface with additional members.
  69467. */
  69468. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69469. }
  69470. /**
  69471. * Loader interface with additional members.
  69472. */
  69473. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69474. baseColorTexture?: ITextureInfo;
  69475. metallicRoughnessTexture?: ITextureInfo;
  69476. }
  69477. /**
  69478. * Loader interface with additional members.
  69479. */
  69480. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69481. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69482. normalTexture?: IMaterialNormalTextureInfo;
  69483. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69484. emissiveTexture?: ITextureInfo;
  69485. /** @hidden */
  69486. _data?: {
  69487. [babylonDrawMode: number]: {
  69488. babylonMaterial: Material;
  69489. babylonMeshes: AbstractMesh[];
  69490. promise: Promise<void>;
  69491. };
  69492. };
  69493. }
  69494. /**
  69495. * Loader interface with additional members.
  69496. */
  69497. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69498. primitives: IMeshPrimitive[];
  69499. }
  69500. /**
  69501. * Loader interface with additional members.
  69502. */
  69503. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69504. /** @hidden */
  69505. _instanceData?: {
  69506. babylonSourceMesh: Mesh;
  69507. promise: Promise<any>;
  69508. };
  69509. }
  69510. /**
  69511. * Loader interface with additional members.
  69512. */
  69513. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69514. /**
  69515. * The parent glTF node.
  69516. */
  69517. parent?: INode;
  69518. /** @hidden */
  69519. _babylonTransformNode?: TransformNode;
  69520. /** @hidden */
  69521. _primitiveBabylonMeshes?: AbstractMesh[];
  69522. /** @hidden */
  69523. _babylonBones?: Bone[];
  69524. /** @hidden */
  69525. _numMorphTargets?: number;
  69526. }
  69527. /** @hidden */
  69528. export interface _ISamplerData {
  69529. noMipMaps: boolean;
  69530. samplingMode: number;
  69531. wrapU: number;
  69532. wrapV: number;
  69533. }
  69534. /**
  69535. * Loader interface with additional members.
  69536. */
  69537. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69538. /** @hidden */
  69539. _data?: _ISamplerData;
  69540. }
  69541. /**
  69542. * Loader interface with additional members.
  69543. */
  69544. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69545. }
  69546. /**
  69547. * Loader interface with additional members.
  69548. */
  69549. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69550. /** @hidden */
  69551. _data?: {
  69552. babylonSkeleton: Skeleton;
  69553. promise: Promise<void>;
  69554. };
  69555. }
  69556. /**
  69557. * Loader interface with additional members.
  69558. */
  69559. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69560. }
  69561. /**
  69562. * Loader interface with additional members.
  69563. */
  69564. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69565. }
  69566. /**
  69567. * Loader interface with additional members.
  69568. */
  69569. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69570. accessors?: IAccessor[];
  69571. animations?: IAnimation[];
  69572. buffers?: IBuffer[];
  69573. bufferViews?: IBufferView[];
  69574. cameras?: ICamera[];
  69575. images?: IImage[];
  69576. materials?: IMaterial[];
  69577. meshes?: IMesh[];
  69578. nodes?: INode[];
  69579. samplers?: ISampler[];
  69580. scenes?: IScene[];
  69581. skins?: ISkin[];
  69582. textures?: ITexture[];
  69583. }
  69584. }
  69585. declare module BABYLON.GLTF2 {
  69586. /**
  69587. * Interface for a glTF loader extension.
  69588. */
  69589. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69590. /**
  69591. * Called after the loader state changes to LOADING.
  69592. */
  69593. onLoading?(): void;
  69594. /**
  69595. * Called after the loader state changes to READY.
  69596. */
  69597. onReady?(): void;
  69598. /**
  69599. * Define this method to modify the default behavior when loading scenes.
  69600. * @param context The context when loading the asset
  69601. * @param scene The glTF scene property
  69602. * @returns A promise that resolves when the load is complete or null if not handled
  69603. */
  69604. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69605. /**
  69606. * Define this method to modify the default behavior when loading nodes.
  69607. * @param context The context when loading the asset
  69608. * @param node The glTF node property
  69609. * @param assign A function called synchronously after parsing the glTF properties
  69610. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69611. */
  69612. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69613. /**
  69614. * Define this method to modify the default behavior when loading cameras.
  69615. * @param context The context when loading the asset
  69616. * @param camera The glTF camera property
  69617. * @param assign A function called synchronously after parsing the glTF properties
  69618. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69619. */
  69620. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69621. /**
  69622. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69623. * @param context The context when loading the asset
  69624. * @param primitive The glTF mesh primitive property
  69625. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69626. */
  69627. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69628. /**
  69629. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69630. * @param context The context when loading the asset
  69631. * @param name The mesh name when loading the asset
  69632. * @param node The glTF node when loading the asset
  69633. * @param mesh The glTF mesh when loading the asset
  69634. * @param primitive The glTF mesh primitive property
  69635. * @param assign A function called synchronously after parsing the glTF properties
  69636. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69637. */
  69638. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69639. /**
  69640. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69641. * @param context The context when loading the asset
  69642. * @param material The glTF material property
  69643. * @param assign A function called synchronously after parsing the glTF properties
  69644. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69645. */
  69646. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69647. /**
  69648. * Define this method to modify the default behavior when creating materials.
  69649. * @param context The context when loading the asset
  69650. * @param material The glTF material property
  69651. * @param babylonDrawMode The draw mode for the Babylon material
  69652. * @returns The Babylon material or null if not handled
  69653. */
  69654. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69655. /**
  69656. * Define this method to modify the default behavior when loading material properties.
  69657. * @param context The context when loading the asset
  69658. * @param material The glTF material property
  69659. * @param babylonMaterial The Babylon material
  69660. * @returns A promise that resolves when the load is complete or null if not handled
  69661. */
  69662. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69663. /**
  69664. * Define this method to modify the default behavior when loading texture infos.
  69665. * @param context The context when loading the asset
  69666. * @param textureInfo The glTF texture info property
  69667. * @param assign A function called synchronously after parsing the glTF properties
  69668. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69669. */
  69670. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69671. /**
  69672. * Define this method to modify the default behavior when loading animations.
  69673. * @param context The context when loading the asset
  69674. * @param animation The glTF animation property
  69675. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69676. */
  69677. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69678. /**
  69679. * @hidden Define this method to modify the default behavior when loading skins.
  69680. * @param context The context when loading the asset
  69681. * @param node The glTF node property
  69682. * @param skin The glTF skin property
  69683. * @returns A promise that resolves when the load is complete or null if not handled
  69684. */
  69685. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69686. /**
  69687. * @hidden Define this method to modify the default behavior when loading uris.
  69688. * @param context The context when loading the asset
  69689. * @param property The glTF property associated with the uri
  69690. * @param uri The uri to load
  69691. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69692. */
  69693. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69694. /**
  69695. * Define this method to modify the default behavior when loading buffer views.
  69696. * @param context The context when loading the asset
  69697. * @param bufferView The glTF buffer view property
  69698. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69699. */
  69700. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69701. /**
  69702. * Define this method to modify the default behavior when loading buffers.
  69703. * @param context The context when loading the asset
  69704. * @param buffer The glTF buffer property
  69705. * @param byteOffset The byte offset to load
  69706. * @param byteLength The byte length to load
  69707. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69708. */
  69709. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69710. }
  69711. }
  69712. declare module BABYLON.GLTF2 {
  69713. /**
  69714. * Helper class for working with arrays when loading the glTF asset
  69715. */
  69716. export class ArrayItem {
  69717. /**
  69718. * Gets an item from the given array.
  69719. * @param context The context when loading the asset
  69720. * @param array The array to get the item from
  69721. * @param index The index to the array
  69722. * @returns The array item
  69723. */
  69724. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69725. /**
  69726. * Assign an `index` field to each item of the given array.
  69727. * @param array The array of items
  69728. */
  69729. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69730. }
  69731. /**
  69732. * The glTF 2.0 loader
  69733. */
  69734. export class GLTFLoader implements IGLTFLoader {
  69735. /** @hidden */
  69736. _completePromises: Promise<any>[];
  69737. private _disposed;
  69738. private _parent;
  69739. private _state;
  69740. private _extensions;
  69741. private _rootUrl;
  69742. private _fileName;
  69743. private _uniqueRootUrl;
  69744. private _gltf;
  69745. private _bin;
  69746. private _babylonScene;
  69747. private _rootBabylonMesh;
  69748. private _defaultBabylonMaterialData;
  69749. private _progressCallback?;
  69750. private _requests;
  69751. private static readonly _DefaultSampler;
  69752. private static _RegisteredExtensions;
  69753. /**
  69754. * Registers a loader extension.
  69755. * @param name The name of the loader extension.
  69756. * @param factory The factory function that creates the loader extension.
  69757. */
  69758. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69759. /**
  69760. * Unregisters a loader extension.
  69761. * @param name The name of the loader extension.
  69762. * @returns A boolean indicating whether the extension has been unregistered
  69763. */
  69764. static UnregisterExtension(name: string): boolean;
  69765. /**
  69766. * Gets the loader state.
  69767. */
  69768. readonly state: Nullable<GLTFLoaderState>;
  69769. /**
  69770. * The object that represents the glTF JSON.
  69771. */
  69772. readonly gltf: IGLTF;
  69773. /**
  69774. * The BIN chunk of a binary glTF.
  69775. */
  69776. readonly bin: Nullable<IDataBuffer>;
  69777. /**
  69778. * The parent file loader.
  69779. */
  69780. readonly parent: GLTFFileLoader;
  69781. /**
  69782. * The Babylon scene when loading the asset.
  69783. */
  69784. readonly babylonScene: Scene;
  69785. /**
  69786. * The root Babylon mesh when loading the asset.
  69787. */
  69788. readonly rootBabylonMesh: Mesh;
  69789. /** @hidden */
  69790. constructor(parent: GLTFFileLoader);
  69791. /** @hidden */
  69792. dispose(): void;
  69793. /** @hidden */
  69794. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69795. meshes: AbstractMesh[];
  69796. particleSystems: IParticleSystem[];
  69797. skeletons: Skeleton[];
  69798. animationGroups: AnimationGroup[];
  69799. }>;
  69800. /** @hidden */
  69801. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69802. private _loadAsync;
  69803. private _loadData;
  69804. private _setupData;
  69805. private _loadExtensions;
  69806. private _checkExtensions;
  69807. private _setState;
  69808. private _createRootNode;
  69809. /**
  69810. * Loads a glTF scene.
  69811. * @param context The context when loading the asset
  69812. * @param scene The glTF scene property
  69813. * @returns A promise that resolves when the load is complete
  69814. */
  69815. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69816. private _forEachPrimitive;
  69817. private _getMeshes;
  69818. private _getSkeletons;
  69819. private _getAnimationGroups;
  69820. private _startAnimations;
  69821. /**
  69822. * Loads a glTF node.
  69823. * @param context The context when loading the asset
  69824. * @param node The glTF node property
  69825. * @param assign A function called synchronously after parsing the glTF properties
  69826. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69827. */
  69828. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69829. private _loadMeshAsync;
  69830. /**
  69831. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69832. * @param context The context when loading the asset
  69833. * @param name The mesh name when loading the asset
  69834. * @param node The glTF node when loading the asset
  69835. * @param mesh The glTF mesh when loading the asset
  69836. * @param primitive The glTF mesh primitive property
  69837. * @param assign A function called synchronously after parsing the glTF properties
  69838. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69839. */
  69840. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69841. private _loadVertexDataAsync;
  69842. private _createMorphTargets;
  69843. private _loadMorphTargetsAsync;
  69844. private _loadMorphTargetVertexDataAsync;
  69845. private static _LoadTransform;
  69846. private _loadSkinAsync;
  69847. private _loadBones;
  69848. private _loadBone;
  69849. private _loadSkinInverseBindMatricesDataAsync;
  69850. private _updateBoneMatrices;
  69851. private _getNodeMatrix;
  69852. /**
  69853. * Loads a glTF camera.
  69854. * @param context The context when loading the asset
  69855. * @param camera The glTF camera property
  69856. * @param assign A function called synchronously after parsing the glTF properties
  69857. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69858. */
  69859. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69860. private _loadAnimationsAsync;
  69861. /**
  69862. * Loads a glTF animation.
  69863. * @param context The context when loading the asset
  69864. * @param animation The glTF animation property
  69865. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69866. */
  69867. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69868. /**
  69869. * @hidden Loads a glTF animation channel.
  69870. * @param context The context when loading the asset
  69871. * @param animationContext The context of the animation when loading the asset
  69872. * @param animation The glTF animation property
  69873. * @param channel The glTF animation channel property
  69874. * @param babylonAnimationGroup The babylon animation group property
  69875. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69876. * @returns A void promise when the channel load is complete
  69877. */
  69878. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69879. private _loadAnimationSamplerAsync;
  69880. private _loadBufferAsync;
  69881. /**
  69882. * Loads a glTF buffer view.
  69883. * @param context The context when loading the asset
  69884. * @param bufferView The glTF buffer view property
  69885. * @returns A promise that resolves with the loaded data when the load is complete
  69886. */
  69887. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69888. private _loadAccessorAsync;
  69889. private _loadFloatAccessorAsync;
  69890. private _loadIndicesAccessorAsync;
  69891. private _loadVertexBufferViewAsync;
  69892. private _loadVertexAccessorAsync;
  69893. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69894. /** @hidden */
  69895. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69896. private _createDefaultMaterial;
  69897. /**
  69898. * Creates a Babylon material from a glTF material.
  69899. * @param context The context when loading the asset
  69900. * @param material The glTF material property
  69901. * @param babylonDrawMode The draw mode for the Babylon material
  69902. * @returns The Babylon material
  69903. */
  69904. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69905. /**
  69906. * Loads properties from a glTF material into a Babylon material.
  69907. * @param context The context when loading the asset
  69908. * @param material The glTF material property
  69909. * @param babylonMaterial The Babylon material
  69910. * @returns A promise that resolves when the load is complete
  69911. */
  69912. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69913. /**
  69914. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69915. * @param context The context when loading the asset
  69916. * @param material The glTF material property
  69917. * @param babylonMaterial The Babylon material
  69918. * @returns A promise that resolves when the load is complete
  69919. */
  69920. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69921. /**
  69922. * Loads the alpha properties from a glTF material into a Babylon material.
  69923. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69924. * @param context The context when loading the asset
  69925. * @param material The glTF material property
  69926. * @param babylonMaterial The Babylon material
  69927. */
  69928. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69929. /**
  69930. * Loads a glTF texture info.
  69931. * @param context The context when loading the asset
  69932. * @param textureInfo The glTF texture info property
  69933. * @param assign A function called synchronously after parsing the glTF properties
  69934. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69935. */
  69936. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69937. private _loadTextureAsync;
  69938. private _loadSampler;
  69939. /**
  69940. * Loads a glTF image.
  69941. * @param context The context when loading the asset
  69942. * @param image The glTF image property
  69943. * @returns A promise that resolves with the loaded data when the load is complete
  69944. */
  69945. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69946. /**
  69947. * Loads a glTF uri.
  69948. * @param context The context when loading the asset
  69949. * @param property The glTF property associated with the uri
  69950. * @param uri The base64 or relative uri
  69951. * @returns A promise that resolves with the loaded data when the load is complete
  69952. */
  69953. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69954. private _onProgress;
  69955. /**
  69956. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69957. * @param babylonObject the Babylon object with metadata
  69958. * @param pointer the JSON pointer
  69959. */
  69960. static AddPointerMetadata(babylonObject: {
  69961. metadata: any;
  69962. }, pointer: string): void;
  69963. private static _GetTextureWrapMode;
  69964. private static _GetTextureSamplingMode;
  69965. private static _GetTypedArrayConstructor;
  69966. private static _GetTypedArray;
  69967. private static _GetNumComponents;
  69968. private static _ValidateUri;
  69969. private static _GetDrawMode;
  69970. private _compileMaterialsAsync;
  69971. private _compileShadowGeneratorsAsync;
  69972. private _forEachExtensions;
  69973. private _applyExtensions;
  69974. private _extensionsOnLoading;
  69975. private _extensionsOnReady;
  69976. private _extensionsLoadSceneAsync;
  69977. private _extensionsLoadNodeAsync;
  69978. private _extensionsLoadCameraAsync;
  69979. private _extensionsLoadVertexDataAsync;
  69980. private _extensionsLoadMeshPrimitiveAsync;
  69981. private _extensionsLoadMaterialAsync;
  69982. private _extensionsCreateMaterial;
  69983. private _extensionsLoadMaterialPropertiesAsync;
  69984. private _extensionsLoadTextureInfoAsync;
  69985. private _extensionsLoadAnimationAsync;
  69986. private _extensionsLoadSkinAsync;
  69987. private _extensionsLoadUriAsync;
  69988. private _extensionsLoadBufferViewAsync;
  69989. private _extensionsLoadBufferAsync;
  69990. /**
  69991. * Helper method called by a loader extension to load an glTF extension.
  69992. * @param context The context when loading the asset
  69993. * @param property The glTF property to load the extension from
  69994. * @param extensionName The name of the extension to load
  69995. * @param actionAsync The action to run
  69996. * @returns The promise returned by actionAsync or null if the extension does not exist
  69997. */
  69998. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69999. /**
  70000. * Helper method called by a loader extension to load a glTF extra.
  70001. * @param context The context when loading the asset
  70002. * @param property The glTF property to load the extra from
  70003. * @param extensionName The name of the extension to load
  70004. * @param actionAsync The action to run
  70005. * @returns The promise returned by actionAsync or null if the extra does not exist
  70006. */
  70007. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70008. /**
  70009. * Checks for presence of an extension.
  70010. * @param name The name of the extension to check
  70011. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  70012. */
  70013. isExtensionUsed(name: string): boolean;
  70014. /**
  70015. * Increments the indentation level and logs a message.
  70016. * @param message The message to log
  70017. */
  70018. logOpen(message: string): void;
  70019. /**
  70020. * Decrements the indentation level.
  70021. */
  70022. logClose(): void;
  70023. /**
  70024. * Logs a message
  70025. * @param message The message to log
  70026. */
  70027. log(message: string): void;
  70028. /**
  70029. * Starts a performance counter.
  70030. * @param counterName The name of the performance counter
  70031. */
  70032. startPerformanceCounter(counterName: string): void;
  70033. /**
  70034. * Ends a performance counter.
  70035. * @param counterName The name of the performance counter
  70036. */
  70037. endPerformanceCounter(counterName: string): void;
  70038. }
  70039. }
  70040. declare module BABYLON.GLTF2.Loader.Extensions {
  70041. /**
  70042. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  70043. */
  70044. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  70045. /**
  70046. * The name of this extension.
  70047. */
  70048. readonly name: string;
  70049. /**
  70050. * Defines whether this extension is enabled.
  70051. */
  70052. enabled: boolean;
  70053. private _loader;
  70054. private _lights?;
  70055. /** @hidden */
  70056. constructor(loader: GLTFLoader);
  70057. /** @hidden */
  70058. dispose(): void;
  70059. /** @hidden */
  70060. onLoading(): void;
  70061. /** @hidden */
  70062. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70063. private _loadLightAsync;
  70064. }
  70065. }
  70066. declare module BABYLON.GLTF2.Loader.Extensions {
  70067. /**
  70068. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  70069. */
  70070. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  70071. /**
  70072. * The name of this extension.
  70073. */
  70074. readonly name: string;
  70075. /**
  70076. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  70077. */
  70078. dracoCompression?: DracoCompression;
  70079. /**
  70080. * Defines whether this extension is enabled.
  70081. */
  70082. enabled: boolean;
  70083. private _loader;
  70084. /** @hidden */
  70085. constructor(loader: GLTFLoader);
  70086. /** @hidden */
  70087. dispose(): void;
  70088. /** @hidden */
  70089. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70090. }
  70091. }
  70092. declare module BABYLON.GLTF2.Loader.Extensions {
  70093. /**
  70094. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70095. */
  70096. export class KHR_lights implements IGLTFLoaderExtension {
  70097. /**
  70098. * The name of this extension.
  70099. */
  70100. readonly name: string;
  70101. /**
  70102. * Defines whether this extension is enabled.
  70103. */
  70104. enabled: boolean;
  70105. private _loader;
  70106. private _lights?;
  70107. /** @hidden */
  70108. constructor(loader: GLTFLoader);
  70109. /** @hidden */
  70110. dispose(): void;
  70111. /** @hidden */
  70112. onLoading(): void;
  70113. /** @hidden */
  70114. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70115. }
  70116. }
  70117. declare module BABYLON.GLTF2.Loader.Extensions {
  70118. /**
  70119. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  70120. */
  70121. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  70122. /**
  70123. * The name of this extension.
  70124. */
  70125. readonly name: string;
  70126. /**
  70127. * Defines whether this extension is enabled.
  70128. */
  70129. enabled: boolean;
  70130. /**
  70131. * Defines a number that determines the order the extensions are applied.
  70132. */
  70133. order: number;
  70134. private _loader;
  70135. /** @hidden */
  70136. constructor(loader: GLTFLoader);
  70137. /** @hidden */
  70138. dispose(): void;
  70139. /** @hidden */
  70140. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70141. private _loadSpecularGlossinessPropertiesAsync;
  70142. }
  70143. }
  70144. declare module BABYLON.GLTF2.Loader.Extensions {
  70145. /**
  70146. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  70147. */
  70148. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  70149. /**
  70150. * The name of this extension.
  70151. */
  70152. readonly name: string;
  70153. /**
  70154. * Defines whether this extension is enabled.
  70155. */
  70156. enabled: boolean;
  70157. /**
  70158. * Defines a number that determines the order the extensions are applied.
  70159. */
  70160. order: number;
  70161. private _loader;
  70162. /** @hidden */
  70163. constructor(loader: GLTFLoader);
  70164. /** @hidden */
  70165. dispose(): void;
  70166. /** @hidden */
  70167. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70168. private _loadUnlitPropertiesAsync;
  70169. }
  70170. }
  70171. declare module BABYLON.GLTF2.Loader.Extensions {
  70172. /**
  70173. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70174. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  70175. * !!! Experimental Extension Subject to Changes !!!
  70176. */
  70177. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  70178. /**
  70179. * The name of this extension.
  70180. */
  70181. readonly name: string;
  70182. /**
  70183. * Defines whether this extension is enabled.
  70184. */
  70185. enabled: boolean;
  70186. /**
  70187. * Defines a number that determines the order the extensions are applied.
  70188. */
  70189. order: number;
  70190. private _loader;
  70191. /** @hidden */
  70192. constructor(loader: GLTFLoader);
  70193. /** @hidden */
  70194. dispose(): void;
  70195. /** @hidden */
  70196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70197. private _loadClearCoatPropertiesAsync;
  70198. }
  70199. }
  70200. declare module BABYLON.GLTF2.Loader.Extensions {
  70201. /**
  70202. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  70203. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70204. * !!! Experimental Extension Subject to Changes !!!
  70205. */
  70206. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  70207. /**
  70208. * The name of this extension.
  70209. */
  70210. readonly name: string;
  70211. /**
  70212. * Defines whether this extension is enabled.
  70213. */
  70214. enabled: boolean;
  70215. /**
  70216. * Defines a number that determines the order the extensions are applied.
  70217. */
  70218. order: number;
  70219. private _loader;
  70220. /** @hidden */
  70221. constructor(loader: GLTFLoader);
  70222. /** @hidden */
  70223. dispose(): void;
  70224. /** @hidden */
  70225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70226. private _loadSheenPropertiesAsync;
  70227. }
  70228. }
  70229. declare module BABYLON.GLTF2.Loader.Extensions {
  70230. /**
  70231. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70232. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70233. * !!! Experimental Extension Subject to Changes !!!
  70234. */
  70235. export class KHR_materials_specular implements IGLTFLoaderExtension {
  70236. /**
  70237. * The name of this extension.
  70238. */
  70239. readonly name: string;
  70240. /**
  70241. * Defines whether this extension is enabled.
  70242. */
  70243. enabled: boolean;
  70244. /**
  70245. * Defines a number that determines the order the extensions are applied.
  70246. */
  70247. order: number;
  70248. private _loader;
  70249. /** @hidden */
  70250. constructor(loader: GLTFLoader);
  70251. /** @hidden */
  70252. dispose(): void;
  70253. /** @hidden */
  70254. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70255. private _loadSpecularPropertiesAsync;
  70256. }
  70257. }
  70258. declare module BABYLON.GLTF2.Loader.Extensions {
  70259. /**
  70260. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  70261. */
  70262. export class KHR_texture_transform implements IGLTFLoaderExtension {
  70263. /**
  70264. * The name of this extension.
  70265. */
  70266. readonly name: string;
  70267. /**
  70268. * Defines whether this extension is enabled.
  70269. */
  70270. enabled: boolean;
  70271. private _loader;
  70272. /** @hidden */
  70273. constructor(loader: GLTFLoader);
  70274. /** @hidden */
  70275. dispose(): void;
  70276. /** @hidden */
  70277. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70278. }
  70279. }
  70280. declare module BABYLON.GLTF2.Loader.Extensions {
  70281. /**
  70282. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  70283. */
  70284. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  70285. /**
  70286. * The name of this extension.
  70287. */
  70288. readonly name: string;
  70289. /**
  70290. * Defines whether this extension is enabled.
  70291. */
  70292. enabled: boolean;
  70293. private _loader;
  70294. private _clips;
  70295. private _emitters;
  70296. /** @hidden */
  70297. constructor(loader: GLTFLoader);
  70298. /** @hidden */
  70299. dispose(): void;
  70300. /** @hidden */
  70301. onLoading(): void;
  70302. /** @hidden */
  70303. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70304. /** @hidden */
  70305. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70306. /** @hidden */
  70307. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70308. private _loadClipAsync;
  70309. private _loadEmitterAsync;
  70310. private _getEventAction;
  70311. private _loadAnimationEventAsync;
  70312. }
  70313. }
  70314. declare module BABYLON.GLTF2.Loader.Extensions {
  70315. /**
  70316. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  70317. */
  70318. export class MSFT_lod implements IGLTFLoaderExtension {
  70319. /**
  70320. * The name of this extension.
  70321. */
  70322. readonly name: string;
  70323. /**
  70324. * Defines whether this extension is enabled.
  70325. */
  70326. enabled: boolean;
  70327. /**
  70328. * Defines a number that determines the order the extensions are applied.
  70329. */
  70330. order: number;
  70331. /**
  70332. * Maximum number of LODs to load, starting from the lowest LOD.
  70333. */
  70334. maxLODsToLoad: number;
  70335. /**
  70336. * Observable raised when all node LODs of one level are loaded.
  70337. * The event data is the index of the loaded LOD starting from zero.
  70338. * Dispose the loader to cancel the loading of the next level of LODs.
  70339. */
  70340. onNodeLODsLoadedObservable: Observable<number>;
  70341. /**
  70342. * Observable raised when all material LODs of one level are loaded.
  70343. * The event data is the index of the loaded LOD starting from zero.
  70344. * Dispose the loader to cancel the loading of the next level of LODs.
  70345. */
  70346. onMaterialLODsLoadedObservable: Observable<number>;
  70347. private _loader;
  70348. private _nodeIndexLOD;
  70349. private _nodeSignalLODs;
  70350. private _nodePromiseLODs;
  70351. private _materialIndexLOD;
  70352. private _materialSignalLODs;
  70353. private _materialPromiseLODs;
  70354. private _indexLOD;
  70355. private _bufferLODs;
  70356. /** @hidden */
  70357. constructor(loader: GLTFLoader);
  70358. /** @hidden */
  70359. dispose(): void;
  70360. /** @hidden */
  70361. onReady(): void;
  70362. /** @hidden */
  70363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70364. /** @hidden */
  70365. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70366. /** @hidden */
  70367. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70368. /** @hidden */
  70369. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70370. private _loadBufferLOD;
  70371. /**
  70372. * Gets an array of LOD properties from lowest to highest.
  70373. */
  70374. private _getLODs;
  70375. private _disposeUnusedMaterials;
  70376. }
  70377. }
  70378. declare module BABYLON.GLTF2.Loader.Extensions {
  70379. /** @hidden */
  70380. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  70381. readonly name: string;
  70382. enabled: boolean;
  70383. private _loader;
  70384. constructor(loader: GLTFLoader);
  70385. dispose(): void;
  70386. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70387. }
  70388. }
  70389. declare module BABYLON.GLTF2.Loader.Extensions {
  70390. /** @hidden */
  70391. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  70392. readonly name: string;
  70393. enabled: boolean;
  70394. private _loader;
  70395. constructor(loader: GLTFLoader);
  70396. dispose(): void;
  70397. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70398. }
  70399. }
  70400. declare module BABYLON.GLTF2.Loader.Extensions {
  70401. /**
  70402. * Store glTF extras (if present) in BJS objects' metadata
  70403. */
  70404. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  70405. /**
  70406. * The name of this extension.
  70407. */
  70408. readonly name: string;
  70409. /**
  70410. * Defines whether this extension is enabled.
  70411. */
  70412. enabled: boolean;
  70413. private _loader;
  70414. private _assignExtras;
  70415. /** @hidden */
  70416. constructor(loader: GLTFLoader);
  70417. /** @hidden */
  70418. dispose(): void;
  70419. /** @hidden */
  70420. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70421. /** @hidden */
  70422. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70423. /** @hidden */
  70424. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /**
  70429. * Class reading and parsing the MTL file bundled with the obj file.
  70430. */
  70431. export class MTLFileLoader {
  70432. /**
  70433. * All material loaded from the mtl will be set here
  70434. */
  70435. materials: StandardMaterial[];
  70436. /**
  70437. * This function will read the mtl file and create each material described inside
  70438. * This function could be improve by adding :
  70439. * -some component missing (Ni, Tf...)
  70440. * -including the specific options available
  70441. *
  70442. * @param scene defines the scene the material will be created in
  70443. * @param data defines the mtl data to parse
  70444. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70445. */
  70446. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70447. /**
  70448. * Gets the texture for the material.
  70449. *
  70450. * If the material is imported from input file,
  70451. * We sanitize the url to ensure it takes the textre from aside the material.
  70452. *
  70453. * @param rootUrl The root url to load from
  70454. * @param value The value stored in the mtl
  70455. * @return The Texture
  70456. */
  70457. private static _getTexture;
  70458. }
  70459. /**
  70460. * Options for loading OBJ/MTL files
  70461. */
  70462. type MeshLoadOptions = {
  70463. /**
  70464. * Defines if UVs are optimized by default during load.
  70465. */
  70466. OptimizeWithUV: boolean;
  70467. /**
  70468. * Defines custom scaling of UV coordinates of loaded meshes.
  70469. */
  70470. UVScaling: Vector2;
  70471. /**
  70472. * Invert model on y-axis (does a model scaling inversion)
  70473. */
  70474. InvertY: boolean;
  70475. /**
  70476. * Invert Y-Axis of referenced textures on load
  70477. */
  70478. InvertTextureY: boolean;
  70479. /**
  70480. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70481. */
  70482. ImportVertexColors: boolean;
  70483. /**
  70484. * Compute the normals for the model, even if normals are present in the file.
  70485. */
  70486. ComputeNormals: boolean;
  70487. /**
  70488. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70489. */
  70490. SkipMaterials: boolean;
  70491. /**
  70492. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70493. */
  70494. MaterialLoadingFailsSilently: boolean;
  70495. };
  70496. /**
  70497. * OBJ file type loader.
  70498. * This is a babylon scene loader plugin.
  70499. */
  70500. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70501. /**
  70502. * Defines if UVs are optimized by default during load.
  70503. */
  70504. static OPTIMIZE_WITH_UV: boolean;
  70505. /**
  70506. * Invert model on y-axis (does a model scaling inversion)
  70507. */
  70508. static INVERT_Y: boolean;
  70509. /**
  70510. * Invert Y-Axis of referenced textures on load
  70511. */
  70512. static INVERT_TEXTURE_Y: boolean;
  70513. /**
  70514. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70515. */
  70516. static IMPORT_VERTEX_COLORS: boolean;
  70517. /**
  70518. * Compute the normals for the model, even if normals are present in the file.
  70519. */
  70520. static COMPUTE_NORMALS: boolean;
  70521. /**
  70522. * Defines custom scaling of UV coordinates of loaded meshes.
  70523. */
  70524. static UV_SCALING: Vector2;
  70525. /**
  70526. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70527. */
  70528. static SKIP_MATERIALS: boolean;
  70529. /**
  70530. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70531. *
  70532. * Defaults to true for backwards compatibility.
  70533. */
  70534. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70535. /**
  70536. * Defines the name of the plugin.
  70537. */
  70538. name: string;
  70539. /**
  70540. * Defines the extension the plugin is able to load.
  70541. */
  70542. extensions: string;
  70543. /** @hidden */
  70544. obj: RegExp;
  70545. /** @hidden */
  70546. group: RegExp;
  70547. /** @hidden */
  70548. mtllib: RegExp;
  70549. /** @hidden */
  70550. usemtl: RegExp;
  70551. /** @hidden */
  70552. smooth: RegExp;
  70553. /** @hidden */
  70554. vertexPattern: RegExp;
  70555. /** @hidden */
  70556. normalPattern: RegExp;
  70557. /** @hidden */
  70558. uvPattern: RegExp;
  70559. /** @hidden */
  70560. facePattern1: RegExp;
  70561. /** @hidden */
  70562. facePattern2: RegExp;
  70563. /** @hidden */
  70564. facePattern3: RegExp;
  70565. /** @hidden */
  70566. facePattern4: RegExp;
  70567. /** @hidden */
  70568. facePattern5: RegExp;
  70569. private _meshLoadOptions;
  70570. /**
  70571. * Creates loader for .OBJ files
  70572. *
  70573. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70574. */
  70575. constructor(meshLoadOptions?: MeshLoadOptions);
  70576. private static readonly currentMeshLoadOptions;
  70577. /**
  70578. * Calls synchronously the MTL file attached to this obj.
  70579. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70580. * Without this function materials are not displayed in the first frame (but displayed after).
  70581. * In consequence it is impossible to get material information in your HTML file
  70582. *
  70583. * @param url The URL of the MTL file
  70584. * @param rootUrl
  70585. * @param onSuccess Callback function to be called when the MTL file is loaded
  70586. * @private
  70587. */
  70588. private _loadMTL;
  70589. /**
  70590. * Instantiates a OBJ file loader plugin.
  70591. * @returns the created plugin
  70592. */
  70593. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70594. /**
  70595. * If the data string can be loaded directly.
  70596. *
  70597. * @param data string containing the file data
  70598. * @returns if the data can be loaded directly
  70599. */
  70600. canDirectLoad(data: string): boolean;
  70601. /**
  70602. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70603. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70604. * @param scene the scene the meshes should be added to
  70605. * @param data the OBJ data to load
  70606. * @param rootUrl root url to load from
  70607. * @param onProgress event that fires when loading progress has occured
  70608. * @param fileName Defines the name of the file to load
  70609. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70610. */
  70611. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70612. meshes: AbstractMesh[];
  70613. particleSystems: IParticleSystem[];
  70614. skeletons: Skeleton[];
  70615. animationGroups: AnimationGroup[];
  70616. }>;
  70617. /**
  70618. * Imports all objects from the loaded OBJ data and adds them to the scene
  70619. * @param scene the scene the objects should be added to
  70620. * @param data the OBJ data to load
  70621. * @param rootUrl root url to load from
  70622. * @param onProgress event that fires when loading progress has occured
  70623. * @param fileName Defines the name of the file to load
  70624. * @returns a promise which completes when objects have been loaded to the scene
  70625. */
  70626. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70627. /**
  70628. * Load into an asset container.
  70629. * @param scene The scene to load into
  70630. * @param data The data to import
  70631. * @param rootUrl The root url for scene and resources
  70632. * @param onProgress The callback when the load progresses
  70633. * @param fileName Defines the name of the file to load
  70634. * @returns The loaded asset container
  70635. */
  70636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70637. /**
  70638. * Read the OBJ file and create an Array of meshes.
  70639. * Each mesh contains all information given by the OBJ and the MTL file.
  70640. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70641. *
  70642. * @param meshesNames
  70643. * @param scene Scene The scene where are displayed the data
  70644. * @param data String The content of the obj file
  70645. * @param rootUrl String The path to the folder
  70646. * @returns Array<AbstractMesh>
  70647. * @private
  70648. */
  70649. private _parseSolid;
  70650. }
  70651. }
  70652. declare module BABYLON {
  70653. /**
  70654. * STL file type loader.
  70655. * This is a babylon scene loader plugin.
  70656. */
  70657. export class STLFileLoader implements ISceneLoaderPlugin {
  70658. /** @hidden */
  70659. solidPattern: RegExp;
  70660. /** @hidden */
  70661. facetsPattern: RegExp;
  70662. /** @hidden */
  70663. normalPattern: RegExp;
  70664. /** @hidden */
  70665. vertexPattern: RegExp;
  70666. /**
  70667. * Defines the name of the plugin.
  70668. */
  70669. name: string;
  70670. /**
  70671. * Defines the extensions the stl loader is able to load.
  70672. * force data to come in as an ArrayBuffer
  70673. * we'll convert to string if it looks like it's an ASCII .stl
  70674. */
  70675. extensions: ISceneLoaderPluginExtensions;
  70676. /**
  70677. * Import meshes into a scene.
  70678. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70679. * @param scene The scene to import into
  70680. * @param data The data to import
  70681. * @param rootUrl The root url for scene and resources
  70682. * @param meshes The meshes array to import into
  70683. * @param particleSystems The particle systems array to import into
  70684. * @param skeletons The skeletons array to import into
  70685. * @param onError The callback when import fails
  70686. * @returns True if successful or false otherwise
  70687. */
  70688. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70689. /**
  70690. * Load into a scene.
  70691. * @param scene The scene to load into
  70692. * @param data The data to import
  70693. * @param rootUrl The root url for scene and resources
  70694. * @param onError The callback when import fails
  70695. * @returns true if successful or false otherwise
  70696. */
  70697. load(scene: Scene, data: any, rootUrl: string): boolean;
  70698. /**
  70699. * Load into an asset container.
  70700. * @param scene The scene to load into
  70701. * @param data The data to import
  70702. * @param rootUrl The root url for scene and resources
  70703. * @param onError The callback when import fails
  70704. * @returns The loaded asset container
  70705. */
  70706. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70707. private _isBinary;
  70708. private _parseBinary;
  70709. private _parseASCII;
  70710. }
  70711. }
  70712. declare module BABYLON {
  70713. /**
  70714. * Class for generating OBJ data from a Babylon scene.
  70715. */
  70716. export class OBJExport {
  70717. /**
  70718. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70719. * @param mesh defines the list of meshes to serialize
  70720. * @param materials defines if materials should be exported
  70721. * @param matlibname defines the name of the associated mtl file
  70722. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70723. * @returns the OBJ content
  70724. */
  70725. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70726. /**
  70727. * Exports the material(s) of a mesh in .MTL file format (text)
  70728. * @param mesh defines the mesh to extract the material from
  70729. * @returns the mtl content
  70730. */
  70731. static MTL(mesh: Mesh): string;
  70732. }
  70733. }
  70734. declare module BABYLON {
  70735. /** @hidden */
  70736. export var __IGLTFExporterExtension: number;
  70737. /**
  70738. * Interface for extending the exporter
  70739. * @hidden
  70740. */
  70741. export interface IGLTFExporterExtension {
  70742. /**
  70743. * The name of this extension
  70744. */
  70745. readonly name: string;
  70746. /**
  70747. * Defines whether this extension is enabled
  70748. */
  70749. enabled: boolean;
  70750. /**
  70751. * Defines whether this extension is required
  70752. */
  70753. required: boolean;
  70754. }
  70755. }
  70756. declare module BABYLON.GLTF2.Exporter {
  70757. /** @hidden */
  70758. export var __IGLTFExporterExtensionV2: number;
  70759. /**
  70760. * Interface for a glTF exporter extension
  70761. * @hidden
  70762. */
  70763. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70764. /**
  70765. * Define this method to modify the default behavior before exporting a texture
  70766. * @param context The context when loading the asset
  70767. * @param babylonTexture The glTF texture info property
  70768. * @param mimeType The mime-type of the generated image
  70769. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70770. */
  70771. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70772. /**
  70773. * Define this method to modify the default behavior when exporting texture info
  70774. * @param context The context when loading the asset
  70775. * @param meshPrimitive glTF mesh primitive
  70776. * @param babylonSubMesh Babylon submesh
  70777. * @param binaryWriter glTF serializer binary writer instance
  70778. * @returns nullable IMeshPrimitive promise
  70779. */
  70780. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70781. /**
  70782. * Define this method to modify the default behavior when exporting a node
  70783. * @param context The context when exporting the node
  70784. * @param node glTF node
  70785. * @param babylonNode BabylonJS node
  70786. * @returns nullable INode promise
  70787. */
  70788. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70789. /**
  70790. * Called after the exporter state changes to EXPORTING
  70791. */
  70792. onExporting?(): void;
  70793. }
  70794. }
  70795. declare module BABYLON.GLTF2.Exporter {
  70796. /**
  70797. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70798. * @hidden
  70799. */
  70800. export class _GLTFMaterialExporter {
  70801. /**
  70802. * Represents the dielectric specular values for R, G and B
  70803. */
  70804. private static readonly _DielectricSpecular;
  70805. /**
  70806. * Allows the maximum specular power to be defined for material calculations
  70807. */
  70808. private static readonly _MaxSpecularPower;
  70809. /**
  70810. * Mapping to store textures
  70811. */
  70812. private _textureMap;
  70813. /**
  70814. * Numeric tolerance value
  70815. */
  70816. private static readonly _Epsilon;
  70817. /**
  70818. * Reference to the glTF Exporter
  70819. */
  70820. private _exporter;
  70821. constructor(exporter: _Exporter);
  70822. /**
  70823. * Specifies if two colors are approximately equal in value
  70824. * @param color1 first color to compare to
  70825. * @param color2 second color to compare to
  70826. * @param epsilon threshold value
  70827. */
  70828. private static FuzzyEquals;
  70829. /**
  70830. * Gets the materials from a Babylon scene and converts them to glTF materials
  70831. * @param scene babylonjs scene
  70832. * @param mimeType texture mime type
  70833. * @param images array of images
  70834. * @param textures array of textures
  70835. * @param materials array of materials
  70836. * @param imageData mapping of texture names to base64 textures
  70837. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70838. */
  70839. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70840. /**
  70841. * Makes a copy of the glTF material without the texture parameters
  70842. * @param originalMaterial original glTF material
  70843. * @returns glTF material without texture parameters
  70844. */
  70845. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70846. /**
  70847. * Specifies if the material has any texture parameters present
  70848. * @param material glTF Material
  70849. * @returns boolean specifying if texture parameters are present
  70850. */
  70851. _hasTexturesPresent(material: IMaterial): boolean;
  70852. /**
  70853. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70854. * @param babylonStandardMaterial
  70855. * @returns glTF Metallic Roughness Material representation
  70856. */
  70857. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70858. /**
  70859. * Computes the metallic factor
  70860. * @param diffuse diffused value
  70861. * @param specular specular value
  70862. * @param oneMinusSpecularStrength one minus the specular strength
  70863. * @returns metallic value
  70864. */
  70865. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70866. /**
  70867. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70868. * @param glTFMaterial glTF material
  70869. * @param babylonMaterial Babylon material
  70870. */
  70871. private static _SetAlphaMode;
  70872. /**
  70873. * Converts a Babylon Standard Material to a glTF Material
  70874. * @param babylonStandardMaterial BJS Standard Material
  70875. * @param mimeType mime type to use for the textures
  70876. * @param images array of glTF image interfaces
  70877. * @param textures array of glTF texture interfaces
  70878. * @param materials array of glTF material interfaces
  70879. * @param imageData map of image file name to data
  70880. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70881. */
  70882. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70883. /**
  70884. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70885. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70886. * @param mimeType mime type to use for the textures
  70887. * @param images array of glTF image interfaces
  70888. * @param textures array of glTF texture interfaces
  70889. * @param materials array of glTF material interfaces
  70890. * @param imageData map of image file name to data
  70891. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70892. */
  70893. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70894. /**
  70895. * Converts an image typed array buffer to a base64 image
  70896. * @param buffer typed array buffer
  70897. * @param width width of the image
  70898. * @param height height of the image
  70899. * @param mimeType mimetype of the image
  70900. * @returns base64 image string
  70901. */
  70902. private _createBase64FromCanvasAsync;
  70903. /**
  70904. * Generates a white texture based on the specified width and height
  70905. * @param width width of the texture in pixels
  70906. * @param height height of the texture in pixels
  70907. * @param scene babylonjs scene
  70908. * @returns white texture
  70909. */
  70910. private _createWhiteTexture;
  70911. /**
  70912. * 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
  70913. * @param texture1 first texture to resize
  70914. * @param texture2 second texture to resize
  70915. * @param scene babylonjs scene
  70916. * @returns resized textures or null
  70917. */
  70918. private _resizeTexturesToSameDimensions;
  70919. /**
  70920. * Converts an array of pixels to a Float32Array
  70921. * Throws an error if the pixel format is not supported
  70922. * @param pixels - array buffer containing pixel values
  70923. * @returns Float32 of pixels
  70924. */
  70925. private _convertPixelArrayToFloat32;
  70926. /**
  70927. * Convert Specular Glossiness Textures to Metallic Roughness
  70928. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70929. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70930. * @param diffuseTexture texture used to store diffuse information
  70931. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70932. * @param factors specular glossiness material factors
  70933. * @param mimeType the mime type to use for the texture
  70934. * @returns pbr metallic roughness interface or null
  70935. */
  70936. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70937. /**
  70938. * Converts specular glossiness material properties to metallic roughness
  70939. * @param specularGlossiness interface with specular glossiness material properties
  70940. * @returns interface with metallic roughness material properties
  70941. */
  70942. private _convertSpecularGlossinessToMetallicRoughness;
  70943. /**
  70944. * Calculates the surface reflectance, independent of lighting conditions
  70945. * @param color Color source to calculate brightness from
  70946. * @returns number representing the perceived brightness, or zero if color is undefined
  70947. */
  70948. private _getPerceivedBrightness;
  70949. /**
  70950. * Returns the maximum color component value
  70951. * @param color
  70952. * @returns maximum color component value, or zero if color is null or undefined
  70953. */
  70954. private _getMaxComponent;
  70955. /**
  70956. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70957. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70958. * @param mimeType mime type to use for the textures
  70959. * @param images array of glTF image interfaces
  70960. * @param textures array of glTF texture interfaces
  70961. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70962. * @param imageData map of image file name to data
  70963. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70964. * @returns glTF PBR Metallic Roughness factors
  70965. */
  70966. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70967. private _getGLTFTextureSampler;
  70968. private _getGLTFTextureWrapMode;
  70969. private _getGLTFTextureWrapModesSampler;
  70970. /**
  70971. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70972. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70973. * @param mimeType mime type to use for the textures
  70974. * @param images array of glTF image interfaces
  70975. * @param textures array of glTF texture interfaces
  70976. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70977. * @param imageData map of image file name to data
  70978. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70979. * @returns glTF PBR Metallic Roughness factors
  70980. */
  70981. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70982. /**
  70983. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70984. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70985. * @param mimeType mime type to use for the textures
  70986. * @param images array of glTF image interfaces
  70987. * @param textures array of glTF texture interfaces
  70988. * @param materials array of glTF material interfaces
  70989. * @param imageData map of image file name to data
  70990. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70991. */
  70992. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70993. private setMetallicRoughnessPbrMaterial;
  70994. private getPixelsFromTexture;
  70995. /**
  70996. * Extracts a texture from a Babylon texture into file data and glTF data
  70997. * @param babylonTexture Babylon texture to extract
  70998. * @param mimeType Mime Type of the babylonTexture
  70999. * @return glTF texture info, or null if the texture format is not supported
  71000. */
  71001. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71002. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71003. /**
  71004. * Builds a texture from base64 string
  71005. * @param base64Texture base64 texture string
  71006. * @param baseTextureName Name to use for the texture
  71007. * @param mimeType image mime type for the texture
  71008. * @param images array of images
  71009. * @param textures array of textures
  71010. * @param imageData map of image data
  71011. * @returns glTF texture info, or null if the texture format is not supported
  71012. */
  71013. private _getTextureInfoFromBase64;
  71014. }
  71015. }
  71016. declare module BABYLON {
  71017. /**
  71018. * Class for holding and downloading glTF file data
  71019. */
  71020. export class GLTFData {
  71021. /**
  71022. * Object which contains the file name as the key and its data as the value
  71023. */
  71024. glTFFiles: {
  71025. [fileName: string]: string | Blob;
  71026. };
  71027. /**
  71028. * Initializes the glTF file object
  71029. */
  71030. constructor();
  71031. /**
  71032. * Downloads the glTF data as files based on their names and data
  71033. */
  71034. downloadFiles(): void;
  71035. }
  71036. }
  71037. declare module BABYLON {
  71038. /**
  71039. * Holds a collection of exporter options and parameters
  71040. */
  71041. export interface IExportOptions {
  71042. /**
  71043. * Function which indicates whether a babylon node should be exported or not
  71044. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  71045. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  71046. */
  71047. shouldExportNode?(node: Node): boolean;
  71048. /**
  71049. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  71050. * @param metadata source metadata to read from
  71051. * @returns the data to store to glTF node extras
  71052. */
  71053. metadataSelector?(metadata: any): any;
  71054. /**
  71055. * The sample rate to bake animation curves
  71056. */
  71057. animationSampleRate?: number;
  71058. /**
  71059. * Begin serialization without waiting for the scene to be ready
  71060. */
  71061. exportWithoutWaitingForScene?: boolean;
  71062. }
  71063. /**
  71064. * Class for generating glTF data from a Babylon scene.
  71065. */
  71066. export class GLTF2Export {
  71067. /**
  71068. * Exports the geometry of the scene to .gltf file format asynchronously
  71069. * @param scene Babylon scene with scene hierarchy information
  71070. * @param filePrefix File prefix to use when generating the glTF file
  71071. * @param options Exporter options
  71072. * @returns Returns an object with a .gltf file and associates texture names
  71073. * as keys and their data and paths as values
  71074. */
  71075. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71076. private static _PreExportAsync;
  71077. private static _PostExportAsync;
  71078. /**
  71079. * Exports the geometry of the scene to .glb file format asychronously
  71080. * @param scene Babylon scene with scene hierarchy information
  71081. * @param filePrefix File prefix to use when generating glb file
  71082. * @param options Exporter options
  71083. * @returns Returns an object with a .glb filename as key and data as value
  71084. */
  71085. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71086. }
  71087. }
  71088. declare module BABYLON.GLTF2.Exporter {
  71089. /**
  71090. * @hidden
  71091. */
  71092. export class _GLTFUtilities {
  71093. /**
  71094. * Creates a buffer view based on the supplied arguments
  71095. * @param bufferIndex index value of the specified buffer
  71096. * @param byteOffset byte offset value
  71097. * @param byteLength byte length of the bufferView
  71098. * @param byteStride byte distance between conequential elements
  71099. * @param name name of the buffer view
  71100. * @returns bufferView for glTF
  71101. */
  71102. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  71103. /**
  71104. * Creates an accessor based on the supplied arguments
  71105. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  71106. * @param name The name of the accessor
  71107. * @param type The type of the accessor
  71108. * @param componentType The datatype of components in the attribute
  71109. * @param count The number of attributes referenced by this accessor
  71110. * @param byteOffset The offset relative to the start of the bufferView in bytes
  71111. * @param min Minimum value of each component in this attribute
  71112. * @param max Maximum value of each component in this attribute
  71113. * @returns accessor for glTF
  71114. */
  71115. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  71116. /**
  71117. * Calculates the minimum and maximum values of an array of position floats
  71118. * @param positions Positions array of a mesh
  71119. * @param vertexStart Starting vertex offset to calculate min and max values
  71120. * @param vertexCount Number of vertices to check for min and max values
  71121. * @returns min number array and max number array
  71122. */
  71123. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  71124. min: number[];
  71125. max: number[];
  71126. };
  71127. /**
  71128. * Converts a new right-handed Vector3
  71129. * @param vector vector3 array
  71130. * @returns right-handed Vector3
  71131. */
  71132. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  71133. /**
  71134. * Converts a Vector3 to right-handed
  71135. * @param vector Vector3 to convert to right-handed
  71136. */
  71137. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  71138. /**
  71139. * Converts a three element number array to right-handed
  71140. * @param vector number array to convert to right-handed
  71141. */
  71142. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  71143. /**
  71144. * Converts a new right-handed Vector3
  71145. * @param vector vector3 array
  71146. * @returns right-handed Vector3
  71147. */
  71148. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  71149. /**
  71150. * Converts a Vector3 to right-handed
  71151. * @param vector Vector3 to convert to right-handed
  71152. */
  71153. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  71154. /**
  71155. * Converts a three element number array to right-handed
  71156. * @param vector number array to convert to right-handed
  71157. */
  71158. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  71159. /**
  71160. * Converts a Vector4 to right-handed
  71161. * @param vector Vector4 to convert to right-handed
  71162. */
  71163. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  71164. /**
  71165. * Converts a Vector4 to right-handed
  71166. * @param vector Vector4 to convert to right-handed
  71167. */
  71168. static _GetRightHandedArray4FromRef(vector: number[]): void;
  71169. /**
  71170. * Converts a Quaternion to right-handed
  71171. * @param quaternion Source quaternion to convert to right-handed
  71172. */
  71173. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  71174. /**
  71175. * Converts a Quaternion to right-handed
  71176. * @param quaternion Source quaternion to convert to right-handed
  71177. */
  71178. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  71179. static _NormalizeTangentFromRef(tangent: Vector4): void;
  71180. }
  71181. }
  71182. declare module BABYLON.GLTF2.Exporter {
  71183. /**
  71184. * Converts Babylon Scene into glTF 2.0.
  71185. * @hidden
  71186. */
  71187. export class _Exporter {
  71188. /**
  71189. * Stores the glTF to export
  71190. */
  71191. _glTF: IGLTF;
  71192. /**
  71193. * Stores all generated buffer views, which represents views into the main glTF buffer data
  71194. */
  71195. _bufferViews: IBufferView[];
  71196. /**
  71197. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  71198. */
  71199. _accessors: IAccessor[];
  71200. /**
  71201. * Stores all the generated nodes, which contains transform and/or mesh information per node
  71202. */
  71203. private _nodes;
  71204. /**
  71205. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  71206. */
  71207. private _scenes;
  71208. /**
  71209. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  71210. */
  71211. private _meshes;
  71212. /**
  71213. * Stores all the generated material information, which represents the appearance of each primitive
  71214. */
  71215. _materials: IMaterial[];
  71216. _materialMap: {
  71217. [materialID: number]: number;
  71218. };
  71219. /**
  71220. * Stores all the generated texture information, which is referenced by glTF materials
  71221. */
  71222. _textures: ITexture[];
  71223. /**
  71224. * Stores all the generated image information, which is referenced by glTF textures
  71225. */
  71226. _images: IImage[];
  71227. /**
  71228. * Stores all the texture samplers
  71229. */
  71230. _samplers: ISampler[];
  71231. /**
  71232. * Stores all the generated animation samplers, which is referenced by glTF animations
  71233. */
  71234. /**
  71235. * Stores the animations for glTF models
  71236. */
  71237. private _animations;
  71238. /**
  71239. * Stores the total amount of bytes stored in the glTF buffer
  71240. */
  71241. private _totalByteLength;
  71242. /**
  71243. * Stores a reference to the Babylon scene containing the source geometry and material information
  71244. */
  71245. _babylonScene: Scene;
  71246. /**
  71247. * Stores a map of the image data, where the key is the file name and the value
  71248. * is the image data
  71249. */
  71250. _imageData: {
  71251. [fileName: string]: {
  71252. data: Uint8Array;
  71253. mimeType: ImageMimeType;
  71254. };
  71255. };
  71256. /**
  71257. * Stores a map of the unique id of a node to its index in the node array
  71258. */
  71259. private _nodeMap;
  71260. /**
  71261. * Specifies if the Babylon scene should be converted to right-handed on export
  71262. */
  71263. _convertToRightHandedSystem: boolean;
  71264. /**
  71265. * Baked animation sample rate
  71266. */
  71267. private _animationSampleRate;
  71268. private _options;
  71269. private _localEngine;
  71270. _glTFMaterialExporter: _GLTFMaterialExporter;
  71271. private _extensions;
  71272. private static _ExtensionNames;
  71273. private static _ExtensionFactories;
  71274. private _applyExtensions;
  71275. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  71276. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71277. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71278. private _forEachExtensions;
  71279. private _extensionsOnExporting;
  71280. /**
  71281. * Load glTF serializer extensions
  71282. */
  71283. private _loadExtensions;
  71284. /**
  71285. * Creates a glTF Exporter instance, which can accept optional exporter options
  71286. * @param babylonScene Babylon scene object
  71287. * @param options Options to modify the behavior of the exporter
  71288. */
  71289. constructor(babylonScene: Scene, options?: IExportOptions);
  71290. /**
  71291. * Registers a glTF exporter extension
  71292. * @param name Name of the extension to export
  71293. * @param factory The factory function that creates the exporter extension
  71294. */
  71295. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  71296. /**
  71297. * Un-registers an exporter extension
  71298. * @param name The name fo the exporter extension
  71299. * @returns A boolean indicating whether the extension has been un-registered
  71300. */
  71301. static UnregisterExtension(name: string): boolean;
  71302. /**
  71303. * Lazy load a local engine with premultiplied alpha set to false
  71304. */
  71305. _getLocalEngine(): Engine;
  71306. private reorderIndicesBasedOnPrimitiveMode;
  71307. /**
  71308. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  71309. * clock-wise during export to glTF
  71310. * @param submesh BabylonJS submesh
  71311. * @param primitiveMode Primitive mode of the mesh
  71312. * @param sideOrientation the winding order of the submesh
  71313. * @param vertexBufferKind The type of vertex attribute
  71314. * @param meshAttributeArray The vertex attribute data
  71315. * @param byteOffset The offset to the binary data
  71316. * @param binaryWriter The binary data for the glTF file
  71317. */
  71318. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  71319. /**
  71320. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  71321. * clock-wise during export to glTF
  71322. * @param submesh BabylonJS submesh
  71323. * @param primitiveMode Primitive mode of the mesh
  71324. * @param sideOrientation the winding order of the submesh
  71325. * @param vertexBufferKind The type of vertex attribute
  71326. * @param meshAttributeArray The vertex attribute data
  71327. * @param byteOffset The offset to the binary data
  71328. * @param binaryWriter The binary data for the glTF file
  71329. */
  71330. private reorderTriangleFillMode;
  71331. /**
  71332. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  71333. * clock-wise during export to glTF
  71334. * @param submesh BabylonJS submesh
  71335. * @param primitiveMode Primitive mode of the mesh
  71336. * @param sideOrientation the winding order of the submesh
  71337. * @param vertexBufferKind The type of vertex attribute
  71338. * @param meshAttributeArray The vertex attribute data
  71339. * @param byteOffset The offset to the binary data
  71340. * @param binaryWriter The binary data for the glTF file
  71341. */
  71342. private reorderTriangleStripDrawMode;
  71343. /**
  71344. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  71345. * clock-wise during export to glTF
  71346. * @param submesh BabylonJS submesh
  71347. * @param primitiveMode Primitive mode of the mesh
  71348. * @param sideOrientation the winding order of the submesh
  71349. * @param vertexBufferKind The type of vertex attribute
  71350. * @param meshAttributeArray The vertex attribute data
  71351. * @param byteOffset The offset to the binary data
  71352. * @param binaryWriter The binary data for the glTF file
  71353. */
  71354. private reorderTriangleFanMode;
  71355. /**
  71356. * Writes the vertex attribute data to binary
  71357. * @param vertices The vertices to write to the binary writer
  71358. * @param byteOffset The offset into the binary writer to overwrite binary data
  71359. * @param vertexAttributeKind The vertex attribute type
  71360. * @param meshAttributeArray The vertex attribute data
  71361. * @param binaryWriter The writer containing the binary data
  71362. */
  71363. private writeVertexAttributeData;
  71364. /**
  71365. * Writes mesh attribute data to a data buffer
  71366. * Returns the bytelength of the data
  71367. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  71368. * @param meshAttributeArray Array containing the attribute data
  71369. * @param binaryWriter The buffer to write the binary data to
  71370. * @param indices Used to specify the order of the vertex data
  71371. */
  71372. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  71373. /**
  71374. * Generates glTF json data
  71375. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  71376. * @param glTFPrefix Text to use when prefixing a glTF file
  71377. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  71378. * @returns json data as string
  71379. */
  71380. private generateJSON;
  71381. /**
  71382. * Generates data for .gltf and .bin files based on the glTF prefix string
  71383. * @param glTFPrefix Text to use when prefixing a glTF file
  71384. * @returns GLTFData with glTF file data
  71385. */
  71386. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  71387. /**
  71388. * Creates a binary buffer for glTF
  71389. * @returns array buffer for binary data
  71390. */
  71391. private _generateBinaryAsync;
  71392. /**
  71393. * Pads the number to a multiple of 4
  71394. * @param num number to pad
  71395. * @returns padded number
  71396. */
  71397. private _getPadding;
  71398. /**
  71399. * Generates a glb file from the json and binary data
  71400. * Returns an object with the glb file name as the key and data as the value
  71401. * @param glTFPrefix
  71402. * @returns object with glb filename as key and data as value
  71403. */
  71404. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  71405. /**
  71406. * Sets the TRS for each node
  71407. * @param node glTF Node for storing the transformation data
  71408. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  71409. */
  71410. private setNodeTransformation;
  71411. private getVertexBufferFromMesh;
  71412. /**
  71413. * Creates a bufferview based on the vertices type for the Babylon mesh
  71414. * @param kind Indicates the type of vertices data
  71415. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  71416. * @param binaryWriter The buffer to write the bufferview data to
  71417. */
  71418. private createBufferViewKind;
  71419. /**
  71420. * The primitive mode of the Babylon mesh
  71421. * @param babylonMesh The BabylonJS mesh
  71422. */
  71423. private getMeshPrimitiveMode;
  71424. /**
  71425. * Sets the primitive mode of the glTF mesh primitive
  71426. * @param meshPrimitive glTF mesh primitive
  71427. * @param primitiveMode The primitive mode
  71428. */
  71429. private setPrimitiveMode;
  71430. /**
  71431. * Sets the vertex attribute accessor based of the glTF mesh primitive
  71432. * @param meshPrimitive glTF mesh primitive
  71433. * @param attributeKind vertex attribute
  71434. * @returns boolean specifying if uv coordinates are present
  71435. */
  71436. private setAttributeKind;
  71437. /**
  71438. * Sets data for the primitive attributes of each submesh
  71439. * @param mesh glTF Mesh object to store the primitive attribute information
  71440. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  71441. * @param binaryWriter Buffer to write the attribute data to
  71442. */
  71443. private setPrimitiveAttributesAsync;
  71444. /**
  71445. * Creates a glTF scene based on the array of meshes
  71446. * Returns the the total byte offset
  71447. * @param babylonScene Babylon scene to get the mesh data from
  71448. * @param binaryWriter Buffer to write binary data to
  71449. */
  71450. private createSceneAsync;
  71451. /**
  71452. * Creates a mapping of Node unique id to node index and handles animations
  71453. * @param babylonScene Babylon Scene
  71454. * @param nodes Babylon transform nodes
  71455. * @param binaryWriter Buffer to write binary data to
  71456. * @returns Node mapping of unique id to index
  71457. */
  71458. private createNodeMapAndAnimationsAsync;
  71459. /**
  71460. * Creates a glTF node from a Babylon mesh
  71461. * @param babylonMesh Source Babylon mesh
  71462. * @param binaryWriter Buffer for storing geometry data
  71463. * @returns glTF node
  71464. */
  71465. private createNodeAsync;
  71466. }
  71467. /**
  71468. * @hidden
  71469. *
  71470. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71471. */
  71472. export class _BinaryWriter {
  71473. /**
  71474. * Array buffer which stores all binary data
  71475. */
  71476. private _arrayBuffer;
  71477. /**
  71478. * View of the array buffer
  71479. */
  71480. private _dataView;
  71481. /**
  71482. * byte offset of data in array buffer
  71483. */
  71484. private _byteOffset;
  71485. /**
  71486. * Initialize binary writer with an initial byte length
  71487. * @param byteLength Initial byte length of the array buffer
  71488. */
  71489. constructor(byteLength: number);
  71490. /**
  71491. * Resize the array buffer to the specified byte length
  71492. * @param byteLength
  71493. */
  71494. private resizeBuffer;
  71495. /**
  71496. * Get an array buffer with the length of the byte offset
  71497. * @returns ArrayBuffer resized to the byte offset
  71498. */
  71499. getArrayBuffer(): ArrayBuffer;
  71500. /**
  71501. * Get the byte offset of the array buffer
  71502. * @returns byte offset
  71503. */
  71504. getByteOffset(): number;
  71505. /**
  71506. * Stores an UInt8 in the array buffer
  71507. * @param entry
  71508. * @param byteOffset If defined, specifies where to set the value as an offset.
  71509. */
  71510. setUInt8(entry: number, byteOffset?: number): void;
  71511. /**
  71512. * Gets an UInt32 in the array buffer
  71513. * @param entry
  71514. * @param byteOffset If defined, specifies where to set the value as an offset.
  71515. */
  71516. getUInt32(byteOffset: number): number;
  71517. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71518. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71519. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71520. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71521. /**
  71522. * Stores a Float32 in the array buffer
  71523. * @param entry
  71524. */
  71525. setFloat32(entry: number, byteOffset?: number): void;
  71526. /**
  71527. * Stores an UInt32 in the array buffer
  71528. * @param entry
  71529. * @param byteOffset If defined, specifies where to set the value as an offset.
  71530. */
  71531. setUInt32(entry: number, byteOffset?: number): void;
  71532. }
  71533. }
  71534. declare module BABYLON.GLTF2.Exporter {
  71535. /**
  71536. * @hidden
  71537. * Interface to store animation data.
  71538. */
  71539. export interface _IAnimationData {
  71540. /**
  71541. * Keyframe data.
  71542. */
  71543. inputs: number[];
  71544. /**
  71545. * Value data.
  71546. */
  71547. outputs: number[][];
  71548. /**
  71549. * Animation interpolation data.
  71550. */
  71551. samplerInterpolation: AnimationSamplerInterpolation;
  71552. /**
  71553. * Minimum keyframe value.
  71554. */
  71555. inputsMin: number;
  71556. /**
  71557. * Maximum keyframe value.
  71558. */
  71559. inputsMax: number;
  71560. }
  71561. /**
  71562. * @hidden
  71563. */
  71564. export interface _IAnimationInfo {
  71565. /**
  71566. * The target channel for the animation
  71567. */
  71568. animationChannelTargetPath: AnimationChannelTargetPath;
  71569. /**
  71570. * The glTF accessor type for the data.
  71571. */
  71572. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71573. /**
  71574. * Specifies if quaternions should be used.
  71575. */
  71576. useQuaternion: boolean;
  71577. }
  71578. /**
  71579. * @hidden
  71580. * Utility class for generating glTF animation data from BabylonJS.
  71581. */
  71582. export class _GLTFAnimation {
  71583. /**
  71584. * @ignore
  71585. *
  71586. * Creates glTF channel animation from BabylonJS animation.
  71587. * @param babylonTransformNode - BabylonJS mesh.
  71588. * @param animation - animation.
  71589. * @param animationChannelTargetPath - The target animation channel.
  71590. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71591. * @param useQuaternion - Specifies if quaternions are used.
  71592. * @returns nullable IAnimationData
  71593. */
  71594. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71595. private static _DeduceAnimationInfo;
  71596. /**
  71597. * @ignore
  71598. * Create node animations from the transform node animations
  71599. * @param babylonNode
  71600. * @param runtimeGLTFAnimation
  71601. * @param idleGLTFAnimations
  71602. * @param nodeMap
  71603. * @param nodes
  71604. * @param binaryWriter
  71605. * @param bufferViews
  71606. * @param accessors
  71607. * @param convertToRightHandedSystem
  71608. */
  71609. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71610. [key: number]: number;
  71611. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71612. /**
  71613. * @ignore
  71614. * Create node animations from the animation groups
  71615. * @param babylonScene
  71616. * @param glTFAnimations
  71617. * @param nodeMap
  71618. * @param nodes
  71619. * @param binaryWriter
  71620. * @param bufferViews
  71621. * @param accessors
  71622. * @param convertToRightHandedSystem
  71623. */
  71624. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71625. [key: number]: number;
  71626. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71627. private static AddAnimation;
  71628. /**
  71629. * Create a baked animation
  71630. * @param babylonTransformNode BabylonJS mesh
  71631. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71632. * @param animationChannelTargetPath animation target channel
  71633. * @param minFrame minimum animation frame
  71634. * @param maxFrame maximum animation frame
  71635. * @param fps frames per second of the animation
  71636. * @param inputs input key frames of the animation
  71637. * @param outputs output key frame data of the animation
  71638. * @param convertToRightHandedSystem converts the values to right-handed
  71639. * @param useQuaternion specifies if quaternions should be used
  71640. */
  71641. private static _CreateBakedAnimation;
  71642. private static _ConvertFactorToVector3OrQuaternion;
  71643. private static _SetInterpolatedValue;
  71644. /**
  71645. * Creates linear animation from the animation key frames
  71646. * @param babylonTransformNode BabylonJS mesh
  71647. * @param animation BabylonJS animation
  71648. * @param animationChannelTargetPath The target animation channel
  71649. * @param frameDelta The difference between the last and first frame of the animation
  71650. * @param inputs Array to store the key frame times
  71651. * @param outputs Array to store the key frame data
  71652. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71653. * @param useQuaternion Specifies if quaternions are used in the animation
  71654. */
  71655. private static _CreateLinearOrStepAnimation;
  71656. /**
  71657. * Creates cubic spline animation from the animation key frames
  71658. * @param babylonTransformNode BabylonJS mesh
  71659. * @param animation BabylonJS animation
  71660. * @param animationChannelTargetPath The target animation channel
  71661. * @param frameDelta The difference between the last and first frame of the animation
  71662. * @param inputs Array to store the key frame times
  71663. * @param outputs Array to store the key frame data
  71664. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71665. * @param useQuaternion Specifies if quaternions are used in the animation
  71666. */
  71667. private static _CreateCubicSplineAnimation;
  71668. private static _GetBasePositionRotationOrScale;
  71669. /**
  71670. * Adds a key frame value
  71671. * @param keyFrame
  71672. * @param animation
  71673. * @param outputs
  71674. * @param animationChannelTargetPath
  71675. * @param basePositionRotationOrScale
  71676. * @param convertToRightHandedSystem
  71677. * @param useQuaternion
  71678. */
  71679. private static _AddKeyframeValue;
  71680. /**
  71681. * Determine the interpolation based on the key frames
  71682. * @param keyFrames
  71683. * @param animationChannelTargetPath
  71684. * @param useQuaternion
  71685. */
  71686. private static _DeduceInterpolation;
  71687. /**
  71688. * Adds an input tangent or output tangent to the output data
  71689. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71690. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71691. * @param outputs The animation data by keyframe
  71692. * @param animationChannelTargetPath The target animation channel
  71693. * @param interpolation The interpolation type
  71694. * @param keyFrame The key frame with the animation data
  71695. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71696. * @param useQuaternion Specifies if quaternions are used
  71697. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71698. */
  71699. private static AddSplineTangent;
  71700. /**
  71701. * Get the minimum and maximum key frames' frame values
  71702. * @param keyFrames animation key frames
  71703. * @returns the minimum and maximum key frame value
  71704. */
  71705. private static calculateMinMaxKeyFrames;
  71706. }
  71707. }
  71708. declare module BABYLON.GLTF2.Exporter {
  71709. /** @hidden */
  71710. export var textureTransformPixelShader: {
  71711. name: string;
  71712. shader: string;
  71713. };
  71714. }
  71715. declare module BABYLON.GLTF2.Exporter.Extensions {
  71716. /**
  71717. * @hidden
  71718. */
  71719. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71720. /** Name of this extension */
  71721. readonly name: string;
  71722. /** Defines whether this extension is enabled */
  71723. enabled: boolean;
  71724. /** Defines whether this extension is required */
  71725. required: boolean;
  71726. /** Reference to the glTF exporter */
  71727. private _exporter;
  71728. constructor(exporter: _Exporter);
  71729. dispose(): void;
  71730. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71731. /**
  71732. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71733. * @param babylonTexture
  71734. * @param offset
  71735. * @param rotation
  71736. * @param scale
  71737. * @param scene
  71738. */
  71739. private _textureTransformTextureAsync;
  71740. }
  71741. }
  71742. declare module BABYLON.GLTF2.Exporter.Extensions {
  71743. /**
  71744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71745. */
  71746. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71747. /** The name of this extension. */
  71748. readonly name: string;
  71749. /** Defines whether this extension is enabled. */
  71750. enabled: boolean;
  71751. /** Defines whether this extension is required */
  71752. required: boolean;
  71753. /** Reference to the glTF exporter */
  71754. private _exporter;
  71755. private _lights;
  71756. /** @hidden */
  71757. constructor(exporter: _Exporter);
  71758. /** @hidden */
  71759. dispose(): void;
  71760. /** @hidden */
  71761. onExporting(): void;
  71762. /**
  71763. * Define this method to modify the default behavior when exporting a node
  71764. * @param context The context when exporting the node
  71765. * @param node glTF node
  71766. * @param babylonNode BabylonJS node
  71767. * @returns nullable INode promise
  71768. */
  71769. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71770. }
  71771. }
  71772. declare module BABYLON {
  71773. /**
  71774. * Class for generating STL data from a Babylon scene.
  71775. */
  71776. export class STLExport {
  71777. /**
  71778. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71779. * @param meshes list defines the mesh to serialize
  71780. * @param download triggers the automatic download of the file.
  71781. * @param fileName changes the downloads fileName.
  71782. * @param binary changes the STL to a binary type.
  71783. * @param isLittleEndian toggle for binary type exporter.
  71784. * @returns the STL as UTF8 string
  71785. */
  71786. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71787. }
  71788. }
  71789. declare module "babylonjs-gltf2interface" {
  71790. export = BABYLON.GLTF2;
  71791. }
  71792. /**
  71793. * Module for glTF 2.0 Interface
  71794. */
  71795. declare module BABYLON.GLTF2 {
  71796. /**
  71797. * The datatype of the components in the attribute
  71798. */
  71799. const enum AccessorComponentType {
  71800. /**
  71801. * Byte
  71802. */
  71803. BYTE = 5120,
  71804. /**
  71805. * Unsigned Byte
  71806. */
  71807. UNSIGNED_BYTE = 5121,
  71808. /**
  71809. * Short
  71810. */
  71811. SHORT = 5122,
  71812. /**
  71813. * Unsigned Short
  71814. */
  71815. UNSIGNED_SHORT = 5123,
  71816. /**
  71817. * Unsigned Int
  71818. */
  71819. UNSIGNED_INT = 5125,
  71820. /**
  71821. * Float
  71822. */
  71823. FLOAT = 5126,
  71824. }
  71825. /**
  71826. * Specifies if the attirbute is a scalar, vector, or matrix
  71827. */
  71828. const enum AccessorType {
  71829. /**
  71830. * Scalar
  71831. */
  71832. SCALAR = "SCALAR",
  71833. /**
  71834. * Vector2
  71835. */
  71836. VEC2 = "VEC2",
  71837. /**
  71838. * Vector3
  71839. */
  71840. VEC3 = "VEC3",
  71841. /**
  71842. * Vector4
  71843. */
  71844. VEC4 = "VEC4",
  71845. /**
  71846. * Matrix2x2
  71847. */
  71848. MAT2 = "MAT2",
  71849. /**
  71850. * Matrix3x3
  71851. */
  71852. MAT3 = "MAT3",
  71853. /**
  71854. * Matrix4x4
  71855. */
  71856. MAT4 = "MAT4",
  71857. }
  71858. /**
  71859. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71860. */
  71861. const enum AnimationChannelTargetPath {
  71862. /**
  71863. * Translation
  71864. */
  71865. TRANSLATION = "translation",
  71866. /**
  71867. * Rotation
  71868. */
  71869. ROTATION = "rotation",
  71870. /**
  71871. * Scale
  71872. */
  71873. SCALE = "scale",
  71874. /**
  71875. * Weights
  71876. */
  71877. WEIGHTS = "weights",
  71878. }
  71879. /**
  71880. * Interpolation algorithm
  71881. */
  71882. const enum AnimationSamplerInterpolation {
  71883. /**
  71884. * The animated values are linearly interpolated between keyframes
  71885. */
  71886. LINEAR = "LINEAR",
  71887. /**
  71888. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71889. */
  71890. STEP = "STEP",
  71891. /**
  71892. * The animation's interpolation is computed using a cubic spline with specified tangents
  71893. */
  71894. CUBICSPLINE = "CUBICSPLINE",
  71895. }
  71896. /**
  71897. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71898. */
  71899. const enum CameraType {
  71900. /**
  71901. * A perspective camera containing properties to create a perspective projection matrix
  71902. */
  71903. PERSPECTIVE = "perspective",
  71904. /**
  71905. * An orthographic camera containing properties to create an orthographic projection matrix
  71906. */
  71907. ORTHOGRAPHIC = "orthographic",
  71908. }
  71909. /**
  71910. * The mime-type of the image
  71911. */
  71912. const enum ImageMimeType {
  71913. /**
  71914. * JPEG Mime-type
  71915. */
  71916. JPEG = "image/jpeg",
  71917. /**
  71918. * PNG Mime-type
  71919. */
  71920. PNG = "image/png",
  71921. }
  71922. /**
  71923. * The alpha rendering mode of the material
  71924. */
  71925. const enum MaterialAlphaMode {
  71926. /**
  71927. * The alpha value is ignored and the rendered output is fully opaque
  71928. */
  71929. OPAQUE = "OPAQUE",
  71930. /**
  71931. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71932. */
  71933. MASK = "MASK",
  71934. /**
  71935. * 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)
  71936. */
  71937. BLEND = "BLEND",
  71938. }
  71939. /**
  71940. * The type of the primitives to render
  71941. */
  71942. const enum MeshPrimitiveMode {
  71943. /**
  71944. * Points
  71945. */
  71946. POINTS = 0,
  71947. /**
  71948. * Lines
  71949. */
  71950. LINES = 1,
  71951. /**
  71952. * Line Loop
  71953. */
  71954. LINE_LOOP = 2,
  71955. /**
  71956. * Line Strip
  71957. */
  71958. LINE_STRIP = 3,
  71959. /**
  71960. * Triangles
  71961. */
  71962. TRIANGLES = 4,
  71963. /**
  71964. * Triangle Strip
  71965. */
  71966. TRIANGLE_STRIP = 5,
  71967. /**
  71968. * Triangle Fan
  71969. */
  71970. TRIANGLE_FAN = 6,
  71971. }
  71972. /**
  71973. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71974. */
  71975. const enum TextureMagFilter {
  71976. /**
  71977. * Nearest
  71978. */
  71979. NEAREST = 9728,
  71980. /**
  71981. * Linear
  71982. */
  71983. LINEAR = 9729,
  71984. }
  71985. /**
  71986. * Minification filter. All valid values correspond to WebGL enums
  71987. */
  71988. const enum TextureMinFilter {
  71989. /**
  71990. * Nearest
  71991. */
  71992. NEAREST = 9728,
  71993. /**
  71994. * Linear
  71995. */
  71996. LINEAR = 9729,
  71997. /**
  71998. * Nearest Mip-Map Nearest
  71999. */
  72000. NEAREST_MIPMAP_NEAREST = 9984,
  72001. /**
  72002. * Linear Mipmap Nearest
  72003. */
  72004. LINEAR_MIPMAP_NEAREST = 9985,
  72005. /**
  72006. * Nearest Mipmap Linear
  72007. */
  72008. NEAREST_MIPMAP_LINEAR = 9986,
  72009. /**
  72010. * Linear Mipmap Linear
  72011. */
  72012. LINEAR_MIPMAP_LINEAR = 9987,
  72013. }
  72014. /**
  72015. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72016. */
  72017. const enum TextureWrapMode {
  72018. /**
  72019. * Clamp to Edge
  72020. */
  72021. CLAMP_TO_EDGE = 33071,
  72022. /**
  72023. * Mirrored Repeat
  72024. */
  72025. MIRRORED_REPEAT = 33648,
  72026. /**
  72027. * Repeat
  72028. */
  72029. REPEAT = 10497,
  72030. }
  72031. /**
  72032. * glTF Property
  72033. */
  72034. interface IProperty {
  72035. /**
  72036. * Dictionary object with extension-specific objects
  72037. */
  72038. extensions?: {
  72039. [key: string]: any;
  72040. };
  72041. /**
  72042. * Application-Specific data
  72043. */
  72044. extras?: any;
  72045. }
  72046. /**
  72047. * glTF Child of Root Property
  72048. */
  72049. interface IChildRootProperty extends IProperty {
  72050. /**
  72051. * The user-defined name of this object
  72052. */
  72053. name?: string;
  72054. }
  72055. /**
  72056. * Indices of those attributes that deviate from their initialization value
  72057. */
  72058. interface IAccessorSparseIndices extends IProperty {
  72059. /**
  72060. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72061. */
  72062. bufferView: number;
  72063. /**
  72064. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72065. */
  72066. byteOffset?: number;
  72067. /**
  72068. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  72069. */
  72070. componentType: AccessorComponentType;
  72071. }
  72072. /**
  72073. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  72074. */
  72075. interface IAccessorSparseValues extends IProperty {
  72076. /**
  72077. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72078. */
  72079. bufferView: number;
  72080. /**
  72081. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72082. */
  72083. byteOffset?: number;
  72084. }
  72085. /**
  72086. * Sparse storage of attributes that deviate from their initialization value
  72087. */
  72088. interface IAccessorSparse extends IProperty {
  72089. /**
  72090. * The number of attributes encoded in this sparse accessor
  72091. */
  72092. count: number;
  72093. /**
  72094. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  72095. */
  72096. indices: IAccessorSparseIndices;
  72097. /**
  72098. * 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
  72099. */
  72100. values: IAccessorSparseValues;
  72101. }
  72102. /**
  72103. * 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
  72104. */
  72105. interface IAccessor extends IChildRootProperty {
  72106. /**
  72107. * The index of the bufferview
  72108. */
  72109. bufferView?: number;
  72110. /**
  72111. * The offset relative to the start of the bufferView in bytes
  72112. */
  72113. byteOffset?: number;
  72114. /**
  72115. * The datatype of components in the attribute
  72116. */
  72117. componentType: AccessorComponentType;
  72118. /**
  72119. * Specifies whether integer data values should be normalized
  72120. */
  72121. normalized?: boolean;
  72122. /**
  72123. * The number of attributes referenced by this accessor
  72124. */
  72125. count: number;
  72126. /**
  72127. * Specifies if the attribute is a scalar, vector, or matrix
  72128. */
  72129. type: AccessorType;
  72130. /**
  72131. * Maximum value of each component in this attribute
  72132. */
  72133. max?: number[];
  72134. /**
  72135. * Minimum value of each component in this attribute
  72136. */
  72137. min?: number[];
  72138. /**
  72139. * Sparse storage of attributes that deviate from their initialization value
  72140. */
  72141. sparse?: IAccessorSparse;
  72142. }
  72143. /**
  72144. * Targets an animation's sampler at a node's property
  72145. */
  72146. interface IAnimationChannel extends IProperty {
  72147. /**
  72148. * The index of a sampler in this animation used to compute the value for the target
  72149. */
  72150. sampler: number;
  72151. /**
  72152. * The index of the node and TRS property to target
  72153. */
  72154. target: IAnimationChannelTarget;
  72155. }
  72156. /**
  72157. * The index of the node and TRS property that an animation channel targets
  72158. */
  72159. interface IAnimationChannelTarget extends IProperty {
  72160. /**
  72161. * The index of the node to target
  72162. */
  72163. node: number;
  72164. /**
  72165. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72166. */
  72167. path: AnimationChannelTargetPath;
  72168. }
  72169. /**
  72170. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72171. */
  72172. interface IAnimationSampler extends IProperty {
  72173. /**
  72174. * The index of an accessor containing keyframe input values, e.g., time
  72175. */
  72176. input: number;
  72177. /**
  72178. * Interpolation algorithm
  72179. */
  72180. interpolation?: AnimationSamplerInterpolation;
  72181. /**
  72182. * The index of an accessor, containing keyframe output values
  72183. */
  72184. output: number;
  72185. }
  72186. /**
  72187. * A keyframe animation
  72188. */
  72189. interface IAnimation extends IChildRootProperty {
  72190. /**
  72191. * An array of channels, each of which targets an animation's sampler at a node's property
  72192. */
  72193. channels: IAnimationChannel[];
  72194. /**
  72195. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72196. */
  72197. samplers: IAnimationSampler[];
  72198. }
  72199. /**
  72200. * Metadata about the glTF asset
  72201. */
  72202. interface IAsset extends IChildRootProperty {
  72203. /**
  72204. * A copyright message suitable for display to credit the content creator
  72205. */
  72206. copyright?: string;
  72207. /**
  72208. * Tool that generated this glTF model. Useful for debugging
  72209. */
  72210. generator?: string;
  72211. /**
  72212. * The glTF version that this asset targets
  72213. */
  72214. version: string;
  72215. /**
  72216. * The minimum glTF version that this asset targets
  72217. */
  72218. minVersion?: string;
  72219. }
  72220. /**
  72221. * A buffer points to binary geometry, animation, or skins
  72222. */
  72223. interface IBuffer extends IChildRootProperty {
  72224. /**
  72225. * 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
  72226. */
  72227. uri?: string;
  72228. /**
  72229. * The length of the buffer in bytes
  72230. */
  72231. byteLength: number;
  72232. }
  72233. /**
  72234. * A view into a buffer generally representing a subset of the buffer
  72235. */
  72236. interface IBufferView extends IChildRootProperty {
  72237. /**
  72238. * The index of the buffer
  72239. */
  72240. buffer: number;
  72241. /**
  72242. * The offset into the buffer in bytes
  72243. */
  72244. byteOffset?: number;
  72245. /**
  72246. * The lenth of the bufferView in bytes
  72247. */
  72248. byteLength: number;
  72249. /**
  72250. * The stride, in bytes
  72251. */
  72252. byteStride?: number;
  72253. }
  72254. /**
  72255. * An orthographic camera containing properties to create an orthographic projection matrix
  72256. */
  72257. interface ICameraOrthographic extends IProperty {
  72258. /**
  72259. * The floating-point horizontal magnification of the view. Must not be zero
  72260. */
  72261. xmag: number;
  72262. /**
  72263. * The floating-point vertical magnification of the view. Must not be zero
  72264. */
  72265. ymag: number;
  72266. /**
  72267. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  72268. */
  72269. zfar: number;
  72270. /**
  72271. * The floating-point distance to the near clipping plane
  72272. */
  72273. znear: number;
  72274. }
  72275. /**
  72276. * A perspective camera containing properties to create a perspective projection matrix
  72277. */
  72278. interface ICameraPerspective extends IProperty {
  72279. /**
  72280. * The floating-point aspect ratio of the field of view
  72281. */
  72282. aspectRatio?: number;
  72283. /**
  72284. * The floating-point vertical field of view in radians
  72285. */
  72286. yfov: number;
  72287. /**
  72288. * The floating-point distance to the far clipping plane
  72289. */
  72290. zfar?: number;
  72291. /**
  72292. * The floating-point distance to the near clipping plane
  72293. */
  72294. znear: number;
  72295. }
  72296. /**
  72297. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72298. */
  72299. interface ICamera extends IChildRootProperty {
  72300. /**
  72301. * An orthographic camera containing properties to create an orthographic projection matrix
  72302. */
  72303. orthographic?: ICameraOrthographic;
  72304. /**
  72305. * A perspective camera containing properties to create a perspective projection matrix
  72306. */
  72307. perspective?: ICameraPerspective;
  72308. /**
  72309. * Specifies if the camera uses a perspective or orthographic projection
  72310. */
  72311. type: CameraType;
  72312. }
  72313. /**
  72314. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  72315. */
  72316. interface IImage extends IChildRootProperty {
  72317. /**
  72318. * 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
  72319. */
  72320. uri?: string;
  72321. /**
  72322. * The image's MIME type
  72323. */
  72324. mimeType?: ImageMimeType;
  72325. /**
  72326. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  72327. */
  72328. bufferView?: number;
  72329. }
  72330. /**
  72331. * Material Normal Texture Info
  72332. */
  72333. interface IMaterialNormalTextureInfo extends ITextureInfo {
  72334. /**
  72335. * The scalar multiplier applied to each normal vector of the normal texture
  72336. */
  72337. scale?: number;
  72338. }
  72339. /**
  72340. * Material Occlusion Texture Info
  72341. */
  72342. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  72343. /**
  72344. * A scalar multiplier controlling the amount of occlusion applied
  72345. */
  72346. strength?: number;
  72347. }
  72348. /**
  72349. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  72350. */
  72351. interface IMaterialPbrMetallicRoughness {
  72352. /**
  72353. * The material's base color factor
  72354. */
  72355. baseColorFactor?: number[];
  72356. /**
  72357. * The base color texture
  72358. */
  72359. baseColorTexture?: ITextureInfo;
  72360. /**
  72361. * The metalness of the material
  72362. */
  72363. metallicFactor?: number;
  72364. /**
  72365. * The roughness of the material
  72366. */
  72367. roughnessFactor?: number;
  72368. /**
  72369. * The metallic-roughness texture
  72370. */
  72371. metallicRoughnessTexture?: ITextureInfo;
  72372. }
  72373. /**
  72374. * The material appearance of a primitive
  72375. */
  72376. interface IMaterial extends IChildRootProperty {
  72377. /**
  72378. * 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
  72379. */
  72380. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72381. /**
  72382. * The normal map texture
  72383. */
  72384. normalTexture?: IMaterialNormalTextureInfo;
  72385. /**
  72386. * The occlusion map texture
  72387. */
  72388. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72389. /**
  72390. * The emissive map texture
  72391. */
  72392. emissiveTexture?: ITextureInfo;
  72393. /**
  72394. * 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
  72395. */
  72396. emissiveFactor?: number[];
  72397. /**
  72398. * The alpha rendering mode of the material
  72399. */
  72400. alphaMode?: MaterialAlphaMode;
  72401. /**
  72402. * The alpha cutoff value of the material
  72403. */
  72404. alphaCutoff?: number;
  72405. /**
  72406. * Specifies whether the material is double sided
  72407. */
  72408. doubleSided?: boolean;
  72409. }
  72410. /**
  72411. * Geometry to be rendered with the given material
  72412. */
  72413. interface IMeshPrimitive extends IProperty {
  72414. /**
  72415. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  72416. */
  72417. attributes: {
  72418. [name: string]: number;
  72419. };
  72420. /**
  72421. * The index of the accessor that contains the indices
  72422. */
  72423. indices?: number;
  72424. /**
  72425. * The index of the material to apply to this primitive when rendering
  72426. */
  72427. material?: number;
  72428. /**
  72429. * The type of primitives to render. All valid values correspond to WebGL enums
  72430. */
  72431. mode?: MeshPrimitiveMode;
  72432. /**
  72433. * 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
  72434. */
  72435. targets?: {
  72436. [name: string]: number;
  72437. }[];
  72438. }
  72439. /**
  72440. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  72441. */
  72442. interface IMesh extends IChildRootProperty {
  72443. /**
  72444. * An array of primitives, each defining geometry to be rendered with a material
  72445. */
  72446. primitives: IMeshPrimitive[];
  72447. /**
  72448. * Array of weights to be applied to the Morph Targets
  72449. */
  72450. weights?: number[];
  72451. }
  72452. /**
  72453. * A node in the node hierarchy
  72454. */
  72455. interface INode extends IChildRootProperty {
  72456. /**
  72457. * The index of the camera referenced by this node
  72458. */
  72459. camera?: number;
  72460. /**
  72461. * The indices of this node's children
  72462. */
  72463. children?: number[];
  72464. /**
  72465. * The index of the skin referenced by this node
  72466. */
  72467. skin?: number;
  72468. /**
  72469. * A floating-point 4x4 transformation matrix stored in column-major order
  72470. */
  72471. matrix?: number[];
  72472. /**
  72473. * The index of the mesh in this node
  72474. */
  72475. mesh?: number;
  72476. /**
  72477. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72478. */
  72479. rotation?: number[];
  72480. /**
  72481. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72482. */
  72483. scale?: number[];
  72484. /**
  72485. * The node's translation along the x, y, and z axes
  72486. */
  72487. translation?: number[];
  72488. /**
  72489. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72490. */
  72491. weights?: number[];
  72492. }
  72493. /**
  72494. * Texture sampler properties for filtering and wrapping modes
  72495. */
  72496. interface ISampler extends IChildRootProperty {
  72497. /**
  72498. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72499. */
  72500. magFilter?: TextureMagFilter;
  72501. /**
  72502. * Minification filter. All valid values correspond to WebGL enums
  72503. */
  72504. minFilter?: TextureMinFilter;
  72505. /**
  72506. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72507. */
  72508. wrapS?: TextureWrapMode;
  72509. /**
  72510. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72511. */
  72512. wrapT?: TextureWrapMode;
  72513. }
  72514. /**
  72515. * The root nodes of a scene
  72516. */
  72517. interface IScene extends IChildRootProperty {
  72518. /**
  72519. * The indices of each root node
  72520. */
  72521. nodes: number[];
  72522. }
  72523. /**
  72524. * Joints and matrices defining a skin
  72525. */
  72526. interface ISkin extends IChildRootProperty {
  72527. /**
  72528. * 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
  72529. */
  72530. inverseBindMatrices?: number;
  72531. /**
  72532. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72533. */
  72534. skeleton?: number;
  72535. /**
  72536. * 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)
  72537. */
  72538. joints: number[];
  72539. }
  72540. /**
  72541. * A texture and its sampler
  72542. */
  72543. interface ITexture extends IChildRootProperty {
  72544. /**
  72545. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72546. */
  72547. sampler?: number;
  72548. /**
  72549. * The index of the image used by this texture
  72550. */
  72551. source: number;
  72552. }
  72553. /**
  72554. * Reference to a texture
  72555. */
  72556. interface ITextureInfo extends IProperty {
  72557. /**
  72558. * The index of the texture
  72559. */
  72560. index: number;
  72561. /**
  72562. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72563. */
  72564. texCoord?: number;
  72565. }
  72566. /**
  72567. * The root object for a glTF asset
  72568. */
  72569. interface IGLTF extends IProperty {
  72570. /**
  72571. * An array of accessors. An accessor is a typed view into a bufferView
  72572. */
  72573. accessors?: IAccessor[];
  72574. /**
  72575. * An array of keyframe animations
  72576. */
  72577. animations?: IAnimation[];
  72578. /**
  72579. * Metadata about the glTF asset
  72580. */
  72581. asset: IAsset;
  72582. /**
  72583. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72584. */
  72585. buffers?: IBuffer[];
  72586. /**
  72587. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72588. */
  72589. bufferViews?: IBufferView[];
  72590. /**
  72591. * An array of cameras
  72592. */
  72593. cameras?: ICamera[];
  72594. /**
  72595. * Names of glTF extensions used somewhere in this asset
  72596. */
  72597. extensionsUsed?: string[];
  72598. /**
  72599. * Names of glTF extensions required to properly load this asset
  72600. */
  72601. extensionsRequired?: string[];
  72602. /**
  72603. * An array of images. An image defines data used to create a texture
  72604. */
  72605. images?: IImage[];
  72606. /**
  72607. * An array of materials. A material defines the appearance of a primitive
  72608. */
  72609. materials?: IMaterial[];
  72610. /**
  72611. * An array of meshes. A mesh is a set of primitives to be rendered
  72612. */
  72613. meshes?: IMesh[];
  72614. /**
  72615. * An array of nodes
  72616. */
  72617. nodes?: INode[];
  72618. /**
  72619. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72620. */
  72621. samplers?: ISampler[];
  72622. /**
  72623. * The index of the default scene
  72624. */
  72625. scene?: number;
  72626. /**
  72627. * An array of scenes
  72628. */
  72629. scenes?: IScene[];
  72630. /**
  72631. * An array of skins. A skin is defined by joints and matrices
  72632. */
  72633. skins?: ISkin[];
  72634. /**
  72635. * An array of textures
  72636. */
  72637. textures?: ITexture[];
  72638. }
  72639. /**
  72640. * The glTF validation results
  72641. * @ignore
  72642. */
  72643. interface IGLTFValidationResults {
  72644. info: {
  72645. generator: string;
  72646. hasAnimations: boolean;
  72647. hasDefaultScene: boolean;
  72648. hasMaterials: boolean;
  72649. hasMorphTargets: boolean;
  72650. hasSkins: boolean;
  72651. hasTextures: boolean;
  72652. maxAttributesUsed: number;
  72653. primitivesCount: number
  72654. };
  72655. issues: {
  72656. messages: Array<string>;
  72657. numErrors: number;
  72658. numHints: number;
  72659. numInfos: number;
  72660. numWarnings: number;
  72661. truncated: boolean
  72662. };
  72663. mimeType: string;
  72664. uri: string;
  72665. validatedAt: string;
  72666. validatorVersion: string;
  72667. }
  72668. /**
  72669. * The glTF validation options
  72670. */
  72671. interface IGLTFValidationOptions {
  72672. /** Uri to use */
  72673. uri?: string;
  72674. /** Function used to load external resources */
  72675. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72676. /** Boolean indicating that we need to validate accessor data */
  72677. validateAccessorData?: boolean;
  72678. /** max number of issues allowed */
  72679. maxIssues?: number;
  72680. /** Ignored issues */
  72681. ignoredIssues?: Array<string>;
  72682. /** Value to override severy settings */
  72683. severityOverrides?: Object;
  72684. }
  72685. /**
  72686. * The glTF validator object
  72687. * @ignore
  72688. */
  72689. interface IGLTFValidator {
  72690. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72691. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72692. }
  72693. }
  72694. declare module BABYLON {
  72695. /** @hidden */
  72696. export var cellPixelShader: {
  72697. name: string;
  72698. shader: string;
  72699. };
  72700. }
  72701. declare module BABYLON {
  72702. /** @hidden */
  72703. export var cellVertexShader: {
  72704. name: string;
  72705. shader: string;
  72706. };
  72707. }
  72708. declare module BABYLON {
  72709. export class CellMaterial extends BABYLON.PushMaterial {
  72710. private _diffuseTexture;
  72711. diffuseTexture: BABYLON.BaseTexture;
  72712. diffuseColor: BABYLON.Color3;
  72713. _computeHighLevel: boolean;
  72714. computeHighLevel: boolean;
  72715. private _disableLighting;
  72716. disableLighting: boolean;
  72717. private _maxSimultaneousLights;
  72718. maxSimultaneousLights: number;
  72719. private _renderId;
  72720. constructor(name: string, scene: BABYLON.Scene);
  72721. needAlphaBlending(): boolean;
  72722. needAlphaTesting(): boolean;
  72723. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72724. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72725. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72726. getAnimatables(): BABYLON.IAnimatable[];
  72727. getActiveTextures(): BABYLON.BaseTexture[];
  72728. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72729. dispose(forceDisposeEffect?: boolean): void;
  72730. getClassName(): string;
  72731. clone(name: string): CellMaterial;
  72732. serialize(): any;
  72733. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72734. }
  72735. }
  72736. declare module BABYLON {
  72737. export class CustomShaderStructure {
  72738. FragmentStore: string;
  72739. VertexStore: string;
  72740. constructor();
  72741. }
  72742. export class ShaderSpecialParts {
  72743. constructor();
  72744. Fragment_Begin: string;
  72745. Fragment_Definitions: string;
  72746. Fragment_MainBegin: string;
  72747. Fragment_Custom_Diffuse: string;
  72748. Fragment_Before_Lights: string;
  72749. Fragment_Before_Fog: string;
  72750. Fragment_Custom_Alpha: string;
  72751. Fragment_Before_FragColor: string;
  72752. Vertex_Begin: string;
  72753. Vertex_Definitions: string;
  72754. Vertex_MainBegin: string;
  72755. Vertex_Before_PositionUpdated: string;
  72756. Vertex_Before_NormalUpdated: string;
  72757. Vertex_MainEnd: string;
  72758. }
  72759. export class CustomMaterial extends BABYLON.StandardMaterial {
  72760. static ShaderIndexer: number;
  72761. CustomParts: ShaderSpecialParts;
  72762. _isCreatedShader: boolean;
  72763. _createdShaderName: string;
  72764. _customUniform: string[];
  72765. _newUniforms: string[];
  72766. _newUniformInstances: any[];
  72767. _newSamplerInstances: BABYLON.Texture[];
  72768. FragmentShader: string;
  72769. VertexShader: string;
  72770. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72771. ReviewUniform(name: string, arr: string[]): string[];
  72772. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72773. constructor(name: string, scene: BABYLON.Scene);
  72774. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72775. Fragment_Begin(shaderPart: string): CustomMaterial;
  72776. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72777. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72778. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72779. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72780. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72781. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72782. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72783. Vertex_Begin(shaderPart: string): CustomMaterial;
  72784. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72785. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72786. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72787. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72788. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72789. }
  72790. }
  72791. declare module BABYLON {
  72792. export class ShaderAlebdoParts {
  72793. constructor();
  72794. Fragment_Begin: string;
  72795. Fragment_Definitions: string;
  72796. Fragment_MainBegin: string;
  72797. Fragment_Custom_Albedo: string;
  72798. Fragment_Before_Lights: string;
  72799. Fragment_Custom_MetallicRoughness: string;
  72800. Fragment_Custom_MicroSurface: string;
  72801. Fragment_Before_Fog: string;
  72802. Fragment_Custom_Alpha: string;
  72803. Fragment_Before_FragColor: string;
  72804. Vertex_Begin: string;
  72805. Vertex_Definitions: string;
  72806. Vertex_MainBegin: string;
  72807. Vertex_Before_PositionUpdated: string;
  72808. Vertex_Before_NormalUpdated: string;
  72809. Vertex_MainEnd: string;
  72810. }
  72811. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72812. static ShaderIndexer: number;
  72813. CustomParts: ShaderAlebdoParts;
  72814. _isCreatedShader: boolean;
  72815. _createdShaderName: string;
  72816. _customUniform: string[];
  72817. _newUniforms: string[];
  72818. _newUniformInstances: any[];
  72819. _newSamplerInstances: BABYLON.Texture[];
  72820. FragmentShader: string;
  72821. VertexShader: string;
  72822. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72823. ReviewUniform(name: string, arr: string[]): string[];
  72824. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72825. constructor(name: string, scene: BABYLON.Scene);
  72826. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72827. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72828. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72829. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72830. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72831. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72832. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72833. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72834. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72835. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72836. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72837. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72838. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72839. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72840. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72841. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72842. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72843. }
  72844. }
  72845. declare module BABYLON {
  72846. /** @hidden */
  72847. export var firePixelShader: {
  72848. name: string;
  72849. shader: string;
  72850. };
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export var fireVertexShader: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module BABYLON {
  72860. export class FireMaterial extends BABYLON.PushMaterial {
  72861. private _diffuseTexture;
  72862. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72863. private _distortionTexture;
  72864. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72865. private _opacityTexture;
  72866. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72867. diffuseColor: BABYLON.Color3;
  72868. speed: number;
  72869. private _scaledDiffuse;
  72870. private _renderId;
  72871. private _lastTime;
  72872. constructor(name: string, scene: BABYLON.Scene);
  72873. needAlphaBlending(): boolean;
  72874. needAlphaTesting(): boolean;
  72875. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72876. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72877. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72878. getAnimatables(): BABYLON.IAnimatable[];
  72879. getActiveTextures(): BABYLON.BaseTexture[];
  72880. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72881. getClassName(): string;
  72882. dispose(forceDisposeEffect?: boolean): void;
  72883. clone(name: string): FireMaterial;
  72884. serialize(): any;
  72885. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72886. }
  72887. }
  72888. declare module BABYLON {
  72889. /** @hidden */
  72890. export var furPixelShader: {
  72891. name: string;
  72892. shader: string;
  72893. };
  72894. }
  72895. declare module BABYLON {
  72896. /** @hidden */
  72897. export var furVertexShader: {
  72898. name: string;
  72899. shader: string;
  72900. };
  72901. }
  72902. declare module BABYLON {
  72903. export class FurMaterial extends BABYLON.PushMaterial {
  72904. private _diffuseTexture;
  72905. diffuseTexture: BABYLON.BaseTexture;
  72906. private _heightTexture;
  72907. heightTexture: BABYLON.BaseTexture;
  72908. diffuseColor: BABYLON.Color3;
  72909. furLength: number;
  72910. furAngle: number;
  72911. furColor: BABYLON.Color3;
  72912. furOffset: number;
  72913. furSpacing: number;
  72914. furGravity: BABYLON.Vector3;
  72915. furSpeed: number;
  72916. furDensity: number;
  72917. furOcclusion: number;
  72918. furTexture: BABYLON.DynamicTexture;
  72919. private _disableLighting;
  72920. disableLighting: boolean;
  72921. private _maxSimultaneousLights;
  72922. maxSimultaneousLights: number;
  72923. highLevelFur: boolean;
  72924. _meshes: BABYLON.AbstractMesh[];
  72925. private _renderId;
  72926. private _furTime;
  72927. constructor(name: string, scene: BABYLON.Scene);
  72928. furTime: number;
  72929. needAlphaBlending(): boolean;
  72930. needAlphaTesting(): boolean;
  72931. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72932. updateFur(): void;
  72933. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72934. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72935. getAnimatables(): BABYLON.IAnimatable[];
  72936. getActiveTextures(): BABYLON.BaseTexture[];
  72937. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72938. dispose(forceDisposeEffect?: boolean): void;
  72939. clone(name: string): FurMaterial;
  72940. serialize(): any;
  72941. getClassName(): string;
  72942. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72943. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72944. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /** @hidden */
  72949. export var gradientPixelShader: {
  72950. name: string;
  72951. shader: string;
  72952. };
  72953. }
  72954. declare module BABYLON {
  72955. /** @hidden */
  72956. export var gradientVertexShader: {
  72957. name: string;
  72958. shader: string;
  72959. };
  72960. }
  72961. declare module BABYLON {
  72962. export class GradientMaterial extends BABYLON.PushMaterial {
  72963. private _maxSimultaneousLights;
  72964. maxSimultaneousLights: number;
  72965. topColor: BABYLON.Color3;
  72966. topColorAlpha: number;
  72967. bottomColor: BABYLON.Color3;
  72968. bottomColorAlpha: number;
  72969. offset: number;
  72970. scale: number;
  72971. smoothness: number;
  72972. private _disableLighting;
  72973. disableLighting: boolean;
  72974. private _renderId;
  72975. constructor(name: string, scene: BABYLON.Scene);
  72976. needAlphaBlending(): boolean;
  72977. needAlphaTesting(): boolean;
  72978. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72979. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72980. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72981. getAnimatables(): BABYLON.IAnimatable[];
  72982. dispose(forceDisposeEffect?: boolean): void;
  72983. clone(name: string): GradientMaterial;
  72984. serialize(): any;
  72985. getClassName(): string;
  72986. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72987. }
  72988. }
  72989. declare module BABYLON {
  72990. /** @hidden */
  72991. export var gridPixelShader: {
  72992. name: string;
  72993. shader: string;
  72994. };
  72995. }
  72996. declare module BABYLON {
  72997. /** @hidden */
  72998. export var gridVertexShader: {
  72999. name: string;
  73000. shader: string;
  73001. };
  73002. }
  73003. declare module BABYLON {
  73004. /**
  73005. * The grid materials allows you to wrap any shape with a grid.
  73006. * Colors are customizable.
  73007. */
  73008. export class GridMaterial extends BABYLON.PushMaterial {
  73009. /**
  73010. * Main color of the grid (e.g. between lines)
  73011. */
  73012. mainColor: BABYLON.Color3;
  73013. /**
  73014. * Color of the grid lines.
  73015. */
  73016. lineColor: BABYLON.Color3;
  73017. /**
  73018. * The scale of the grid compared to unit.
  73019. */
  73020. gridRatio: number;
  73021. /**
  73022. * Allows setting an offset for the grid lines.
  73023. */
  73024. gridOffset: BABYLON.Vector3;
  73025. /**
  73026. * The frequency of thicker lines.
  73027. */
  73028. majorUnitFrequency: number;
  73029. /**
  73030. * The visibility of minor units in the grid.
  73031. */
  73032. minorUnitVisibility: number;
  73033. /**
  73034. * The grid opacity outside of the lines.
  73035. */
  73036. opacity: number;
  73037. /**
  73038. * Determine RBG output is premultiplied by alpha value.
  73039. */
  73040. preMultiplyAlpha: boolean;
  73041. private _opacityTexture;
  73042. opacityTexture: BABYLON.BaseTexture;
  73043. private _gridControl;
  73044. private _renderId;
  73045. /**
  73046. * constructor
  73047. * @param name The name given to the material in order to identify it afterwards.
  73048. * @param scene The scene the material is used in.
  73049. */
  73050. constructor(name: string, scene: BABYLON.Scene);
  73051. /**
  73052. * Returns wehter or not the grid requires alpha blending.
  73053. */
  73054. needAlphaBlending(): boolean;
  73055. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73056. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73057. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73058. /**
  73059. * Dispose the material and its associated resources.
  73060. * @param forceDisposeEffect will also dispose the used effect when true
  73061. */
  73062. dispose(forceDisposeEffect?: boolean): void;
  73063. clone(name: string): GridMaterial;
  73064. serialize(): any;
  73065. getClassName(): string;
  73066. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  73067. }
  73068. }
  73069. declare module BABYLON {
  73070. /** @hidden */
  73071. export var lavaPixelShader: {
  73072. name: string;
  73073. shader: string;
  73074. };
  73075. }
  73076. declare module BABYLON {
  73077. /** @hidden */
  73078. export var lavaVertexShader: {
  73079. name: string;
  73080. shader: string;
  73081. };
  73082. }
  73083. declare module BABYLON {
  73084. export class LavaMaterial extends BABYLON.PushMaterial {
  73085. private _diffuseTexture;
  73086. diffuseTexture: BABYLON.BaseTexture;
  73087. noiseTexture: BABYLON.BaseTexture;
  73088. fogColor: BABYLON.Color3;
  73089. speed: number;
  73090. movingSpeed: number;
  73091. lowFrequencySpeed: number;
  73092. fogDensity: number;
  73093. private _lastTime;
  73094. diffuseColor: BABYLON.Color3;
  73095. private _disableLighting;
  73096. disableLighting: boolean;
  73097. private _unlit;
  73098. unlit: boolean;
  73099. private _maxSimultaneousLights;
  73100. maxSimultaneousLights: number;
  73101. private _scaledDiffuse;
  73102. private _renderId;
  73103. constructor(name: string, scene: BABYLON.Scene);
  73104. needAlphaBlending(): boolean;
  73105. needAlphaTesting(): boolean;
  73106. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73107. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73108. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73109. getAnimatables(): BABYLON.IAnimatable[];
  73110. getActiveTextures(): BABYLON.BaseTexture[];
  73111. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73112. dispose(forceDisposeEffect?: boolean): void;
  73113. clone(name: string): LavaMaterial;
  73114. serialize(): any;
  73115. getClassName(): string;
  73116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  73117. }
  73118. }
  73119. declare module BABYLON {
  73120. /** @hidden */
  73121. export var mixPixelShader: {
  73122. name: string;
  73123. shader: string;
  73124. };
  73125. }
  73126. declare module BABYLON {
  73127. /** @hidden */
  73128. export var mixVertexShader: {
  73129. name: string;
  73130. shader: string;
  73131. };
  73132. }
  73133. declare module BABYLON {
  73134. export class MixMaterial extends BABYLON.PushMaterial {
  73135. /**
  73136. * Mix textures
  73137. */
  73138. private _mixTexture1;
  73139. mixTexture1: BABYLON.BaseTexture;
  73140. private _mixTexture2;
  73141. mixTexture2: BABYLON.BaseTexture;
  73142. /**
  73143. * Diffuse textures
  73144. */
  73145. private _diffuseTexture1;
  73146. diffuseTexture1: BABYLON.Texture;
  73147. private _diffuseTexture2;
  73148. diffuseTexture2: BABYLON.Texture;
  73149. private _diffuseTexture3;
  73150. diffuseTexture3: BABYLON.Texture;
  73151. private _diffuseTexture4;
  73152. diffuseTexture4: BABYLON.Texture;
  73153. private _diffuseTexture5;
  73154. diffuseTexture5: BABYLON.Texture;
  73155. private _diffuseTexture6;
  73156. diffuseTexture6: BABYLON.Texture;
  73157. private _diffuseTexture7;
  73158. diffuseTexture7: BABYLON.Texture;
  73159. private _diffuseTexture8;
  73160. diffuseTexture8: BABYLON.Texture;
  73161. /**
  73162. * Uniforms
  73163. */
  73164. diffuseColor: BABYLON.Color3;
  73165. specularColor: BABYLON.Color3;
  73166. specularPower: number;
  73167. private _disableLighting;
  73168. disableLighting: boolean;
  73169. private _maxSimultaneousLights;
  73170. maxSimultaneousLights: number;
  73171. private _renderId;
  73172. constructor(name: string, scene: BABYLON.Scene);
  73173. needAlphaBlending(): boolean;
  73174. needAlphaTesting(): boolean;
  73175. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73176. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73177. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73178. getAnimatables(): BABYLON.IAnimatable[];
  73179. getActiveTextures(): BABYLON.BaseTexture[];
  73180. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73181. dispose(forceDisposeEffect?: boolean): void;
  73182. clone(name: string): MixMaterial;
  73183. serialize(): any;
  73184. getClassName(): string;
  73185. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  73186. }
  73187. }
  73188. declare module BABYLON {
  73189. /** @hidden */
  73190. export var normalPixelShader: {
  73191. name: string;
  73192. shader: string;
  73193. };
  73194. }
  73195. declare module BABYLON {
  73196. /** @hidden */
  73197. export var normalVertexShader: {
  73198. name: string;
  73199. shader: string;
  73200. };
  73201. }
  73202. declare module BABYLON {
  73203. export class NormalMaterial extends BABYLON.PushMaterial {
  73204. private _diffuseTexture;
  73205. diffuseTexture: BABYLON.BaseTexture;
  73206. diffuseColor: BABYLON.Color3;
  73207. private _disableLighting;
  73208. disableLighting: boolean;
  73209. private _maxSimultaneousLights;
  73210. maxSimultaneousLights: number;
  73211. private _renderId;
  73212. constructor(name: string, scene: BABYLON.Scene);
  73213. needAlphaBlending(): boolean;
  73214. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73215. needAlphaTesting(): boolean;
  73216. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73218. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73219. getAnimatables(): BABYLON.IAnimatable[];
  73220. getActiveTextures(): BABYLON.BaseTexture[];
  73221. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73222. dispose(forceDisposeEffect?: boolean): void;
  73223. clone(name: string): NormalMaterial;
  73224. serialize(): any;
  73225. getClassName(): string;
  73226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /** @hidden */
  73231. export var shadowOnlyPixelShader: {
  73232. name: string;
  73233. shader: string;
  73234. };
  73235. }
  73236. declare module BABYLON {
  73237. /** @hidden */
  73238. export var shadowOnlyVertexShader: {
  73239. name: string;
  73240. shader: string;
  73241. };
  73242. }
  73243. declare module BABYLON {
  73244. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  73245. private _renderId;
  73246. private _activeLight;
  73247. constructor(name: string, scene: BABYLON.Scene);
  73248. shadowColor: BABYLON.Color3;
  73249. needAlphaBlending(): boolean;
  73250. needAlphaTesting(): boolean;
  73251. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73252. activeLight: BABYLON.IShadowLight;
  73253. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73254. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73255. clone(name: string): ShadowOnlyMaterial;
  73256. serialize(): any;
  73257. getClassName(): string;
  73258. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  73259. }
  73260. }
  73261. declare module BABYLON {
  73262. /** @hidden */
  73263. export var simplePixelShader: {
  73264. name: string;
  73265. shader: string;
  73266. };
  73267. }
  73268. declare module BABYLON {
  73269. /** @hidden */
  73270. export var simpleVertexShader: {
  73271. name: string;
  73272. shader: string;
  73273. };
  73274. }
  73275. declare module BABYLON {
  73276. export class SimpleMaterial extends BABYLON.PushMaterial {
  73277. private _diffuseTexture;
  73278. diffuseTexture: BABYLON.BaseTexture;
  73279. diffuseColor: BABYLON.Color3;
  73280. private _disableLighting;
  73281. disableLighting: boolean;
  73282. private _maxSimultaneousLights;
  73283. maxSimultaneousLights: number;
  73284. private _renderId;
  73285. constructor(name: string, scene: BABYLON.Scene);
  73286. needAlphaBlending(): boolean;
  73287. needAlphaTesting(): boolean;
  73288. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73289. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73291. getAnimatables(): BABYLON.IAnimatable[];
  73292. getActiveTextures(): BABYLON.BaseTexture[];
  73293. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73294. dispose(forceDisposeEffect?: boolean): void;
  73295. clone(name: string): SimpleMaterial;
  73296. serialize(): any;
  73297. getClassName(): string;
  73298. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  73299. }
  73300. }
  73301. declare module BABYLON {
  73302. /** @hidden */
  73303. export var skyPixelShader: {
  73304. name: string;
  73305. shader: string;
  73306. };
  73307. }
  73308. declare module BABYLON {
  73309. /** @hidden */
  73310. export var skyVertexShader: {
  73311. name: string;
  73312. shader: string;
  73313. };
  73314. }
  73315. declare module BABYLON {
  73316. /**
  73317. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  73318. * @see https://doc.babylonjs.com/extensions/sky
  73319. */
  73320. export class SkyMaterial extends BABYLON.PushMaterial {
  73321. /**
  73322. * Defines the overall luminance of sky in interval ]0, 1[.
  73323. */
  73324. luminance: number;
  73325. /**
  73326. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  73327. */
  73328. turbidity: number;
  73329. /**
  73330. * Defines the sky appearance (light intensity).
  73331. */
  73332. rayleigh: number;
  73333. /**
  73334. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  73335. */
  73336. mieCoefficient: number;
  73337. /**
  73338. * Defines the amount of haze particles following the Mie scattering theory.
  73339. */
  73340. mieDirectionalG: number;
  73341. /**
  73342. * Defines the distance of the sun according to the active scene camera.
  73343. */
  73344. distance: number;
  73345. /**
  73346. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  73347. * "inclined".
  73348. */
  73349. inclination: number;
  73350. /**
  73351. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  73352. * an object direction and a reference direction.
  73353. */
  73354. azimuth: number;
  73355. /**
  73356. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  73357. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  73358. */
  73359. sunPosition: BABYLON.Vector3;
  73360. /**
  73361. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  73362. * .sunPosition property.
  73363. */
  73364. useSunPosition: boolean;
  73365. /**
  73366. * Defines an offset vector used to get a horizon offset.
  73367. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  73368. */
  73369. cameraOffset: BABYLON.Vector3;
  73370. private _cameraPosition;
  73371. private _renderId;
  73372. /**
  73373. * Instantiates a new sky material.
  73374. * This material allows to create dynamic and texture free
  73375. * effects for skyboxes by taking care of the atmosphere state.
  73376. * @see https://doc.babylonjs.com/extensions/sky
  73377. * @param name Define the name of the material in the scene
  73378. * @param scene Define the scene the material belong to
  73379. */
  73380. constructor(name: string, scene: BABYLON.Scene);
  73381. /**
  73382. * Specifies if the material will require alpha blending
  73383. * @returns a boolean specifying if alpha blending is needed
  73384. */
  73385. needAlphaBlending(): boolean;
  73386. /**
  73387. * Specifies if this material should be rendered in alpha test mode
  73388. * @returns false as the sky material doesn't need alpha testing.
  73389. */
  73390. needAlphaTesting(): boolean;
  73391. /**
  73392. * Get the texture used for alpha test purpose.
  73393. * @returns null as the sky material has no texture.
  73394. */
  73395. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73396. /**
  73397. * Get if the submesh is ready to be used and all its information available.
  73398. * Child classes can use it to update shaders
  73399. * @param mesh defines the mesh to check
  73400. * @param subMesh defines which submesh to check
  73401. * @param useInstances specifies that instances should be used
  73402. * @returns a boolean indicating that the submesh is ready or not
  73403. */
  73404. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73405. /**
  73406. * Binds the submesh to this material by preparing the effect and shader to draw
  73407. * @param world defines the world transformation matrix
  73408. * @param mesh defines the mesh containing the submesh
  73409. * @param subMesh defines the submesh to bind the material to
  73410. */
  73411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73412. /**
  73413. * Get the list of animatables in the material.
  73414. * @returns the list of animatables object used in the material
  73415. */
  73416. getAnimatables(): BABYLON.IAnimatable[];
  73417. /**
  73418. * Disposes the material
  73419. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73420. */
  73421. dispose(forceDisposeEffect?: boolean): void;
  73422. /**
  73423. * Makes a duplicate of the material, and gives it a new name
  73424. * @param name defines the new name for the duplicated material
  73425. * @returns the cloned material
  73426. */
  73427. clone(name: string): SkyMaterial;
  73428. /**
  73429. * Serializes this material in a JSON representation
  73430. * @returns the serialized material object
  73431. */
  73432. serialize(): any;
  73433. /**
  73434. * Gets the current class name of the material e.g. "SkyMaterial"
  73435. * Mainly use in serialization.
  73436. * @returns the class name
  73437. */
  73438. getClassName(): string;
  73439. /**
  73440. * Creates a sky material from parsed material data
  73441. * @param source defines the JSON representation of the material
  73442. * @param scene defines the hosting scene
  73443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73444. * @returns a new sky material
  73445. */
  73446. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73447. }
  73448. }
  73449. declare module BABYLON {
  73450. /** @hidden */
  73451. export var terrainPixelShader: {
  73452. name: string;
  73453. shader: string;
  73454. };
  73455. }
  73456. declare module BABYLON {
  73457. /** @hidden */
  73458. export var terrainVertexShader: {
  73459. name: string;
  73460. shader: string;
  73461. };
  73462. }
  73463. declare module BABYLON {
  73464. export class TerrainMaterial extends BABYLON.PushMaterial {
  73465. private _mixTexture;
  73466. mixTexture: BABYLON.BaseTexture;
  73467. private _diffuseTexture1;
  73468. diffuseTexture1: BABYLON.Texture;
  73469. private _diffuseTexture2;
  73470. diffuseTexture2: BABYLON.Texture;
  73471. private _diffuseTexture3;
  73472. diffuseTexture3: BABYLON.Texture;
  73473. private _bumpTexture1;
  73474. bumpTexture1: BABYLON.Texture;
  73475. private _bumpTexture2;
  73476. bumpTexture2: BABYLON.Texture;
  73477. private _bumpTexture3;
  73478. bumpTexture3: BABYLON.Texture;
  73479. diffuseColor: BABYLON.Color3;
  73480. specularColor: BABYLON.Color3;
  73481. specularPower: number;
  73482. private _disableLighting;
  73483. disableLighting: boolean;
  73484. private _maxSimultaneousLights;
  73485. maxSimultaneousLights: number;
  73486. private _renderId;
  73487. constructor(name: string, scene: BABYLON.Scene);
  73488. needAlphaBlending(): boolean;
  73489. needAlphaTesting(): boolean;
  73490. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73492. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73493. getAnimatables(): BABYLON.IAnimatable[];
  73494. getActiveTextures(): BABYLON.BaseTexture[];
  73495. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73496. dispose(forceDisposeEffect?: boolean): void;
  73497. clone(name: string): TerrainMaterial;
  73498. serialize(): any;
  73499. getClassName(): string;
  73500. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73501. }
  73502. }
  73503. declare module BABYLON {
  73504. /** @hidden */
  73505. export var triplanarPixelShader: {
  73506. name: string;
  73507. shader: string;
  73508. };
  73509. }
  73510. declare module BABYLON {
  73511. /** @hidden */
  73512. export var triplanarVertexShader: {
  73513. name: string;
  73514. shader: string;
  73515. };
  73516. }
  73517. declare module BABYLON {
  73518. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73519. mixTexture: BABYLON.BaseTexture;
  73520. private _diffuseTextureX;
  73521. diffuseTextureX: BABYLON.BaseTexture;
  73522. private _diffuseTextureY;
  73523. diffuseTextureY: BABYLON.BaseTexture;
  73524. private _diffuseTextureZ;
  73525. diffuseTextureZ: BABYLON.BaseTexture;
  73526. private _normalTextureX;
  73527. normalTextureX: BABYLON.BaseTexture;
  73528. private _normalTextureY;
  73529. normalTextureY: BABYLON.BaseTexture;
  73530. private _normalTextureZ;
  73531. normalTextureZ: BABYLON.BaseTexture;
  73532. tileSize: number;
  73533. diffuseColor: BABYLON.Color3;
  73534. specularColor: BABYLON.Color3;
  73535. specularPower: number;
  73536. private _disableLighting;
  73537. disableLighting: boolean;
  73538. private _maxSimultaneousLights;
  73539. maxSimultaneousLights: number;
  73540. private _renderId;
  73541. constructor(name: string, scene: BABYLON.Scene);
  73542. needAlphaBlending(): boolean;
  73543. needAlphaTesting(): boolean;
  73544. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73545. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73546. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73547. getAnimatables(): BABYLON.IAnimatable[];
  73548. getActiveTextures(): BABYLON.BaseTexture[];
  73549. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73550. dispose(forceDisposeEffect?: boolean): void;
  73551. clone(name: string): TriPlanarMaterial;
  73552. serialize(): any;
  73553. getClassName(): string;
  73554. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73555. }
  73556. }
  73557. declare module BABYLON {
  73558. /** @hidden */
  73559. export var waterPixelShader: {
  73560. name: string;
  73561. shader: string;
  73562. };
  73563. }
  73564. declare module BABYLON {
  73565. /** @hidden */
  73566. export var waterVertexShader: {
  73567. name: string;
  73568. shader: string;
  73569. };
  73570. }
  73571. declare module BABYLON {
  73572. export class WaterMaterial extends BABYLON.PushMaterial {
  73573. renderTargetSize: BABYLON.Vector2;
  73574. private _bumpTexture;
  73575. bumpTexture: BABYLON.BaseTexture;
  73576. diffuseColor: BABYLON.Color3;
  73577. specularColor: BABYLON.Color3;
  73578. specularPower: number;
  73579. private _disableLighting;
  73580. disableLighting: boolean;
  73581. private _maxSimultaneousLights;
  73582. maxSimultaneousLights: number;
  73583. /**
  73584. * @param {number}: Represents the wind force
  73585. */
  73586. windForce: number;
  73587. /**
  73588. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73589. */
  73590. windDirection: BABYLON.Vector2;
  73591. /**
  73592. * @param {number}: Wave height, represents the height of the waves
  73593. */
  73594. waveHeight: number;
  73595. /**
  73596. * @param {number}: Bump height, represents the bump height related to the bump map
  73597. */
  73598. bumpHeight: number;
  73599. /**
  73600. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73601. */
  73602. private _bumpSuperimpose;
  73603. bumpSuperimpose: boolean;
  73604. /**
  73605. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73606. */
  73607. private _fresnelSeparate;
  73608. fresnelSeparate: boolean;
  73609. /**
  73610. * @param {boolean}: bump Waves modify the reflection.
  73611. */
  73612. private _bumpAffectsReflection;
  73613. bumpAffectsReflection: boolean;
  73614. /**
  73615. * @param {number}: The water color blended with the refraction (near)
  73616. */
  73617. waterColor: BABYLON.Color3;
  73618. /**
  73619. * @param {number}: The blend factor related to the water color
  73620. */
  73621. colorBlendFactor: number;
  73622. /**
  73623. * @param {number}: The water color blended with the reflection (far)
  73624. */
  73625. waterColor2: BABYLON.Color3;
  73626. /**
  73627. * @param {number}: The blend factor related to the water color (reflection, far)
  73628. */
  73629. colorBlendFactor2: number;
  73630. /**
  73631. * @param {number}: Represents the maximum length of a wave
  73632. */
  73633. waveLength: number;
  73634. /**
  73635. * @param {number}: Defines the waves speed
  73636. */
  73637. waveSpeed: number;
  73638. /**
  73639. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73640. * will avoid calculating useless pixels in the pixel shader of the water material.
  73641. */
  73642. disableClipPlane: boolean;
  73643. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73644. private _mesh;
  73645. private _refractionRTT;
  73646. private _reflectionRTT;
  73647. private _reflectionTransform;
  73648. private _lastTime;
  73649. private _lastDeltaTime;
  73650. private _renderId;
  73651. private _useLogarithmicDepth;
  73652. private _waitingRenderList;
  73653. private _imageProcessingConfiguration;
  73654. private _imageProcessingObserver;
  73655. /**
  73656. * Gets a boolean indicating that current material needs to register RTT
  73657. */
  73658. readonly hasRenderTargetTextures: boolean;
  73659. /**
  73660. * Constructor
  73661. */
  73662. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73663. useLogarithmicDepth: boolean;
  73664. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73665. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73666. addToRenderList(node: any): void;
  73667. enableRenderTargets(enable: boolean): void;
  73668. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73669. readonly renderTargetsEnabled: boolean;
  73670. needAlphaBlending(): boolean;
  73671. needAlphaTesting(): boolean;
  73672. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73675. private _createRenderTargets;
  73676. getAnimatables(): BABYLON.IAnimatable[];
  73677. getActiveTextures(): BABYLON.BaseTexture[];
  73678. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73679. dispose(forceDisposeEffect?: boolean): void;
  73680. clone(name: string): WaterMaterial;
  73681. serialize(): any;
  73682. getClassName(): string;
  73683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73684. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73685. }
  73686. }
  73687. declare module BABYLON {
  73688. /** @hidden */
  73689. export var asciiartPixelShader: {
  73690. name: string;
  73691. shader: string;
  73692. };
  73693. }
  73694. declare module BABYLON {
  73695. /**
  73696. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73697. *
  73698. * It basically takes care rendering the font front the given font size to a texture.
  73699. * This is used later on in the postprocess.
  73700. */
  73701. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73702. private _font;
  73703. private _text;
  73704. private _charSize;
  73705. /**
  73706. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73707. */
  73708. readonly charSize: number;
  73709. /**
  73710. * Create a new instance of the Ascii Art FontTexture class
  73711. * @param name the name of the texture
  73712. * @param font the font to use, use the W3C CSS notation
  73713. * @param text the caracter set to use in the rendering.
  73714. * @param scene the scene that owns the texture
  73715. */
  73716. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73717. /**
  73718. * Gets the max char width of a font.
  73719. * @param font the font to use, use the W3C CSS notation
  73720. * @return the max char width
  73721. */
  73722. private getFontWidth;
  73723. /**
  73724. * Gets the max char height of a font.
  73725. * @param font the font to use, use the W3C CSS notation
  73726. * @return the max char height
  73727. */
  73728. private getFontHeight;
  73729. /**
  73730. * Clones the current AsciiArtTexture.
  73731. * @return the clone of the texture.
  73732. */
  73733. clone(): AsciiArtFontTexture;
  73734. /**
  73735. * Parses a json object representing the texture and returns an instance of it.
  73736. * @param source the source JSON representation
  73737. * @param scene the scene to create the texture for
  73738. * @return the parsed texture
  73739. */
  73740. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73741. }
  73742. /**
  73743. * Option available in the Ascii Art Post Process.
  73744. */
  73745. export interface IAsciiArtPostProcessOptions {
  73746. /**
  73747. * The font to use following the w3c font definition.
  73748. */
  73749. font?: string;
  73750. /**
  73751. * The character set to use in the postprocess.
  73752. */
  73753. characterSet?: string;
  73754. /**
  73755. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73756. * This number is defined between 0 and 1;
  73757. */
  73758. mixToTile?: number;
  73759. /**
  73760. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73761. * This number is defined between 0 and 1;
  73762. */
  73763. mixToNormal?: number;
  73764. }
  73765. /**
  73766. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73767. *
  73768. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73769. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73770. */
  73771. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73772. /**
  73773. * The font texture used to render the char in the post process.
  73774. */
  73775. private _asciiArtFontTexture;
  73776. /**
  73777. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73778. * This number is defined between 0 and 1;
  73779. */
  73780. mixToTile: number;
  73781. /**
  73782. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73783. * This number is defined between 0 and 1;
  73784. */
  73785. mixToNormal: number;
  73786. /**
  73787. * Instantiates a new Ascii Art Post Process.
  73788. * @param name the name to give to the postprocess
  73789. * @camera the camera to apply the post process to.
  73790. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73791. */
  73792. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73793. }
  73794. }
  73795. declare module BABYLON {
  73796. /** @hidden */
  73797. export var digitalrainPixelShader: {
  73798. name: string;
  73799. shader: string;
  73800. };
  73801. }
  73802. declare module BABYLON {
  73803. /**
  73804. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73805. *
  73806. * It basically takes care rendering the font front the given font size to a texture.
  73807. * This is used later on in the postprocess.
  73808. */
  73809. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73810. private _font;
  73811. private _text;
  73812. private _charSize;
  73813. /**
  73814. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73815. */
  73816. readonly charSize: number;
  73817. /**
  73818. * Create a new instance of the Digital Rain FontTexture class
  73819. * @param name the name of the texture
  73820. * @param font the font to use, use the W3C CSS notation
  73821. * @param text the caracter set to use in the rendering.
  73822. * @param scene the scene that owns the texture
  73823. */
  73824. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73825. /**
  73826. * Gets the max char width of a font.
  73827. * @param font the font to use, use the W3C CSS notation
  73828. * @return the max char width
  73829. */
  73830. private getFontWidth;
  73831. /**
  73832. * Gets the max char height of a font.
  73833. * @param font the font to use, use the W3C CSS notation
  73834. * @return the max char height
  73835. */
  73836. private getFontHeight;
  73837. /**
  73838. * Clones the current DigitalRainFontTexture.
  73839. * @return the clone of the texture.
  73840. */
  73841. clone(): DigitalRainFontTexture;
  73842. /**
  73843. * Parses a json object representing the texture and returns an instance of it.
  73844. * @param source the source JSON representation
  73845. * @param scene the scene to create the texture for
  73846. * @return the parsed texture
  73847. */
  73848. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73849. }
  73850. /**
  73851. * Option available in the Digital Rain Post Process.
  73852. */
  73853. export interface IDigitalRainPostProcessOptions {
  73854. /**
  73855. * The font to use following the w3c font definition.
  73856. */
  73857. font?: string;
  73858. /**
  73859. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73860. * This number is defined between 0 and 1;
  73861. */
  73862. mixToTile?: number;
  73863. /**
  73864. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73865. * This number is defined between 0 and 1;
  73866. */
  73867. mixToNormal?: number;
  73868. }
  73869. /**
  73870. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73871. *
  73872. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73873. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73874. */
  73875. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73876. /**
  73877. * The font texture used to render the char in the post process.
  73878. */
  73879. private _digitalRainFontTexture;
  73880. /**
  73881. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73882. * This number is defined between 0 and 1;
  73883. */
  73884. mixToTile: number;
  73885. /**
  73886. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73887. * This number is defined between 0 and 1;
  73888. */
  73889. mixToNormal: number;
  73890. /**
  73891. * Instantiates a new Digital Rain Post Process.
  73892. * @param name the name to give to the postprocess
  73893. * @camera the camera to apply the post process to.
  73894. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73895. */
  73896. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73897. }
  73898. }
  73899. declare module BABYLON {
  73900. /** @hidden */
  73901. export var oceanPostProcessPixelShader: {
  73902. name: string;
  73903. shader: string;
  73904. };
  73905. }
  73906. declare module BABYLON {
  73907. /**
  73908. * Option available in the Ocean Post Process.
  73909. */
  73910. export interface IOceanPostProcessOptions {
  73911. /**
  73912. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73913. */
  73914. reflectionSize?: number | {
  73915. width: number;
  73916. height: number;
  73917. } | {
  73918. ratio: number;
  73919. };
  73920. /**
  73921. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73922. */
  73923. refractionSize?: number | {
  73924. width: number;
  73925. height: number;
  73926. } | {
  73927. ratio: number;
  73928. };
  73929. }
  73930. /**
  73931. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73932. *
  73933. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73934. * Example usage:
  73935. * var pp = new OceanPostProcess("myOcean", camera);
  73936. * pp.reflectionEnabled = true;
  73937. * pp.refractionEnabled = true;
  73938. */
  73939. export class OceanPostProcess extends BABYLON.PostProcess {
  73940. /**
  73941. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73942. */
  73943. /**
  73944. * Sets weither or not the real-time reflection is enabled on the ocean.
  73945. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73946. */
  73947. reflectionEnabled: boolean;
  73948. /**
  73949. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73950. */
  73951. /**
  73952. * Sets weither or not the real-time refraction is enabled on the ocean.
  73953. * Is set to true, the refraction render target texture will be used as refraction texture.
  73954. */
  73955. refractionEnabled: boolean;
  73956. /**
  73957. * Gets wether or not the post-processes is supported by the running hardware.
  73958. * This requires draw buffer supports.
  73959. */
  73960. readonly isSupported: boolean;
  73961. /**
  73962. * This is the reflection mirror texture used to display reflections on the ocean.
  73963. * By default, render list is empty.
  73964. */
  73965. reflectionTexture: BABYLON.MirrorTexture;
  73966. /**
  73967. * This is the refraction render target texture used to display refraction on the ocean.
  73968. * By default, render list is empty.
  73969. */
  73970. refractionTexture: BABYLON.RenderTargetTexture;
  73971. private _time;
  73972. private _cameraRotation;
  73973. private _cameraViewMatrix;
  73974. private _reflectionEnabled;
  73975. private _refractionEnabled;
  73976. private _geometryRenderer;
  73977. /**
  73978. * Instantiates a new Ocean Post Process.
  73979. * @param name the name to give to the postprocess.
  73980. * @camera the camera to apply the post process to.
  73981. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73982. */
  73983. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73984. /**
  73985. * Returns the appropriate defines according to the current configuration.
  73986. */
  73987. private _getDefines;
  73988. /**
  73989. * Computes the current camera rotation as the shader requires a camera rotation.
  73990. */
  73991. private _computeCameraRotation;
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /** @hidden */
  73996. export var brickProceduralTexturePixelShader: {
  73997. name: string;
  73998. shader: string;
  73999. };
  74000. }
  74001. declare module BABYLON {
  74002. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  74003. private _numberOfBricksHeight;
  74004. private _numberOfBricksWidth;
  74005. private _jointColor;
  74006. private _brickColor;
  74007. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74008. updateShaderUniforms(): void;
  74009. numberOfBricksHeight: number;
  74010. numberOfBricksWidth: number;
  74011. jointColor: BABYLON.Color3;
  74012. brickColor: BABYLON.Color3;
  74013. /**
  74014. * Serializes this brick procedural texture
  74015. * @returns a serialized brick procedural texture object
  74016. */
  74017. serialize(): any;
  74018. /**
  74019. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  74020. * @param parsedTexture defines parsed texture data
  74021. * @param scene defines the current scene
  74022. * @param rootUrl defines the root URL containing brick procedural texture information
  74023. * @returns a parsed Brick Procedural BABYLON.Texture
  74024. */
  74025. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  74026. }
  74027. }
  74028. declare module BABYLON {
  74029. /** @hidden */
  74030. export var cloudProceduralTexturePixelShader: {
  74031. name: string;
  74032. shader: string;
  74033. };
  74034. }
  74035. declare module BABYLON {
  74036. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  74037. private _skyColor;
  74038. private _cloudColor;
  74039. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74040. updateShaderUniforms(): void;
  74041. skyColor: BABYLON.Color4;
  74042. cloudColor: BABYLON.Color4;
  74043. /**
  74044. * Serializes this cloud procedural texture
  74045. * @returns a serialized cloud procedural texture object
  74046. */
  74047. serialize(): any;
  74048. /**
  74049. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  74050. * @param parsedTexture defines parsed texture data
  74051. * @param scene defines the current scene
  74052. * @param rootUrl defines the root URL containing cloud procedural texture information
  74053. * @returns a parsed Cloud Procedural BABYLON.Texture
  74054. */
  74055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  74056. }
  74057. }
  74058. declare module BABYLON {
  74059. /** @hidden */
  74060. export var fireProceduralTexturePixelShader: {
  74061. name: string;
  74062. shader: string;
  74063. };
  74064. }
  74065. declare module BABYLON {
  74066. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  74067. private _time;
  74068. private _speed;
  74069. private _autoGenerateTime;
  74070. private _fireColors;
  74071. private _alphaThreshold;
  74072. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74073. updateShaderUniforms(): void;
  74074. render(useCameraPostProcess?: boolean): void;
  74075. static readonly PurpleFireColors: BABYLON.Color3[];
  74076. static readonly GreenFireColors: BABYLON.Color3[];
  74077. static readonly RedFireColors: BABYLON.Color3[];
  74078. static readonly BlueFireColors: BABYLON.Color3[];
  74079. autoGenerateTime: boolean;
  74080. fireColors: BABYLON.Color3[];
  74081. time: number;
  74082. speed: BABYLON.Vector2;
  74083. alphaThreshold: number;
  74084. /**
  74085. * Serializes this fire procedural texture
  74086. * @returns a serialized fire procedural texture object
  74087. */
  74088. serialize(): any;
  74089. /**
  74090. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  74091. * @param parsedTexture defines parsed texture data
  74092. * @param scene defines the current scene
  74093. * @param rootUrl defines the root URL containing fire procedural texture information
  74094. * @returns a parsed Fire Procedural BABYLON.Texture
  74095. */
  74096. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  74097. }
  74098. }
  74099. declare module BABYLON {
  74100. /** @hidden */
  74101. export var grassProceduralTexturePixelShader: {
  74102. name: string;
  74103. shader: string;
  74104. };
  74105. }
  74106. declare module BABYLON {
  74107. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  74108. private _grassColors;
  74109. private _groundColor;
  74110. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74111. updateShaderUniforms(): void;
  74112. grassColors: BABYLON.Color3[];
  74113. groundColor: BABYLON.Color3;
  74114. /**
  74115. * Serializes this grass procedural texture
  74116. * @returns a serialized grass procedural texture object
  74117. */
  74118. serialize(): any;
  74119. /**
  74120. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  74121. * @param parsedTexture defines parsed texture data
  74122. * @param scene defines the current scene
  74123. * @param rootUrl defines the root URL containing grass procedural texture information
  74124. * @returns a parsed Grass Procedural BABYLON.Texture
  74125. */
  74126. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  74127. }
  74128. }
  74129. declare module BABYLON {
  74130. /** @hidden */
  74131. export var marbleProceduralTexturePixelShader: {
  74132. name: string;
  74133. shader: string;
  74134. };
  74135. }
  74136. declare module BABYLON {
  74137. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  74138. private _numberOfTilesHeight;
  74139. private _numberOfTilesWidth;
  74140. private _amplitude;
  74141. private _jointColor;
  74142. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74143. updateShaderUniforms(): void;
  74144. numberOfTilesHeight: number;
  74145. amplitude: number;
  74146. numberOfTilesWidth: number;
  74147. jointColor: BABYLON.Color3;
  74148. /**
  74149. * Serializes this marble procedural texture
  74150. * @returns a serialized marble procedural texture object
  74151. */
  74152. serialize(): any;
  74153. /**
  74154. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  74155. * @param parsedTexture defines parsed texture data
  74156. * @param scene defines the current scene
  74157. * @param rootUrl defines the root URL containing marble procedural texture information
  74158. * @returns a parsed Marble Procedural BABYLON.Texture
  74159. */
  74160. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  74161. }
  74162. }
  74163. declare module BABYLON {
  74164. /** @hidden */
  74165. export var normalMapProceduralTexturePixelShader: {
  74166. name: string;
  74167. shader: string;
  74168. };
  74169. }
  74170. declare module BABYLON {
  74171. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  74172. private _baseTexture;
  74173. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74174. updateShaderUniforms(): void;
  74175. render(useCameraPostProcess?: boolean): void;
  74176. resize(size: any, generateMipMaps: any): void;
  74177. baseTexture: BABYLON.Texture;
  74178. /**
  74179. * Serializes this normal map procedural texture
  74180. * @returns a serialized normal map procedural texture object
  74181. */
  74182. serialize(): any;
  74183. /**
  74184. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  74185. * @param parsedTexture defines parsed texture data
  74186. * @param scene defines the current scene
  74187. * @param rootUrl defines the root URL containing normal map procedural texture information
  74188. * @returns a parsed Normal Map Procedural BABYLON.Texture
  74189. */
  74190. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  74191. }
  74192. }
  74193. declare module BABYLON {
  74194. /** @hidden */
  74195. export var perlinNoiseProceduralTexturePixelShader: {
  74196. name: string;
  74197. shader: string;
  74198. };
  74199. }
  74200. declare module BABYLON {
  74201. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  74202. time: number;
  74203. timeScale: number;
  74204. translationSpeed: number;
  74205. private _currentTranslation;
  74206. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74207. updateShaderUniforms(): void;
  74208. render(useCameraPostProcess?: boolean): void;
  74209. resize(size: any, generateMipMaps: any): void;
  74210. /**
  74211. * Serializes this perlin noise procedural texture
  74212. * @returns a serialized perlin noise procedural texture object
  74213. */
  74214. serialize(): any;
  74215. /**
  74216. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  74217. * @param parsedTexture defines parsed texture data
  74218. * @param scene defines the current scene
  74219. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  74220. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  74221. */
  74222. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /** @hidden */
  74227. export var roadProceduralTexturePixelShader: {
  74228. name: string;
  74229. shader: string;
  74230. };
  74231. }
  74232. declare module BABYLON {
  74233. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  74234. private _roadColor;
  74235. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74236. updateShaderUniforms(): void;
  74237. roadColor: BABYLON.Color3;
  74238. /**
  74239. * Serializes this road procedural texture
  74240. * @returns a serialized road procedural texture object
  74241. */
  74242. serialize(): any;
  74243. /**
  74244. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  74245. * @param parsedTexture defines parsed texture data
  74246. * @param scene defines the current scene
  74247. * @param rootUrl defines the root URL containing road procedural texture information
  74248. * @returns a parsed Road Procedural BABYLON.Texture
  74249. */
  74250. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  74251. }
  74252. }
  74253. declare module BABYLON {
  74254. /** @hidden */
  74255. export var starfieldProceduralTexturePixelShader: {
  74256. name: string;
  74257. shader: string;
  74258. };
  74259. }
  74260. declare module BABYLON {
  74261. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  74262. private _time;
  74263. private _alpha;
  74264. private _beta;
  74265. private _zoom;
  74266. private _formuparam;
  74267. private _stepsize;
  74268. private _tile;
  74269. private _brightness;
  74270. private _darkmatter;
  74271. private _distfading;
  74272. private _saturation;
  74273. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74274. updateShaderUniforms(): void;
  74275. time: number;
  74276. alpha: number;
  74277. beta: number;
  74278. formuparam: number;
  74279. stepsize: number;
  74280. zoom: number;
  74281. tile: number;
  74282. brightness: number;
  74283. darkmatter: number;
  74284. distfading: number;
  74285. saturation: number;
  74286. /**
  74287. * Serializes this starfield procedural texture
  74288. * @returns a serialized starfield procedural texture object
  74289. */
  74290. serialize(): any;
  74291. /**
  74292. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  74293. * @param parsedTexture defines parsed texture data
  74294. * @param scene defines the current scene
  74295. * @param rootUrl defines the root URL containing startfield procedural texture information
  74296. * @returns a parsed Starfield Procedural BABYLON.Texture
  74297. */
  74298. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /** @hidden */
  74303. export var woodProceduralTexturePixelShader: {
  74304. name: string;
  74305. shader: string;
  74306. };
  74307. }
  74308. declare module BABYLON {
  74309. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  74310. private _ampScale;
  74311. private _woodColor;
  74312. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74313. updateShaderUniforms(): void;
  74314. ampScale: number;
  74315. woodColor: BABYLON.Color3;
  74316. /**
  74317. * Serializes this wood procedural texture
  74318. * @returns a serialized wood procedural texture object
  74319. */
  74320. serialize(): any;
  74321. /**
  74322. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  74323. * @param parsedTexture defines parsed texture data
  74324. * @param scene defines the current scene
  74325. * @param rootUrl defines the root URL containing wood procedural texture information
  74326. * @returns a parsed Wood Procedural BABYLON.Texture
  74327. */
  74328. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  74329. }
  74330. }