documentation.d.ts 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575
  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 _matrixArrays;
  19133. private _matrices3x3;
  19134. private _matrices2x2;
  19135. private _vectors2Arrays;
  19136. private _vectors3Arrays;
  19137. private _vectors4Arrays;
  19138. private _cachedWorldViewMatrix;
  19139. private _cachedWorldViewProjectionMatrix;
  19140. private _renderId;
  19141. /**
  19142. * Instantiate a new shader material.
  19143. * 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.
  19144. * This returned material effects how the mesh will look based on the code in the shaders.
  19145. * @see http://doc.babylonjs.com/how_to/shader_material
  19146. * @param name Define the name of the material in the scene
  19147. * @param scene Define the scene the material belongs to
  19148. * @param shaderPath Defines the route to the shader code in one of three ways:
  19149. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19150. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19151. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19152. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19153. * @param options Define the options used to create the shader
  19154. */
  19155. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19156. /**
  19157. * Gets the shader path used to define the shader code
  19158. * It can be modified to trigger a new compilation
  19159. */
  19160. /**
  19161. * Sets the shader path used to define the shader code
  19162. * It can be modified to trigger a new compilation
  19163. */
  19164. shaderPath: any;
  19165. /**
  19166. * Gets the options used to compile the shader.
  19167. * They can be modified to trigger a new compilation
  19168. */
  19169. readonly options: IShaderMaterialOptions;
  19170. /**
  19171. * Gets the current class name of the material e.g. "ShaderMaterial"
  19172. * Mainly use in serialization.
  19173. * @returns the class name
  19174. */
  19175. getClassName(): string;
  19176. /**
  19177. * Specifies if the material will require alpha blending
  19178. * @returns a boolean specifying if alpha blending is needed
  19179. */
  19180. needAlphaBlending(): boolean;
  19181. /**
  19182. * Specifies if this material should be rendered in alpha test mode
  19183. * @returns a boolean specifying if an alpha test is needed.
  19184. */
  19185. needAlphaTesting(): boolean;
  19186. private _checkUniform;
  19187. /**
  19188. * Set a texture in the shader.
  19189. * @param name Define the name of the uniform samplers as defined in the shader
  19190. * @param texture Define the texture to bind to this sampler
  19191. * @return the material itself allowing "fluent" like uniform updates
  19192. */
  19193. setTexture(name: string, texture: Texture): ShaderMaterial;
  19194. /**
  19195. * Set a texture array in the shader.
  19196. * @param name Define the name of the uniform sampler array as defined in the shader
  19197. * @param textures Define the list of textures to bind to this sampler
  19198. * @return the material itself allowing "fluent" like uniform updates
  19199. */
  19200. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19201. /**
  19202. * Set a float in the shader.
  19203. * @param name Define the name of the uniform as defined in the shader
  19204. * @param value Define the value to give to the uniform
  19205. * @return the material itself allowing "fluent" like uniform updates
  19206. */
  19207. setFloat(name: string, value: number): ShaderMaterial;
  19208. /**
  19209. * Set a int in the shader.
  19210. * @param name Define the name of the uniform as defined in the shader
  19211. * @param value Define the value to give to the uniform
  19212. * @return the material itself allowing "fluent" like uniform updates
  19213. */
  19214. setInt(name: string, value: number): ShaderMaterial;
  19215. /**
  19216. * Set an array of floats in the shader.
  19217. * @param name Define the name of the uniform as defined in the shader
  19218. * @param value Define the value to give to the uniform
  19219. * @return the material itself allowing "fluent" like uniform updates
  19220. */
  19221. setFloats(name: string, value: number[]): ShaderMaterial;
  19222. /**
  19223. * Set a vec3 in the shader from a Color3.
  19224. * @param name Define the name of the uniform as defined in the shader
  19225. * @param value Define the value to give to the uniform
  19226. * @return the material itself allowing "fluent" like uniform updates
  19227. */
  19228. setColor3(name: string, value: Color3): ShaderMaterial;
  19229. /**
  19230. * Set a vec3 array in the shader from a Color3 array.
  19231. * @param name Define the name of the uniform as defined in the shader
  19232. * @param value Define the value to give to the uniform
  19233. * @return the material itself allowing "fluent" like uniform updates
  19234. */
  19235. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19236. /**
  19237. * Set a vec4 in the shader from a Color4.
  19238. * @param name Define the name of the uniform as defined in the shader
  19239. * @param value Define the value to give to the uniform
  19240. * @return the material itself allowing "fluent" like uniform updates
  19241. */
  19242. setColor4(name: string, value: Color4): ShaderMaterial;
  19243. /**
  19244. * Set a vec4 array in the shader from a Color4 array.
  19245. * @param name Define the name of the uniform as defined in the shader
  19246. * @param value Define the value to give to the uniform
  19247. * @return the material itself allowing "fluent" like uniform updates
  19248. */
  19249. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19250. /**
  19251. * Set a vec2 in the shader from a Vector2.
  19252. * @param name Define the name of the uniform as defined in the shader
  19253. * @param value Define the value to give to the uniform
  19254. * @return the material itself allowing "fluent" like uniform updates
  19255. */
  19256. setVector2(name: string, value: Vector2): ShaderMaterial;
  19257. /**
  19258. * Set a vec3 in the shader from a Vector3.
  19259. * @param name Define the name of the uniform as defined in the shader
  19260. * @param value Define the value to give to the uniform
  19261. * @return the material itself allowing "fluent" like uniform updates
  19262. */
  19263. setVector3(name: string, value: Vector3): ShaderMaterial;
  19264. /**
  19265. * Set a vec4 in the shader from a Vector4.
  19266. * @param name Define the name of the uniform as defined in the shader
  19267. * @param value Define the value to give to the uniform
  19268. * @return the material itself allowing "fluent" like uniform updates
  19269. */
  19270. setVector4(name: string, value: Vector4): ShaderMaterial;
  19271. /**
  19272. * Set a mat4 in the shader from a Matrix.
  19273. * @param name Define the name of the uniform as defined in the shader
  19274. * @param value Define the value to give to the uniform
  19275. * @return the material itself allowing "fluent" like uniform updates
  19276. */
  19277. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19278. /**
  19279. * Set a float32Array in the shader from a matrix array.
  19280. * @param name Define the name of the uniform as defined in the shader
  19281. * @param value Define the value to give to the uniform
  19282. * @return the material itself allowing "fluent" like uniform updates
  19283. */
  19284. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19285. /**
  19286. * Set a mat3 in the shader from a Float32Array.
  19287. * @param name Define the name of the uniform as defined in the shader
  19288. * @param value Define the value to give to the uniform
  19289. * @return the material itself allowing "fluent" like uniform updates
  19290. */
  19291. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19292. /**
  19293. * Set a mat2 in the shader from a Float32Array.
  19294. * @param name Define the name of the uniform as defined in the shader
  19295. * @param value Define the value to give to the uniform
  19296. * @return the material itself allowing "fluent" like uniform updates
  19297. */
  19298. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19299. /**
  19300. * Set a vec2 array in the shader from a number array.
  19301. * @param name Define the name of the uniform as defined in the shader
  19302. * @param value Define the value to give to the uniform
  19303. * @return the material itself allowing "fluent" like uniform updates
  19304. */
  19305. setArray2(name: string, value: number[]): ShaderMaterial;
  19306. /**
  19307. * Set a vec3 array in the shader from a number array.
  19308. * @param name Define the name of the uniform as defined in the shader
  19309. * @param value Define the value to give to the uniform
  19310. * @return the material itself allowing "fluent" like uniform updates
  19311. */
  19312. setArray3(name: string, value: number[]): ShaderMaterial;
  19313. /**
  19314. * Set a vec4 array in the shader from a number array.
  19315. * @param name Define the name of the uniform as defined in the shader
  19316. * @param value Define the value to give to the uniform
  19317. * @return the material itself allowing "fluent" like uniform updates
  19318. */
  19319. setArray4(name: string, value: number[]): ShaderMaterial;
  19320. private _checkCache;
  19321. /**
  19322. * Specifies that the submesh is ready to be used
  19323. * @param mesh defines the mesh to check
  19324. * @param subMesh defines which submesh to check
  19325. * @param useInstances specifies that instances should be used
  19326. * @returns a boolean indicating that the submesh is ready or not
  19327. */
  19328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19329. /**
  19330. * Checks if the material is ready to render the requested mesh
  19331. * @param mesh Define the mesh to render
  19332. * @param useInstances Define whether or not the material is used with instances
  19333. * @returns true if ready, otherwise false
  19334. */
  19335. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19336. /**
  19337. * Binds the world matrix to the material
  19338. * @param world defines the world transformation matrix
  19339. */
  19340. bindOnlyWorldMatrix(world: Matrix): void;
  19341. /**
  19342. * Binds the material to the mesh
  19343. * @param world defines the world transformation matrix
  19344. * @param mesh defines the mesh to bind the material to
  19345. */
  19346. bind(world: Matrix, mesh?: Mesh): void;
  19347. /**
  19348. * Gets the active textures from the material
  19349. * @returns an array of textures
  19350. */
  19351. getActiveTextures(): BaseTexture[];
  19352. /**
  19353. * Specifies if the material uses a texture
  19354. * @param texture defines the texture to check against the material
  19355. * @returns a boolean specifying if the material uses the texture
  19356. */
  19357. hasTexture(texture: BaseTexture): boolean;
  19358. /**
  19359. * Makes a duplicate of the material, and gives it a new name
  19360. * @param name defines the new name for the duplicated material
  19361. * @returns the cloned material
  19362. */
  19363. clone(name: string): ShaderMaterial;
  19364. /**
  19365. * Disposes the material
  19366. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19367. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19368. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19369. */
  19370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19371. /**
  19372. * Serializes this material in a JSON representation
  19373. * @returns the serialized material object
  19374. */
  19375. serialize(): any;
  19376. /**
  19377. * Creates a shader material from parsed shader material data
  19378. * @param source defines the JSON represnetation of the material
  19379. * @param scene defines the hosting scene
  19380. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19381. * @returns a new material
  19382. */
  19383. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19384. }
  19385. }
  19386. declare module BABYLON {
  19387. /** @hidden */
  19388. export var colorPixelShader: {
  19389. name: string;
  19390. shader: string;
  19391. };
  19392. }
  19393. declare module BABYLON {
  19394. /** @hidden */
  19395. export var colorVertexShader: {
  19396. name: string;
  19397. shader: string;
  19398. };
  19399. }
  19400. declare module BABYLON {
  19401. /**
  19402. * Line mesh
  19403. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19404. */
  19405. export class LinesMesh extends Mesh {
  19406. /**
  19407. * If vertex color should be applied to the mesh
  19408. */
  19409. readonly useVertexColor?: boolean | undefined;
  19410. /**
  19411. * If vertex alpha should be applied to the mesh
  19412. */
  19413. readonly useVertexAlpha?: boolean | undefined;
  19414. /**
  19415. * Color of the line (Default: White)
  19416. */
  19417. color: Color3;
  19418. /**
  19419. * Alpha of the line (Default: 1)
  19420. */
  19421. alpha: number;
  19422. /**
  19423. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19424. * This margin is expressed in world space coordinates, so its value may vary.
  19425. * Default value is 0.1
  19426. */
  19427. intersectionThreshold: number;
  19428. private _colorShader;
  19429. private color4;
  19430. /**
  19431. * Creates a new LinesMesh
  19432. * @param name defines the name
  19433. * @param scene defines the hosting scene
  19434. * @param parent defines the parent mesh if any
  19435. * @param source defines the optional source LinesMesh used to clone data from
  19436. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19437. * When false, achieved by calling a clone(), also passing False.
  19438. * This will make creation of children, recursive.
  19439. * @param useVertexColor defines if this LinesMesh supports vertex color
  19440. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19441. */
  19442. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19443. /**
  19444. * If vertex color should be applied to the mesh
  19445. */
  19446. useVertexColor?: boolean | undefined,
  19447. /**
  19448. * If vertex alpha should be applied to the mesh
  19449. */
  19450. useVertexAlpha?: boolean | undefined);
  19451. private _addClipPlaneDefine;
  19452. private _removeClipPlaneDefine;
  19453. isReady(): boolean;
  19454. /**
  19455. * Returns the string "LineMesh"
  19456. */
  19457. getClassName(): string;
  19458. /**
  19459. * @hidden
  19460. */
  19461. /**
  19462. * @hidden
  19463. */
  19464. material: Material;
  19465. /**
  19466. * @hidden
  19467. */
  19468. readonly checkCollisions: boolean;
  19469. /** @hidden */
  19470. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19471. /** @hidden */
  19472. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19473. /**
  19474. * Disposes of the line mesh
  19475. * @param doNotRecurse If children should be disposed
  19476. */
  19477. dispose(doNotRecurse?: boolean): void;
  19478. /**
  19479. * Returns a new LineMesh object cloned from the current one.
  19480. */
  19481. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19482. /**
  19483. * Creates a new InstancedLinesMesh object from the mesh model.
  19484. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19485. * @param name defines the name of the new instance
  19486. * @returns a new InstancedLinesMesh
  19487. */
  19488. createInstance(name: string): InstancedLinesMesh;
  19489. }
  19490. /**
  19491. * Creates an instance based on a source LinesMesh
  19492. */
  19493. export class InstancedLinesMesh extends InstancedMesh {
  19494. /**
  19495. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19496. * This margin is expressed in world space coordinates, so its value may vary.
  19497. * Initilized with the intersectionThreshold value of the source LinesMesh
  19498. */
  19499. intersectionThreshold: number;
  19500. constructor(name: string, source: LinesMesh);
  19501. /**
  19502. * Returns the string "InstancedLinesMesh".
  19503. */
  19504. getClassName(): string;
  19505. }
  19506. }
  19507. declare module BABYLON {
  19508. /** @hidden */
  19509. export var linePixelShader: {
  19510. name: string;
  19511. shader: string;
  19512. };
  19513. }
  19514. declare module BABYLON {
  19515. /** @hidden */
  19516. export var lineVertexShader: {
  19517. name: string;
  19518. shader: string;
  19519. };
  19520. }
  19521. declare module BABYLON {
  19522. interface AbstractMesh {
  19523. /**
  19524. * Gets the edgesRenderer associated with the mesh
  19525. */
  19526. edgesRenderer: Nullable<EdgesRenderer>;
  19527. }
  19528. interface LinesMesh {
  19529. /**
  19530. * Enables the edge rendering mode on the mesh.
  19531. * This mode makes the mesh edges visible
  19532. * @param epsilon defines the maximal distance between two angles to detect a face
  19533. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19534. * @returns the currentAbstractMesh
  19535. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19536. */
  19537. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19538. }
  19539. interface InstancedLinesMesh {
  19540. /**
  19541. * Enables the edge rendering mode on the mesh.
  19542. * This mode makes the mesh edges visible
  19543. * @param epsilon defines the maximal distance between two angles to detect a face
  19544. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19545. * @returns the current InstancedLinesMesh
  19546. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19547. */
  19548. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19549. }
  19550. /**
  19551. * Defines the minimum contract an Edges renderer should follow.
  19552. */
  19553. export interface IEdgesRenderer extends IDisposable {
  19554. /**
  19555. * Gets or sets a boolean indicating if the edgesRenderer is active
  19556. */
  19557. isEnabled: boolean;
  19558. /**
  19559. * Renders the edges of the attached mesh,
  19560. */
  19561. render(): void;
  19562. /**
  19563. * Checks wether or not the edges renderer is ready to render.
  19564. * @return true if ready, otherwise false.
  19565. */
  19566. isReady(): boolean;
  19567. }
  19568. /**
  19569. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19570. */
  19571. export class EdgesRenderer implements IEdgesRenderer {
  19572. /**
  19573. * Define the size of the edges with an orthographic camera
  19574. */
  19575. edgesWidthScalerForOrthographic: number;
  19576. /**
  19577. * Define the size of the edges with a perspective camera
  19578. */
  19579. edgesWidthScalerForPerspective: number;
  19580. protected _source: AbstractMesh;
  19581. protected _linesPositions: number[];
  19582. protected _linesNormals: number[];
  19583. protected _linesIndices: number[];
  19584. protected _epsilon: number;
  19585. protected _indicesCount: number;
  19586. protected _lineShader: ShaderMaterial;
  19587. protected _ib: DataBuffer;
  19588. protected _buffers: {
  19589. [key: string]: Nullable<VertexBuffer>;
  19590. };
  19591. protected _checkVerticesInsteadOfIndices: boolean;
  19592. private _meshRebuildObserver;
  19593. private _meshDisposeObserver;
  19594. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19595. isEnabled: boolean;
  19596. /**
  19597. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19598. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19599. * @param source Mesh used to create edges
  19600. * @param epsilon sum of angles in adjacency to check for edge
  19601. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19602. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19603. */
  19604. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19605. protected _prepareRessources(): void;
  19606. /** @hidden */
  19607. _rebuild(): void;
  19608. /**
  19609. * Releases the required resources for the edges renderer
  19610. */
  19611. dispose(): void;
  19612. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19613. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19614. /**
  19615. * Checks if the pair of p0 and p1 is en edge
  19616. * @param faceIndex
  19617. * @param edge
  19618. * @param faceNormals
  19619. * @param p0
  19620. * @param p1
  19621. * @private
  19622. */
  19623. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19624. /**
  19625. * push line into the position, normal and index buffer
  19626. * @protected
  19627. */
  19628. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19629. /**
  19630. * Generates lines edges from adjacencjes
  19631. * @private
  19632. */
  19633. _generateEdgesLines(): void;
  19634. /**
  19635. * Checks wether or not the edges renderer is ready to render.
  19636. * @return true if ready, otherwise false.
  19637. */
  19638. isReady(): boolean;
  19639. /**
  19640. * Renders the edges of the attached mesh,
  19641. */
  19642. render(): void;
  19643. }
  19644. /**
  19645. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19646. */
  19647. export class LineEdgesRenderer extends EdgesRenderer {
  19648. /**
  19649. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19650. * @param source LineMesh used to generate edges
  19651. * @param epsilon not important (specified angle for edge detection)
  19652. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19653. */
  19654. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19655. /**
  19656. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19657. */
  19658. _generateEdgesLines(): void;
  19659. }
  19660. }
  19661. declare module BABYLON {
  19662. /**
  19663. * This represents the object necessary to create a rendering group.
  19664. * This is exclusively used and created by the rendering manager.
  19665. * To modify the behavior, you use the available helpers in your scene or meshes.
  19666. * @hidden
  19667. */
  19668. export class RenderingGroup {
  19669. index: number;
  19670. private static _zeroVector;
  19671. private _scene;
  19672. private _opaqueSubMeshes;
  19673. private _transparentSubMeshes;
  19674. private _alphaTestSubMeshes;
  19675. private _depthOnlySubMeshes;
  19676. private _particleSystems;
  19677. private _spriteManagers;
  19678. private _opaqueSortCompareFn;
  19679. private _alphaTestSortCompareFn;
  19680. private _transparentSortCompareFn;
  19681. private _renderOpaque;
  19682. private _renderAlphaTest;
  19683. private _renderTransparent;
  19684. /** @hidden */
  19685. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19686. onBeforeTransparentRendering: () => void;
  19687. /**
  19688. * Set the opaque sort comparison function.
  19689. * If null the sub meshes will be render in the order they were created
  19690. */
  19691. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19692. /**
  19693. * Set the alpha test sort comparison function.
  19694. * If null the sub meshes will be render in the order they were created
  19695. */
  19696. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19697. /**
  19698. * Set the transparent sort comparison function.
  19699. * If null the sub meshes will be render in the order they were created
  19700. */
  19701. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19702. /**
  19703. * Creates a new rendering group.
  19704. * @param index The rendering group index
  19705. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19706. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19707. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19708. */
  19709. 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>);
  19710. /**
  19711. * Render all the sub meshes contained in the group.
  19712. * @param customRenderFunction Used to override the default render behaviour of the group.
  19713. * @returns true if rendered some submeshes.
  19714. */
  19715. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19716. /**
  19717. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19718. * @param subMeshes The submeshes to render
  19719. */
  19720. private renderOpaqueSorted;
  19721. /**
  19722. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19723. * @param subMeshes The submeshes to render
  19724. */
  19725. private renderAlphaTestSorted;
  19726. /**
  19727. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19728. * @param subMeshes The submeshes to render
  19729. */
  19730. private renderTransparentSorted;
  19731. /**
  19732. * Renders the submeshes in a specified order.
  19733. * @param subMeshes The submeshes to sort before render
  19734. * @param sortCompareFn The comparison function use to sort
  19735. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19736. * @param transparent Specifies to activate blending if true
  19737. */
  19738. private static renderSorted;
  19739. /**
  19740. * Renders the submeshes in the order they were dispatched (no sort applied).
  19741. * @param subMeshes The submeshes to render
  19742. */
  19743. private static renderUnsorted;
  19744. /**
  19745. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19746. * are rendered back to front if in the same alpha index.
  19747. *
  19748. * @param a The first submesh
  19749. * @param b The second submesh
  19750. * @returns The result of the comparison
  19751. */
  19752. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19753. /**
  19754. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19755. * are rendered back to front.
  19756. *
  19757. * @param a The first submesh
  19758. * @param b The second submesh
  19759. * @returns The result of the comparison
  19760. */
  19761. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19762. /**
  19763. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19764. * are rendered front to back (prevent overdraw).
  19765. *
  19766. * @param a The first submesh
  19767. * @param b The second submesh
  19768. * @returns The result of the comparison
  19769. */
  19770. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19771. /**
  19772. * Resets the different lists of submeshes to prepare a new frame.
  19773. */
  19774. prepare(): void;
  19775. dispose(): void;
  19776. /**
  19777. * Inserts the submesh in its correct queue depending on its material.
  19778. * @param subMesh The submesh to dispatch
  19779. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19780. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19781. */
  19782. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19783. dispatchSprites(spriteManager: ISpriteManager): void;
  19784. dispatchParticles(particleSystem: IParticleSystem): void;
  19785. private _renderParticles;
  19786. private _renderSprites;
  19787. }
  19788. }
  19789. declare module BABYLON {
  19790. /**
  19791. * Interface describing the different options available in the rendering manager
  19792. * regarding Auto Clear between groups.
  19793. */
  19794. export interface IRenderingManagerAutoClearSetup {
  19795. /**
  19796. * Defines whether or not autoclear is enable.
  19797. */
  19798. autoClear: boolean;
  19799. /**
  19800. * Defines whether or not to autoclear the depth buffer.
  19801. */
  19802. depth: boolean;
  19803. /**
  19804. * Defines whether or not to autoclear the stencil buffer.
  19805. */
  19806. stencil: boolean;
  19807. }
  19808. /**
  19809. * This class is used by the onRenderingGroupObservable
  19810. */
  19811. export class RenderingGroupInfo {
  19812. /**
  19813. * The Scene that being rendered
  19814. */
  19815. scene: Scene;
  19816. /**
  19817. * The camera currently used for the rendering pass
  19818. */
  19819. camera: Nullable<Camera>;
  19820. /**
  19821. * The ID of the renderingGroup being processed
  19822. */
  19823. renderingGroupId: number;
  19824. }
  19825. /**
  19826. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19827. * It is enable to manage the different groups as well as the different necessary sort functions.
  19828. * This should not be used directly aside of the few static configurations
  19829. */
  19830. export class RenderingManager {
  19831. /**
  19832. * The max id used for rendering groups (not included)
  19833. */
  19834. static MAX_RENDERINGGROUPS: number;
  19835. /**
  19836. * The min id used for rendering groups (included)
  19837. */
  19838. static MIN_RENDERINGGROUPS: number;
  19839. /**
  19840. * Used to globally prevent autoclearing scenes.
  19841. */
  19842. static AUTOCLEAR: boolean;
  19843. /**
  19844. * @hidden
  19845. */
  19846. _useSceneAutoClearSetup: boolean;
  19847. private _scene;
  19848. private _renderingGroups;
  19849. private _depthStencilBufferAlreadyCleaned;
  19850. private _autoClearDepthStencil;
  19851. private _customOpaqueSortCompareFn;
  19852. private _customAlphaTestSortCompareFn;
  19853. private _customTransparentSortCompareFn;
  19854. private _renderingGroupInfo;
  19855. /**
  19856. * Instantiates a new rendering group for a particular scene
  19857. * @param scene Defines the scene the groups belongs to
  19858. */
  19859. constructor(scene: Scene);
  19860. private _clearDepthStencilBuffer;
  19861. /**
  19862. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19863. * @hidden
  19864. */
  19865. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19866. /**
  19867. * Resets the different information of the group to prepare a new frame
  19868. * @hidden
  19869. */
  19870. reset(): void;
  19871. /**
  19872. * Dispose and release the group and its associated resources.
  19873. * @hidden
  19874. */
  19875. dispose(): void;
  19876. /**
  19877. * Clear the info related to rendering groups preventing retention points during dispose.
  19878. */
  19879. freeRenderingGroups(): void;
  19880. private _prepareRenderingGroup;
  19881. /**
  19882. * Add a sprite manager to the rendering manager in order to render it this frame.
  19883. * @param spriteManager Define the sprite manager to render
  19884. */
  19885. dispatchSprites(spriteManager: ISpriteManager): void;
  19886. /**
  19887. * Add a particle system to the rendering manager in order to render it this frame.
  19888. * @param particleSystem Define the particle system to render
  19889. */
  19890. dispatchParticles(particleSystem: IParticleSystem): void;
  19891. /**
  19892. * Add a submesh to the manager in order to render it this frame
  19893. * @param subMesh The submesh to dispatch
  19894. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19895. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19896. */
  19897. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19898. /**
  19899. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19900. * This allowed control for front to back rendering or reversly depending of the special needs.
  19901. *
  19902. * @param renderingGroupId The rendering group id corresponding to its index
  19903. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19904. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19905. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19906. */
  19907. 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;
  19908. /**
  19909. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19910. *
  19911. * @param renderingGroupId The rendering group id corresponding to its index
  19912. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19913. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19914. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19915. */
  19916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19917. /**
  19918. * Gets the current auto clear configuration for one rendering group of the rendering
  19919. * manager.
  19920. * @param index the rendering group index to get the information for
  19921. * @returns The auto clear setup for the requested rendering group
  19922. */
  19923. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19924. }
  19925. }
  19926. declare module BABYLON {
  19927. /**
  19928. * This Helps creating a texture that will be created from a camera in your scene.
  19929. * It is basically a dynamic texture that could be used to create special effects for instance.
  19930. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19931. */
  19932. export class RenderTargetTexture extends Texture {
  19933. isCube: boolean;
  19934. /**
  19935. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19936. */
  19937. static readonly REFRESHRATE_RENDER_ONCE: number;
  19938. /**
  19939. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19940. */
  19941. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19942. /**
  19943. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19944. * the central point of your effect and can save a lot of performances.
  19945. */
  19946. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19947. /**
  19948. * Use this predicate to dynamically define the list of mesh you want to render.
  19949. * If set, the renderList property will be overwritten.
  19950. */
  19951. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19952. private _renderList;
  19953. /**
  19954. * Use this list to define the list of mesh you want to render.
  19955. */
  19956. renderList: Nullable<Array<AbstractMesh>>;
  19957. private _hookArray;
  19958. /**
  19959. * Define if particles should be rendered in your texture.
  19960. */
  19961. renderParticles: boolean;
  19962. /**
  19963. * Define if sprites should be rendered in your texture.
  19964. */
  19965. renderSprites: boolean;
  19966. /**
  19967. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19968. */
  19969. coordinatesMode: number;
  19970. /**
  19971. * Define the camera used to render the texture.
  19972. */
  19973. activeCamera: Nullable<Camera>;
  19974. /**
  19975. * Override the render function of the texture with your own one.
  19976. */
  19977. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19978. /**
  19979. * Define if camera post processes should be use while rendering the texture.
  19980. */
  19981. useCameraPostProcesses: boolean;
  19982. /**
  19983. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19984. */
  19985. ignoreCameraViewport: boolean;
  19986. private _postProcessManager;
  19987. private _postProcesses;
  19988. private _resizeObserver;
  19989. /**
  19990. * An event triggered when the texture is unbind.
  19991. */
  19992. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19993. /**
  19994. * An event triggered when the texture is unbind.
  19995. */
  19996. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19997. private _onAfterUnbindObserver;
  19998. /**
  19999. * Set a after unbind callback in the texture.
  20000. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20001. */
  20002. onAfterUnbind: () => void;
  20003. /**
  20004. * An event triggered before rendering the texture
  20005. */
  20006. onBeforeRenderObservable: Observable<number>;
  20007. private _onBeforeRenderObserver;
  20008. /**
  20009. * Set a before render callback in the texture.
  20010. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20011. */
  20012. onBeforeRender: (faceIndex: number) => void;
  20013. /**
  20014. * An event triggered after rendering the texture
  20015. */
  20016. onAfterRenderObservable: Observable<number>;
  20017. private _onAfterRenderObserver;
  20018. /**
  20019. * Set a after render callback in the texture.
  20020. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20021. */
  20022. onAfterRender: (faceIndex: number) => void;
  20023. /**
  20024. * An event triggered after the texture clear
  20025. */
  20026. onClearObservable: Observable<Engine>;
  20027. private _onClearObserver;
  20028. /**
  20029. * Set a clear callback in the texture.
  20030. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20031. */
  20032. onClear: (Engine: Engine) => void;
  20033. /**
  20034. * An event triggered when the texture is resized.
  20035. */
  20036. onResizeObservable: Observable<RenderTargetTexture>;
  20037. /**
  20038. * Define the clear color of the Render Target if it should be different from the scene.
  20039. */
  20040. clearColor: Color4;
  20041. protected _size: number | {
  20042. width: number;
  20043. height: number;
  20044. };
  20045. protected _initialSizeParameter: number | {
  20046. width: number;
  20047. height: number;
  20048. } | {
  20049. ratio: number;
  20050. };
  20051. protected _sizeRatio: Nullable<number>;
  20052. /** @hidden */
  20053. _generateMipMaps: boolean;
  20054. protected _renderingManager: RenderingManager;
  20055. /** @hidden */
  20056. _waitingRenderList: string[];
  20057. protected _doNotChangeAspectRatio: boolean;
  20058. protected _currentRefreshId: number;
  20059. protected _refreshRate: number;
  20060. protected _textureMatrix: Matrix;
  20061. protected _samples: number;
  20062. protected _renderTargetOptions: RenderTargetCreationOptions;
  20063. /**
  20064. * Gets render target creation options that were used.
  20065. */
  20066. readonly renderTargetOptions: RenderTargetCreationOptions;
  20067. protected _engine: Engine;
  20068. protected _onRatioRescale(): void;
  20069. /**
  20070. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20071. * It must define where the camera used to render the texture is set
  20072. */
  20073. boundingBoxPosition: Vector3;
  20074. private _boundingBoxSize;
  20075. /**
  20076. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20077. * When defined, the cubemap will switch to local mode
  20078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20079. * @example https://www.babylonjs-playground.com/#RNASML
  20080. */
  20081. boundingBoxSize: Vector3;
  20082. /**
  20083. * In case the RTT has been created with a depth texture, get the associated
  20084. * depth texture.
  20085. * Otherwise, return null.
  20086. */
  20087. depthStencilTexture: Nullable<InternalTexture>;
  20088. /**
  20089. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20090. * or used a shadow, depth texture...
  20091. * @param name The friendly name of the texture
  20092. * @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)
  20093. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20094. * @param generateMipMaps True if mip maps need to be generated after render.
  20095. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20096. * @param type The type of the buffer in the RTT (int, half float, float...)
  20097. * @param isCube True if a cube texture needs to be created
  20098. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20099. * @param generateDepthBuffer True to generate a depth buffer
  20100. * @param generateStencilBuffer True to generate a stencil buffer
  20101. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20102. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20103. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20104. */
  20105. constructor(name: string, size: number | {
  20106. width: number;
  20107. height: number;
  20108. } | {
  20109. ratio: number;
  20110. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20111. /**
  20112. * Creates a depth stencil texture.
  20113. * This is only available in WebGL 2 or with the depth texture extension available.
  20114. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20115. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20116. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20117. */
  20118. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20119. private _processSizeParameter;
  20120. /**
  20121. * Define the number of samples to use in case of MSAA.
  20122. * It defaults to one meaning no MSAA has been enabled.
  20123. */
  20124. samples: number;
  20125. /**
  20126. * Resets the refresh counter of the texture and start bak from scratch.
  20127. * Could be useful to regenerate the texture if it is setup to render only once.
  20128. */
  20129. resetRefreshCounter(): void;
  20130. /**
  20131. * Define the refresh rate of the texture or the rendering frequency.
  20132. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20133. */
  20134. refreshRate: number;
  20135. /**
  20136. * Adds a post process to the render target rendering passes.
  20137. * @param postProcess define the post process to add
  20138. */
  20139. addPostProcess(postProcess: PostProcess): void;
  20140. /**
  20141. * Clear all the post processes attached to the render target
  20142. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20143. */
  20144. clearPostProcesses(dispose?: boolean): void;
  20145. /**
  20146. * Remove one of the post process from the list of attached post processes to the texture
  20147. * @param postProcess define the post process to remove from the list
  20148. */
  20149. removePostProcess(postProcess: PostProcess): void;
  20150. /** @hidden */
  20151. _shouldRender(): boolean;
  20152. /**
  20153. * Gets the actual render size of the texture.
  20154. * @returns the width of the render size
  20155. */
  20156. getRenderSize(): number;
  20157. /**
  20158. * Gets the actual render width of the texture.
  20159. * @returns the width of the render size
  20160. */
  20161. getRenderWidth(): number;
  20162. /**
  20163. * Gets the actual render height of the texture.
  20164. * @returns the height of the render size
  20165. */
  20166. getRenderHeight(): number;
  20167. /**
  20168. * Get if the texture can be rescaled or not.
  20169. */
  20170. readonly canRescale: boolean;
  20171. /**
  20172. * Resize the texture using a ratio.
  20173. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20174. */
  20175. scale(ratio: number): void;
  20176. /**
  20177. * Get the texture reflection matrix used to rotate/transform the reflection.
  20178. * @returns the reflection matrix
  20179. */
  20180. getReflectionTextureMatrix(): Matrix;
  20181. /**
  20182. * Resize the texture to a new desired size.
  20183. * Be carrefull as it will recreate all the data in the new texture.
  20184. * @param size Define the new size. It can be:
  20185. * - a number for squared texture,
  20186. * - an object containing { width: number, height: number }
  20187. * - or an object containing a ratio { ratio: number }
  20188. */
  20189. resize(size: number | {
  20190. width: number;
  20191. height: number;
  20192. } | {
  20193. ratio: number;
  20194. }): void;
  20195. /**
  20196. * Renders all the objects from the render list into the texture.
  20197. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20198. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20199. */
  20200. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20201. private _bestReflectionRenderTargetDimension;
  20202. /**
  20203. * @hidden
  20204. * @param faceIndex face index to bind to if this is a cubetexture
  20205. */
  20206. _bindFrameBuffer(faceIndex?: number): void;
  20207. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20208. private renderToTarget;
  20209. /**
  20210. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20211. * This allowed control for front to back rendering or reversly depending of the special needs.
  20212. *
  20213. * @param renderingGroupId The rendering group id corresponding to its index
  20214. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20215. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20216. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20217. */
  20218. 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;
  20219. /**
  20220. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20221. *
  20222. * @param renderingGroupId The rendering group id corresponding to its index
  20223. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20224. */
  20225. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20226. /**
  20227. * Clones the texture.
  20228. * @returns the cloned texture
  20229. */
  20230. clone(): RenderTargetTexture;
  20231. /**
  20232. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20233. * @returns The JSON representation of the texture
  20234. */
  20235. serialize(): any;
  20236. /**
  20237. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20238. */
  20239. disposeFramebufferObjects(): void;
  20240. /**
  20241. * Dispose the texture and release its associated resources.
  20242. */
  20243. dispose(): void;
  20244. /** @hidden */
  20245. _rebuild(): void;
  20246. /**
  20247. * Clear the info related to rendering groups preventing retention point in material dispose.
  20248. */
  20249. freeRenderingGroups(): void;
  20250. /**
  20251. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20252. * @returns the view count
  20253. */
  20254. getViewCount(): number;
  20255. }
  20256. }
  20257. declare module BABYLON {
  20258. /**
  20259. * Options for compiling materials.
  20260. */
  20261. export interface IMaterialCompilationOptions {
  20262. /**
  20263. * Defines whether clip planes are enabled.
  20264. */
  20265. clipPlane: boolean;
  20266. /**
  20267. * Defines whether instances are enabled.
  20268. */
  20269. useInstances: boolean;
  20270. }
  20271. /**
  20272. * Base class for the main features of a material in Babylon.js
  20273. */
  20274. export class Material implements IAnimatable {
  20275. /**
  20276. * Returns the triangle fill mode
  20277. */
  20278. static readonly TriangleFillMode: number;
  20279. /**
  20280. * Returns the wireframe mode
  20281. */
  20282. static readonly WireFrameFillMode: number;
  20283. /**
  20284. * Returns the point fill mode
  20285. */
  20286. static readonly PointFillMode: number;
  20287. /**
  20288. * Returns the point list draw mode
  20289. */
  20290. static readonly PointListDrawMode: number;
  20291. /**
  20292. * Returns the line list draw mode
  20293. */
  20294. static readonly LineListDrawMode: number;
  20295. /**
  20296. * Returns the line loop draw mode
  20297. */
  20298. static readonly LineLoopDrawMode: number;
  20299. /**
  20300. * Returns the line strip draw mode
  20301. */
  20302. static readonly LineStripDrawMode: number;
  20303. /**
  20304. * Returns the triangle strip draw mode
  20305. */
  20306. static readonly TriangleStripDrawMode: number;
  20307. /**
  20308. * Returns the triangle fan draw mode
  20309. */
  20310. static readonly TriangleFanDrawMode: number;
  20311. /**
  20312. * Stores the clock-wise side orientation
  20313. */
  20314. static readonly ClockWiseSideOrientation: number;
  20315. /**
  20316. * Stores the counter clock-wise side orientation
  20317. */
  20318. static readonly CounterClockWiseSideOrientation: number;
  20319. /**
  20320. * The dirty texture flag value
  20321. */
  20322. static readonly TextureDirtyFlag: number;
  20323. /**
  20324. * The dirty light flag value
  20325. */
  20326. static readonly LightDirtyFlag: number;
  20327. /**
  20328. * The dirty fresnel flag value
  20329. */
  20330. static readonly FresnelDirtyFlag: number;
  20331. /**
  20332. * The dirty attribute flag value
  20333. */
  20334. static readonly AttributesDirtyFlag: number;
  20335. /**
  20336. * The dirty misc flag value
  20337. */
  20338. static readonly MiscDirtyFlag: number;
  20339. /**
  20340. * The all dirty flag value
  20341. */
  20342. static readonly AllDirtyFlag: number;
  20343. /**
  20344. * The ID of the material
  20345. */
  20346. id: string;
  20347. /**
  20348. * Gets or sets the unique id of the material
  20349. */
  20350. uniqueId: number;
  20351. /**
  20352. * The name of the material
  20353. */
  20354. name: string;
  20355. /**
  20356. * Gets or sets user defined metadata
  20357. */
  20358. metadata: any;
  20359. /**
  20360. * For internal use only. Please do not use.
  20361. */
  20362. reservedDataStore: any;
  20363. /**
  20364. * Specifies if the ready state should be checked on each call
  20365. */
  20366. checkReadyOnEveryCall: boolean;
  20367. /**
  20368. * Specifies if the ready state should be checked once
  20369. */
  20370. checkReadyOnlyOnce: boolean;
  20371. /**
  20372. * The state of the material
  20373. */
  20374. state: string;
  20375. /**
  20376. * The alpha value of the material
  20377. */
  20378. protected _alpha: number;
  20379. /**
  20380. * List of inspectable custom properties (used by the Inspector)
  20381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20382. */
  20383. inspectableCustomProperties: IInspectable[];
  20384. /**
  20385. * Sets the alpha value of the material
  20386. */
  20387. /**
  20388. * Gets the alpha value of the material
  20389. */
  20390. alpha: number;
  20391. /**
  20392. * Specifies if back face culling is enabled
  20393. */
  20394. protected _backFaceCulling: boolean;
  20395. /**
  20396. * Sets the back-face culling state
  20397. */
  20398. /**
  20399. * Gets the back-face culling state
  20400. */
  20401. backFaceCulling: boolean;
  20402. /**
  20403. * Stores the value for side orientation
  20404. */
  20405. sideOrientation: number;
  20406. /**
  20407. * Callback triggered when the material is compiled
  20408. */
  20409. onCompiled: Nullable<(effect: Effect) => void>;
  20410. /**
  20411. * Callback triggered when an error occurs
  20412. */
  20413. onError: Nullable<(effect: Effect, errors: string) => void>;
  20414. /**
  20415. * Callback triggered to get the render target textures
  20416. */
  20417. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20418. /**
  20419. * Gets a boolean indicating that current material needs to register RTT
  20420. */
  20421. readonly hasRenderTargetTextures: boolean;
  20422. /**
  20423. * Specifies if the material should be serialized
  20424. */
  20425. doNotSerialize: boolean;
  20426. /**
  20427. * @hidden
  20428. */
  20429. _storeEffectOnSubMeshes: boolean;
  20430. /**
  20431. * Stores the animations for the material
  20432. */
  20433. animations: Nullable<Array<Animation>>;
  20434. /**
  20435. * An event triggered when the material is disposed
  20436. */
  20437. onDisposeObservable: Observable<Material>;
  20438. /**
  20439. * An observer which watches for dispose events
  20440. */
  20441. private _onDisposeObserver;
  20442. private _onUnBindObservable;
  20443. /**
  20444. * Called during a dispose event
  20445. */
  20446. onDispose: () => void;
  20447. private _onBindObservable;
  20448. /**
  20449. * An event triggered when the material is bound
  20450. */
  20451. readonly onBindObservable: Observable<AbstractMesh>;
  20452. /**
  20453. * An observer which watches for bind events
  20454. */
  20455. private _onBindObserver;
  20456. /**
  20457. * Called during a bind event
  20458. */
  20459. onBind: (Mesh: AbstractMesh) => void;
  20460. /**
  20461. * An event triggered when the material is unbound
  20462. */
  20463. readonly onUnBindObservable: Observable<Material>;
  20464. /**
  20465. * Stores the value of the alpha mode
  20466. */
  20467. private _alphaMode;
  20468. /**
  20469. * Sets the value of the alpha mode.
  20470. *
  20471. * | Value | Type | Description |
  20472. * | --- | --- | --- |
  20473. * | 0 | ALPHA_DISABLE | |
  20474. * | 1 | ALPHA_ADD | |
  20475. * | 2 | ALPHA_COMBINE | |
  20476. * | 3 | ALPHA_SUBTRACT | |
  20477. * | 4 | ALPHA_MULTIPLY | |
  20478. * | 5 | ALPHA_MAXIMIZED | |
  20479. * | 6 | ALPHA_ONEONE | |
  20480. * | 7 | ALPHA_PREMULTIPLIED | |
  20481. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20482. * | 9 | ALPHA_INTERPOLATE | |
  20483. * | 10 | ALPHA_SCREENMODE | |
  20484. *
  20485. */
  20486. /**
  20487. * Gets the value of the alpha mode
  20488. */
  20489. alphaMode: number;
  20490. /**
  20491. * Stores the state of the need depth pre-pass value
  20492. */
  20493. private _needDepthPrePass;
  20494. /**
  20495. * Sets the need depth pre-pass value
  20496. */
  20497. /**
  20498. * Gets the depth pre-pass value
  20499. */
  20500. needDepthPrePass: boolean;
  20501. /**
  20502. * Specifies if depth writing should be disabled
  20503. */
  20504. disableDepthWrite: boolean;
  20505. /**
  20506. * Specifies if depth writing should be forced
  20507. */
  20508. forceDepthWrite: boolean;
  20509. /**
  20510. * Specifies if there should be a separate pass for culling
  20511. */
  20512. separateCullingPass: boolean;
  20513. /**
  20514. * Stores the state specifing if fog should be enabled
  20515. */
  20516. private _fogEnabled;
  20517. /**
  20518. * Sets the state for enabling fog
  20519. */
  20520. /**
  20521. * Gets the value of the fog enabled state
  20522. */
  20523. fogEnabled: boolean;
  20524. /**
  20525. * Stores the size of points
  20526. */
  20527. pointSize: number;
  20528. /**
  20529. * Stores the z offset value
  20530. */
  20531. zOffset: number;
  20532. /**
  20533. * Gets a value specifying if wireframe mode is enabled
  20534. */
  20535. /**
  20536. * Sets the state of wireframe mode
  20537. */
  20538. wireframe: boolean;
  20539. /**
  20540. * Gets the value specifying if point clouds are enabled
  20541. */
  20542. /**
  20543. * Sets the state of point cloud mode
  20544. */
  20545. pointsCloud: boolean;
  20546. /**
  20547. * Gets the material fill mode
  20548. */
  20549. /**
  20550. * Sets the material fill mode
  20551. */
  20552. fillMode: number;
  20553. /**
  20554. * @hidden
  20555. * Stores the effects for the material
  20556. */
  20557. _effect: Nullable<Effect>;
  20558. /**
  20559. * @hidden
  20560. * Specifies if the material was previously ready
  20561. */
  20562. _wasPreviouslyReady: boolean;
  20563. /**
  20564. * Specifies if uniform buffers should be used
  20565. */
  20566. private _useUBO;
  20567. /**
  20568. * Stores a reference to the scene
  20569. */
  20570. private _scene;
  20571. /**
  20572. * Stores the fill mode state
  20573. */
  20574. private _fillMode;
  20575. /**
  20576. * Specifies if the depth write state should be cached
  20577. */
  20578. private _cachedDepthWriteState;
  20579. /**
  20580. * Stores the uniform buffer
  20581. */
  20582. protected _uniformBuffer: UniformBuffer;
  20583. /** @hidden */
  20584. _indexInSceneMaterialArray: number;
  20585. /** @hidden */
  20586. meshMap: Nullable<{
  20587. [id: string]: AbstractMesh | undefined;
  20588. }>;
  20589. /**
  20590. * Creates a material instance
  20591. * @param name defines the name of the material
  20592. * @param scene defines the scene to reference
  20593. * @param doNotAdd specifies if the material should be added to the scene
  20594. */
  20595. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20596. /**
  20597. * Returns a string representation of the current material
  20598. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20599. * @returns a string with material information
  20600. */
  20601. toString(fullDetails?: boolean): string;
  20602. /**
  20603. * Gets the class name of the material
  20604. * @returns a string with the class name of the material
  20605. */
  20606. getClassName(): string;
  20607. /**
  20608. * Specifies if updates for the material been locked
  20609. */
  20610. readonly isFrozen: boolean;
  20611. /**
  20612. * Locks updates for the material
  20613. */
  20614. freeze(): void;
  20615. /**
  20616. * Unlocks updates for the material
  20617. */
  20618. unfreeze(): void;
  20619. /**
  20620. * Specifies if the material is ready to be used
  20621. * @param mesh defines the mesh to check
  20622. * @param useInstances specifies if instances should be used
  20623. * @returns a boolean indicating if the material is ready to be used
  20624. */
  20625. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20626. /**
  20627. * Specifies that the submesh is ready to be used
  20628. * @param mesh defines the mesh to check
  20629. * @param subMesh defines which submesh to check
  20630. * @param useInstances specifies that instances should be used
  20631. * @returns a boolean indicating that the submesh is ready or not
  20632. */
  20633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20634. /**
  20635. * Returns the material effect
  20636. * @returns the effect associated with the material
  20637. */
  20638. getEffect(): Nullable<Effect>;
  20639. /**
  20640. * Returns the current scene
  20641. * @returns a Scene
  20642. */
  20643. getScene(): Scene;
  20644. /**
  20645. * Specifies if the material will require alpha blending
  20646. * @returns a boolean specifying if alpha blending is needed
  20647. */
  20648. needAlphaBlending(): boolean;
  20649. /**
  20650. * Specifies if the mesh will require alpha blending
  20651. * @param mesh defines the mesh to check
  20652. * @returns a boolean specifying if alpha blending is needed for the mesh
  20653. */
  20654. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20655. /**
  20656. * Specifies if this material should be rendered in alpha test mode
  20657. * @returns a boolean specifying if an alpha test is needed.
  20658. */
  20659. needAlphaTesting(): boolean;
  20660. /**
  20661. * Gets the texture used for the alpha test
  20662. * @returns the texture to use for alpha testing
  20663. */
  20664. getAlphaTestTexture(): Nullable<BaseTexture>;
  20665. /**
  20666. * Marks the material to indicate that it needs to be re-calculated
  20667. */
  20668. markDirty(): void;
  20669. /** @hidden */
  20670. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20671. /**
  20672. * Binds the material to the mesh
  20673. * @param world defines the world transformation matrix
  20674. * @param mesh defines the mesh to bind the material to
  20675. */
  20676. bind(world: Matrix, mesh?: Mesh): void;
  20677. /**
  20678. * Binds the submesh to the material
  20679. * @param world defines the world transformation matrix
  20680. * @param mesh defines the mesh containing the submesh
  20681. * @param subMesh defines the submesh to bind the material to
  20682. */
  20683. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20684. /**
  20685. * Binds the world matrix to the material
  20686. * @param world defines the world transformation matrix
  20687. */
  20688. bindOnlyWorldMatrix(world: Matrix): void;
  20689. /**
  20690. * Binds the scene's uniform buffer to the effect.
  20691. * @param effect defines the effect to bind to the scene uniform buffer
  20692. * @param sceneUbo defines the uniform buffer storing scene data
  20693. */
  20694. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20695. /**
  20696. * Binds the view matrix to the effect
  20697. * @param effect defines the effect to bind the view matrix to
  20698. */
  20699. bindView(effect: Effect): void;
  20700. /**
  20701. * Binds the view projection matrix to the effect
  20702. * @param effect defines the effect to bind the view projection matrix to
  20703. */
  20704. bindViewProjection(effect: Effect): void;
  20705. /**
  20706. * Specifies if material alpha testing should be turned on for the mesh
  20707. * @param mesh defines the mesh to check
  20708. */
  20709. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20710. /**
  20711. * Processes to execute after binding the material to a mesh
  20712. * @param mesh defines the rendered mesh
  20713. */
  20714. protected _afterBind(mesh?: Mesh): void;
  20715. /**
  20716. * Unbinds the material from the mesh
  20717. */
  20718. unbind(): void;
  20719. /**
  20720. * Gets the active textures from the material
  20721. * @returns an array of textures
  20722. */
  20723. getActiveTextures(): BaseTexture[];
  20724. /**
  20725. * Specifies if the material uses a texture
  20726. * @param texture defines the texture to check against the material
  20727. * @returns a boolean specifying if the material uses the texture
  20728. */
  20729. hasTexture(texture: BaseTexture): boolean;
  20730. /**
  20731. * Makes a duplicate of the material, and gives it a new name
  20732. * @param name defines the new name for the duplicated material
  20733. * @returns the cloned material
  20734. */
  20735. clone(name: string): Nullable<Material>;
  20736. /**
  20737. * Gets the meshes bound to the material
  20738. * @returns an array of meshes bound to the material
  20739. */
  20740. getBindedMeshes(): AbstractMesh[];
  20741. /**
  20742. * Force shader compilation
  20743. * @param mesh defines the mesh associated with this material
  20744. * @param onCompiled defines a function to execute once the material is compiled
  20745. * @param options defines the options to configure the compilation
  20746. * @param onError defines a function to execute if the material fails compiling
  20747. */
  20748. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  20749. /**
  20750. * Force shader compilation
  20751. * @param mesh defines the mesh that will use this material
  20752. * @param options defines additional options for compiling the shaders
  20753. * @returns a promise that resolves when the compilation completes
  20754. */
  20755. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  20756. private static readonly _AllDirtyCallBack;
  20757. private static readonly _ImageProcessingDirtyCallBack;
  20758. private static readonly _TextureDirtyCallBack;
  20759. private static readonly _FresnelDirtyCallBack;
  20760. private static readonly _MiscDirtyCallBack;
  20761. private static readonly _LightsDirtyCallBack;
  20762. private static readonly _AttributeDirtyCallBack;
  20763. private static _FresnelAndMiscDirtyCallBack;
  20764. private static _TextureAndMiscDirtyCallBack;
  20765. private static readonly _DirtyCallbackArray;
  20766. private static readonly _RunDirtyCallBacks;
  20767. /**
  20768. * Marks a define in the material to indicate that it needs to be re-computed
  20769. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20770. */
  20771. markAsDirty(flag: number): void;
  20772. /**
  20773. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20774. * @param func defines a function which checks material defines against the submeshes
  20775. */
  20776. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20777. /**
  20778. * Indicates that we need to re-calculated for all submeshes
  20779. */
  20780. protected _markAllSubMeshesAsAllDirty(): void;
  20781. /**
  20782. * Indicates that image processing needs to be re-calculated for all submeshes
  20783. */
  20784. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20785. /**
  20786. * Indicates that textures need to be re-calculated for all submeshes
  20787. */
  20788. protected _markAllSubMeshesAsTexturesDirty(): void;
  20789. /**
  20790. * Indicates that fresnel needs to be re-calculated for all submeshes
  20791. */
  20792. protected _markAllSubMeshesAsFresnelDirty(): void;
  20793. /**
  20794. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20795. */
  20796. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20797. /**
  20798. * Indicates that lights need to be re-calculated for all submeshes
  20799. */
  20800. protected _markAllSubMeshesAsLightsDirty(): void;
  20801. /**
  20802. * Indicates that attributes need to be re-calculated for all submeshes
  20803. */
  20804. protected _markAllSubMeshesAsAttributesDirty(): void;
  20805. /**
  20806. * Indicates that misc needs to be re-calculated for all submeshes
  20807. */
  20808. protected _markAllSubMeshesAsMiscDirty(): void;
  20809. /**
  20810. * Indicates that textures and misc need to be re-calculated for all submeshes
  20811. */
  20812. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20813. /**
  20814. * Disposes the material
  20815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20816. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20817. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20818. */
  20819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20820. /** @hidden */
  20821. private releaseVertexArrayObject;
  20822. /**
  20823. * Serializes this material
  20824. * @returns the serialized material object
  20825. */
  20826. serialize(): any;
  20827. /**
  20828. * Creates a material from parsed material data
  20829. * @param parsedMaterial defines parsed material data
  20830. * @param scene defines the hosting scene
  20831. * @param rootUrl defines the root URL to use to load textures
  20832. * @returns a new material
  20833. */
  20834. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20835. }
  20836. }
  20837. declare module BABYLON {
  20838. /**
  20839. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20840. * separate meshes. This can be use to improve performances.
  20841. * @see http://doc.babylonjs.com/how_to/multi_materials
  20842. */
  20843. export class MultiMaterial extends Material {
  20844. private _subMaterials;
  20845. /**
  20846. * Gets or Sets the list of Materials used within the multi material.
  20847. * They need to be ordered according to the submeshes order in the associated mesh
  20848. */
  20849. subMaterials: Nullable<Material>[];
  20850. /**
  20851. * Function used to align with Node.getChildren()
  20852. * @returns the list of Materials used within the multi material
  20853. */
  20854. getChildren(): Nullable<Material>[];
  20855. /**
  20856. * Instantiates a new Multi Material
  20857. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20858. * separate meshes. This can be use to improve performances.
  20859. * @see http://doc.babylonjs.com/how_to/multi_materials
  20860. * @param name Define the name in the scene
  20861. * @param scene Define the scene the material belongs to
  20862. */
  20863. constructor(name: string, scene: Scene);
  20864. private _hookArray;
  20865. /**
  20866. * Get one of the submaterial by its index in the submaterials array
  20867. * @param index The index to look the sub material at
  20868. * @returns The Material if the index has been defined
  20869. */
  20870. getSubMaterial(index: number): Nullable<Material>;
  20871. /**
  20872. * Get the list of active textures for the whole sub materials list.
  20873. * @returns All the textures that will be used during the rendering
  20874. */
  20875. getActiveTextures(): BaseTexture[];
  20876. /**
  20877. * Gets the current class name of the material e.g. "MultiMaterial"
  20878. * Mainly use in serialization.
  20879. * @returns the class name
  20880. */
  20881. getClassName(): string;
  20882. /**
  20883. * Checks if the material is ready to render the requested sub mesh
  20884. * @param mesh Define the mesh the submesh belongs to
  20885. * @param subMesh Define the sub mesh to look readyness for
  20886. * @param useInstances Define whether or not the material is used with instances
  20887. * @returns true if ready, otherwise false
  20888. */
  20889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20890. /**
  20891. * Clones the current material and its related sub materials
  20892. * @param name Define the name of the newly cloned material
  20893. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20894. * @returns the cloned material
  20895. */
  20896. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20897. /**
  20898. * Serializes the materials into a JSON representation.
  20899. * @returns the JSON representation
  20900. */
  20901. serialize(): any;
  20902. /**
  20903. * Dispose the material and release its associated resources
  20904. * @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)
  20905. * @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)
  20906. * @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)
  20907. */
  20908. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20909. /**
  20910. * Creates a MultiMaterial from parsed MultiMaterial data.
  20911. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20912. * @param scene defines the hosting scene
  20913. * @returns a new MultiMaterial
  20914. */
  20915. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20916. }
  20917. }
  20918. declare module BABYLON {
  20919. /**
  20920. * Base class for submeshes
  20921. */
  20922. export class BaseSubMesh {
  20923. /** @hidden */
  20924. _materialDefines: Nullable<MaterialDefines>;
  20925. /** @hidden */
  20926. _materialEffect: Nullable<Effect>;
  20927. /**
  20928. * Gets associated effect
  20929. */
  20930. readonly effect: Nullable<Effect>;
  20931. /**
  20932. * Sets associated effect (effect used to render this submesh)
  20933. * @param effect defines the effect to associate with
  20934. * @param defines defines the set of defines used to compile this effect
  20935. */
  20936. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20937. }
  20938. /**
  20939. * Defines a subdivision inside a mesh
  20940. */
  20941. export class SubMesh extends BaseSubMesh implements ICullable {
  20942. /** the material index to use */
  20943. materialIndex: number;
  20944. /** vertex index start */
  20945. verticesStart: number;
  20946. /** vertices count */
  20947. verticesCount: number;
  20948. /** index start */
  20949. indexStart: number;
  20950. /** indices count */
  20951. indexCount: number;
  20952. /** @hidden */
  20953. _linesIndexCount: number;
  20954. private _mesh;
  20955. private _renderingMesh;
  20956. private _boundingInfo;
  20957. private _linesIndexBuffer;
  20958. /** @hidden */
  20959. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20960. /** @hidden */
  20961. _trianglePlanes: Plane[];
  20962. /** @hidden */
  20963. _lastColliderTransformMatrix: Nullable<Matrix>;
  20964. /** @hidden */
  20965. _renderId: number;
  20966. /** @hidden */
  20967. _alphaIndex: number;
  20968. /** @hidden */
  20969. _distanceToCamera: number;
  20970. /** @hidden */
  20971. _id: number;
  20972. private _currentMaterial;
  20973. /**
  20974. * Add a new submesh to a mesh
  20975. * @param materialIndex defines the material index to use
  20976. * @param verticesStart defines vertex index start
  20977. * @param verticesCount defines vertices count
  20978. * @param indexStart defines index start
  20979. * @param indexCount defines indices count
  20980. * @param mesh defines the parent mesh
  20981. * @param renderingMesh defines an optional rendering mesh
  20982. * @param createBoundingBox defines if bounding box should be created for this submesh
  20983. * @returns the new submesh
  20984. */
  20985. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20986. /**
  20987. * Creates a new submesh
  20988. * @param materialIndex defines the material index to use
  20989. * @param verticesStart defines vertex index start
  20990. * @param verticesCount defines vertices count
  20991. * @param indexStart defines index start
  20992. * @param indexCount defines indices count
  20993. * @param mesh defines the parent mesh
  20994. * @param renderingMesh defines an optional rendering mesh
  20995. * @param createBoundingBox defines if bounding box should be created for this submesh
  20996. */
  20997. constructor(
  20998. /** the material index to use */
  20999. materialIndex: number,
  21000. /** vertex index start */
  21001. verticesStart: number,
  21002. /** vertices count */
  21003. verticesCount: number,
  21004. /** index start */
  21005. indexStart: number,
  21006. /** indices count */
  21007. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21008. /**
  21009. * Returns true if this submesh covers the entire parent mesh
  21010. * @ignorenaming
  21011. */
  21012. readonly IsGlobal: boolean;
  21013. /**
  21014. * Returns the submesh BoudingInfo object
  21015. * @returns current bounding info (or mesh's one if the submesh is global)
  21016. */
  21017. getBoundingInfo(): BoundingInfo;
  21018. /**
  21019. * Sets the submesh BoundingInfo
  21020. * @param boundingInfo defines the new bounding info to use
  21021. * @returns the SubMesh
  21022. */
  21023. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21024. /**
  21025. * Returns the mesh of the current submesh
  21026. * @return the parent mesh
  21027. */
  21028. getMesh(): AbstractMesh;
  21029. /**
  21030. * Returns the rendering mesh of the submesh
  21031. * @returns the rendering mesh (could be different from parent mesh)
  21032. */
  21033. getRenderingMesh(): Mesh;
  21034. /**
  21035. * Returns the submesh material
  21036. * @returns null or the current material
  21037. */
  21038. getMaterial(): Nullable<Material>;
  21039. /**
  21040. * Sets a new updated BoundingInfo object to the submesh
  21041. * @param data defines an optional position array to use to determine the bounding info
  21042. * @returns the SubMesh
  21043. */
  21044. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21045. /** @hidden */
  21046. _checkCollision(collider: Collider): boolean;
  21047. /**
  21048. * Updates the submesh BoundingInfo
  21049. * @param world defines the world matrix to use to update the bounding info
  21050. * @returns the submesh
  21051. */
  21052. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21053. /**
  21054. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21055. * @param frustumPlanes defines the frustum planes
  21056. * @returns true if the submesh is intersecting with the frustum
  21057. */
  21058. isInFrustum(frustumPlanes: Plane[]): boolean;
  21059. /**
  21060. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21061. * @param frustumPlanes defines the frustum planes
  21062. * @returns true if the submesh is inside the frustum
  21063. */
  21064. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21065. /**
  21066. * Renders the submesh
  21067. * @param enableAlphaMode defines if alpha needs to be used
  21068. * @returns the submesh
  21069. */
  21070. render(enableAlphaMode: boolean): SubMesh;
  21071. /**
  21072. * @hidden
  21073. */
  21074. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21075. /**
  21076. * Checks if the submesh intersects with a ray
  21077. * @param ray defines the ray to test
  21078. * @returns true is the passed ray intersects the submesh bounding box
  21079. */
  21080. canIntersects(ray: Ray): boolean;
  21081. /**
  21082. * Intersects current submesh with a ray
  21083. * @param ray defines the ray to test
  21084. * @param positions defines mesh's positions array
  21085. * @param indices defines mesh's indices array
  21086. * @param fastCheck defines if only bounding info should be used
  21087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21088. * @returns intersection info or null if no intersection
  21089. */
  21090. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21091. /** @hidden */
  21092. private _intersectLines;
  21093. /** @hidden */
  21094. private _intersectUnIndexedLines;
  21095. /** @hidden */
  21096. private _intersectTriangles;
  21097. /** @hidden */
  21098. private _intersectUnIndexedTriangles;
  21099. /** @hidden */
  21100. _rebuild(): void;
  21101. /**
  21102. * Creates a new submesh from the passed mesh
  21103. * @param newMesh defines the new hosting mesh
  21104. * @param newRenderingMesh defines an optional rendering mesh
  21105. * @returns the new submesh
  21106. */
  21107. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21108. /**
  21109. * Release associated resources
  21110. */
  21111. dispose(): void;
  21112. /**
  21113. * Gets the class name
  21114. * @returns the string "SubMesh".
  21115. */
  21116. getClassName(): string;
  21117. /**
  21118. * Creates a new submesh from indices data
  21119. * @param materialIndex the index of the main mesh material
  21120. * @param startIndex the index where to start the copy in the mesh indices array
  21121. * @param indexCount the number of indices to copy then from the startIndex
  21122. * @param mesh the main mesh to create the submesh from
  21123. * @param renderingMesh the optional rendering mesh
  21124. * @returns a new submesh
  21125. */
  21126. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21127. }
  21128. }
  21129. declare module BABYLON {
  21130. /**
  21131. * Class used to represent data loading progression
  21132. */
  21133. export class SceneLoaderFlags {
  21134. private static _ForceFullSceneLoadingForIncremental;
  21135. private static _ShowLoadingScreen;
  21136. private static _CleanBoneMatrixWeights;
  21137. private static _loggingLevel;
  21138. /**
  21139. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21140. */
  21141. static ForceFullSceneLoadingForIncremental: boolean;
  21142. /**
  21143. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21144. */
  21145. static ShowLoadingScreen: boolean;
  21146. /**
  21147. * Defines the current logging level (while loading the scene)
  21148. * @ignorenaming
  21149. */
  21150. static loggingLevel: number;
  21151. /**
  21152. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21153. */
  21154. static CleanBoneMatrixWeights: boolean;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class used to store geometry data (vertex buffers + index buffer)
  21160. */
  21161. export class Geometry implements IGetSetVerticesData {
  21162. /**
  21163. * Gets or sets the ID of the geometry
  21164. */
  21165. id: string;
  21166. /**
  21167. * Gets or sets the unique ID of the geometry
  21168. */
  21169. uniqueId: number;
  21170. /**
  21171. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21172. */
  21173. delayLoadState: number;
  21174. /**
  21175. * Gets the file containing the data to load when running in delay load state
  21176. */
  21177. delayLoadingFile: Nullable<string>;
  21178. /**
  21179. * Callback called when the geometry is updated
  21180. */
  21181. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21182. private _scene;
  21183. private _engine;
  21184. private _meshes;
  21185. private _totalVertices;
  21186. /** @hidden */
  21187. _indices: IndicesArray;
  21188. /** @hidden */
  21189. _vertexBuffers: {
  21190. [key: string]: VertexBuffer;
  21191. };
  21192. private _isDisposed;
  21193. private _extend;
  21194. private _boundingBias;
  21195. /** @hidden */
  21196. _delayInfo: Array<string>;
  21197. private _indexBuffer;
  21198. private _indexBufferIsUpdatable;
  21199. /** @hidden */
  21200. _boundingInfo: Nullable<BoundingInfo>;
  21201. /** @hidden */
  21202. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21203. /** @hidden */
  21204. _softwareSkinningFrameId: number;
  21205. private _vertexArrayObjects;
  21206. private _updatable;
  21207. /** @hidden */
  21208. _positions: Nullable<Vector3[]>;
  21209. /**
  21210. * 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
  21211. */
  21212. /**
  21213. * 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
  21214. */
  21215. boundingBias: Vector2;
  21216. /**
  21217. * Static function used to attach a new empty geometry to a mesh
  21218. * @param mesh defines the mesh to attach the geometry to
  21219. * @returns the new Geometry
  21220. */
  21221. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21222. /**
  21223. * Creates a new geometry
  21224. * @param id defines the unique ID
  21225. * @param scene defines the hosting scene
  21226. * @param vertexData defines the VertexData used to get geometry data
  21227. * @param updatable defines if geometry must be updatable (false by default)
  21228. * @param mesh defines the mesh that will be associated with the geometry
  21229. */
  21230. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21231. /**
  21232. * Gets the current extend of the geometry
  21233. */
  21234. readonly extend: {
  21235. minimum: Vector3;
  21236. maximum: Vector3;
  21237. };
  21238. /**
  21239. * Gets the hosting scene
  21240. * @returns the hosting Scene
  21241. */
  21242. getScene(): Scene;
  21243. /**
  21244. * Gets the hosting engine
  21245. * @returns the hosting Engine
  21246. */
  21247. getEngine(): Engine;
  21248. /**
  21249. * Defines if the geometry is ready to use
  21250. * @returns true if the geometry is ready to be used
  21251. */
  21252. isReady(): boolean;
  21253. /**
  21254. * Gets a value indicating that the geometry should not be serialized
  21255. */
  21256. readonly doNotSerialize: boolean;
  21257. /** @hidden */
  21258. _rebuild(): void;
  21259. /**
  21260. * Affects all geometry data in one call
  21261. * @param vertexData defines the geometry data
  21262. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21263. */
  21264. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21265. /**
  21266. * Set specific vertex data
  21267. * @param kind defines the data kind (Position, normal, etc...)
  21268. * @param data defines the vertex data to use
  21269. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21270. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21271. */
  21272. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21273. /**
  21274. * Removes a specific vertex data
  21275. * @param kind defines the data kind (Position, normal, etc...)
  21276. */
  21277. removeVerticesData(kind: string): void;
  21278. /**
  21279. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21280. * @param buffer defines the vertex buffer to use
  21281. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21282. */
  21283. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21284. /**
  21285. * Update a specific vertex buffer
  21286. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21287. * It will do nothing if the buffer is not updatable
  21288. * @param kind defines the data kind (Position, normal, etc...)
  21289. * @param data defines the data to use
  21290. * @param offset defines the offset in the target buffer where to store the data
  21291. * @param useBytes set to true if the offset is in bytes
  21292. */
  21293. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21294. /**
  21295. * Update a specific vertex buffer
  21296. * This function will create a new buffer if the current one is not updatable
  21297. * @param kind defines the data kind (Position, normal, etc...)
  21298. * @param data defines the data to use
  21299. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21300. */
  21301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21302. private _updateBoundingInfo;
  21303. /** @hidden */
  21304. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21305. /**
  21306. * Gets total number of vertices
  21307. * @returns the total number of vertices
  21308. */
  21309. getTotalVertices(): number;
  21310. /**
  21311. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21312. * @param kind defines the data kind (Position, normal, etc...)
  21313. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21314. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21315. * @returns a float array containing vertex data
  21316. */
  21317. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21318. /**
  21319. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21320. * @param kind defines the data kind (Position, normal, etc...)
  21321. * @returns true if the vertex buffer with the specified kind is updatable
  21322. */
  21323. isVertexBufferUpdatable(kind: string): boolean;
  21324. /**
  21325. * Gets a specific vertex buffer
  21326. * @param kind defines the data kind (Position, normal, etc...)
  21327. * @returns a VertexBuffer
  21328. */
  21329. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21330. /**
  21331. * Returns all vertex buffers
  21332. * @return an object holding all vertex buffers indexed by kind
  21333. */
  21334. getVertexBuffers(): Nullable<{
  21335. [key: string]: VertexBuffer;
  21336. }>;
  21337. /**
  21338. * Gets a boolean indicating if specific vertex buffer is present
  21339. * @param kind defines the data kind (Position, normal, etc...)
  21340. * @returns true if data is present
  21341. */
  21342. isVerticesDataPresent(kind: string): boolean;
  21343. /**
  21344. * Gets a list of all attached data kinds (Position, normal, etc...)
  21345. * @returns a list of string containing all kinds
  21346. */
  21347. getVerticesDataKinds(): string[];
  21348. /**
  21349. * Update index buffer
  21350. * @param indices defines the indices to store in the index buffer
  21351. * @param offset defines the offset in the target buffer where to store the data
  21352. * @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)
  21353. */
  21354. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21355. /**
  21356. * Creates a new index buffer
  21357. * @param indices defines the indices to store in the index buffer
  21358. * @param totalVertices defines the total number of vertices (could be null)
  21359. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21360. */
  21361. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21362. /**
  21363. * Return the total number of indices
  21364. * @returns the total number of indices
  21365. */
  21366. getTotalIndices(): number;
  21367. /**
  21368. * Gets the index buffer array
  21369. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21371. * @returns the index buffer array
  21372. */
  21373. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21374. /**
  21375. * Gets the index buffer
  21376. * @return the index buffer
  21377. */
  21378. getIndexBuffer(): Nullable<DataBuffer>;
  21379. /** @hidden */
  21380. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21381. /**
  21382. * Release the associated resources for a specific mesh
  21383. * @param mesh defines the source mesh
  21384. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21385. */
  21386. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21387. /**
  21388. * Apply current geometry to a given mesh
  21389. * @param mesh defines the mesh to apply geometry to
  21390. */
  21391. applyToMesh(mesh: Mesh): void;
  21392. private _updateExtend;
  21393. private _applyToMesh;
  21394. private notifyUpdate;
  21395. /**
  21396. * Load the geometry if it was flagged as delay loaded
  21397. * @param scene defines the hosting scene
  21398. * @param onLoaded defines a callback called when the geometry is loaded
  21399. */
  21400. load(scene: Scene, onLoaded?: () => void): void;
  21401. private _queueLoad;
  21402. /**
  21403. * Invert the geometry to move from a right handed system to a left handed one.
  21404. */
  21405. toLeftHanded(): void;
  21406. /** @hidden */
  21407. _resetPointsArrayCache(): void;
  21408. /** @hidden */
  21409. _generatePointsArray(): boolean;
  21410. /**
  21411. * Gets a value indicating if the geometry is disposed
  21412. * @returns true if the geometry was disposed
  21413. */
  21414. isDisposed(): boolean;
  21415. private _disposeVertexArrayObjects;
  21416. /**
  21417. * Free all associated resources
  21418. */
  21419. dispose(): void;
  21420. /**
  21421. * Clone the current geometry into a new geometry
  21422. * @param id defines the unique ID of the new geometry
  21423. * @returns a new geometry object
  21424. */
  21425. copy(id: string): Geometry;
  21426. /**
  21427. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21428. * @return a JSON representation of the current geometry data (without the vertices data)
  21429. */
  21430. serialize(): any;
  21431. private toNumberArray;
  21432. /**
  21433. * Serialize all vertices data into a JSON oject
  21434. * @returns a JSON representation of the current geometry data
  21435. */
  21436. serializeVerticeData(): any;
  21437. /**
  21438. * Extracts a clone of a mesh geometry
  21439. * @param mesh defines the source mesh
  21440. * @param id defines the unique ID of the new geometry object
  21441. * @returns the new geometry object
  21442. */
  21443. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21444. /**
  21445. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21446. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21447. * Be aware Math.random() could cause collisions, but:
  21448. * "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"
  21449. * @returns a string containing a new GUID
  21450. */
  21451. static RandomId(): string;
  21452. /** @hidden */
  21453. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21454. private static _CleanMatricesWeights;
  21455. /**
  21456. * Create a new geometry from persisted data (Using .babylon file format)
  21457. * @param parsedVertexData defines the persisted data
  21458. * @param scene defines the hosting scene
  21459. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21460. * @returns the new geometry object
  21461. */
  21462. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21463. }
  21464. }
  21465. declare module BABYLON {
  21466. /**
  21467. * Define an interface for all classes that will get and set the data on vertices
  21468. */
  21469. export interface IGetSetVerticesData {
  21470. /**
  21471. * Gets a boolean indicating if specific vertex data is present
  21472. * @param kind defines the vertex data kind to use
  21473. * @returns true is data kind is present
  21474. */
  21475. isVerticesDataPresent(kind: string): boolean;
  21476. /**
  21477. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21478. * @param kind defines the data kind (Position, normal, etc...)
  21479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21481. * @returns a float array containing vertex data
  21482. */
  21483. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21484. /**
  21485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21486. * @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.
  21487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21488. * @returns the indices array or an empty array if the mesh has no geometry
  21489. */
  21490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21491. /**
  21492. * Set specific vertex data
  21493. * @param kind defines the data kind (Position, normal, etc...)
  21494. * @param data defines the vertex data to use
  21495. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21496. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21497. */
  21498. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21499. /**
  21500. * Update a specific associated vertex buffer
  21501. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21502. * - VertexBuffer.PositionKind
  21503. * - VertexBuffer.UVKind
  21504. * - VertexBuffer.UV2Kind
  21505. * - VertexBuffer.UV3Kind
  21506. * - VertexBuffer.UV4Kind
  21507. * - VertexBuffer.UV5Kind
  21508. * - VertexBuffer.UV6Kind
  21509. * - VertexBuffer.ColorKind
  21510. * - VertexBuffer.MatricesIndicesKind
  21511. * - VertexBuffer.MatricesIndicesExtraKind
  21512. * - VertexBuffer.MatricesWeightsKind
  21513. * - VertexBuffer.MatricesWeightsExtraKind
  21514. * @param data defines the data source
  21515. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21516. * @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)
  21517. */
  21518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21519. /**
  21520. * Creates a new index buffer
  21521. * @param indices defines the indices to store in the index buffer
  21522. * @param totalVertices defines the total number of vertices (could be null)
  21523. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21524. */
  21525. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21526. }
  21527. /**
  21528. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21529. */
  21530. export class VertexData {
  21531. /**
  21532. * Mesh side orientation : usually the external or front surface
  21533. */
  21534. static readonly FRONTSIDE: number;
  21535. /**
  21536. * Mesh side orientation : usually the internal or back surface
  21537. */
  21538. static readonly BACKSIDE: number;
  21539. /**
  21540. * Mesh side orientation : both internal and external or front and back surfaces
  21541. */
  21542. static readonly DOUBLESIDE: number;
  21543. /**
  21544. * Mesh side orientation : by default, `FRONTSIDE`
  21545. */
  21546. static readonly DEFAULTSIDE: number;
  21547. /**
  21548. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21549. */
  21550. positions: Nullable<FloatArray>;
  21551. /**
  21552. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21553. */
  21554. normals: Nullable<FloatArray>;
  21555. /**
  21556. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21557. */
  21558. tangents: Nullable<FloatArray>;
  21559. /**
  21560. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21561. */
  21562. uvs: Nullable<FloatArray>;
  21563. /**
  21564. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21565. */
  21566. uvs2: Nullable<FloatArray>;
  21567. /**
  21568. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21569. */
  21570. uvs3: Nullable<FloatArray>;
  21571. /**
  21572. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21573. */
  21574. uvs4: Nullable<FloatArray>;
  21575. /**
  21576. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21577. */
  21578. uvs5: Nullable<FloatArray>;
  21579. /**
  21580. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21581. */
  21582. uvs6: Nullable<FloatArray>;
  21583. /**
  21584. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21585. */
  21586. colors: Nullable<FloatArray>;
  21587. /**
  21588. * 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).
  21589. */
  21590. matricesIndices: Nullable<FloatArray>;
  21591. /**
  21592. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21593. */
  21594. matricesWeights: Nullable<FloatArray>;
  21595. /**
  21596. * An array extending the number of possible indices
  21597. */
  21598. matricesIndicesExtra: Nullable<FloatArray>;
  21599. /**
  21600. * An array extending the number of possible weights when the number of indices is extended
  21601. */
  21602. matricesWeightsExtra: Nullable<FloatArray>;
  21603. /**
  21604. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21605. */
  21606. indices: Nullable<IndicesArray>;
  21607. /**
  21608. * Uses the passed data array to set the set the values for the specified kind of data
  21609. * @param data a linear array of floating numbers
  21610. * @param kind the type of data that is being set, eg positions, colors etc
  21611. */
  21612. set(data: FloatArray, kind: string): void;
  21613. /**
  21614. * Associates the vertexData to the passed Mesh.
  21615. * Sets it as updatable or not (default `false`)
  21616. * @param mesh the mesh the vertexData is applied to
  21617. * @param updatable when used and having the value true allows new data to update the vertexData
  21618. * @returns the VertexData
  21619. */
  21620. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21621. /**
  21622. * Associates the vertexData to the passed Geometry.
  21623. * Sets it as updatable or not (default `false`)
  21624. * @param geometry the geometry the vertexData is applied to
  21625. * @param updatable when used and having the value true allows new data to update the vertexData
  21626. * @returns VertexData
  21627. */
  21628. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21629. /**
  21630. * Updates the associated mesh
  21631. * @param mesh the mesh to be updated
  21632. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21633. * @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
  21634. * @returns VertexData
  21635. */
  21636. updateMesh(mesh: Mesh): VertexData;
  21637. /**
  21638. * Updates the associated geometry
  21639. * @param geometry the geometry to be updated
  21640. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21641. * @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
  21642. * @returns VertexData.
  21643. */
  21644. updateGeometry(geometry: Geometry): VertexData;
  21645. private _applyTo;
  21646. private _update;
  21647. /**
  21648. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21649. * @param matrix the transforming matrix
  21650. * @returns the VertexData
  21651. */
  21652. transform(matrix: Matrix): VertexData;
  21653. /**
  21654. * Merges the passed VertexData into the current one
  21655. * @param other the VertexData to be merged into the current one
  21656. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21657. * @returns the modified VertexData
  21658. */
  21659. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21660. private _mergeElement;
  21661. private _validate;
  21662. /**
  21663. * Serializes the VertexData
  21664. * @returns a serialized object
  21665. */
  21666. serialize(): any;
  21667. /**
  21668. * Extracts the vertexData from a mesh
  21669. * @param mesh the mesh from which to extract the VertexData
  21670. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21671. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21672. * @returns the object VertexData associated to the passed mesh
  21673. */
  21674. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21675. /**
  21676. * Extracts the vertexData from the geometry
  21677. * @param geometry the geometry from which to extract the VertexData
  21678. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21679. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21680. * @returns the object VertexData associated to the passed mesh
  21681. */
  21682. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21683. private static _ExtractFrom;
  21684. /**
  21685. * Creates the VertexData for a Ribbon
  21686. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21687. * * pathArray array of paths, each of which an array of successive Vector3
  21688. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21689. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21690. * * 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
  21691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21692. * * 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)
  21693. * * 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)
  21694. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21695. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21696. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21697. * @returns the VertexData of the ribbon
  21698. */
  21699. static CreateRibbon(options: {
  21700. pathArray: Vector3[][];
  21701. closeArray?: boolean;
  21702. closePath?: boolean;
  21703. offset?: number;
  21704. sideOrientation?: number;
  21705. frontUVs?: Vector4;
  21706. backUVs?: Vector4;
  21707. invertUV?: boolean;
  21708. uvs?: Vector2[];
  21709. colors?: Color4[];
  21710. }): VertexData;
  21711. /**
  21712. * Creates the VertexData for a box
  21713. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21714. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21715. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21716. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21717. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21718. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21719. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21721. * * 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)
  21722. * * 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)
  21723. * @returns the VertexData of the box
  21724. */
  21725. static CreateBox(options: {
  21726. size?: number;
  21727. width?: number;
  21728. height?: number;
  21729. depth?: number;
  21730. faceUV?: Vector4[];
  21731. faceColors?: Color4[];
  21732. sideOrientation?: number;
  21733. frontUVs?: Vector4;
  21734. backUVs?: Vector4;
  21735. }): VertexData;
  21736. /**
  21737. * Creates the VertexData for a tiled box
  21738. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21739. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21740. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21741. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21743. * @returns the VertexData of the box
  21744. */
  21745. static CreateTiledBox(options: {
  21746. pattern?: number;
  21747. width?: number;
  21748. height?: number;
  21749. depth?: number;
  21750. tileSize?: number;
  21751. tileWidth?: number;
  21752. tileHeight?: number;
  21753. alignHorizontal?: number;
  21754. alignVertical?: number;
  21755. faceUV?: Vector4[];
  21756. faceColors?: Color4[];
  21757. sideOrientation?: number;
  21758. }): VertexData;
  21759. /**
  21760. * Creates the VertexData for a tiled plane
  21761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21762. * * pattern a limited pattern arrangement depending on the number
  21763. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21764. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21765. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21767. * * 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)
  21768. * * 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)
  21769. * @returns the VertexData of the tiled plane
  21770. */
  21771. static CreateTiledPlane(options: {
  21772. pattern?: number;
  21773. tileSize?: number;
  21774. tileWidth?: number;
  21775. tileHeight?: number;
  21776. size?: number;
  21777. width?: number;
  21778. height?: number;
  21779. alignHorizontal?: number;
  21780. alignVertical?: number;
  21781. sideOrientation?: number;
  21782. frontUVs?: Vector4;
  21783. backUVs?: Vector4;
  21784. }): VertexData;
  21785. /**
  21786. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21788. * * segments sets the number of horizontal strips optional, default 32
  21789. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21790. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21791. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21792. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21793. * * 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
  21794. * * 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
  21795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21796. * * 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)
  21797. * * 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)
  21798. * @returns the VertexData of the ellipsoid
  21799. */
  21800. static CreateSphere(options: {
  21801. segments?: number;
  21802. diameter?: number;
  21803. diameterX?: number;
  21804. diameterY?: number;
  21805. diameterZ?: number;
  21806. arc?: number;
  21807. slice?: number;
  21808. sideOrientation?: number;
  21809. frontUVs?: Vector4;
  21810. backUVs?: Vector4;
  21811. }): VertexData;
  21812. /**
  21813. * Creates the VertexData for a cylinder, cone or prism
  21814. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21815. * * height sets the height (y direction) of the cylinder, optional, default 2
  21816. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21817. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21818. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21819. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21820. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21821. * * 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
  21822. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21823. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21824. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21825. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21827. * * 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)
  21828. * * 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)
  21829. * @returns the VertexData of the cylinder, cone or prism
  21830. */
  21831. static CreateCylinder(options: {
  21832. height?: number;
  21833. diameterTop?: number;
  21834. diameterBottom?: number;
  21835. diameter?: number;
  21836. tessellation?: number;
  21837. subdivisions?: number;
  21838. arc?: number;
  21839. faceColors?: Color4[];
  21840. faceUV?: Vector4[];
  21841. hasRings?: boolean;
  21842. enclose?: boolean;
  21843. sideOrientation?: number;
  21844. frontUVs?: Vector4;
  21845. backUVs?: Vector4;
  21846. }): VertexData;
  21847. /**
  21848. * Creates the VertexData for a torus
  21849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21850. * * diameter the diameter of the torus, optional default 1
  21851. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21852. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21854. * * 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)
  21855. * * 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)
  21856. * @returns the VertexData of the torus
  21857. */
  21858. static CreateTorus(options: {
  21859. diameter?: number;
  21860. thickness?: number;
  21861. tessellation?: number;
  21862. sideOrientation?: number;
  21863. frontUVs?: Vector4;
  21864. backUVs?: Vector4;
  21865. }): VertexData;
  21866. /**
  21867. * Creates the VertexData of the LineSystem
  21868. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21869. * - lines an array of lines, each line being an array of successive Vector3
  21870. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21871. * @returns the VertexData of the LineSystem
  21872. */
  21873. static CreateLineSystem(options: {
  21874. lines: Vector3[][];
  21875. colors?: Nullable<Color4[][]>;
  21876. }): VertexData;
  21877. /**
  21878. * Create the VertexData for a DashedLines
  21879. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21880. * - points an array successive Vector3
  21881. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21882. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21883. * - dashNb the intended total number of dashes, optional, default 200
  21884. * @returns the VertexData for the DashedLines
  21885. */
  21886. static CreateDashedLines(options: {
  21887. points: Vector3[];
  21888. dashSize?: number;
  21889. gapSize?: number;
  21890. dashNb?: number;
  21891. }): VertexData;
  21892. /**
  21893. * Creates the VertexData for a Ground
  21894. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21895. * - width the width (x direction) of the ground, optional, default 1
  21896. * - height the height (z direction) of the ground, optional, default 1
  21897. * - subdivisions the number of subdivisions per side, optional, default 1
  21898. * @returns the VertexData of the Ground
  21899. */
  21900. static CreateGround(options: {
  21901. width?: number;
  21902. height?: number;
  21903. subdivisions?: number;
  21904. subdivisionsX?: number;
  21905. subdivisionsY?: number;
  21906. }): VertexData;
  21907. /**
  21908. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21909. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21910. * * xmin the ground minimum X coordinate, optional, default -1
  21911. * * zmin the ground minimum Z coordinate, optional, default -1
  21912. * * xmax the ground maximum X coordinate, optional, default 1
  21913. * * zmax the ground maximum Z coordinate, optional, default 1
  21914. * * 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}
  21915. * * 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}
  21916. * @returns the VertexData of the TiledGround
  21917. */
  21918. static CreateTiledGround(options: {
  21919. xmin: number;
  21920. zmin: number;
  21921. xmax: number;
  21922. zmax: number;
  21923. subdivisions?: {
  21924. w: number;
  21925. h: number;
  21926. };
  21927. precision?: {
  21928. w: number;
  21929. h: number;
  21930. };
  21931. }): VertexData;
  21932. /**
  21933. * Creates the VertexData of the Ground designed from a heightmap
  21934. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21935. * * width the width (x direction) of the ground
  21936. * * height the height (z direction) of the ground
  21937. * * subdivisions the number of subdivisions per side
  21938. * * minHeight the minimum altitude on the ground, optional, default 0
  21939. * * maxHeight the maximum altitude on the ground, optional default 1
  21940. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21941. * * buffer the array holding the image color data
  21942. * * bufferWidth the width of image
  21943. * * bufferHeight the height of image
  21944. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21945. * @returns the VertexData of the Ground designed from a heightmap
  21946. */
  21947. static CreateGroundFromHeightMap(options: {
  21948. width: number;
  21949. height: number;
  21950. subdivisions: number;
  21951. minHeight: number;
  21952. maxHeight: number;
  21953. colorFilter: Color3;
  21954. buffer: Uint8Array;
  21955. bufferWidth: number;
  21956. bufferHeight: number;
  21957. alphaFilter: number;
  21958. }): VertexData;
  21959. /**
  21960. * Creates the VertexData for a Plane
  21961. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21962. * * size sets the width and height of the plane to the value of size, optional default 1
  21963. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21964. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21966. * * 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)
  21967. * * 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)
  21968. * @returns the VertexData of the box
  21969. */
  21970. static CreatePlane(options: {
  21971. size?: number;
  21972. width?: number;
  21973. height?: number;
  21974. sideOrientation?: number;
  21975. frontUVs?: Vector4;
  21976. backUVs?: Vector4;
  21977. }): VertexData;
  21978. /**
  21979. * Creates the VertexData of the Disc or regular Polygon
  21980. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21981. * * radius the radius of the disc, optional default 0.5
  21982. * * tessellation the number of polygon sides, optional, default 64
  21983. * * 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
  21984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21985. * * 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)
  21986. * * 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)
  21987. * @returns the VertexData of the box
  21988. */
  21989. static CreateDisc(options: {
  21990. radius?: number;
  21991. tessellation?: number;
  21992. arc?: number;
  21993. sideOrientation?: number;
  21994. frontUVs?: Vector4;
  21995. backUVs?: Vector4;
  21996. }): VertexData;
  21997. /**
  21998. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21999. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22000. * @param polygon a mesh built from polygonTriangulation.build()
  22001. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22002. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22003. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22004. * @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)
  22005. * @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)
  22006. * @returns the VertexData of the Polygon
  22007. */
  22008. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22009. /**
  22010. * Creates the VertexData of the IcoSphere
  22011. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22012. * * radius the radius of the IcoSphere, optional default 1
  22013. * * radiusX allows stretching in the x direction, optional, default radius
  22014. * * radiusY allows stretching in the y direction, optional, default radius
  22015. * * radiusZ allows stretching in the z direction, optional, default radius
  22016. * * flat when true creates a flat shaded mesh, optional, default true
  22017. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22019. * * 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)
  22020. * * 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)
  22021. * @returns the VertexData of the IcoSphere
  22022. */
  22023. static CreateIcoSphere(options: {
  22024. radius?: number;
  22025. radiusX?: number;
  22026. radiusY?: number;
  22027. radiusZ?: number;
  22028. flat?: boolean;
  22029. subdivisions?: number;
  22030. sideOrientation?: number;
  22031. frontUVs?: Vector4;
  22032. backUVs?: Vector4;
  22033. }): VertexData;
  22034. /**
  22035. * Creates the VertexData for a Polyhedron
  22036. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22037. * * type provided types are:
  22038. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22039. * * 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)
  22040. * * size the size of the IcoSphere, optional default 1
  22041. * * sizeX allows stretching in the x direction, optional, default size
  22042. * * sizeY allows stretching in the y direction, optional, default size
  22043. * * sizeZ allows stretching in the z direction, optional, default size
  22044. * * 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
  22045. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22046. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22047. * * flat when true creates a flat shaded mesh, optional, default true
  22048. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22050. * * 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)
  22051. * * 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)
  22052. * @returns the VertexData of the Polyhedron
  22053. */
  22054. static CreatePolyhedron(options: {
  22055. type?: number;
  22056. size?: number;
  22057. sizeX?: number;
  22058. sizeY?: number;
  22059. sizeZ?: number;
  22060. custom?: any;
  22061. faceUV?: Vector4[];
  22062. faceColors?: Color4[];
  22063. flat?: boolean;
  22064. sideOrientation?: number;
  22065. frontUVs?: Vector4;
  22066. backUVs?: Vector4;
  22067. }): VertexData;
  22068. /**
  22069. * Creates the VertexData for a TorusKnot
  22070. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22071. * * radius the radius of the torus knot, optional, default 2
  22072. * * tube the thickness of the tube, optional, default 0.5
  22073. * * radialSegments the number of sides on each tube segments, optional, default 32
  22074. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22075. * * p the number of windings around the z axis, optional, default 2
  22076. * * q the number of windings around the x axis, optional, default 3
  22077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22078. * * 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)
  22079. * * 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)
  22080. * @returns the VertexData of the Torus Knot
  22081. */
  22082. static CreateTorusKnot(options: {
  22083. radius?: number;
  22084. tube?: number;
  22085. radialSegments?: number;
  22086. tubularSegments?: number;
  22087. p?: number;
  22088. q?: number;
  22089. sideOrientation?: number;
  22090. frontUVs?: Vector4;
  22091. backUVs?: Vector4;
  22092. }): VertexData;
  22093. /**
  22094. * Compute normals for given positions and indices
  22095. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22096. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22097. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22098. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22099. * * facetNormals : optional array of facet normals (vector3)
  22100. * * facetPositions : optional array of facet positions (vector3)
  22101. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22102. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22103. * * bInfo : optional bounding info, required for facetPartitioning computation
  22104. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22105. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22106. * * useRightHandedSystem: optional boolean to for right handed system computation
  22107. * * depthSort : optional boolean to enable the facet depth sort computation
  22108. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22109. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22110. */
  22111. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22112. facetNormals?: any;
  22113. facetPositions?: any;
  22114. facetPartitioning?: any;
  22115. ratio?: number;
  22116. bInfo?: any;
  22117. bbSize?: Vector3;
  22118. subDiv?: any;
  22119. useRightHandedSystem?: boolean;
  22120. depthSort?: boolean;
  22121. distanceTo?: Vector3;
  22122. depthSortedFacets?: any;
  22123. }): void;
  22124. /** @hidden */
  22125. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22126. /**
  22127. * Applies VertexData created from the imported parameters to the geometry
  22128. * @param parsedVertexData the parsed data from an imported file
  22129. * @param geometry the geometry to apply the VertexData to
  22130. */
  22131. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22132. }
  22133. }
  22134. declare module BABYLON {
  22135. /**
  22136. * Defines a target to use with MorphTargetManager
  22137. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22138. */
  22139. export class MorphTarget implements IAnimatable {
  22140. /** defines the name of the target */
  22141. name: string;
  22142. /**
  22143. * Gets or sets the list of animations
  22144. */
  22145. animations: Animation[];
  22146. private _scene;
  22147. private _positions;
  22148. private _normals;
  22149. private _tangents;
  22150. private _uvs;
  22151. private _influence;
  22152. private _uniqueId;
  22153. /**
  22154. * Observable raised when the influence changes
  22155. */
  22156. onInfluenceChanged: Observable<boolean>;
  22157. /** @hidden */
  22158. _onDataLayoutChanged: Observable<void>;
  22159. /**
  22160. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22161. */
  22162. influence: number;
  22163. /**
  22164. * Gets or sets the id of the morph Target
  22165. */
  22166. id: string;
  22167. private _animationPropertiesOverride;
  22168. /**
  22169. * Gets or sets the animation properties override
  22170. */
  22171. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22172. /**
  22173. * Creates a new MorphTarget
  22174. * @param name defines the name of the target
  22175. * @param influence defines the influence to use
  22176. * @param scene defines the scene the morphtarget belongs to
  22177. */
  22178. constructor(
  22179. /** defines the name of the target */
  22180. name: string, influence?: number, scene?: Nullable<Scene>);
  22181. /**
  22182. * Gets the unique ID of this manager
  22183. */
  22184. readonly uniqueId: number;
  22185. /**
  22186. * Gets a boolean defining if the target contains position data
  22187. */
  22188. readonly hasPositions: boolean;
  22189. /**
  22190. * Gets a boolean defining if the target contains normal data
  22191. */
  22192. readonly hasNormals: boolean;
  22193. /**
  22194. * Gets a boolean defining if the target contains tangent data
  22195. */
  22196. readonly hasTangents: boolean;
  22197. /**
  22198. * Gets a boolean defining if the target contains texture coordinates data
  22199. */
  22200. readonly hasUVs: boolean;
  22201. /**
  22202. * Affects position data to this target
  22203. * @param data defines the position data to use
  22204. */
  22205. setPositions(data: Nullable<FloatArray>): void;
  22206. /**
  22207. * Gets the position data stored in this target
  22208. * @returns a FloatArray containing the position data (or null if not present)
  22209. */
  22210. getPositions(): Nullable<FloatArray>;
  22211. /**
  22212. * Affects normal data to this target
  22213. * @param data defines the normal data to use
  22214. */
  22215. setNormals(data: Nullable<FloatArray>): void;
  22216. /**
  22217. * Gets the normal data stored in this target
  22218. * @returns a FloatArray containing the normal data (or null if not present)
  22219. */
  22220. getNormals(): Nullable<FloatArray>;
  22221. /**
  22222. * Affects tangent data to this target
  22223. * @param data defines the tangent data to use
  22224. */
  22225. setTangents(data: Nullable<FloatArray>): void;
  22226. /**
  22227. * Gets the tangent data stored in this target
  22228. * @returns a FloatArray containing the tangent data (or null if not present)
  22229. */
  22230. getTangents(): Nullable<FloatArray>;
  22231. /**
  22232. * Affects texture coordinates data to this target
  22233. * @param data defines the texture coordinates data to use
  22234. */
  22235. setUVs(data: Nullable<FloatArray>): void;
  22236. /**
  22237. * Gets the texture coordinates data stored in this target
  22238. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22239. */
  22240. getUVs(): Nullable<FloatArray>;
  22241. /**
  22242. * Clone the current target
  22243. * @returns a new MorphTarget
  22244. */
  22245. clone(): MorphTarget;
  22246. /**
  22247. * Serializes the current target into a Serialization object
  22248. * @returns the serialized object
  22249. */
  22250. serialize(): any;
  22251. /**
  22252. * Returns the string "MorphTarget"
  22253. * @returns "MorphTarget"
  22254. */
  22255. getClassName(): string;
  22256. /**
  22257. * Creates a new target from serialized data
  22258. * @param serializationObject defines the serialized data to use
  22259. * @returns a new MorphTarget
  22260. */
  22261. static Parse(serializationObject: any): MorphTarget;
  22262. /**
  22263. * Creates a MorphTarget from mesh data
  22264. * @param mesh defines the source mesh
  22265. * @param name defines the name to use for the new target
  22266. * @param influence defines the influence to attach to the target
  22267. * @returns a new MorphTarget
  22268. */
  22269. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22270. }
  22271. }
  22272. declare module BABYLON {
  22273. /**
  22274. * This class is used to deform meshes using morphing between different targets
  22275. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22276. */
  22277. export class MorphTargetManager {
  22278. private _targets;
  22279. private _targetInfluenceChangedObservers;
  22280. private _targetDataLayoutChangedObservers;
  22281. private _activeTargets;
  22282. private _scene;
  22283. private _influences;
  22284. private _supportsNormals;
  22285. private _supportsTangents;
  22286. private _supportsUVs;
  22287. private _vertexCount;
  22288. private _uniqueId;
  22289. private _tempInfluences;
  22290. /**
  22291. * Gets or sets a boolean indicating if normals must be morphed
  22292. */
  22293. enableNormalMorphing: boolean;
  22294. /**
  22295. * Gets or sets a boolean indicating if tangents must be morphed
  22296. */
  22297. enableTangentMorphing: boolean;
  22298. /**
  22299. * Gets or sets a boolean indicating if UV must be morphed
  22300. */
  22301. enableUVMorphing: boolean;
  22302. /**
  22303. * Creates a new MorphTargetManager
  22304. * @param scene defines the current scene
  22305. */
  22306. constructor(scene?: Nullable<Scene>);
  22307. /**
  22308. * Gets the unique ID of this manager
  22309. */
  22310. readonly uniqueId: number;
  22311. /**
  22312. * Gets the number of vertices handled by this manager
  22313. */
  22314. readonly vertexCount: number;
  22315. /**
  22316. * Gets a boolean indicating if this manager supports morphing of normals
  22317. */
  22318. readonly supportsNormals: boolean;
  22319. /**
  22320. * Gets a boolean indicating if this manager supports morphing of tangents
  22321. */
  22322. readonly supportsTangents: boolean;
  22323. /**
  22324. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22325. */
  22326. readonly supportsUVs: boolean;
  22327. /**
  22328. * Gets the number of targets stored in this manager
  22329. */
  22330. readonly numTargets: number;
  22331. /**
  22332. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22333. */
  22334. readonly numInfluencers: number;
  22335. /**
  22336. * Gets the list of influences (one per target)
  22337. */
  22338. readonly influences: Float32Array;
  22339. /**
  22340. * Gets the active target at specified index. An active target is a target with an influence > 0
  22341. * @param index defines the index to check
  22342. * @returns the requested target
  22343. */
  22344. getActiveTarget(index: number): MorphTarget;
  22345. /**
  22346. * Gets the target at specified index
  22347. * @param index defines the index to check
  22348. * @returns the requested target
  22349. */
  22350. getTarget(index: number): MorphTarget;
  22351. /**
  22352. * Add a new target to this manager
  22353. * @param target defines the target to add
  22354. */
  22355. addTarget(target: MorphTarget): void;
  22356. /**
  22357. * Removes a target from the manager
  22358. * @param target defines the target to remove
  22359. */
  22360. removeTarget(target: MorphTarget): void;
  22361. /**
  22362. * Clone the current manager
  22363. * @returns a new MorphTargetManager
  22364. */
  22365. clone(): MorphTargetManager;
  22366. /**
  22367. * Serializes the current manager into a Serialization object
  22368. * @returns the serialized object
  22369. */
  22370. serialize(): any;
  22371. private _syncActiveTargets;
  22372. /**
  22373. * Syncrhonize the targets with all the meshes using this morph target manager
  22374. */
  22375. synchronize(): void;
  22376. /**
  22377. * Creates a new MorphTargetManager from serialized data
  22378. * @param serializationObject defines the serialized data
  22379. * @param scene defines the hosting scene
  22380. * @returns the new MorphTargetManager
  22381. */
  22382. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * Class used to represent a specific level of detail of a mesh
  22388. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22389. */
  22390. export class MeshLODLevel {
  22391. /** Defines the distance where this level should start being displayed */
  22392. distance: number;
  22393. /** Defines the mesh to use to render this level */
  22394. mesh: Nullable<Mesh>;
  22395. /**
  22396. * Creates a new LOD level
  22397. * @param distance defines the distance where this level should star being displayed
  22398. * @param mesh defines the mesh to use to render this level
  22399. */
  22400. constructor(
  22401. /** Defines the distance where this level should start being displayed */
  22402. distance: number,
  22403. /** Defines the mesh to use to render this level */
  22404. mesh: Nullable<Mesh>);
  22405. }
  22406. }
  22407. declare module BABYLON {
  22408. /**
  22409. * Mesh representing the gorund
  22410. */
  22411. export class GroundMesh extends Mesh {
  22412. /** If octree should be generated */
  22413. generateOctree: boolean;
  22414. private _heightQuads;
  22415. /** @hidden */
  22416. _subdivisionsX: number;
  22417. /** @hidden */
  22418. _subdivisionsY: number;
  22419. /** @hidden */
  22420. _width: number;
  22421. /** @hidden */
  22422. _height: number;
  22423. /** @hidden */
  22424. _minX: number;
  22425. /** @hidden */
  22426. _maxX: number;
  22427. /** @hidden */
  22428. _minZ: number;
  22429. /** @hidden */
  22430. _maxZ: number;
  22431. constructor(name: string, scene: Scene);
  22432. /**
  22433. * "GroundMesh"
  22434. * @returns "GroundMesh"
  22435. */
  22436. getClassName(): string;
  22437. /**
  22438. * The minimum of x and y subdivisions
  22439. */
  22440. readonly subdivisions: number;
  22441. /**
  22442. * X subdivisions
  22443. */
  22444. readonly subdivisionsX: number;
  22445. /**
  22446. * Y subdivisions
  22447. */
  22448. readonly subdivisionsY: number;
  22449. /**
  22450. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22451. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22452. * @param chunksCount the number of subdivisions for x and y
  22453. * @param octreeBlocksSize (Default: 32)
  22454. */
  22455. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22456. /**
  22457. * Returns a height (y) value in the Worl system :
  22458. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22459. * @param x x coordinate
  22460. * @param z z coordinate
  22461. * @returns the ground y position if (x, z) are outside the ground surface.
  22462. */
  22463. getHeightAtCoordinates(x: number, z: number): number;
  22464. /**
  22465. * Returns a normalized vector (Vector3) orthogonal to the ground
  22466. * at the ground coordinates (x, z) expressed in the World system.
  22467. * @param x x coordinate
  22468. * @param z z coordinate
  22469. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22470. */
  22471. getNormalAtCoordinates(x: number, z: number): Vector3;
  22472. /**
  22473. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22474. * at the ground coordinates (x, z) expressed in the World system.
  22475. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22476. * @param x x coordinate
  22477. * @param z z coordinate
  22478. * @param ref vector to store the result
  22479. * @returns the GroundMesh.
  22480. */
  22481. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22482. /**
  22483. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22484. * if the ground has been updated.
  22485. * This can be used in the render loop.
  22486. * @returns the GroundMesh.
  22487. */
  22488. updateCoordinateHeights(): GroundMesh;
  22489. private _getFacetAt;
  22490. private _initHeightQuads;
  22491. private _computeHeightQuads;
  22492. /**
  22493. * Serializes this ground mesh
  22494. * @param serializationObject object to write serialization to
  22495. */
  22496. serialize(serializationObject: any): void;
  22497. /**
  22498. * Parses a serialized ground mesh
  22499. * @param parsedMesh the serialized mesh
  22500. * @param scene the scene to create the ground mesh in
  22501. * @returns the created ground mesh
  22502. */
  22503. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22504. }
  22505. }
  22506. declare module BABYLON {
  22507. /**
  22508. * Interface for Physics-Joint data
  22509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22510. */
  22511. export interface PhysicsJointData {
  22512. /**
  22513. * The main pivot of the joint
  22514. */
  22515. mainPivot?: Vector3;
  22516. /**
  22517. * The connected pivot of the joint
  22518. */
  22519. connectedPivot?: Vector3;
  22520. /**
  22521. * The main axis of the joint
  22522. */
  22523. mainAxis?: Vector3;
  22524. /**
  22525. * The connected axis of the joint
  22526. */
  22527. connectedAxis?: Vector3;
  22528. /**
  22529. * The collision of the joint
  22530. */
  22531. collision?: boolean;
  22532. /**
  22533. * Native Oimo/Cannon/Energy data
  22534. */
  22535. nativeParams?: any;
  22536. }
  22537. /**
  22538. * This is a holder class for the physics joint created by the physics plugin
  22539. * It holds a set of functions to control the underlying joint
  22540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22541. */
  22542. export class PhysicsJoint {
  22543. /**
  22544. * The type of the physics joint
  22545. */
  22546. type: number;
  22547. /**
  22548. * The data for the physics joint
  22549. */
  22550. jointData: PhysicsJointData;
  22551. private _physicsJoint;
  22552. protected _physicsPlugin: IPhysicsEnginePlugin;
  22553. /**
  22554. * Initializes the physics joint
  22555. * @param type The type of the physics joint
  22556. * @param jointData The data for the physics joint
  22557. */
  22558. constructor(
  22559. /**
  22560. * The type of the physics joint
  22561. */
  22562. type: number,
  22563. /**
  22564. * The data for the physics joint
  22565. */
  22566. jointData: PhysicsJointData);
  22567. /**
  22568. * Gets the physics joint
  22569. */
  22570. /**
  22571. * Sets the physics joint
  22572. */
  22573. physicsJoint: any;
  22574. /**
  22575. * Sets the physics plugin
  22576. */
  22577. physicsPlugin: IPhysicsEnginePlugin;
  22578. /**
  22579. * Execute a function that is physics-plugin specific.
  22580. * @param {Function} func the function that will be executed.
  22581. * It accepts two parameters: the physics world and the physics joint
  22582. */
  22583. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22584. /**
  22585. * Distance-Joint type
  22586. */
  22587. static DistanceJoint: number;
  22588. /**
  22589. * Hinge-Joint type
  22590. */
  22591. static HingeJoint: number;
  22592. /**
  22593. * Ball-and-Socket joint type
  22594. */
  22595. static BallAndSocketJoint: number;
  22596. /**
  22597. * Wheel-Joint type
  22598. */
  22599. static WheelJoint: number;
  22600. /**
  22601. * Slider-Joint type
  22602. */
  22603. static SliderJoint: number;
  22604. /**
  22605. * Prismatic-Joint type
  22606. */
  22607. static PrismaticJoint: number;
  22608. /**
  22609. * Universal-Joint type
  22610. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22611. */
  22612. static UniversalJoint: number;
  22613. /**
  22614. * Hinge-Joint 2 type
  22615. */
  22616. static Hinge2Joint: number;
  22617. /**
  22618. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22619. */
  22620. static PointToPointJoint: number;
  22621. /**
  22622. * Spring-Joint type
  22623. */
  22624. static SpringJoint: number;
  22625. /**
  22626. * Lock-Joint type
  22627. */
  22628. static LockJoint: number;
  22629. }
  22630. /**
  22631. * A class representing a physics distance joint
  22632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22633. */
  22634. export class DistanceJoint extends PhysicsJoint {
  22635. /**
  22636. *
  22637. * @param jointData The data for the Distance-Joint
  22638. */
  22639. constructor(jointData: DistanceJointData);
  22640. /**
  22641. * Update the predefined distance.
  22642. * @param maxDistance The maximum preferred distance
  22643. * @param minDistance The minimum preferred distance
  22644. */
  22645. updateDistance(maxDistance: number, minDistance?: number): void;
  22646. }
  22647. /**
  22648. * Represents a Motor-Enabled Joint
  22649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22650. */
  22651. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22652. /**
  22653. * Initializes the Motor-Enabled Joint
  22654. * @param type The type of the joint
  22655. * @param jointData The physica joint data for the joint
  22656. */
  22657. constructor(type: number, jointData: PhysicsJointData);
  22658. /**
  22659. * Set the motor values.
  22660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22661. * @param force the force to apply
  22662. * @param maxForce max force for this motor.
  22663. */
  22664. setMotor(force?: number, maxForce?: number): void;
  22665. /**
  22666. * Set the motor's limits.
  22667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22668. * @param upperLimit The upper limit of the motor
  22669. * @param lowerLimit The lower limit of the motor
  22670. */
  22671. setLimit(upperLimit: number, lowerLimit?: number): void;
  22672. }
  22673. /**
  22674. * This class represents a single physics Hinge-Joint
  22675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22676. */
  22677. export class HingeJoint extends MotorEnabledJoint {
  22678. /**
  22679. * Initializes the Hinge-Joint
  22680. * @param jointData The joint data for the Hinge-Joint
  22681. */
  22682. constructor(jointData: PhysicsJointData);
  22683. /**
  22684. * Set the motor values.
  22685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22686. * @param {number} force the force to apply
  22687. * @param {number} maxForce max force for this motor.
  22688. */
  22689. setMotor(force?: number, maxForce?: number): void;
  22690. /**
  22691. * Set the motor's limits.
  22692. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22693. * @param upperLimit The upper limit of the motor
  22694. * @param lowerLimit The lower limit of the motor
  22695. */
  22696. setLimit(upperLimit: number, lowerLimit?: number): void;
  22697. }
  22698. /**
  22699. * This class represents a dual hinge physics joint (same as wheel joint)
  22700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22701. */
  22702. export class Hinge2Joint extends MotorEnabledJoint {
  22703. /**
  22704. * Initializes the Hinge2-Joint
  22705. * @param jointData The joint data for the Hinge2-Joint
  22706. */
  22707. constructor(jointData: PhysicsJointData);
  22708. /**
  22709. * Set the motor values.
  22710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22711. * @param {number} targetSpeed the speed the motor is to reach
  22712. * @param {number} maxForce max force for this motor.
  22713. * @param {motorIndex} the motor's index, 0 or 1.
  22714. */
  22715. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22716. /**
  22717. * Set the motor limits.
  22718. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22719. * @param {number} upperLimit the upper limit
  22720. * @param {number} lowerLimit lower limit
  22721. * @param {motorIndex} the motor's index, 0 or 1.
  22722. */
  22723. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22724. }
  22725. /**
  22726. * Interface for a motor enabled joint
  22727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22728. */
  22729. export interface IMotorEnabledJoint {
  22730. /**
  22731. * Physics joint
  22732. */
  22733. physicsJoint: any;
  22734. /**
  22735. * Sets the motor of the motor-enabled joint
  22736. * @param force The force of the motor
  22737. * @param maxForce The maximum force of the motor
  22738. * @param motorIndex The index of the motor
  22739. */
  22740. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22741. /**
  22742. * Sets the limit of the motor
  22743. * @param upperLimit The upper limit of the motor
  22744. * @param lowerLimit The lower limit of the motor
  22745. * @param motorIndex The index of the motor
  22746. */
  22747. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22748. }
  22749. /**
  22750. * Joint data for a Distance-Joint
  22751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22752. */
  22753. export interface DistanceJointData extends PhysicsJointData {
  22754. /**
  22755. * Max distance the 2 joint objects can be apart
  22756. */
  22757. maxDistance: number;
  22758. }
  22759. /**
  22760. * Joint data from a spring joint
  22761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22762. */
  22763. export interface SpringJointData extends PhysicsJointData {
  22764. /**
  22765. * Length of the spring
  22766. */
  22767. length: number;
  22768. /**
  22769. * Stiffness of the spring
  22770. */
  22771. stiffness: number;
  22772. /**
  22773. * Damping of the spring
  22774. */
  22775. damping: number;
  22776. /** this callback will be called when applying the force to the impostors. */
  22777. forceApplicationCallback: () => void;
  22778. }
  22779. }
  22780. declare module BABYLON {
  22781. /**
  22782. * Holds the data for the raycast result
  22783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22784. */
  22785. export class PhysicsRaycastResult {
  22786. private _hasHit;
  22787. private _hitDistance;
  22788. private _hitNormalWorld;
  22789. private _hitPointWorld;
  22790. private _rayFromWorld;
  22791. private _rayToWorld;
  22792. /**
  22793. * Gets if there was a hit
  22794. */
  22795. readonly hasHit: boolean;
  22796. /**
  22797. * Gets the distance from the hit
  22798. */
  22799. readonly hitDistance: number;
  22800. /**
  22801. * Gets the hit normal/direction in the world
  22802. */
  22803. readonly hitNormalWorld: Vector3;
  22804. /**
  22805. * Gets the hit point in the world
  22806. */
  22807. readonly hitPointWorld: Vector3;
  22808. /**
  22809. * Gets the ray "start point" of the ray in the world
  22810. */
  22811. readonly rayFromWorld: Vector3;
  22812. /**
  22813. * Gets the ray "end point" of the ray in the world
  22814. */
  22815. readonly rayToWorld: Vector3;
  22816. /**
  22817. * Sets the hit data (normal & point in world space)
  22818. * @param hitNormalWorld defines the normal in world space
  22819. * @param hitPointWorld defines the point in world space
  22820. */
  22821. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22822. /**
  22823. * Sets the distance from the start point to the hit point
  22824. * @param distance
  22825. */
  22826. setHitDistance(distance: number): void;
  22827. /**
  22828. * Calculates the distance manually
  22829. */
  22830. calculateHitDistance(): void;
  22831. /**
  22832. * Resets all the values to default
  22833. * @param from The from point on world space
  22834. * @param to The to point on world space
  22835. */
  22836. reset(from?: Vector3, to?: Vector3): void;
  22837. }
  22838. /**
  22839. * Interface for the size containing width and height
  22840. */
  22841. interface IXYZ {
  22842. /**
  22843. * X
  22844. */
  22845. x: number;
  22846. /**
  22847. * Y
  22848. */
  22849. y: number;
  22850. /**
  22851. * Z
  22852. */
  22853. z: number;
  22854. }
  22855. }
  22856. declare module BABYLON {
  22857. /**
  22858. * Interface used to describe a physics joint
  22859. */
  22860. export interface PhysicsImpostorJoint {
  22861. /** Defines the main impostor to which the joint is linked */
  22862. mainImpostor: PhysicsImpostor;
  22863. /** Defines the impostor that is connected to the main impostor using this joint */
  22864. connectedImpostor: PhysicsImpostor;
  22865. /** Defines the joint itself */
  22866. joint: PhysicsJoint;
  22867. }
  22868. /** @hidden */
  22869. export interface IPhysicsEnginePlugin {
  22870. world: any;
  22871. name: string;
  22872. setGravity(gravity: Vector3): void;
  22873. setTimeStep(timeStep: number): void;
  22874. getTimeStep(): number;
  22875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22879. removePhysicsBody(impostor: PhysicsImpostor): void;
  22880. generateJoint(joint: PhysicsImpostorJoint): void;
  22881. removeJoint(joint: PhysicsImpostorJoint): void;
  22882. isSupported(): boolean;
  22883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22884. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22890. getBodyMass(impostor: PhysicsImpostor): number;
  22891. getBodyFriction(impostor: PhysicsImpostor): number;
  22892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22893. getBodyRestitution(impostor: PhysicsImpostor): number;
  22894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22895. getBodyPressure?(impostor: PhysicsImpostor): number;
  22896. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22897. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22898. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22899. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22900. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22901. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22902. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22903. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22904. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22905. sleepBody(impostor: PhysicsImpostor): void;
  22906. wakeUpBody(impostor: PhysicsImpostor): void;
  22907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22909. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22911. getRadius(impostor: PhysicsImpostor): number;
  22912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22914. dispose(): void;
  22915. }
  22916. /**
  22917. * Interface used to define a physics engine
  22918. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22919. */
  22920. export interface IPhysicsEngine {
  22921. /**
  22922. * Gets the gravity vector used by the simulation
  22923. */
  22924. gravity: Vector3;
  22925. /**
  22926. * Sets the gravity vector used by the simulation
  22927. * @param gravity defines the gravity vector to use
  22928. */
  22929. setGravity(gravity: Vector3): void;
  22930. /**
  22931. * Set the time step of the physics engine.
  22932. * Default is 1/60.
  22933. * To slow it down, enter 1/600 for example.
  22934. * To speed it up, 1/30
  22935. * @param newTimeStep the new timestep to apply to this world.
  22936. */
  22937. setTimeStep(newTimeStep: number): void;
  22938. /**
  22939. * Get the time step of the physics engine.
  22940. * @returns the current time step
  22941. */
  22942. getTimeStep(): number;
  22943. /**
  22944. * Release all resources
  22945. */
  22946. dispose(): void;
  22947. /**
  22948. * Gets the name of the current physics plugin
  22949. * @returns the name of the plugin
  22950. */
  22951. getPhysicsPluginName(): string;
  22952. /**
  22953. * Adding a new impostor for the impostor tracking.
  22954. * This will be done by the impostor itself.
  22955. * @param impostor the impostor to add
  22956. */
  22957. addImpostor(impostor: PhysicsImpostor): void;
  22958. /**
  22959. * Remove an impostor from the engine.
  22960. * This impostor and its mesh will not longer be updated by the physics engine.
  22961. * @param impostor the impostor to remove
  22962. */
  22963. removeImpostor(impostor: PhysicsImpostor): void;
  22964. /**
  22965. * Add a joint to the physics engine
  22966. * @param mainImpostor defines the main impostor to which the joint is added.
  22967. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22968. * @param joint defines the joint that will connect both impostors.
  22969. */
  22970. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22971. /**
  22972. * Removes a joint from the simulation
  22973. * @param mainImpostor defines the impostor used with the joint
  22974. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22975. * @param joint defines the joint to remove
  22976. */
  22977. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22978. /**
  22979. * Gets the current plugin used to run the simulation
  22980. * @returns current plugin
  22981. */
  22982. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22983. /**
  22984. * Gets the list of physic impostors
  22985. * @returns an array of PhysicsImpostor
  22986. */
  22987. getImpostors(): Array<PhysicsImpostor>;
  22988. /**
  22989. * Gets the impostor for a physics enabled object
  22990. * @param object defines the object impersonated by the impostor
  22991. * @returns the PhysicsImpostor or null if not found
  22992. */
  22993. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22994. /**
  22995. * Gets the impostor for a physics body object
  22996. * @param body defines physics body used by the impostor
  22997. * @returns the PhysicsImpostor or null if not found
  22998. */
  22999. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23000. /**
  23001. * Does a raycast in the physics world
  23002. * @param from when should the ray start?
  23003. * @param to when should the ray end?
  23004. * @returns PhysicsRaycastResult
  23005. */
  23006. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23007. /**
  23008. * Called by the scene. No need to call it.
  23009. * @param delta defines the timespam between frames
  23010. */
  23011. _step(delta: number): void;
  23012. }
  23013. }
  23014. declare module BABYLON {
  23015. /**
  23016. * The interface for the physics imposter parameters
  23017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23018. */
  23019. export interface PhysicsImpostorParameters {
  23020. /**
  23021. * The mass of the physics imposter
  23022. */
  23023. mass: number;
  23024. /**
  23025. * The friction of the physics imposter
  23026. */
  23027. friction?: number;
  23028. /**
  23029. * The coefficient of restitution of the physics imposter
  23030. */
  23031. restitution?: number;
  23032. /**
  23033. * The native options of the physics imposter
  23034. */
  23035. nativeOptions?: any;
  23036. /**
  23037. * Specifies if the parent should be ignored
  23038. */
  23039. ignoreParent?: boolean;
  23040. /**
  23041. * Specifies if bi-directional transformations should be disabled
  23042. */
  23043. disableBidirectionalTransformation?: boolean;
  23044. /**
  23045. * The pressure inside the physics imposter, soft object only
  23046. */
  23047. pressure?: number;
  23048. /**
  23049. * The stiffness the physics imposter, soft object only
  23050. */
  23051. stiffness?: number;
  23052. /**
  23053. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23054. */
  23055. velocityIterations?: number;
  23056. /**
  23057. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23058. */
  23059. positionIterations?: number;
  23060. /**
  23061. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23062. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23063. * Add to fix multiple points
  23064. */
  23065. fixedPoints?: number;
  23066. /**
  23067. * The collision margin around a soft object
  23068. */
  23069. margin?: number;
  23070. /**
  23071. * The collision margin around a soft object
  23072. */
  23073. damping?: number;
  23074. /**
  23075. * The path for a rope based on an extrusion
  23076. */
  23077. path?: any;
  23078. /**
  23079. * The shape of an extrusion used for a rope based on an extrusion
  23080. */
  23081. shape?: any;
  23082. }
  23083. /**
  23084. * Interface for a physics-enabled object
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export interface IPhysicsEnabledObject {
  23088. /**
  23089. * The position of the physics-enabled object
  23090. */
  23091. position: Vector3;
  23092. /**
  23093. * The rotation of the physics-enabled object
  23094. */
  23095. rotationQuaternion: Nullable<Quaternion>;
  23096. /**
  23097. * The scale of the physics-enabled object
  23098. */
  23099. scaling: Vector3;
  23100. /**
  23101. * The rotation of the physics-enabled object
  23102. */
  23103. rotation?: Vector3;
  23104. /**
  23105. * The parent of the physics-enabled object
  23106. */
  23107. parent?: any;
  23108. /**
  23109. * The bounding info of the physics-enabled object
  23110. * @returns The bounding info of the physics-enabled object
  23111. */
  23112. getBoundingInfo(): BoundingInfo;
  23113. /**
  23114. * Computes the world matrix
  23115. * @param force Specifies if the world matrix should be computed by force
  23116. * @returns A world matrix
  23117. */
  23118. computeWorldMatrix(force: boolean): Matrix;
  23119. /**
  23120. * Gets the world matrix
  23121. * @returns A world matrix
  23122. */
  23123. getWorldMatrix?(): Matrix;
  23124. /**
  23125. * Gets the child meshes
  23126. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23127. * @returns An array of abstract meshes
  23128. */
  23129. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23130. /**
  23131. * Gets the vertex data
  23132. * @param kind The type of vertex data
  23133. * @returns A nullable array of numbers, or a float32 array
  23134. */
  23135. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23136. /**
  23137. * Gets the indices from the mesh
  23138. * @returns A nullable array of index arrays
  23139. */
  23140. getIndices?(): Nullable<IndicesArray>;
  23141. /**
  23142. * Gets the scene from the mesh
  23143. * @returns the indices array or null
  23144. */
  23145. getScene?(): Scene;
  23146. /**
  23147. * Gets the absolute position from the mesh
  23148. * @returns the absolute position
  23149. */
  23150. getAbsolutePosition(): Vector3;
  23151. /**
  23152. * Gets the absolute pivot point from the mesh
  23153. * @returns the absolute pivot point
  23154. */
  23155. getAbsolutePivotPoint(): Vector3;
  23156. /**
  23157. * Rotates the mesh
  23158. * @param axis The axis of rotation
  23159. * @param amount The amount of rotation
  23160. * @param space The space of the rotation
  23161. * @returns The rotation transform node
  23162. */
  23163. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23164. /**
  23165. * Translates the mesh
  23166. * @param axis The axis of translation
  23167. * @param distance The distance of translation
  23168. * @param space The space of the translation
  23169. * @returns The transform node
  23170. */
  23171. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23172. /**
  23173. * Sets the absolute position of the mesh
  23174. * @param absolutePosition The absolute position of the mesh
  23175. * @returns The transform node
  23176. */
  23177. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23178. /**
  23179. * Gets the class name of the mesh
  23180. * @returns The class name
  23181. */
  23182. getClassName(): string;
  23183. }
  23184. /**
  23185. * Represents a physics imposter
  23186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23187. */
  23188. export class PhysicsImpostor {
  23189. /**
  23190. * The physics-enabled object used as the physics imposter
  23191. */
  23192. object: IPhysicsEnabledObject;
  23193. /**
  23194. * The type of the physics imposter
  23195. */
  23196. type: number;
  23197. private _options;
  23198. private _scene?;
  23199. /**
  23200. * The default object size of the imposter
  23201. */
  23202. static DEFAULT_OBJECT_SIZE: Vector3;
  23203. /**
  23204. * The identity quaternion of the imposter
  23205. */
  23206. static IDENTITY_QUATERNION: Quaternion;
  23207. /** @hidden */
  23208. _pluginData: any;
  23209. private _physicsEngine;
  23210. private _physicsBody;
  23211. private _bodyUpdateRequired;
  23212. private _onBeforePhysicsStepCallbacks;
  23213. private _onAfterPhysicsStepCallbacks;
  23214. /** @hidden */
  23215. _onPhysicsCollideCallbacks: Array<{
  23216. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23217. otherImpostors: Array<PhysicsImpostor>;
  23218. }>;
  23219. private _deltaPosition;
  23220. private _deltaRotation;
  23221. private _deltaRotationConjugated;
  23222. /** @hidden */
  23223. _isFromLine: boolean;
  23224. private _parent;
  23225. private _isDisposed;
  23226. private static _tmpVecs;
  23227. private static _tmpQuat;
  23228. /**
  23229. * Specifies if the physics imposter is disposed
  23230. */
  23231. readonly isDisposed: boolean;
  23232. /**
  23233. * Gets the mass of the physics imposter
  23234. */
  23235. mass: number;
  23236. /**
  23237. * Gets the coefficient of friction
  23238. */
  23239. /**
  23240. * Sets the coefficient of friction
  23241. */
  23242. friction: number;
  23243. /**
  23244. * Gets the coefficient of restitution
  23245. */
  23246. /**
  23247. * Sets the coefficient of restitution
  23248. */
  23249. restitution: number;
  23250. /**
  23251. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23252. */
  23253. /**
  23254. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23255. */
  23256. pressure: number;
  23257. /**
  23258. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23259. */
  23260. /**
  23261. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23262. */
  23263. stiffness: number;
  23264. /**
  23265. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23266. */
  23267. /**
  23268. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23269. */
  23270. velocityIterations: number;
  23271. /**
  23272. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23273. */
  23274. /**
  23275. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23276. */
  23277. positionIterations: number;
  23278. /**
  23279. * The unique id of the physics imposter
  23280. * set by the physics engine when adding this impostor to the array
  23281. */
  23282. uniqueId: number;
  23283. /**
  23284. * @hidden
  23285. */
  23286. soft: boolean;
  23287. /**
  23288. * @hidden
  23289. */
  23290. segments: number;
  23291. private _joints;
  23292. /**
  23293. * Initializes the physics imposter
  23294. * @param object The physics-enabled object used as the physics imposter
  23295. * @param type The type of the physics imposter
  23296. * @param _options The options for the physics imposter
  23297. * @param _scene The Babylon scene
  23298. */
  23299. constructor(
  23300. /**
  23301. * The physics-enabled object used as the physics imposter
  23302. */
  23303. object: IPhysicsEnabledObject,
  23304. /**
  23305. * The type of the physics imposter
  23306. */
  23307. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23308. /**
  23309. * This function will completly initialize this impostor.
  23310. * It will create a new body - but only if this mesh has no parent.
  23311. * If it has, this impostor will not be used other than to define the impostor
  23312. * of the child mesh.
  23313. * @hidden
  23314. */
  23315. _init(): void;
  23316. private _getPhysicsParent;
  23317. /**
  23318. * Should a new body be generated.
  23319. * @returns boolean specifying if body initialization is required
  23320. */
  23321. isBodyInitRequired(): boolean;
  23322. /**
  23323. * Sets the updated scaling
  23324. * @param updated Specifies if the scaling is updated
  23325. */
  23326. setScalingUpdated(): void;
  23327. /**
  23328. * Force a regeneration of this or the parent's impostor's body.
  23329. * Use under cautious - This will remove all joints already implemented.
  23330. */
  23331. forceUpdate(): void;
  23332. /**
  23333. * Gets the body that holds this impostor. Either its own, or its parent.
  23334. */
  23335. /**
  23336. * Set the physics body. Used mainly by the physics engine/plugin
  23337. */
  23338. physicsBody: any;
  23339. /**
  23340. * Get the parent of the physics imposter
  23341. * @returns Physics imposter or null
  23342. */
  23343. /**
  23344. * Sets the parent of the physics imposter
  23345. */
  23346. parent: Nullable<PhysicsImpostor>;
  23347. /**
  23348. * Resets the update flags
  23349. */
  23350. resetUpdateFlags(): void;
  23351. /**
  23352. * Gets the object extend size
  23353. * @returns the object extend size
  23354. */
  23355. getObjectExtendSize(): Vector3;
  23356. /**
  23357. * Gets the object center
  23358. * @returns The object center
  23359. */
  23360. getObjectCenter(): Vector3;
  23361. /**
  23362. * Get a specific parametes from the options parameter
  23363. * @param paramName The object parameter name
  23364. * @returns The object parameter
  23365. */
  23366. getParam(paramName: string): any;
  23367. /**
  23368. * Sets a specific parameter in the options given to the physics plugin
  23369. * @param paramName The parameter name
  23370. * @param value The value of the parameter
  23371. */
  23372. setParam(paramName: string, value: number): void;
  23373. /**
  23374. * Specifically change the body's mass option. Won't recreate the physics body object
  23375. * @param mass The mass of the physics imposter
  23376. */
  23377. setMass(mass: number): void;
  23378. /**
  23379. * Gets the linear velocity
  23380. * @returns linear velocity or null
  23381. */
  23382. getLinearVelocity(): Nullable<Vector3>;
  23383. /**
  23384. * Sets the linear velocity
  23385. * @param velocity linear velocity or null
  23386. */
  23387. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23388. /**
  23389. * Gets the angular velocity
  23390. * @returns angular velocity or null
  23391. */
  23392. getAngularVelocity(): Nullable<Vector3>;
  23393. /**
  23394. * Sets the angular velocity
  23395. * @param velocity The velocity or null
  23396. */
  23397. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23398. /**
  23399. * Execute a function with the physics plugin native code
  23400. * Provide a function the will have two variables - the world object and the physics body object
  23401. * @param func The function to execute with the physics plugin native code
  23402. */
  23403. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23404. /**
  23405. * Register a function that will be executed before the physics world is stepping forward
  23406. * @param func The function to execute before the physics world is stepped forward
  23407. */
  23408. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23409. /**
  23410. * Unregister a function that will be executed before the physics world is stepping forward
  23411. * @param func The function to execute before the physics world is stepped forward
  23412. */
  23413. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23414. /**
  23415. * Register a function that will be executed after the physics step
  23416. * @param func The function to execute after physics step
  23417. */
  23418. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23419. /**
  23420. * Unregisters a function that will be executed after the physics step
  23421. * @param func The function to execute after physics step
  23422. */
  23423. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23424. /**
  23425. * register a function that will be executed when this impostor collides against a different body
  23426. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23427. * @param func Callback that is executed on collision
  23428. */
  23429. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23430. /**
  23431. * Unregisters the physics imposter on contact
  23432. * @param collideAgainst The physics object to collide against
  23433. * @param func Callback to execute on collision
  23434. */
  23435. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23436. private _tmpQuat;
  23437. private _tmpQuat2;
  23438. /**
  23439. * Get the parent rotation
  23440. * @returns The parent rotation
  23441. */
  23442. getParentsRotation(): Quaternion;
  23443. /**
  23444. * this function is executed by the physics engine.
  23445. */
  23446. beforeStep: () => void;
  23447. /**
  23448. * this function is executed by the physics engine
  23449. */
  23450. afterStep: () => void;
  23451. /**
  23452. * Legacy collision detection event support
  23453. */
  23454. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23455. /**
  23456. * event and body object due to cannon's event-based architecture.
  23457. */
  23458. onCollide: (e: {
  23459. body: any;
  23460. }) => void;
  23461. /**
  23462. * Apply a force
  23463. * @param force The force to apply
  23464. * @param contactPoint The contact point for the force
  23465. * @returns The physics imposter
  23466. */
  23467. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23468. /**
  23469. * Apply an impulse
  23470. * @param force The impulse force
  23471. * @param contactPoint The contact point for the impulse force
  23472. * @returns The physics imposter
  23473. */
  23474. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23475. /**
  23476. * A help function to create a joint
  23477. * @param otherImpostor A physics imposter used to create a joint
  23478. * @param jointType The type of joint
  23479. * @param jointData The data for the joint
  23480. * @returns The physics imposter
  23481. */
  23482. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23483. /**
  23484. * Add a joint to this impostor with a different impostor
  23485. * @param otherImpostor A physics imposter used to add a joint
  23486. * @param joint The joint to add
  23487. * @returns The physics imposter
  23488. */
  23489. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23490. /**
  23491. * Add an anchor to a cloth impostor
  23492. * @param otherImpostor rigid impostor to anchor to
  23493. * @param width ratio across width from 0 to 1
  23494. * @param height ratio up height from 0 to 1
  23495. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23496. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23497. * @returns impostor the soft imposter
  23498. */
  23499. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23500. /**
  23501. * Add a hook to a rope impostor
  23502. * @param otherImpostor rigid impostor to anchor to
  23503. * @param length ratio across rope from 0 to 1
  23504. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23505. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23506. * @returns impostor the rope imposter
  23507. */
  23508. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23509. /**
  23510. * Will keep this body still, in a sleep mode.
  23511. * @returns the physics imposter
  23512. */
  23513. sleep(): PhysicsImpostor;
  23514. /**
  23515. * Wake the body up.
  23516. * @returns The physics imposter
  23517. */
  23518. wakeUp(): PhysicsImpostor;
  23519. /**
  23520. * Clones the physics imposter
  23521. * @param newObject The physics imposter clones to this physics-enabled object
  23522. * @returns A nullable physics imposter
  23523. */
  23524. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23525. /**
  23526. * Disposes the physics imposter
  23527. */
  23528. dispose(): void;
  23529. /**
  23530. * Sets the delta position
  23531. * @param position The delta position amount
  23532. */
  23533. setDeltaPosition(position: Vector3): void;
  23534. /**
  23535. * Sets the delta rotation
  23536. * @param rotation The delta rotation amount
  23537. */
  23538. setDeltaRotation(rotation: Quaternion): void;
  23539. /**
  23540. * Gets the box size of the physics imposter and stores the result in the input parameter
  23541. * @param result Stores the box size
  23542. * @returns The physics imposter
  23543. */
  23544. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23545. /**
  23546. * Gets the radius of the physics imposter
  23547. * @returns Radius of the physics imposter
  23548. */
  23549. getRadius(): number;
  23550. /**
  23551. * Sync a bone with this impostor
  23552. * @param bone The bone to sync to the impostor.
  23553. * @param boneMesh The mesh that the bone is influencing.
  23554. * @param jointPivot The pivot of the joint / bone in local space.
  23555. * @param distToJoint Optional distance from the impostor to the joint.
  23556. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23557. */
  23558. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23559. /**
  23560. * Sync impostor to a bone
  23561. * @param bone The bone that the impostor will be synced to.
  23562. * @param boneMesh The mesh that the bone is influencing.
  23563. * @param jointPivot The pivot of the joint / bone in local space.
  23564. * @param distToJoint Optional distance from the impostor to the joint.
  23565. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23566. * @param boneAxis Optional vector3 axis the bone is aligned with
  23567. */
  23568. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23569. /**
  23570. * No-Imposter type
  23571. */
  23572. static NoImpostor: number;
  23573. /**
  23574. * Sphere-Imposter type
  23575. */
  23576. static SphereImpostor: number;
  23577. /**
  23578. * Box-Imposter type
  23579. */
  23580. static BoxImpostor: number;
  23581. /**
  23582. * Plane-Imposter type
  23583. */
  23584. static PlaneImpostor: number;
  23585. /**
  23586. * Mesh-imposter type
  23587. */
  23588. static MeshImpostor: number;
  23589. /**
  23590. * Capsule-Impostor type (Ammo.js plugin only)
  23591. */
  23592. static CapsuleImpostor: number;
  23593. /**
  23594. * Cylinder-Imposter type
  23595. */
  23596. static CylinderImpostor: number;
  23597. /**
  23598. * Particle-Imposter type
  23599. */
  23600. static ParticleImpostor: number;
  23601. /**
  23602. * Heightmap-Imposter type
  23603. */
  23604. static HeightmapImpostor: number;
  23605. /**
  23606. * ConvexHull-Impostor type (Ammo.js plugin only)
  23607. */
  23608. static ConvexHullImpostor: number;
  23609. /**
  23610. * Rope-Imposter type
  23611. */
  23612. static RopeImpostor: number;
  23613. /**
  23614. * Cloth-Imposter type
  23615. */
  23616. static ClothImpostor: number;
  23617. /**
  23618. * Softbody-Imposter type
  23619. */
  23620. static SoftbodyImpostor: number;
  23621. }
  23622. }
  23623. declare module BABYLON {
  23624. /**
  23625. * @hidden
  23626. **/
  23627. export class _CreationDataStorage {
  23628. closePath?: boolean;
  23629. closeArray?: boolean;
  23630. idx: number[];
  23631. dashSize: number;
  23632. gapSize: number;
  23633. path3D: Path3D;
  23634. pathArray: Vector3[][];
  23635. arc: number;
  23636. radius: number;
  23637. cap: number;
  23638. tessellation: number;
  23639. }
  23640. /**
  23641. * @hidden
  23642. **/
  23643. class _InstanceDataStorage {
  23644. visibleInstances: any;
  23645. batchCache: _InstancesBatch;
  23646. instancesBufferSize: number;
  23647. instancesBuffer: Nullable<Buffer>;
  23648. instancesData: Float32Array;
  23649. overridenInstanceCount: number;
  23650. isFrozen: boolean;
  23651. previousBatch: Nullable<_InstancesBatch>;
  23652. hardwareInstancedRendering: boolean;
  23653. sideOrientation: number;
  23654. }
  23655. /**
  23656. * @hidden
  23657. **/
  23658. export class _InstancesBatch {
  23659. mustReturn: boolean;
  23660. visibleInstances: Nullable<InstancedMesh[]>[];
  23661. renderSelf: boolean[];
  23662. hardwareInstancedRendering: boolean[];
  23663. }
  23664. /**
  23665. * Class used to represent renderable models
  23666. */
  23667. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23668. /**
  23669. * Mesh side orientation : usually the external or front surface
  23670. */
  23671. static readonly FRONTSIDE: number;
  23672. /**
  23673. * Mesh side orientation : usually the internal or back surface
  23674. */
  23675. static readonly BACKSIDE: number;
  23676. /**
  23677. * Mesh side orientation : both internal and external or front and back surfaces
  23678. */
  23679. static readonly DOUBLESIDE: number;
  23680. /**
  23681. * Mesh side orientation : by default, `FRONTSIDE`
  23682. */
  23683. static readonly DEFAULTSIDE: number;
  23684. /**
  23685. * Mesh cap setting : no cap
  23686. */
  23687. static readonly NO_CAP: number;
  23688. /**
  23689. * Mesh cap setting : one cap at the beginning of the mesh
  23690. */
  23691. static readonly CAP_START: number;
  23692. /**
  23693. * Mesh cap setting : one cap at the end of the mesh
  23694. */
  23695. static readonly CAP_END: number;
  23696. /**
  23697. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23698. */
  23699. static readonly CAP_ALL: number;
  23700. /**
  23701. * Mesh pattern setting : no flip or rotate
  23702. */
  23703. static readonly NO_FLIP: number;
  23704. /**
  23705. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23706. */
  23707. static readonly FLIP_TILE: number;
  23708. /**
  23709. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23710. */
  23711. static readonly ROTATE_TILE: number;
  23712. /**
  23713. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23714. */
  23715. static readonly FLIP_ROW: number;
  23716. /**
  23717. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23718. */
  23719. static readonly ROTATE_ROW: number;
  23720. /**
  23721. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23722. */
  23723. static readonly FLIP_N_ROTATE_TILE: number;
  23724. /**
  23725. * Mesh pattern setting : rotate pattern and rotate
  23726. */
  23727. static readonly FLIP_N_ROTATE_ROW: number;
  23728. /**
  23729. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23730. */
  23731. static readonly CENTER: number;
  23732. /**
  23733. * Mesh tile positioning : part tiles on left
  23734. */
  23735. static readonly LEFT: number;
  23736. /**
  23737. * Mesh tile positioning : part tiles on right
  23738. */
  23739. static readonly RIGHT: number;
  23740. /**
  23741. * Mesh tile positioning : part tiles on top
  23742. */
  23743. static readonly TOP: number;
  23744. /**
  23745. * Mesh tile positioning : part tiles on bottom
  23746. */
  23747. static readonly BOTTOM: number;
  23748. /**
  23749. * Gets the default side orientation.
  23750. * @param orientation the orientation to value to attempt to get
  23751. * @returns the default orientation
  23752. * @hidden
  23753. */
  23754. static _GetDefaultSideOrientation(orientation?: number): number;
  23755. private _internalMeshDataInfo;
  23756. /**
  23757. * An event triggered before rendering the mesh
  23758. */
  23759. readonly onBeforeRenderObservable: Observable<Mesh>;
  23760. /**
  23761. * An event triggered before binding the mesh
  23762. */
  23763. readonly onBeforeBindObservable: Observable<Mesh>;
  23764. /**
  23765. * An event triggered after rendering the mesh
  23766. */
  23767. readonly onAfterRenderObservable: Observable<Mesh>;
  23768. /**
  23769. * An event triggered before drawing the mesh
  23770. */
  23771. readonly onBeforeDrawObservable: Observable<Mesh>;
  23772. private _onBeforeDrawObserver;
  23773. /**
  23774. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23775. */
  23776. onBeforeDraw: () => void;
  23777. readonly hasInstances: boolean;
  23778. /**
  23779. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23780. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23781. */
  23782. delayLoadState: number;
  23783. /**
  23784. * Gets the list of instances created from this mesh
  23785. * it is not supposed to be modified manually.
  23786. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23787. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23788. */
  23789. instances: InstancedMesh[];
  23790. /**
  23791. * Gets the file containing delay loading data for this mesh
  23792. */
  23793. delayLoadingFile: string;
  23794. /** @hidden */
  23795. _binaryInfo: any;
  23796. /**
  23797. * User defined function used to change how LOD level selection is done
  23798. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23799. */
  23800. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23801. /**
  23802. * Gets or sets the morph target manager
  23803. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23804. */
  23805. morphTargetManager: Nullable<MorphTargetManager>;
  23806. /** @hidden */
  23807. _creationDataStorage: Nullable<_CreationDataStorage>;
  23808. /** @hidden */
  23809. _geometry: Nullable<Geometry>;
  23810. /** @hidden */
  23811. _delayInfo: Array<string>;
  23812. /** @hidden */
  23813. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23814. /** @hidden */
  23815. _instanceDataStorage: _InstanceDataStorage;
  23816. private _effectiveMaterial;
  23817. /** @hidden */
  23818. _shouldGenerateFlatShading: boolean;
  23819. /** @hidden */
  23820. _originalBuilderSideOrientation: number;
  23821. /**
  23822. * Use this property to change the original side orientation defined at construction time
  23823. */
  23824. overrideMaterialSideOrientation: Nullable<number>;
  23825. /**
  23826. * Gets the source mesh (the one used to clone this one from)
  23827. */
  23828. readonly source: Nullable<Mesh>;
  23829. /**
  23830. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23831. */
  23832. isUnIndexed: boolean;
  23833. /**
  23834. * @constructor
  23835. * @param name The value used by scene.getMeshByName() to do a lookup.
  23836. * @param scene The scene to add this mesh to.
  23837. * @param parent The parent of this mesh, if it has one
  23838. * @param source An optional Mesh from which geometry is shared, cloned.
  23839. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23840. * When false, achieved by calling a clone(), also passing False.
  23841. * This will make creation of children, recursive.
  23842. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23843. */
  23844. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23845. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  23846. doNotInstantiate: boolean;
  23847. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  23848. /**
  23849. * Gets the class name
  23850. * @returns the string "Mesh".
  23851. */
  23852. getClassName(): string;
  23853. /** @hidden */
  23854. readonly _isMesh: boolean;
  23855. /**
  23856. * Returns a description of this mesh
  23857. * @param fullDetails define if full details about this mesh must be used
  23858. * @returns a descriptive string representing this mesh
  23859. */
  23860. toString(fullDetails?: boolean): string;
  23861. /** @hidden */
  23862. _unBindEffect(): void;
  23863. /**
  23864. * Gets a boolean indicating if this mesh has LOD
  23865. */
  23866. readonly hasLODLevels: boolean;
  23867. /**
  23868. * Gets the list of MeshLODLevel associated with the current mesh
  23869. * @returns an array of MeshLODLevel
  23870. */
  23871. getLODLevels(): MeshLODLevel[];
  23872. private _sortLODLevels;
  23873. /**
  23874. * Add a mesh as LOD level triggered at the given distance.
  23875. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23876. * @param distance The distance from the center of the object to show this level
  23877. * @param mesh The mesh to be added as LOD level (can be null)
  23878. * @return This mesh (for chaining)
  23879. */
  23880. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23881. /**
  23882. * Returns the LOD level mesh at the passed distance or null if not found.
  23883. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23884. * @param distance The distance from the center of the object to show this level
  23885. * @returns a Mesh or `null`
  23886. */
  23887. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23888. /**
  23889. * Remove a mesh from the LOD array
  23890. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23891. * @param mesh defines the mesh to be removed
  23892. * @return This mesh (for chaining)
  23893. */
  23894. removeLODLevel(mesh: Mesh): Mesh;
  23895. /**
  23896. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23897. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23898. * @param camera defines the camera to use to compute distance
  23899. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23900. * @return This mesh (for chaining)
  23901. */
  23902. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23903. /**
  23904. * Gets the mesh internal Geometry object
  23905. */
  23906. readonly geometry: Nullable<Geometry>;
  23907. /**
  23908. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23909. * @returns the total number of vertices
  23910. */
  23911. getTotalVertices(): number;
  23912. /**
  23913. * Returns the content of an associated vertex buffer
  23914. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23915. * - VertexBuffer.PositionKind
  23916. * - VertexBuffer.UVKind
  23917. * - VertexBuffer.UV2Kind
  23918. * - VertexBuffer.UV3Kind
  23919. * - VertexBuffer.UV4Kind
  23920. * - VertexBuffer.UV5Kind
  23921. * - VertexBuffer.UV6Kind
  23922. * - VertexBuffer.ColorKind
  23923. * - VertexBuffer.MatricesIndicesKind
  23924. * - VertexBuffer.MatricesIndicesExtraKind
  23925. * - VertexBuffer.MatricesWeightsKind
  23926. * - VertexBuffer.MatricesWeightsExtraKind
  23927. * @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
  23928. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23929. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23930. */
  23931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23932. /**
  23933. * Returns the mesh VertexBuffer object from the requested `kind`
  23934. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23935. * - VertexBuffer.PositionKind
  23936. * - VertexBuffer.NormalKind
  23937. * - VertexBuffer.UVKind
  23938. * - VertexBuffer.UV2Kind
  23939. * - VertexBuffer.UV3Kind
  23940. * - VertexBuffer.UV4Kind
  23941. * - VertexBuffer.UV5Kind
  23942. * - VertexBuffer.UV6Kind
  23943. * - VertexBuffer.ColorKind
  23944. * - VertexBuffer.MatricesIndicesKind
  23945. * - VertexBuffer.MatricesIndicesExtraKind
  23946. * - VertexBuffer.MatricesWeightsKind
  23947. * - VertexBuffer.MatricesWeightsExtraKind
  23948. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23949. */
  23950. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23951. /**
  23952. * Tests if a specific vertex buffer is associated with this mesh
  23953. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23954. * - VertexBuffer.PositionKind
  23955. * - VertexBuffer.NormalKind
  23956. * - VertexBuffer.UVKind
  23957. * - VertexBuffer.UV2Kind
  23958. * - VertexBuffer.UV3Kind
  23959. * - VertexBuffer.UV4Kind
  23960. * - VertexBuffer.UV5Kind
  23961. * - VertexBuffer.UV6Kind
  23962. * - VertexBuffer.ColorKind
  23963. * - VertexBuffer.MatricesIndicesKind
  23964. * - VertexBuffer.MatricesIndicesExtraKind
  23965. * - VertexBuffer.MatricesWeightsKind
  23966. * - VertexBuffer.MatricesWeightsExtraKind
  23967. * @returns a boolean
  23968. */
  23969. isVerticesDataPresent(kind: string): boolean;
  23970. /**
  23971. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23972. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23973. * - VertexBuffer.PositionKind
  23974. * - VertexBuffer.UVKind
  23975. * - VertexBuffer.UV2Kind
  23976. * - VertexBuffer.UV3Kind
  23977. * - VertexBuffer.UV4Kind
  23978. * - VertexBuffer.UV5Kind
  23979. * - VertexBuffer.UV6Kind
  23980. * - VertexBuffer.ColorKind
  23981. * - VertexBuffer.MatricesIndicesKind
  23982. * - VertexBuffer.MatricesIndicesExtraKind
  23983. * - VertexBuffer.MatricesWeightsKind
  23984. * - VertexBuffer.MatricesWeightsExtraKind
  23985. * @returns a boolean
  23986. */
  23987. isVertexBufferUpdatable(kind: string): boolean;
  23988. /**
  23989. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23990. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23991. * - VertexBuffer.PositionKind
  23992. * - VertexBuffer.NormalKind
  23993. * - VertexBuffer.UVKind
  23994. * - VertexBuffer.UV2Kind
  23995. * - VertexBuffer.UV3Kind
  23996. * - VertexBuffer.UV4Kind
  23997. * - VertexBuffer.UV5Kind
  23998. * - VertexBuffer.UV6Kind
  23999. * - VertexBuffer.ColorKind
  24000. * - VertexBuffer.MatricesIndicesKind
  24001. * - VertexBuffer.MatricesIndicesExtraKind
  24002. * - VertexBuffer.MatricesWeightsKind
  24003. * - VertexBuffer.MatricesWeightsExtraKind
  24004. * @returns an array of strings
  24005. */
  24006. getVerticesDataKinds(): string[];
  24007. /**
  24008. * Returns a positive integer : the total number of indices in this mesh geometry.
  24009. * @returns the numner of indices or zero if the mesh has no geometry.
  24010. */
  24011. getTotalIndices(): number;
  24012. /**
  24013. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24014. * @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.
  24015. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24016. * @returns the indices array or an empty array if the mesh has no geometry
  24017. */
  24018. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24019. readonly isBlocked: boolean;
  24020. /**
  24021. * Determine if the current mesh is ready to be rendered
  24022. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24023. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24024. * @returns true if all associated assets are ready (material, textures, shaders)
  24025. */
  24026. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24027. /**
  24028. * 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.
  24029. */
  24030. readonly areNormalsFrozen: boolean;
  24031. /**
  24032. * 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.
  24033. * @returns the current mesh
  24034. */
  24035. freezeNormals(): Mesh;
  24036. /**
  24037. * 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
  24038. * @returns the current mesh
  24039. */
  24040. unfreezeNormals(): Mesh;
  24041. /**
  24042. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24043. */
  24044. overridenInstanceCount: number;
  24045. /** @hidden */
  24046. _preActivate(): Mesh;
  24047. /** @hidden */
  24048. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24049. /** @hidden */
  24050. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24051. /**
  24052. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24053. * This means the mesh underlying bounding box and sphere are recomputed.
  24054. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24055. * @returns the current mesh
  24056. */
  24057. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24058. /** @hidden */
  24059. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24060. /**
  24061. * This function will subdivide the mesh into multiple submeshes
  24062. * @param count defines the expected number of submeshes
  24063. */
  24064. subdivide(count: number): void;
  24065. /**
  24066. * Copy a FloatArray into a specific associated vertex buffer
  24067. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24068. * - VertexBuffer.PositionKind
  24069. * - VertexBuffer.UVKind
  24070. * - VertexBuffer.UV2Kind
  24071. * - VertexBuffer.UV3Kind
  24072. * - VertexBuffer.UV4Kind
  24073. * - VertexBuffer.UV5Kind
  24074. * - VertexBuffer.UV6Kind
  24075. * - VertexBuffer.ColorKind
  24076. * - VertexBuffer.MatricesIndicesKind
  24077. * - VertexBuffer.MatricesIndicesExtraKind
  24078. * - VertexBuffer.MatricesWeightsKind
  24079. * - VertexBuffer.MatricesWeightsExtraKind
  24080. * @param data defines the data source
  24081. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24082. * @param stride defines the data stride size (can be null)
  24083. * @returns the current mesh
  24084. */
  24085. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24086. /**
  24087. * Delete a vertex buffer associated with this mesh
  24088. * @param kind defines which buffer to delete (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. */
  24102. removeVerticesData(kind: string): void;
  24103. /**
  24104. * Flags an associated vertex buffer as updatable
  24105. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24106. * - VertexBuffer.PositionKind
  24107. * - VertexBuffer.UVKind
  24108. * - VertexBuffer.UV2Kind
  24109. * - VertexBuffer.UV3Kind
  24110. * - VertexBuffer.UV4Kind
  24111. * - VertexBuffer.UV5Kind
  24112. * - VertexBuffer.UV6Kind
  24113. * - VertexBuffer.ColorKind
  24114. * - VertexBuffer.MatricesIndicesKind
  24115. * - VertexBuffer.MatricesIndicesExtraKind
  24116. * - VertexBuffer.MatricesWeightsKind
  24117. * - VertexBuffer.MatricesWeightsExtraKind
  24118. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24119. */
  24120. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24121. /**
  24122. * Sets the mesh global Vertex Buffer
  24123. * @param buffer defines the buffer to use
  24124. * @returns the current mesh
  24125. */
  24126. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24127. /**
  24128. * Update a specific associated vertex buffer
  24129. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24130. * - VertexBuffer.PositionKind
  24131. * - VertexBuffer.UVKind
  24132. * - VertexBuffer.UV2Kind
  24133. * - VertexBuffer.UV3Kind
  24134. * - VertexBuffer.UV4Kind
  24135. * - VertexBuffer.UV5Kind
  24136. * - VertexBuffer.UV6Kind
  24137. * - VertexBuffer.ColorKind
  24138. * - VertexBuffer.MatricesIndicesKind
  24139. * - VertexBuffer.MatricesIndicesExtraKind
  24140. * - VertexBuffer.MatricesWeightsKind
  24141. * - VertexBuffer.MatricesWeightsExtraKind
  24142. * @param data defines the data source
  24143. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24144. * @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)
  24145. * @returns the current mesh
  24146. */
  24147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24148. /**
  24149. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24150. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24151. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24152. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24153. * @returns the current mesh
  24154. */
  24155. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24156. /**
  24157. * Creates a un-shared specific occurence of the geometry for the mesh.
  24158. * @returns the current mesh
  24159. */
  24160. makeGeometryUnique(): Mesh;
  24161. /**
  24162. * Set the index buffer of this mesh
  24163. * @param indices defines the source data
  24164. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24165. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24166. * @returns the current mesh
  24167. */
  24168. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24169. /**
  24170. * Update the current index buffer
  24171. * @param indices defines the source data
  24172. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24173. * @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)
  24174. * @returns the current mesh
  24175. */
  24176. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24177. /**
  24178. * Invert the geometry to move from a right handed system to a left handed one.
  24179. * @returns the current mesh
  24180. */
  24181. toLeftHanded(): Mesh;
  24182. /** @hidden */
  24183. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24184. /** @hidden */
  24185. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24186. /**
  24187. * Registers for this mesh a javascript function called just before the rendering process
  24188. * @param func defines the function to call before rendering this mesh
  24189. * @returns the current mesh
  24190. */
  24191. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24192. /**
  24193. * Disposes a previously registered javascript function called before the rendering
  24194. * @param func defines the function to remove
  24195. * @returns the current mesh
  24196. */
  24197. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24198. /**
  24199. * Registers for this mesh a javascript function called just after the rendering is complete
  24200. * @param func defines the function to call after rendering this mesh
  24201. * @returns the current mesh
  24202. */
  24203. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24204. /**
  24205. * Disposes a previously registered javascript function called after the rendering.
  24206. * @param func defines the function to remove
  24207. * @returns the current mesh
  24208. */
  24209. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24210. /** @hidden */
  24211. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24212. /** @hidden */
  24213. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24214. /** @hidden */
  24215. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24216. /** @hidden */
  24217. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24218. /** @hidden */
  24219. _rebuild(): void;
  24220. /** @hidden */
  24221. _freeze(): void;
  24222. /** @hidden */
  24223. _unFreeze(): void;
  24224. /**
  24225. * 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
  24226. * @param subMesh defines the subMesh to render
  24227. * @param enableAlphaMode defines if alpha mode can be changed
  24228. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24229. * @returns the current mesh
  24230. */
  24231. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24232. private _onBeforeDraw;
  24233. /**
  24234. * Renormalize the mesh and patch it up if there are no weights
  24235. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24236. * However in the case of zero weights then we set just a single influence to 1.
  24237. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24238. */
  24239. cleanMatrixWeights(): void;
  24240. private normalizeSkinFourWeights;
  24241. private normalizeSkinWeightsAndExtra;
  24242. /**
  24243. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24244. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24245. * the user know there was an issue with importing the mesh
  24246. * @returns a validation object with skinned, valid and report string
  24247. */
  24248. validateSkinning(): {
  24249. skinned: boolean;
  24250. valid: boolean;
  24251. report: string;
  24252. };
  24253. /** @hidden */
  24254. _checkDelayState(): Mesh;
  24255. private _queueLoad;
  24256. /**
  24257. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24258. * A mesh is in the frustum if its bounding box intersects the frustum
  24259. * @param frustumPlanes defines the frustum to test
  24260. * @returns true if the mesh is in the frustum planes
  24261. */
  24262. isInFrustum(frustumPlanes: Plane[]): boolean;
  24263. /**
  24264. * Sets the mesh material by the material or multiMaterial `id` property
  24265. * @param id is a string identifying the material or the multiMaterial
  24266. * @returns the current mesh
  24267. */
  24268. setMaterialByID(id: string): Mesh;
  24269. /**
  24270. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24271. * @returns an array of IAnimatable
  24272. */
  24273. getAnimatables(): IAnimatable[];
  24274. /**
  24275. * Modifies the mesh geometry according to the passed transformation matrix.
  24276. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24277. * The mesh normals are modified using the same transformation.
  24278. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24279. * @param transform defines the transform matrix to use
  24280. * @see http://doc.babylonjs.com/resources/baking_transformations
  24281. * @returns the current mesh
  24282. */
  24283. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24284. /**
  24285. * Modifies the mesh geometry according to its own current World Matrix.
  24286. * The mesh World Matrix is then reset.
  24287. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24288. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24289. * @see http://doc.babylonjs.com/resources/baking_transformations
  24290. * @returns the current mesh
  24291. */
  24292. bakeCurrentTransformIntoVertices(): Mesh;
  24293. /** @hidden */
  24294. readonly _positions: Nullable<Vector3[]>;
  24295. /** @hidden */
  24296. _resetPointsArrayCache(): Mesh;
  24297. /** @hidden */
  24298. _generatePointsArray(): boolean;
  24299. /**
  24300. * Returns a new Mesh object generated from the current mesh properties.
  24301. * This method must not get confused with createInstance()
  24302. * @param name is a string, the name given to the new mesh
  24303. * @param newParent can be any Node object (default `null`)
  24304. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24305. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24306. * @returns a new mesh
  24307. */
  24308. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24309. /**
  24310. * Releases resources associated with this mesh.
  24311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24313. */
  24314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24315. /** @hidden */
  24316. _disposeInstanceSpecificData(): void;
  24317. /**
  24318. * Modifies the mesh geometry according to a displacement map.
  24319. * 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.
  24320. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24321. * @param url is a string, the URL from the image file is to be downloaded.
  24322. * @param minHeight is the lower limit of the displacement.
  24323. * @param maxHeight is the upper limit of the displacement.
  24324. * @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.
  24325. * @param uvOffset is an optional vector2 used to offset UV.
  24326. * @param uvScale is an optional vector2 used to scale UV.
  24327. * @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.
  24328. * @returns the Mesh.
  24329. */
  24330. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24331. /**
  24332. * Modifies the mesh geometry according to a displacementMap buffer.
  24333. * 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.
  24334. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24335. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24336. * @param heightMapWidth is the width of the buffer image.
  24337. * @param heightMapHeight is the height of the buffer image.
  24338. * @param minHeight is the lower limit of the displacement.
  24339. * @param maxHeight is the upper limit of the displacement.
  24340. * @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.
  24341. * @param uvOffset is an optional vector2 used to offset UV.
  24342. * @param uvScale is an optional vector2 used to scale UV.
  24343. * @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.
  24344. * @returns the Mesh.
  24345. */
  24346. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24347. /**
  24348. * Modify the mesh to get a flat shading rendering.
  24349. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24350. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24351. * @returns current mesh
  24352. */
  24353. convertToFlatShadedMesh(): Mesh;
  24354. /**
  24355. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24356. * In other words, more vertices, no more indices and a single bigger VBO.
  24357. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24358. * @returns current mesh
  24359. */
  24360. convertToUnIndexedMesh(): Mesh;
  24361. /**
  24362. * Inverses facet orientations.
  24363. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24364. * @param flipNormals will also inverts the normals
  24365. * @returns current mesh
  24366. */
  24367. flipFaces(flipNormals?: boolean): Mesh;
  24368. /**
  24369. * Increase the number of facets and hence vertices in a mesh
  24370. * Vertex normals are interpolated from existing vertex normals
  24371. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24372. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24373. */
  24374. increaseVertices(numberPerEdge: number): void;
  24375. /**
  24376. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24377. * This will undo any application of covertToFlatShadedMesh
  24378. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24379. */
  24380. forceSharedVertices(): void;
  24381. /** @hidden */
  24382. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24383. /** @hidden */
  24384. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24385. /**
  24386. * Creates a new InstancedMesh object from the mesh model.
  24387. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24388. * @param name defines the name of the new instance
  24389. * @returns a new InstancedMesh
  24390. */
  24391. createInstance(name: string): InstancedMesh;
  24392. /**
  24393. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24394. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24395. * @returns the current mesh
  24396. */
  24397. synchronizeInstances(): Mesh;
  24398. /**
  24399. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24400. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24401. * This should be used together with the simplification to avoid disappearing triangles.
  24402. * @param successCallback an optional success callback to be called after the optimization finished.
  24403. * @returns the current mesh
  24404. */
  24405. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24406. /**
  24407. * Serialize current mesh
  24408. * @param serializationObject defines the object which will receive the serialization data
  24409. */
  24410. serialize(serializationObject: any): void;
  24411. /** @hidden */
  24412. _syncGeometryWithMorphTargetManager(): void;
  24413. /** @hidden */
  24414. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24415. /**
  24416. * Returns a new Mesh object parsed from the source provided.
  24417. * @param parsedMesh is the source
  24418. * @param scene defines the hosting scene
  24419. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24420. * @returns a new Mesh
  24421. */
  24422. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24423. /**
  24424. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24425. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24426. * @param name defines the name of the mesh to create
  24427. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24428. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24429. * @param closePath creates a seam between the first and the last points of each path of the path array
  24430. * @param offset is taken in account only if the `pathArray` is containing a single path
  24431. * @param scene defines the hosting scene
  24432. * @param updatable defines if the mesh must be flagged as updatable
  24433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24434. * @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)
  24435. * @returns a new Mesh
  24436. */
  24437. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24438. /**
  24439. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24440. * @param name defines the name of the mesh to create
  24441. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24442. * @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
  24443. * @param scene defines the hosting scene
  24444. * @param updatable defines if the mesh must be flagged as updatable
  24445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24446. * @returns a new Mesh
  24447. */
  24448. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24449. /**
  24450. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24451. * @param name defines the name of the mesh to create
  24452. * @param size sets the size (float) of each box side (default 1)
  24453. * @param scene defines the hosting scene
  24454. * @param updatable defines if the mesh must be flagged as updatable
  24455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24456. * @returns a new Mesh
  24457. */
  24458. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24459. /**
  24460. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24461. * @param name defines the name of the mesh to create
  24462. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24463. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24464. * @param scene defines the hosting scene
  24465. * @param updatable defines if the mesh must be flagged as updatable
  24466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24467. * @returns a new Mesh
  24468. */
  24469. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24470. /**
  24471. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24472. * @param name defines the name of the mesh to create
  24473. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24474. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24475. * @param scene defines the hosting scene
  24476. * @returns a new Mesh
  24477. */
  24478. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24479. /**
  24480. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24481. * @param name defines the name of the mesh to create
  24482. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24483. * @param diameterTop set the top cap diameter (floats, default 1)
  24484. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24485. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24486. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24487. * @param scene defines the hosting scene
  24488. * @param updatable defines if the mesh must be flagged as updatable
  24489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24490. * @returns a new Mesh
  24491. */
  24492. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24493. /**
  24494. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24495. * @param name defines the name of the mesh to create
  24496. * @param diameter sets the diameter size (float) of the torus (default 1)
  24497. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24498. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24499. * @param scene defines the hosting scene
  24500. * @param updatable defines if the mesh must be flagged as updatable
  24501. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24502. * @returns a new Mesh
  24503. */
  24504. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24505. /**
  24506. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24507. * @param name defines the name of the mesh to create
  24508. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24509. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24510. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24511. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24512. * @param p the number of windings on X axis (positive integers, default 2)
  24513. * @param q the number of windings on Y axis (positive integers, default 3)
  24514. * @param scene defines the hosting scene
  24515. * @param updatable defines if the mesh must be flagged as updatable
  24516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24517. * @returns a new Mesh
  24518. */
  24519. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24520. /**
  24521. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24522. * @param name defines the name of the mesh to create
  24523. * @param points is an array successive Vector3
  24524. * @param scene defines the hosting scene
  24525. * @param updatable defines if the mesh must be flagged as updatable
  24526. * @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).
  24527. * @returns a new Mesh
  24528. */
  24529. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24530. /**
  24531. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24532. * @param name defines the name of the mesh to create
  24533. * @param points is an array successive Vector3
  24534. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24535. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24536. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24537. * @param scene defines the hosting scene
  24538. * @param updatable defines if the mesh must be flagged as updatable
  24539. * @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)
  24540. * @returns a new Mesh
  24541. */
  24542. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24543. /**
  24544. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24545. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24546. * 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.
  24547. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24548. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24549. * Remember you can only change the shape positions, not their number when updating a polygon.
  24550. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24551. * @param name defines the name of the mesh to create
  24552. * @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
  24553. * @param scene defines the hosting scene
  24554. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24555. * @param updatable defines if the mesh must be flagged as updatable
  24556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24557. * @param earcutInjection can be used to inject your own earcut reference
  24558. * @returns a new Mesh
  24559. */
  24560. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24561. /**
  24562. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24563. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24564. * @param name defines the name of the mesh to create
  24565. * @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
  24566. * @param depth defines the height of extrusion
  24567. * @param scene defines the hosting scene
  24568. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24569. * @param updatable defines if the mesh must be flagged as updatable
  24570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24571. * @param earcutInjection can be used to inject your own earcut reference
  24572. * @returns a new Mesh
  24573. */
  24574. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24575. /**
  24576. * Creates an extruded shape mesh.
  24577. * 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
  24578. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24579. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24580. * @param name defines the name of the mesh to create
  24581. * @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
  24582. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24583. * @param scale is the value to scale the shape
  24584. * @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
  24585. * @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
  24586. * @param scene defines the hosting scene
  24587. * @param updatable defines if the mesh must be flagged as updatable
  24588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24589. * @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)
  24590. * @returns a new Mesh
  24591. */
  24592. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24593. /**
  24594. * Creates an custom extruded shape mesh.
  24595. * The custom extrusion is a parametric shape.
  24596. * It has no predefined shape. Its final shape will depend on the input parameters.
  24597. * Please consider using the same method from the MeshBuilder class instead
  24598. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24599. * @param name defines the name of the mesh to create
  24600. * @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
  24601. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24602. * @param scaleFunction is a custom Javascript function called on each path point
  24603. * @param rotationFunction is a custom Javascript function called on each path point
  24604. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24605. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24606. * @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
  24607. * @param scene defines the hosting scene
  24608. * @param updatable defines if the mesh must be flagged as updatable
  24609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24610. * @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)
  24611. * @returns a new Mesh
  24612. */
  24613. 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;
  24614. /**
  24615. * Creates lathe mesh.
  24616. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24617. * Please consider using the same method from the MeshBuilder class instead
  24618. * @param name defines the name of the mesh to create
  24619. * @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
  24620. * @param radius is the radius value of the lathe
  24621. * @param tessellation is the side number of the lathe.
  24622. * @param scene defines the hosting scene
  24623. * @param updatable defines if the mesh must be flagged as updatable
  24624. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24625. * @returns a new Mesh
  24626. */
  24627. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24628. /**
  24629. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24630. * @param name defines the name of the mesh to create
  24631. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24632. * @param scene defines the hosting scene
  24633. * @param updatable defines if the mesh must be flagged as updatable
  24634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24635. * @returns a new Mesh
  24636. */
  24637. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24638. /**
  24639. * Creates a ground mesh.
  24640. * Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param width set the width of the ground
  24643. * @param height set the height of the ground
  24644. * @param subdivisions sets the number of subdivisions per side
  24645. * @param scene defines the hosting scene
  24646. * @param updatable defines if the mesh must be flagged as updatable
  24647. * @returns a new Mesh
  24648. */
  24649. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24650. /**
  24651. * Creates a tiled ground mesh.
  24652. * Please consider using the same method from the MeshBuilder class instead
  24653. * @param name defines the name of the mesh to create
  24654. * @param xmin set the ground minimum X coordinate
  24655. * @param zmin set the ground minimum Y coordinate
  24656. * @param xmax set the ground maximum X coordinate
  24657. * @param zmax set the ground maximum Z coordinate
  24658. * @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
  24659. * @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
  24660. * @param scene defines the hosting scene
  24661. * @param updatable defines if the mesh must be flagged as updatable
  24662. * @returns a new Mesh
  24663. */
  24664. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24665. w: number;
  24666. h: number;
  24667. }, precision: {
  24668. w: number;
  24669. h: number;
  24670. }, scene: Scene, updatable?: boolean): Mesh;
  24671. /**
  24672. * Creates a ground mesh from a height map.
  24673. * Please consider using the same method from the MeshBuilder class instead
  24674. * @see http://doc.babylonjs.com/babylon101/height_map
  24675. * @param name defines the name of the mesh to create
  24676. * @param url sets the URL of the height map image resource
  24677. * @param width set the ground width size
  24678. * @param height set the ground height size
  24679. * @param subdivisions sets the number of subdivision per side
  24680. * @param minHeight is the minimum altitude on the ground
  24681. * @param maxHeight is the maximum altitude on the ground
  24682. * @param scene defines the hosting scene
  24683. * @param updatable defines if the mesh must be flagged as updatable
  24684. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24685. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24686. * @returns a new Mesh
  24687. */
  24688. 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;
  24689. /**
  24690. * Creates a tube mesh.
  24691. * The tube is a parametric shape.
  24692. * It has no predefined shape. Its final shape will depend on the input parameters.
  24693. * Please consider using the same method from the MeshBuilder class instead
  24694. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24695. * @param name defines the name of the mesh to create
  24696. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24697. * @param radius sets the tube radius size
  24698. * @param tessellation is the number of sides on the tubular surface
  24699. * @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
  24700. * @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
  24701. * @param scene defines the hosting scene
  24702. * @param updatable defines if the mesh must be flagged as updatable
  24703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24704. * @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)
  24705. * @returns a new Mesh
  24706. */
  24707. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24708. (i: number, distance: number): number;
  24709. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24710. /**
  24711. * Creates a polyhedron mesh.
  24712. * Please consider using the same method from the MeshBuilder class instead.
  24713. * * 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
  24714. * * The parameter `size` (positive float, default 1) sets the polygon size
  24715. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24716. * * 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`
  24717. * * 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
  24718. * * 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)`)
  24719. * * 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
  24720. * * 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
  24721. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24722. * * 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
  24723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24724. * @param name defines the name of the mesh to create
  24725. * @param options defines the options used to create the mesh
  24726. * @param scene defines the hosting scene
  24727. * @returns a new Mesh
  24728. */
  24729. static CreatePolyhedron(name: string, options: {
  24730. type?: number;
  24731. size?: number;
  24732. sizeX?: number;
  24733. sizeY?: number;
  24734. sizeZ?: number;
  24735. custom?: any;
  24736. faceUV?: Vector4[];
  24737. faceColors?: Color4[];
  24738. updatable?: boolean;
  24739. sideOrientation?: number;
  24740. }, scene: Scene): Mesh;
  24741. /**
  24742. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24743. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24744. * * 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`)
  24745. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24746. * * 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
  24747. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24748. * * 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
  24749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24750. * @param name defines the name of the mesh
  24751. * @param options defines the options used to create the mesh
  24752. * @param scene defines the hosting scene
  24753. * @returns a new Mesh
  24754. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24755. */
  24756. static CreateIcoSphere(name: string, options: {
  24757. radius?: number;
  24758. flat?: boolean;
  24759. subdivisions?: number;
  24760. sideOrientation?: number;
  24761. updatable?: boolean;
  24762. }, scene: Scene): Mesh;
  24763. /**
  24764. * Creates a decal mesh.
  24765. * Please consider using the same method from the MeshBuilder class instead.
  24766. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24767. * @param name defines the name of the mesh
  24768. * @param sourceMesh defines the mesh receiving the decal
  24769. * @param position sets the position of the decal in world coordinates
  24770. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24771. * @param size sets the decal scaling
  24772. * @param angle sets the angle to rotate the decal
  24773. * @returns a new Mesh
  24774. */
  24775. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24776. /**
  24777. * Prepare internal position array for software CPU skinning
  24778. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24779. */
  24780. setPositionsForCPUSkinning(): Float32Array;
  24781. /**
  24782. * Prepare internal normal array for software CPU skinning
  24783. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24784. */
  24785. setNormalsForCPUSkinning(): Float32Array;
  24786. /**
  24787. * Updates the vertex buffer by applying transformation from the bones
  24788. * @param skeleton defines the skeleton to apply to current mesh
  24789. * @returns the current mesh
  24790. */
  24791. applySkeleton(skeleton: Skeleton): Mesh;
  24792. /**
  24793. * 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
  24794. * @param meshes defines the list of meshes to scan
  24795. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24796. */
  24797. static MinMax(meshes: AbstractMesh[]): {
  24798. min: Vector3;
  24799. max: Vector3;
  24800. };
  24801. /**
  24802. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24803. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24804. * @returns a vector3
  24805. */
  24806. static Center(meshesOrMinMaxVector: {
  24807. min: Vector3;
  24808. max: Vector3;
  24809. } | AbstractMesh[]): Vector3;
  24810. /**
  24811. * Merge the array of meshes into a single mesh for performance reasons.
  24812. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24813. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24814. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24815. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24816. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24817. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24818. * @returns a new mesh
  24819. */
  24820. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24821. /** @hidden */
  24822. addInstance(instance: InstancedMesh): void;
  24823. /** @hidden */
  24824. removeInstance(instance: InstancedMesh): void;
  24825. }
  24826. }
  24827. declare module BABYLON {
  24828. /**
  24829. * This is the base class of all the camera used in the application.
  24830. * @see http://doc.babylonjs.com/features/cameras
  24831. */
  24832. export class Camera extends Node {
  24833. /** @hidden */
  24834. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24835. /**
  24836. * This is the default projection mode used by the cameras.
  24837. * It helps recreating a feeling of perspective and better appreciate depth.
  24838. * This is the best way to simulate real life cameras.
  24839. */
  24840. static readonly PERSPECTIVE_CAMERA: number;
  24841. /**
  24842. * This helps creating camera with an orthographic mode.
  24843. * 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.
  24844. */
  24845. static readonly ORTHOGRAPHIC_CAMERA: number;
  24846. /**
  24847. * This is the default FOV mode for perspective cameras.
  24848. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24849. */
  24850. static readonly FOVMODE_VERTICAL_FIXED: number;
  24851. /**
  24852. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24853. */
  24854. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24855. /**
  24856. * This specifies ther is no need for a camera rig.
  24857. * Basically only one eye is rendered corresponding to the camera.
  24858. */
  24859. static readonly RIG_MODE_NONE: number;
  24860. /**
  24861. * Simulates a camera Rig with one blue eye and one red eye.
  24862. * This can be use with 3d blue and red glasses.
  24863. */
  24864. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24865. /**
  24866. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24867. */
  24868. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24869. /**
  24870. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24871. */
  24872. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24873. /**
  24874. * Defines that both eyes of the camera will be rendered over under each other.
  24875. */
  24876. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24877. /**
  24878. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24879. */
  24880. static readonly RIG_MODE_VR: number;
  24881. /**
  24882. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24883. */
  24884. static readonly RIG_MODE_WEBVR: number;
  24885. /**
  24886. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24887. */
  24888. static readonly RIG_MODE_CUSTOM: number;
  24889. /**
  24890. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24891. */
  24892. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24893. /**
  24894. * Define the input manager associated with the camera.
  24895. */
  24896. inputs: CameraInputsManager<Camera>;
  24897. /** @hidden */
  24898. _position: Vector3;
  24899. /**
  24900. * Define the current local position of the camera in the scene
  24901. */
  24902. position: Vector3;
  24903. /**
  24904. * The vector the camera should consider as up.
  24905. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24906. */
  24907. upVector: Vector3;
  24908. /**
  24909. * Define the current limit on the left side for an orthographic camera
  24910. * In scene unit
  24911. */
  24912. orthoLeft: Nullable<number>;
  24913. /**
  24914. * Define the current limit on the right side for an orthographic camera
  24915. * In scene unit
  24916. */
  24917. orthoRight: Nullable<number>;
  24918. /**
  24919. * Define the current limit on the bottom side for an orthographic camera
  24920. * In scene unit
  24921. */
  24922. orthoBottom: Nullable<number>;
  24923. /**
  24924. * Define the current limit on the top side for an orthographic camera
  24925. * In scene unit
  24926. */
  24927. orthoTop: Nullable<number>;
  24928. /**
  24929. * Field Of View is set in Radians. (default is 0.8)
  24930. */
  24931. fov: number;
  24932. /**
  24933. * Define the minimum distance the camera can see from.
  24934. * This is important to note that the depth buffer are not infinite and the closer it starts
  24935. * the more your scene might encounter depth fighting issue.
  24936. */
  24937. minZ: number;
  24938. /**
  24939. * Define the maximum distance the camera can see to.
  24940. * This is important to note that the depth buffer are not infinite and the further it end
  24941. * the more your scene might encounter depth fighting issue.
  24942. */
  24943. maxZ: number;
  24944. /**
  24945. * Define the default inertia of the camera.
  24946. * This helps giving a smooth feeling to the camera movement.
  24947. */
  24948. inertia: number;
  24949. /**
  24950. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24951. */
  24952. mode: number;
  24953. /**
  24954. * Define wether the camera is intermediate.
  24955. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24956. */
  24957. isIntermediate: boolean;
  24958. /**
  24959. * Define the viewport of the camera.
  24960. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24961. */
  24962. viewport: Viewport;
  24963. /**
  24964. * Restricts the camera to viewing objects with the same layerMask.
  24965. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24966. */
  24967. layerMask: number;
  24968. /**
  24969. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24970. */
  24971. fovMode: number;
  24972. /**
  24973. * Rig mode of the camera.
  24974. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24975. * This is normally controlled byt the camera themselves as internal use.
  24976. */
  24977. cameraRigMode: number;
  24978. /**
  24979. * Defines the distance between both "eyes" in case of a RIG
  24980. */
  24981. interaxialDistance: number;
  24982. /**
  24983. * Defines if stereoscopic rendering is done side by side or over under.
  24984. */
  24985. isStereoscopicSideBySide: boolean;
  24986. /**
  24987. * 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
  24988. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24989. * else in the scene. (Eg. security camera)
  24990. *
  24991. * 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)
  24992. */
  24993. customRenderTargets: RenderTargetTexture[];
  24994. /**
  24995. * When set, the camera will render to this render target instead of the default canvas
  24996. *
  24997. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24998. */
  24999. outputRenderTarget: Nullable<RenderTargetTexture>;
  25000. /**
  25001. * Observable triggered when the camera view matrix has changed.
  25002. */
  25003. onViewMatrixChangedObservable: Observable<Camera>;
  25004. /**
  25005. * Observable triggered when the camera Projection matrix has changed.
  25006. */
  25007. onProjectionMatrixChangedObservable: Observable<Camera>;
  25008. /**
  25009. * Observable triggered when the inputs have been processed.
  25010. */
  25011. onAfterCheckInputsObservable: Observable<Camera>;
  25012. /**
  25013. * Observable triggered when reset has been called and applied to the camera.
  25014. */
  25015. onRestoreStateObservable: Observable<Camera>;
  25016. /** @hidden */
  25017. _cameraRigParams: any;
  25018. /** @hidden */
  25019. _rigCameras: Camera[];
  25020. /** @hidden */
  25021. _rigPostProcess: Nullable<PostProcess>;
  25022. protected _webvrViewMatrix: Matrix;
  25023. /** @hidden */
  25024. _skipRendering: boolean;
  25025. /** @hidden */
  25026. _projectionMatrix: Matrix;
  25027. /** @hidden */
  25028. _postProcesses: Nullable<PostProcess>[];
  25029. /** @hidden */
  25030. _activeMeshes: SmartArray<AbstractMesh>;
  25031. protected _globalPosition: Vector3;
  25032. /** @hidden */
  25033. _computedViewMatrix: Matrix;
  25034. private _doNotComputeProjectionMatrix;
  25035. private _transformMatrix;
  25036. private _frustumPlanes;
  25037. private _refreshFrustumPlanes;
  25038. private _storedFov;
  25039. private _stateStored;
  25040. /**
  25041. * Instantiates a new camera object.
  25042. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25043. * @see http://doc.babylonjs.com/features/cameras
  25044. * @param name Defines the name of the camera in the scene
  25045. * @param position Defines the position of the camera
  25046. * @param scene Defines the scene the camera belongs too
  25047. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25048. */
  25049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25050. /**
  25051. * Store current camera state (fov, position, etc..)
  25052. * @returns the camera
  25053. */
  25054. storeState(): Camera;
  25055. /**
  25056. * Restores the camera state values if it has been stored. You must call storeState() first
  25057. */
  25058. protected _restoreStateValues(): boolean;
  25059. /**
  25060. * Restored camera state. You must call storeState() first.
  25061. * @returns true if restored and false otherwise
  25062. */
  25063. restoreState(): boolean;
  25064. /**
  25065. * Gets the class name of the camera.
  25066. * @returns the class name
  25067. */
  25068. getClassName(): string;
  25069. /** @hidden */
  25070. readonly _isCamera: boolean;
  25071. /**
  25072. * Gets a string representation of the camera useful for debug purpose.
  25073. * @param fullDetails Defines that a more verboe level of logging is required
  25074. * @returns the string representation
  25075. */
  25076. toString(fullDetails?: boolean): string;
  25077. /**
  25078. * Gets the current world space position of the camera.
  25079. */
  25080. readonly globalPosition: Vector3;
  25081. /**
  25082. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25083. * @returns the active meshe list
  25084. */
  25085. getActiveMeshes(): SmartArray<AbstractMesh>;
  25086. /**
  25087. * Check wether a mesh is part of the current active mesh list of the camera
  25088. * @param mesh Defines the mesh to check
  25089. * @returns true if active, false otherwise
  25090. */
  25091. isActiveMesh(mesh: Mesh): boolean;
  25092. /**
  25093. * Is this camera ready to be used/rendered
  25094. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25095. * @return true if the camera is ready
  25096. */
  25097. isReady(completeCheck?: boolean): boolean;
  25098. /** @hidden */
  25099. _initCache(): void;
  25100. /** @hidden */
  25101. _updateCache(ignoreParentClass?: boolean): void;
  25102. /** @hidden */
  25103. _isSynchronized(): boolean;
  25104. /** @hidden */
  25105. _isSynchronizedViewMatrix(): boolean;
  25106. /** @hidden */
  25107. _isSynchronizedProjectionMatrix(): boolean;
  25108. /**
  25109. * Attach the input controls to a specific dom element to get the input from.
  25110. * @param element Defines the element the controls should be listened from
  25111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25112. */
  25113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25114. /**
  25115. * Detach the current controls from the specified dom element.
  25116. * @param element Defines the element to stop listening the inputs from
  25117. */
  25118. detachControl(element: HTMLElement): void;
  25119. /**
  25120. * Update the camera state according to the different inputs gathered during the frame.
  25121. */
  25122. update(): void;
  25123. /** @hidden */
  25124. _checkInputs(): void;
  25125. /** @hidden */
  25126. readonly rigCameras: Camera[];
  25127. /**
  25128. * Gets the post process used by the rig cameras
  25129. */
  25130. readonly rigPostProcess: Nullable<PostProcess>;
  25131. /**
  25132. * Internal, gets the first post proces.
  25133. * @returns the first post process to be run on this camera.
  25134. */
  25135. _getFirstPostProcess(): Nullable<PostProcess>;
  25136. private _cascadePostProcessesToRigCams;
  25137. /**
  25138. * Attach a post process to the camera.
  25139. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25140. * @param postProcess The post process to attach to the camera
  25141. * @param insertAt The position of the post process in case several of them are in use in the scene
  25142. * @returns the position the post process has been inserted at
  25143. */
  25144. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25145. /**
  25146. * Detach a post process to the camera.
  25147. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25148. * @param postProcess The post process to detach from the camera
  25149. */
  25150. detachPostProcess(postProcess: PostProcess): void;
  25151. /**
  25152. * Gets the current world matrix of the camera
  25153. */
  25154. getWorldMatrix(): Matrix;
  25155. /** @hidden */
  25156. _getViewMatrix(): Matrix;
  25157. /**
  25158. * Gets the current view matrix of the camera.
  25159. * @param force forces the camera to recompute the matrix without looking at the cached state
  25160. * @returns the view matrix
  25161. */
  25162. getViewMatrix(force?: boolean): Matrix;
  25163. /**
  25164. * Freeze the projection matrix.
  25165. * It will prevent the cache check of the camera projection compute and can speed up perf
  25166. * if no parameter of the camera are meant to change
  25167. * @param projection Defines manually a projection if necessary
  25168. */
  25169. freezeProjectionMatrix(projection?: Matrix): void;
  25170. /**
  25171. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25172. */
  25173. unfreezeProjectionMatrix(): void;
  25174. /**
  25175. * Gets the current projection matrix of the camera.
  25176. * @param force forces the camera to recompute the matrix without looking at the cached state
  25177. * @returns the projection matrix
  25178. */
  25179. getProjectionMatrix(force?: boolean): Matrix;
  25180. /**
  25181. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25182. * @returns a Matrix
  25183. */
  25184. getTransformationMatrix(): Matrix;
  25185. private _updateFrustumPlanes;
  25186. /**
  25187. * Checks if a cullable object (mesh...) is in the camera frustum
  25188. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25189. * @param target The object to check
  25190. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25191. * @returns true if the object is in frustum otherwise false
  25192. */
  25193. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25194. /**
  25195. * Checks if a cullable object (mesh...) is in the camera frustum
  25196. * Unlike isInFrustum this cheks the full bounding box
  25197. * @param target The object to check
  25198. * @returns true if the object is in frustum otherwise false
  25199. */
  25200. isCompletelyInFrustum(target: ICullable): boolean;
  25201. /**
  25202. * Gets a ray in the forward direction from the camera.
  25203. * @param length Defines the length of the ray to create
  25204. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25205. * @param origin Defines the start point of the ray which defaults to the camera position
  25206. * @returns the forward ray
  25207. */
  25208. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25209. /**
  25210. * Releases resources associated with this node.
  25211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25213. */
  25214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25215. /** @hidden */
  25216. _isLeftCamera: boolean;
  25217. /**
  25218. * Gets the left camera of a rig setup in case of Rigged Camera
  25219. */
  25220. readonly isLeftCamera: boolean;
  25221. /** @hidden */
  25222. _isRightCamera: boolean;
  25223. /**
  25224. * Gets the right camera of a rig setup in case of Rigged Camera
  25225. */
  25226. readonly isRightCamera: boolean;
  25227. /**
  25228. * Gets the left camera of a rig setup in case of Rigged Camera
  25229. */
  25230. readonly leftCamera: Nullable<FreeCamera>;
  25231. /**
  25232. * Gets the right camera of a rig setup in case of Rigged Camera
  25233. */
  25234. readonly rightCamera: Nullable<FreeCamera>;
  25235. /**
  25236. * Gets the left camera target of a rig setup in case of Rigged Camera
  25237. * @returns the target position
  25238. */
  25239. getLeftTarget(): Nullable<Vector3>;
  25240. /**
  25241. * Gets the right camera target of a rig setup in case of Rigged Camera
  25242. * @returns the target position
  25243. */
  25244. getRightTarget(): Nullable<Vector3>;
  25245. /**
  25246. * @hidden
  25247. */
  25248. setCameraRigMode(mode: number, rigParams: any): void;
  25249. /** @hidden */
  25250. static _setStereoscopicRigMode(camera: Camera): void;
  25251. /** @hidden */
  25252. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25253. /** @hidden */
  25254. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25255. /** @hidden */
  25256. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25257. /** @hidden */
  25258. _getVRProjectionMatrix(): Matrix;
  25259. protected _updateCameraRotationMatrix(): void;
  25260. protected _updateWebVRCameraRotationMatrix(): void;
  25261. /**
  25262. * This function MUST be overwritten by the different WebVR cameras available.
  25263. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25264. * @hidden
  25265. */
  25266. _getWebVRProjectionMatrix(): Matrix;
  25267. /**
  25268. * This function MUST be overwritten by the different WebVR cameras available.
  25269. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25270. * @hidden
  25271. */
  25272. _getWebVRViewMatrix(): Matrix;
  25273. /** @hidden */
  25274. setCameraRigParameter(name: string, value: any): void;
  25275. /**
  25276. * needs to be overridden by children so sub has required properties to be copied
  25277. * @hidden
  25278. */
  25279. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25280. /**
  25281. * May need to be overridden by children
  25282. * @hidden
  25283. */
  25284. _updateRigCameras(): void;
  25285. /** @hidden */
  25286. _setupInputs(): void;
  25287. /**
  25288. * Serialiaze the camera setup to a json represention
  25289. * @returns the JSON representation
  25290. */
  25291. serialize(): any;
  25292. /**
  25293. * Clones the current camera.
  25294. * @param name The cloned camera name
  25295. * @returns the cloned camera
  25296. */
  25297. clone(name: string): Camera;
  25298. /**
  25299. * Gets the direction of the camera relative to a given local axis.
  25300. * @param localAxis Defines the reference axis to provide a relative direction.
  25301. * @return the direction
  25302. */
  25303. getDirection(localAxis: Vector3): Vector3;
  25304. /**
  25305. * Returns the current camera absolute rotation
  25306. */
  25307. readonly absoluteRotation: Quaternion;
  25308. /**
  25309. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25310. * @param localAxis Defines the reference axis to provide a relative direction.
  25311. * @param result Defines the vector to store the result in
  25312. */
  25313. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25314. /**
  25315. * Gets a camera constructor for a given camera type
  25316. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25317. * @param name The name of the camera the result will be able to instantiate
  25318. * @param scene The scene the result will construct the camera in
  25319. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25320. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25321. * @returns a factory method to construc the camera
  25322. */
  25323. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25324. /**
  25325. * Compute the world matrix of the camera.
  25326. * @returns the camera world matrix
  25327. */
  25328. computeWorldMatrix(): Matrix;
  25329. /**
  25330. * Parse a JSON and creates the camera from the parsed information
  25331. * @param parsedCamera The JSON to parse
  25332. * @param scene The scene to instantiate the camera in
  25333. * @returns the newly constructed camera
  25334. */
  25335. static Parse(parsedCamera: any, scene: Scene): Camera;
  25336. }
  25337. }
  25338. declare module BABYLON {
  25339. /**
  25340. * Class containing static functions to help procedurally build meshes
  25341. */
  25342. export class DiscBuilder {
  25343. /**
  25344. * Creates a plane polygonal mesh. By default, this is a disc
  25345. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25346. * * 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
  25347. * * 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
  25348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25349. * * 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
  25350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25351. * @param name defines the name of the mesh
  25352. * @param options defines the options used to create the mesh
  25353. * @param scene defines the hosting scene
  25354. * @returns the plane polygonal mesh
  25355. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25356. */
  25357. static CreateDisc(name: string, options: {
  25358. radius?: number;
  25359. tessellation?: number;
  25360. arc?: number;
  25361. updatable?: boolean;
  25362. sideOrientation?: number;
  25363. frontUVs?: Vector4;
  25364. backUVs?: Vector4;
  25365. }, scene?: Nullable<Scene>): Mesh;
  25366. }
  25367. }
  25368. declare module BABYLON {
  25369. /**
  25370. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25371. *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.
  25372. * The SPS is also a particle system. It provides some methods to manage the particles.
  25373. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25374. *
  25375. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25376. */
  25377. export class SolidParticleSystem implements IDisposable {
  25378. /**
  25379. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25380. * Example : var p = SPS.particles[i];
  25381. */
  25382. particles: SolidParticle[];
  25383. /**
  25384. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25385. */
  25386. nbParticles: number;
  25387. /**
  25388. * If the particles must ever face the camera (default false). Useful for planar particles.
  25389. */
  25390. billboard: boolean;
  25391. /**
  25392. * Recompute normals when adding a shape
  25393. */
  25394. recomputeNormals: boolean;
  25395. /**
  25396. * This a counter ofr your own usage. It's not set by any SPS functions.
  25397. */
  25398. counter: number;
  25399. /**
  25400. * The SPS name. This name is also given to the underlying mesh.
  25401. */
  25402. name: string;
  25403. /**
  25404. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25405. */
  25406. mesh: Mesh;
  25407. /**
  25408. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25409. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25410. */
  25411. vars: any;
  25412. /**
  25413. * This array is populated when the SPS is set as 'pickable'.
  25414. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25415. * Each element of this array is an object `{idx: int, faceId: int}`.
  25416. * `idx` is the picked particle index in the `SPS.particles` array
  25417. * `faceId` is the picked face index counted within this particle.
  25418. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25419. */
  25420. pickedParticles: {
  25421. idx: number;
  25422. faceId: number;
  25423. }[];
  25424. /**
  25425. * This array is populated when `enableDepthSort` is set to true.
  25426. * Each element of this array is an instance of the class DepthSortedParticle.
  25427. */
  25428. depthSortedParticles: DepthSortedParticle[];
  25429. /**
  25430. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25431. * @hidden
  25432. */
  25433. _bSphereOnly: boolean;
  25434. /**
  25435. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25436. * @hidden
  25437. */
  25438. _bSphereRadiusFactor: number;
  25439. private _scene;
  25440. private _positions;
  25441. private _indices;
  25442. private _normals;
  25443. private _colors;
  25444. private _uvs;
  25445. private _indices32;
  25446. private _positions32;
  25447. private _normals32;
  25448. private _fixedNormal32;
  25449. private _colors32;
  25450. private _uvs32;
  25451. private _index;
  25452. private _updatable;
  25453. private _pickable;
  25454. private _isVisibilityBoxLocked;
  25455. private _alwaysVisible;
  25456. private _depthSort;
  25457. private _expandable;
  25458. private _shapeCounter;
  25459. private _copy;
  25460. private _mustResetCopy;
  25461. private _color;
  25462. private _computeParticleColor;
  25463. private _computeParticleTexture;
  25464. private _computeParticleRotation;
  25465. private _computeParticleVertex;
  25466. private _computeBoundingBox;
  25467. private _depthSortParticles;
  25468. private _camera;
  25469. private _mustUnrotateFixedNormals;
  25470. private _particlesIntersect;
  25471. private _needs32Bits;
  25472. private _isNotBuilt;
  25473. private _lastParticleId;
  25474. private _idxOfId;
  25475. /**
  25476. * Creates a SPS (Solid Particle System) object.
  25477. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25478. * @param scene (Scene) is the scene in which the SPS is added.
  25479. * @param options defines the options of the sps e.g.
  25480. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25481. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25482. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25483. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25484. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25485. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25486. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25487. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25488. */
  25489. constructor(name: string, scene: Scene, options?: {
  25490. updatable?: boolean;
  25491. isPickable?: boolean;
  25492. enableDepthSort?: boolean;
  25493. particleIntersection?: boolean;
  25494. boundingSphereOnly?: boolean;
  25495. bSphereRadiusFactor?: number;
  25496. expandable?: boolean;
  25497. });
  25498. /**
  25499. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25500. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25501. * @returns the created mesh
  25502. */
  25503. buildMesh(): Mesh;
  25504. /**
  25505. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25506. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25507. * Thus the particles generated from `digest()` have their property `position` set yet.
  25508. * @param mesh ( Mesh ) is the mesh to be digested
  25509. * @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
  25510. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25511. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25512. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25513. * @returns the current SPS
  25514. */
  25515. digest(mesh: Mesh, options?: {
  25516. facetNb?: number;
  25517. number?: number;
  25518. delta?: number;
  25519. storage?: [];
  25520. }): SolidParticleSystem;
  25521. /**
  25522. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  25523. * @hidden
  25524. */
  25525. private _unrotateFixedNormals;
  25526. /**
  25527. * Resets the temporary working copy particle
  25528. * @hidden
  25529. */
  25530. private _resetCopy;
  25531. /**
  25532. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  25533. * @param p the current index in the positions array to be updated
  25534. * @param shape a Vector3 array, the shape geometry
  25535. * @param positions the positions array to be updated
  25536. * @param meshInd the shape indices array
  25537. * @param indices the indices array to be updated
  25538. * @param meshUV the shape uv array
  25539. * @param uvs the uv array to be updated
  25540. * @param meshCol the shape color array
  25541. * @param colors the color array to be updated
  25542. * @param meshNor the shape normals array
  25543. * @param normals the normals array to be updated
  25544. * @param idx the particle index
  25545. * @param idxInShape the particle index in its shape
  25546. * @param options the addShape() method passed options
  25547. * @hidden
  25548. */
  25549. private _meshBuilder;
  25550. /**
  25551. * Returns a shape Vector3 array from positions float array
  25552. * @param positions float array
  25553. * @returns a vector3 array
  25554. * @hidden
  25555. */
  25556. private _posToShape;
  25557. /**
  25558. * Returns a shapeUV array from a float uvs (array deep copy)
  25559. * @param uvs as a float array
  25560. * @returns a shapeUV array
  25561. * @hidden
  25562. */
  25563. private _uvsToShapeUV;
  25564. /**
  25565. * Adds a new particle object in the particles array
  25566. * @param idx particle index in particles array
  25567. * @param id particle id
  25568. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  25569. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  25570. * @param model particle ModelShape object
  25571. * @param shapeId model shape identifier
  25572. * @param idxInShape index of the particle in the current model
  25573. * @param bInfo model bounding info object
  25574. * @param storage target storage array, if any
  25575. * @hidden
  25576. */
  25577. private _addParticle;
  25578. /**
  25579. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25580. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25581. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25582. * @param nb (positive integer) the number of particles to be created from this model
  25583. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25584. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25585. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  25586. * @returns the number of shapes in the system
  25587. */
  25588. addShape(mesh: Mesh, nb: number, options?: {
  25589. positionFunction?: any;
  25590. vertexFunction?: any;
  25591. storage?: [];
  25592. }): number;
  25593. /**
  25594. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  25595. * @hidden
  25596. */
  25597. private _rebuildParticle;
  25598. /**
  25599. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25600. * @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.
  25601. * @returns the SPS.
  25602. */
  25603. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25604. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25605. * Returns an array with the removed particles.
  25606. * 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.
  25607. * The SPS can't be empty so at least one particle needs to remain in place.
  25608. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25609. * @param start index of the first particle to remove
  25610. * @param end index of the last particle to remove (included)
  25611. * @returns an array populated with the removed particles
  25612. */
  25613. removeParticles(start: number, end: number): SolidParticle[];
  25614. /**
  25615. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  25616. * @param solidParticleArray an array populated with Solid Particles objects
  25617. * @returns the SPS
  25618. */
  25619. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  25620. /**
  25621. * Creates a new particle and modifies the SPS mesh geometry :
  25622. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  25623. * - calls _addParticle() to populate the particle array
  25624. * factorized code from addShape() and insertParticlesFromArray()
  25625. * @param idx particle index in the particles array
  25626. * @param i particle index in its shape
  25627. * @param modelShape particle ModelShape object
  25628. * @param shape shape vertex array
  25629. * @param meshInd shape indices array
  25630. * @param meshUV shape uv array
  25631. * @param meshCol shape color array
  25632. * @param meshNor shape normals array
  25633. * @param bbInfo shape bounding info
  25634. * @param storage target particle storage
  25635. * @options addShape() passed options
  25636. * @hidden
  25637. */
  25638. private _insertNewParticle;
  25639. /**
  25640. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25641. * This method calls `updateParticle()` for each particle of the SPS.
  25642. * For an animated SPS, it is usually called within the render loop.
  25643. * 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.
  25644. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25645. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25646. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25647. * @returns the SPS.
  25648. */
  25649. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25650. /**
  25651. * Disposes the SPS.
  25652. */
  25653. dispose(): void;
  25654. /**
  25655. * Returns a SolidParticle object from its identifier : particle.id
  25656. * @param id (integer) the particle Id
  25657. * @returns the searched particle or null if not found in the SPS.
  25658. */
  25659. getParticleById(id: number): Nullable<SolidParticle>;
  25660. /**
  25661. * Returns a new array populated with the particles having the passed shapeId.
  25662. * @param shapeId (integer) the shape identifier
  25663. * @returns a new solid particle array
  25664. */
  25665. getParticlesByShapeId(shapeId: number): SolidParticle[];
  25666. /**
  25667. * Populates the passed array "ref" with the particles having the passed shapeId.
  25668. * @param shapeId the shape identifier
  25669. * @returns the SPS
  25670. * @param ref
  25671. */
  25672. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  25673. /**
  25674. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25675. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25676. * @returns the SPS.
  25677. */
  25678. refreshVisibleSize(): SolidParticleSystem;
  25679. /**
  25680. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25681. * @param size the size (float) of the visibility box
  25682. * note : this doesn't lock the SPS mesh bounding box.
  25683. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25684. */
  25685. setVisibilityBox(size: number): void;
  25686. /**
  25687. * Gets whether the SPS as always visible or not
  25688. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25689. */
  25690. /**
  25691. * Sets the SPS as always visible or not
  25692. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25693. */
  25694. isAlwaysVisible: boolean;
  25695. /**
  25696. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25697. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25698. */
  25699. /**
  25700. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25701. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25702. */
  25703. isVisibilityBoxLocked: boolean;
  25704. /**
  25705. * Tells to `setParticles()` to compute the particle rotations or not.
  25706. * Default value : true. The SPS is faster when it's set to false.
  25707. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25708. */
  25709. /**
  25710. * Gets if `setParticles()` computes the particle rotations or not.
  25711. * Default value : true. The SPS is faster when it's set to false.
  25712. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25713. */
  25714. computeParticleRotation: boolean;
  25715. /**
  25716. * Tells to `setParticles()` to compute the particle colors or not.
  25717. * Default value : true. The SPS is faster when it's set to false.
  25718. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25719. */
  25720. /**
  25721. * Gets if `setParticles()` computes the particle colors or not.
  25722. * Default value : true. The SPS is faster when it's set to false.
  25723. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25724. */
  25725. computeParticleColor: boolean;
  25726. /**
  25727. * Gets if `setParticles()` computes the particle textures or not.
  25728. * Default value : true. The SPS is faster when it's set to false.
  25729. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25730. */
  25731. computeParticleTexture: boolean;
  25732. /**
  25733. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25734. * Default value : false. The SPS is faster when it's set to false.
  25735. * Note : the particle custom vertex positions aren't stored values.
  25736. */
  25737. /**
  25738. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25739. * Default value : false. The SPS is faster when it's set to false.
  25740. * Note : the particle custom vertex positions aren't stored values.
  25741. */
  25742. computeParticleVertex: boolean;
  25743. /**
  25744. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25745. */
  25746. /**
  25747. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25748. */
  25749. computeBoundingBox: boolean;
  25750. /**
  25751. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25752. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25753. * Default : `true`
  25754. */
  25755. /**
  25756. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25757. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25758. * Default : `true`
  25759. */
  25760. depthSortParticles: boolean;
  25761. /**
  25762. * Gets if the SPS is created as expandable at construction time.
  25763. * Default : `false`
  25764. */
  25765. readonly expandable: boolean;
  25766. /**
  25767. * This function does nothing. It may be overwritten to set all the particle first values.
  25768. * The SPS doesn't call this function, you may have to call it by your own.
  25769. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25770. */
  25771. initParticles(): void;
  25772. /**
  25773. * This function does nothing. It may be overwritten to recycle a particle.
  25774. * The SPS doesn't call this function, you may have to call it by your own.
  25775. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25776. * @param particle The particle to recycle
  25777. * @returns the recycled particle
  25778. */
  25779. recycleParticle(particle: SolidParticle): SolidParticle;
  25780. /**
  25781. * Updates a particle : this function should be overwritten by the user.
  25782. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25783. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25784. * @example : just set a particle position or velocity and recycle conditions
  25785. * @param particle The particle to update
  25786. * @returns the updated particle
  25787. */
  25788. updateParticle(particle: SolidParticle): SolidParticle;
  25789. /**
  25790. * Updates a vertex of a particle : it can be overwritten by the user.
  25791. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25792. * @param particle the current particle
  25793. * @param vertex the current index of the current particle
  25794. * @param pt the index of the current vertex in the particle shape
  25795. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25796. * @example : just set a vertex particle position
  25797. * @returns the updated vertex
  25798. */
  25799. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25800. /**
  25801. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25802. * This does nothing and may be overwritten by the user.
  25803. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25804. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25805. * @param update the boolean update value actually passed to setParticles()
  25806. */
  25807. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25808. /**
  25809. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25810. * This will be passed three parameters.
  25811. * This does nothing and may be overwritten by the user.
  25812. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25813. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25814. * @param update the boolean update value actually passed to setParticles()
  25815. */
  25816. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25817. }
  25818. }
  25819. declare module BABYLON {
  25820. /**
  25821. * Represents one particle of a solid particle system.
  25822. */
  25823. export class SolidParticle {
  25824. /**
  25825. * particle global index
  25826. */
  25827. idx: number;
  25828. /**
  25829. * particle identifier
  25830. */
  25831. id: number;
  25832. /**
  25833. * The color of the particle
  25834. */
  25835. color: Nullable<Color4>;
  25836. /**
  25837. * The world space position of the particle.
  25838. */
  25839. position: Vector3;
  25840. /**
  25841. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25842. */
  25843. rotation: Vector3;
  25844. /**
  25845. * The world space rotation quaternion of the particle.
  25846. */
  25847. rotationQuaternion: Nullable<Quaternion>;
  25848. /**
  25849. * The scaling of the particle.
  25850. */
  25851. scaling: Vector3;
  25852. /**
  25853. * The uvs of the particle.
  25854. */
  25855. uvs: Vector4;
  25856. /**
  25857. * The current speed of the particle.
  25858. */
  25859. velocity: Vector3;
  25860. /**
  25861. * The pivot point in the particle local space.
  25862. */
  25863. pivot: Vector3;
  25864. /**
  25865. * Must the particle be translated from its pivot point in its local space ?
  25866. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25867. * Default : false
  25868. */
  25869. translateFromPivot: boolean;
  25870. /**
  25871. * Is the particle active or not ?
  25872. */
  25873. alive: boolean;
  25874. /**
  25875. * Is the particle visible or not ?
  25876. */
  25877. isVisible: boolean;
  25878. /**
  25879. * Index of this particle in the global "positions" array (Internal use)
  25880. * @hidden
  25881. */
  25882. _pos: number;
  25883. /**
  25884. * @hidden Index of this particle in the global "indices" array (Internal use)
  25885. */
  25886. _ind: number;
  25887. /**
  25888. * @hidden ModelShape of this particle (Internal use)
  25889. */
  25890. _model: ModelShape;
  25891. /**
  25892. * ModelShape id of this particle
  25893. */
  25894. shapeId: number;
  25895. /**
  25896. * Index of the particle in its shape id
  25897. */
  25898. idxInShape: number;
  25899. /**
  25900. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25901. */
  25902. _modelBoundingInfo: BoundingInfo;
  25903. /**
  25904. * @hidden Particle BoundingInfo object (Internal use)
  25905. */
  25906. _boundingInfo: BoundingInfo;
  25907. /**
  25908. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25909. */
  25910. _sps: SolidParticleSystem;
  25911. /**
  25912. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25913. */
  25914. _stillInvisible: boolean;
  25915. /**
  25916. * @hidden Last computed particle rotation matrix
  25917. */
  25918. _rotationMatrix: number[];
  25919. /**
  25920. * Parent particle Id, if any.
  25921. * Default null.
  25922. */
  25923. parentId: Nullable<number>;
  25924. /**
  25925. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25926. * The possible values are :
  25927. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25928. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25929. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25930. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25931. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25932. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25933. * */
  25934. cullingStrategy: number;
  25935. /**
  25936. * @hidden Internal global position in the SPS.
  25937. */
  25938. _globalPosition: Vector3;
  25939. /**
  25940. * Creates a Solid Particle object.
  25941. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25942. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  25943. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  25944. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25945. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25946. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25947. * @param shapeId (integer) is the model shape identifier in the SPS.
  25948. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25949. * @param sps defines the sps it is associated to
  25950. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25951. */
  25952. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25953. /**
  25954. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  25955. * @param target the particle target
  25956. * @returns the current particle
  25957. */
  25958. copyToRef(target: SolidParticle): SolidParticle;
  25959. /**
  25960. * Legacy support, changed scale to scaling
  25961. */
  25962. /**
  25963. * Legacy support, changed scale to scaling
  25964. */
  25965. scale: Vector3;
  25966. /**
  25967. * Legacy support, changed quaternion to rotationQuaternion
  25968. */
  25969. /**
  25970. * Legacy support, changed quaternion to rotationQuaternion
  25971. */
  25972. quaternion: Nullable<Quaternion>;
  25973. /**
  25974. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25975. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25976. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25977. * @returns true if it intersects
  25978. */
  25979. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25980. /**
  25981. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25982. * A particle is in the frustum if its bounding box intersects the frustum
  25983. * @param frustumPlanes defines the frustum to test
  25984. * @returns true if the particle is in the frustum planes
  25985. */
  25986. isInFrustum(frustumPlanes: Plane[]): boolean;
  25987. /**
  25988. * get the rotation matrix of the particle
  25989. * @hidden
  25990. */
  25991. getRotationMatrix(m: Matrix): void;
  25992. }
  25993. /**
  25994. * Represents the shape of the model used by one particle of a solid particle system.
  25995. * SPS internal tool, don't use it manually.
  25996. */
  25997. export class ModelShape {
  25998. /**
  25999. * The shape id
  26000. * @hidden
  26001. */
  26002. shapeID: number;
  26003. /**
  26004. * flat array of model positions (internal use)
  26005. * @hidden
  26006. */
  26007. _shape: Vector3[];
  26008. /**
  26009. * flat array of model UVs (internal use)
  26010. * @hidden
  26011. */
  26012. _shapeUV: number[];
  26013. /**
  26014. * color array of the model
  26015. * @hidden
  26016. */
  26017. _shapeColors: number[];
  26018. /**
  26019. * indices array of the model
  26020. * @hidden
  26021. */
  26022. _indices: number[];
  26023. /**
  26024. * normals array of the model
  26025. * @hidden
  26026. */
  26027. _normals: number[];
  26028. /**
  26029. * length of the shape in the model indices array (internal use)
  26030. * @hidden
  26031. */
  26032. _indicesLength: number;
  26033. /**
  26034. * Custom position function (internal use)
  26035. * @hidden
  26036. */
  26037. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26038. /**
  26039. * Custom vertex function (internal use)
  26040. * @hidden
  26041. */
  26042. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26043. /**
  26044. * 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.
  26045. * SPS internal tool, don't use it manually.
  26046. * @hidden
  26047. */
  26048. 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>);
  26049. }
  26050. /**
  26051. * Represents a Depth Sorted Particle in the solid particle system.
  26052. */
  26053. export class DepthSortedParticle {
  26054. /**
  26055. * Index of the particle in the "indices" array
  26056. */
  26057. ind: number;
  26058. /**
  26059. * Length of the particle shape in the "indices" array
  26060. */
  26061. indicesLength: number;
  26062. /**
  26063. * Squared distance from the particle to the camera
  26064. */
  26065. sqDistance: number;
  26066. }
  26067. }
  26068. declare module BABYLON {
  26069. /**
  26070. * @hidden
  26071. */
  26072. export class _MeshCollisionData {
  26073. _checkCollisions: boolean;
  26074. _collisionMask: number;
  26075. _collisionGroup: number;
  26076. _collider: Nullable<Collider>;
  26077. _oldPositionForCollisions: Vector3;
  26078. _diffPositionForCollisions: Vector3;
  26079. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26080. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26081. }
  26082. }
  26083. declare module BABYLON {
  26084. /** @hidden */
  26085. class _FacetDataStorage {
  26086. facetPositions: Vector3[];
  26087. facetNormals: Vector3[];
  26088. facetPartitioning: number[][];
  26089. facetNb: number;
  26090. partitioningSubdivisions: number;
  26091. partitioningBBoxRatio: number;
  26092. facetDataEnabled: boolean;
  26093. facetParameters: any;
  26094. bbSize: Vector3;
  26095. subDiv: {
  26096. max: number;
  26097. X: number;
  26098. Y: number;
  26099. Z: number;
  26100. };
  26101. facetDepthSort: boolean;
  26102. facetDepthSortEnabled: boolean;
  26103. depthSortedIndices: IndicesArray;
  26104. depthSortedFacets: {
  26105. ind: number;
  26106. sqDistance: number;
  26107. }[];
  26108. facetDepthSortFunction: (f1: {
  26109. ind: number;
  26110. sqDistance: number;
  26111. }, f2: {
  26112. ind: number;
  26113. sqDistance: number;
  26114. }) => number;
  26115. facetDepthSortFrom: Vector3;
  26116. facetDepthSortOrigin: Vector3;
  26117. invertedMatrix: Matrix;
  26118. }
  26119. /**
  26120. * @hidden
  26121. **/
  26122. class _InternalAbstractMeshDataInfo {
  26123. _hasVertexAlpha: boolean;
  26124. _useVertexColors: boolean;
  26125. _numBoneInfluencers: number;
  26126. _applyFog: boolean;
  26127. _receiveShadows: boolean;
  26128. _facetData: _FacetDataStorage;
  26129. _visibility: number;
  26130. _skeleton: Nullable<Skeleton>;
  26131. _layerMask: number;
  26132. _computeBonesUsingShaders: boolean;
  26133. _isActive: boolean;
  26134. _onlyForInstances: boolean;
  26135. _isActiveIntermediate: boolean;
  26136. _onlyForInstancesIntermediate: boolean;
  26137. _actAsRegularMesh: boolean;
  26138. }
  26139. /**
  26140. * Class used to store all common mesh properties
  26141. */
  26142. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26143. /** No occlusion */
  26144. static OCCLUSION_TYPE_NONE: number;
  26145. /** Occlusion set to optimisitic */
  26146. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26147. /** Occlusion set to strict */
  26148. static OCCLUSION_TYPE_STRICT: number;
  26149. /** Use an accurante occlusion algorithm */
  26150. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26151. /** Use a conservative occlusion algorithm */
  26152. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26153. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26154. * Test order :
  26155. * Is the bounding sphere outside the frustum ?
  26156. * If not, are the bounding box vertices outside the frustum ?
  26157. * It not, then the cullable object is in the frustum.
  26158. */
  26159. static readonly CULLINGSTRATEGY_STANDARD: number;
  26160. /** Culling strategy : Bounding Sphere Only.
  26161. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26162. * It's also less accurate than the standard because some not visible objects can still be selected.
  26163. * Test : is the bounding sphere outside the frustum ?
  26164. * If not, then the cullable object is in the frustum.
  26165. */
  26166. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26167. /** Culling strategy : Optimistic Inclusion.
  26168. * This in an inclusion test first, then the standard exclusion test.
  26169. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26170. * 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.
  26171. * Anyway, it's as accurate as the standard strategy.
  26172. * Test :
  26173. * Is the cullable object bounding sphere center in the frustum ?
  26174. * If not, apply the default culling strategy.
  26175. */
  26176. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26177. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26178. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26179. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26180. * 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.
  26181. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26182. * Test :
  26183. * Is the cullable object bounding sphere center in the frustum ?
  26184. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26185. */
  26186. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26187. /**
  26188. * No billboard
  26189. */
  26190. static readonly BILLBOARDMODE_NONE: number;
  26191. /** Billboard on X axis */
  26192. static readonly BILLBOARDMODE_X: number;
  26193. /** Billboard on Y axis */
  26194. static readonly BILLBOARDMODE_Y: number;
  26195. /** Billboard on Z axis */
  26196. static readonly BILLBOARDMODE_Z: number;
  26197. /** Billboard on all axes */
  26198. static readonly BILLBOARDMODE_ALL: number;
  26199. /** Billboard on using position instead of orientation */
  26200. static readonly BILLBOARDMODE_USE_POSITION: number;
  26201. /** @hidden */
  26202. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26203. /**
  26204. * The culling strategy to use to check whether the mesh must be rendered or not.
  26205. * This value can be changed at any time and will be used on the next render mesh selection.
  26206. * The possible values are :
  26207. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26208. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26209. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26210. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26211. * Please read each static variable documentation to get details about the culling process.
  26212. * */
  26213. cullingStrategy: number;
  26214. /**
  26215. * Gets the number of facets in the mesh
  26216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26217. */
  26218. readonly facetNb: number;
  26219. /**
  26220. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26222. */
  26223. partitioningSubdivisions: number;
  26224. /**
  26225. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26226. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26228. */
  26229. partitioningBBoxRatio: number;
  26230. /**
  26231. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26232. * Works only for updatable meshes.
  26233. * Doesn't work with multi-materials
  26234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26235. */
  26236. mustDepthSortFacets: boolean;
  26237. /**
  26238. * The location (Vector3) where the facet depth sort must be computed from.
  26239. * By default, the active camera position.
  26240. * Used only when facet depth sort is enabled
  26241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26242. */
  26243. facetDepthSortFrom: Vector3;
  26244. /**
  26245. * gets a boolean indicating if facetData is enabled
  26246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26247. */
  26248. readonly isFacetDataEnabled: boolean;
  26249. /** @hidden */
  26250. _updateNonUniformScalingState(value: boolean): boolean;
  26251. /**
  26252. * An event triggered when this mesh collides with another one
  26253. */
  26254. onCollideObservable: Observable<AbstractMesh>;
  26255. /** Set a function to call when this mesh collides with another one */
  26256. onCollide: () => void;
  26257. /**
  26258. * An event triggered when the collision's position changes
  26259. */
  26260. onCollisionPositionChangeObservable: Observable<Vector3>;
  26261. /** Set a function to call when the collision's position changes */
  26262. onCollisionPositionChange: () => void;
  26263. /**
  26264. * An event triggered when material is changed
  26265. */
  26266. onMaterialChangedObservable: Observable<AbstractMesh>;
  26267. /**
  26268. * Gets or sets the orientation for POV movement & rotation
  26269. */
  26270. definedFacingForward: boolean;
  26271. /** @hidden */
  26272. _occlusionQuery: Nullable<WebGLQuery>;
  26273. /** @hidden */
  26274. _renderingGroup: Nullable<RenderingGroup>;
  26275. /**
  26276. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26277. */
  26278. /**
  26279. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26280. */
  26281. visibility: number;
  26282. /** Gets or sets the alpha index used to sort transparent meshes
  26283. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26284. */
  26285. alphaIndex: number;
  26286. /**
  26287. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26288. */
  26289. isVisible: boolean;
  26290. /**
  26291. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26292. */
  26293. isPickable: boolean;
  26294. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26295. showSubMeshesBoundingBox: boolean;
  26296. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26298. */
  26299. isBlocker: boolean;
  26300. /**
  26301. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26302. */
  26303. enablePointerMoveEvents: boolean;
  26304. /**
  26305. * Specifies the rendering group id for this mesh (0 by default)
  26306. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26307. */
  26308. renderingGroupId: number;
  26309. private _material;
  26310. /** Gets or sets current material */
  26311. material: Nullable<Material>;
  26312. /**
  26313. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26314. * @see http://doc.babylonjs.com/babylon101/shadows
  26315. */
  26316. receiveShadows: boolean;
  26317. /** Defines color to use when rendering outline */
  26318. outlineColor: Color3;
  26319. /** Define width to use when rendering outline */
  26320. outlineWidth: number;
  26321. /** Defines color to use when rendering overlay */
  26322. overlayColor: Color3;
  26323. /** Defines alpha to use when rendering overlay */
  26324. overlayAlpha: number;
  26325. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26326. hasVertexAlpha: boolean;
  26327. /** 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) */
  26328. useVertexColors: boolean;
  26329. /**
  26330. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26331. */
  26332. computeBonesUsingShaders: boolean;
  26333. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26334. numBoneInfluencers: number;
  26335. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26336. applyFog: boolean;
  26337. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26338. useOctreeForRenderingSelection: boolean;
  26339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26340. useOctreeForPicking: boolean;
  26341. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26342. useOctreeForCollisions: boolean;
  26343. /**
  26344. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26345. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26346. */
  26347. layerMask: number;
  26348. /**
  26349. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26350. */
  26351. alwaysSelectAsActiveMesh: boolean;
  26352. /**
  26353. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26354. */
  26355. doNotSyncBoundingInfo: boolean;
  26356. /**
  26357. * Gets or sets the current action manager
  26358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26359. */
  26360. actionManager: Nullable<AbstractActionManager>;
  26361. private _meshCollisionData;
  26362. /**
  26363. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26364. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26365. */
  26366. ellipsoid: Vector3;
  26367. /**
  26368. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26370. */
  26371. ellipsoidOffset: Vector3;
  26372. /**
  26373. * Gets or sets a collision mask used to mask collisions (default is -1).
  26374. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26375. */
  26376. collisionMask: number;
  26377. /**
  26378. * Gets or sets the current collision group mask (-1 by default).
  26379. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26380. */
  26381. collisionGroup: number;
  26382. /**
  26383. * Defines edge width used when edgesRenderer is enabled
  26384. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26385. */
  26386. edgesWidth: number;
  26387. /**
  26388. * Defines edge color used when edgesRenderer is enabled
  26389. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26390. */
  26391. edgesColor: Color4;
  26392. /** @hidden */
  26393. _edgesRenderer: Nullable<IEdgesRenderer>;
  26394. /** @hidden */
  26395. _masterMesh: Nullable<AbstractMesh>;
  26396. /** @hidden */
  26397. _boundingInfo: Nullable<BoundingInfo>;
  26398. /** @hidden */
  26399. _renderId: number;
  26400. /**
  26401. * Gets or sets the list of subMeshes
  26402. * @see http://doc.babylonjs.com/how_to/multi_materials
  26403. */
  26404. subMeshes: SubMesh[];
  26405. /** @hidden */
  26406. _intersectionsInProgress: AbstractMesh[];
  26407. /** @hidden */
  26408. _unIndexed: boolean;
  26409. /** @hidden */
  26410. _lightSources: Light[];
  26411. /** Gets the list of lights affecting that mesh */
  26412. readonly lightSources: Light[];
  26413. /** @hidden */
  26414. readonly _positions: Nullable<Vector3[]>;
  26415. /** @hidden */
  26416. _waitingData: {
  26417. lods: Nullable<any>;
  26418. actions: Nullable<any>;
  26419. freezeWorldMatrix: Nullable<boolean>;
  26420. };
  26421. /** @hidden */
  26422. _bonesTransformMatrices: Nullable<Float32Array>;
  26423. /** @hidden */
  26424. _transformMatrixTexture: Nullable<RawTexture>;
  26425. /**
  26426. * Gets or sets a skeleton to apply skining transformations
  26427. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26428. */
  26429. skeleton: Nullable<Skeleton>;
  26430. /**
  26431. * An event triggered when the mesh is rebuilt.
  26432. */
  26433. onRebuildObservable: Observable<AbstractMesh>;
  26434. /**
  26435. * Creates a new AbstractMesh
  26436. * @param name defines the name of the mesh
  26437. * @param scene defines the hosting scene
  26438. */
  26439. constructor(name: string, scene?: Nullable<Scene>);
  26440. /**
  26441. * Returns the string "AbstractMesh"
  26442. * @returns "AbstractMesh"
  26443. */
  26444. getClassName(): string;
  26445. /**
  26446. * Gets a string representation of the current mesh
  26447. * @param fullDetails defines a boolean indicating if full details must be included
  26448. * @returns a string representation of the current mesh
  26449. */
  26450. toString(fullDetails?: boolean): string;
  26451. /**
  26452. * @hidden
  26453. */
  26454. protected _getEffectiveParent(): Nullable<Node>;
  26455. /** @hidden */
  26456. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26457. /** @hidden */
  26458. _rebuild(): void;
  26459. /** @hidden */
  26460. _resyncLightSources(): void;
  26461. /** @hidden */
  26462. _resyncLighSource(light: Light): void;
  26463. /** @hidden */
  26464. _unBindEffect(): void;
  26465. /** @hidden */
  26466. _removeLightSource(light: Light, dispose: boolean): void;
  26467. private _markSubMeshesAsDirty;
  26468. /** @hidden */
  26469. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26470. /** @hidden */
  26471. _markSubMeshesAsAttributesDirty(): void;
  26472. /** @hidden */
  26473. _markSubMeshesAsMiscDirty(): void;
  26474. /**
  26475. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26476. */
  26477. scaling: Vector3;
  26478. /**
  26479. * Returns true if the mesh is blocked. Implemented by child classes
  26480. */
  26481. readonly isBlocked: boolean;
  26482. /**
  26483. * Returns the mesh itself by default. Implemented by child classes
  26484. * @param camera defines the camera to use to pick the right LOD level
  26485. * @returns the currentAbstractMesh
  26486. */
  26487. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26488. /**
  26489. * Returns 0 by default. Implemented by child classes
  26490. * @returns an integer
  26491. */
  26492. getTotalVertices(): number;
  26493. /**
  26494. * Returns a positive integer : the total number of indices in this mesh geometry.
  26495. * @returns the numner of indices or zero if the mesh has no geometry.
  26496. */
  26497. getTotalIndices(): number;
  26498. /**
  26499. * Returns null by default. Implemented by child classes
  26500. * @returns null
  26501. */
  26502. getIndices(): Nullable<IndicesArray>;
  26503. /**
  26504. * Returns the array of the requested vertex data kind. Implemented by child classes
  26505. * @param kind defines the vertex data kind to use
  26506. * @returns null
  26507. */
  26508. getVerticesData(kind: string): Nullable<FloatArray>;
  26509. /**
  26510. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26511. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26512. * Note that a new underlying VertexBuffer object is created each call.
  26513. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26514. * @param kind defines vertex data kind:
  26515. * * VertexBuffer.PositionKind
  26516. * * VertexBuffer.UVKind
  26517. * * VertexBuffer.UV2Kind
  26518. * * VertexBuffer.UV3Kind
  26519. * * VertexBuffer.UV4Kind
  26520. * * VertexBuffer.UV5Kind
  26521. * * VertexBuffer.UV6Kind
  26522. * * VertexBuffer.ColorKind
  26523. * * VertexBuffer.MatricesIndicesKind
  26524. * * VertexBuffer.MatricesIndicesExtraKind
  26525. * * VertexBuffer.MatricesWeightsKind
  26526. * * VertexBuffer.MatricesWeightsExtraKind
  26527. * @param data defines the data source
  26528. * @param updatable defines if the data must be flagged as updatable (or static)
  26529. * @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
  26530. * @returns the current mesh
  26531. */
  26532. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26533. /**
  26534. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26535. * If the mesh has no geometry, it is simply returned as it is.
  26536. * @param kind defines vertex data kind:
  26537. * * VertexBuffer.PositionKind
  26538. * * VertexBuffer.UVKind
  26539. * * VertexBuffer.UV2Kind
  26540. * * VertexBuffer.UV3Kind
  26541. * * VertexBuffer.UV4Kind
  26542. * * VertexBuffer.UV5Kind
  26543. * * VertexBuffer.UV6Kind
  26544. * * VertexBuffer.ColorKind
  26545. * * VertexBuffer.MatricesIndicesKind
  26546. * * VertexBuffer.MatricesIndicesExtraKind
  26547. * * VertexBuffer.MatricesWeightsKind
  26548. * * VertexBuffer.MatricesWeightsExtraKind
  26549. * @param data defines the data source
  26550. * @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
  26551. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26552. * @returns the current mesh
  26553. */
  26554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26555. /**
  26556. * Sets the mesh indices,
  26557. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26558. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26559. * @param totalVertices Defines the total number of vertices
  26560. * @returns the current mesh
  26561. */
  26562. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26563. /**
  26564. * Gets a boolean indicating if specific vertex data is present
  26565. * @param kind defines the vertex data kind to use
  26566. * @returns true is data kind is present
  26567. */
  26568. isVerticesDataPresent(kind: string): boolean;
  26569. /**
  26570. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26571. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26572. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26573. * @returns a BoundingInfo
  26574. */
  26575. getBoundingInfo(): BoundingInfo;
  26576. /**
  26577. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26578. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26579. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26580. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26581. * @returns the current mesh
  26582. */
  26583. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26584. /**
  26585. * Overwrite the current bounding info
  26586. * @param boundingInfo defines the new bounding info
  26587. * @returns the current mesh
  26588. */
  26589. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26590. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26591. readonly useBones: boolean;
  26592. /** @hidden */
  26593. _preActivate(): void;
  26594. /** @hidden */
  26595. _preActivateForIntermediateRendering(renderId: number): void;
  26596. /** @hidden */
  26597. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26598. /** @hidden */
  26599. _postActivate(): void;
  26600. /** @hidden */
  26601. _freeze(): void;
  26602. /** @hidden */
  26603. _unFreeze(): void;
  26604. /**
  26605. * Gets the current world matrix
  26606. * @returns a Matrix
  26607. */
  26608. getWorldMatrix(): Matrix;
  26609. /** @hidden */
  26610. _getWorldMatrixDeterminant(): number;
  26611. /**
  26612. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26613. */
  26614. readonly isAnInstance: boolean;
  26615. /**
  26616. * Gets a boolean indicating if this mesh has instances
  26617. */
  26618. readonly hasInstances: boolean;
  26619. /**
  26620. * Perform relative position change from the point of view of behind the front of the mesh.
  26621. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26622. * Supports definition of mesh facing forward or backward
  26623. * @param amountRight defines the distance on the right axis
  26624. * @param amountUp defines the distance on the up axis
  26625. * @param amountForward defines the distance on the forward axis
  26626. * @returns the current mesh
  26627. */
  26628. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26629. /**
  26630. * Calculate relative position change from the point of view of behind the front of the mesh.
  26631. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26632. * Supports definition of mesh facing forward or backward
  26633. * @param amountRight defines the distance on the right axis
  26634. * @param amountUp defines the distance on the up axis
  26635. * @param amountForward defines the distance on the forward axis
  26636. * @returns the new displacement vector
  26637. */
  26638. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26639. /**
  26640. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26641. * Supports definition of mesh facing forward or backward
  26642. * @param flipBack defines the flip
  26643. * @param twirlClockwise defines the twirl
  26644. * @param tiltRight defines the tilt
  26645. * @returns the current mesh
  26646. */
  26647. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26648. /**
  26649. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26650. * Supports definition of mesh facing forward or backward.
  26651. * @param flipBack defines the flip
  26652. * @param twirlClockwise defines the twirl
  26653. * @param tiltRight defines the tilt
  26654. * @returns the new rotation vector
  26655. */
  26656. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26657. /**
  26658. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26659. * This means the mesh underlying bounding box and sphere are recomputed.
  26660. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26661. * @returns the current mesh
  26662. */
  26663. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26664. /** @hidden */
  26665. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26666. /** @hidden */
  26667. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26668. /** @hidden */
  26669. _updateBoundingInfo(): AbstractMesh;
  26670. /** @hidden */
  26671. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26672. /** @hidden */
  26673. protected _afterComputeWorldMatrix(): void;
  26674. /** @hidden */
  26675. readonly _effectiveMesh: AbstractMesh;
  26676. /**
  26677. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26678. * A mesh is in the frustum if its bounding box intersects the frustum
  26679. * @param frustumPlanes defines the frustum to test
  26680. * @returns true if the mesh is in the frustum planes
  26681. */
  26682. isInFrustum(frustumPlanes: Plane[]): boolean;
  26683. /**
  26684. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26685. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26686. * @param frustumPlanes defines the frustum to test
  26687. * @returns true if the mesh is completely in the frustum planes
  26688. */
  26689. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26690. /**
  26691. * True if the mesh intersects another mesh or a SolidParticle object
  26692. * @param mesh defines a target mesh or SolidParticle to test
  26693. * @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)
  26694. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26695. * @returns true if there is an intersection
  26696. */
  26697. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26698. /**
  26699. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26700. * @param point defines the point to test
  26701. * @returns true if there is an intersection
  26702. */
  26703. intersectsPoint(point: Vector3): boolean;
  26704. /**
  26705. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26706. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26707. */
  26708. checkCollisions: boolean;
  26709. /**
  26710. * Gets Collider object used to compute collisions (not physics)
  26711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26712. */
  26713. readonly collider: Nullable<Collider>;
  26714. /**
  26715. * Move the mesh using collision engine
  26716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26717. * @param displacement defines the requested displacement vector
  26718. * @returns the current mesh
  26719. */
  26720. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26721. private _onCollisionPositionChange;
  26722. /** @hidden */
  26723. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26724. /** @hidden */
  26725. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26726. /** @hidden */
  26727. _checkCollision(collider: Collider): AbstractMesh;
  26728. /** @hidden */
  26729. _generatePointsArray(): boolean;
  26730. /**
  26731. * Checks if the passed Ray intersects with the mesh
  26732. * @param ray defines the ray to use
  26733. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26734. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26735. * @returns the picking info
  26736. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26737. */
  26738. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26739. /**
  26740. * Clones the current mesh
  26741. * @param name defines the mesh name
  26742. * @param newParent defines the new mesh parent
  26743. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26744. * @returns the new mesh
  26745. */
  26746. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26747. /**
  26748. * Disposes all the submeshes of the current meshnp
  26749. * @returns the current mesh
  26750. */
  26751. releaseSubMeshes(): AbstractMesh;
  26752. /**
  26753. * Releases resources associated with this abstract mesh.
  26754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26756. */
  26757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26758. /**
  26759. * Adds the passed mesh as a child to the current mesh
  26760. * @param mesh defines the child mesh
  26761. * @returns the current mesh
  26762. */
  26763. addChild(mesh: AbstractMesh): AbstractMesh;
  26764. /**
  26765. * Removes the passed mesh from the current mesh children list
  26766. * @param mesh defines the child mesh
  26767. * @returns the current mesh
  26768. */
  26769. removeChild(mesh: AbstractMesh): AbstractMesh;
  26770. /** @hidden */
  26771. private _initFacetData;
  26772. /**
  26773. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26774. * This method can be called within the render loop.
  26775. * 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
  26776. * @returns the current mesh
  26777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26778. */
  26779. updateFacetData(): AbstractMesh;
  26780. /**
  26781. * Returns the facetLocalNormals array.
  26782. * The normals are expressed in the mesh local spac
  26783. * @returns an array of Vector3
  26784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26785. */
  26786. getFacetLocalNormals(): Vector3[];
  26787. /**
  26788. * Returns the facetLocalPositions array.
  26789. * The facet positions are expressed in the mesh local space
  26790. * @returns an array of Vector3
  26791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26792. */
  26793. getFacetLocalPositions(): Vector3[];
  26794. /**
  26795. * Returns the facetLocalPartioning array
  26796. * @returns an array of array of numbers
  26797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26798. */
  26799. getFacetLocalPartitioning(): number[][];
  26800. /**
  26801. * Returns the i-th facet position in the world system.
  26802. * This method allocates a new Vector3 per call
  26803. * @param i defines the facet index
  26804. * @returns a new Vector3
  26805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26806. */
  26807. getFacetPosition(i: number): Vector3;
  26808. /**
  26809. * Sets the reference Vector3 with the i-th facet position in the world system
  26810. * @param i defines the facet index
  26811. * @param ref defines the target vector
  26812. * @returns the current mesh
  26813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26814. */
  26815. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26816. /**
  26817. * Returns the i-th facet normal in the world system.
  26818. * This method allocates a new Vector3 per call
  26819. * @param i defines the facet index
  26820. * @returns a new Vector3
  26821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26822. */
  26823. getFacetNormal(i: number): Vector3;
  26824. /**
  26825. * Sets the reference Vector3 with the i-th facet normal in the world system
  26826. * @param i defines the facet index
  26827. * @param ref defines the target vector
  26828. * @returns the current mesh
  26829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26830. */
  26831. getFacetNormalToRef(i: number, ref: Vector3): this;
  26832. /**
  26833. * 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)
  26834. * @param x defines x coordinate
  26835. * @param y defines y coordinate
  26836. * @param z defines z coordinate
  26837. * @returns the array of facet indexes
  26838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26839. */
  26840. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26841. /**
  26842. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26843. * @param projected sets as the (x,y,z) world projection on the facet
  26844. * @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
  26845. * @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
  26846. * @param x defines x coordinate
  26847. * @param y defines y coordinate
  26848. * @param z defines z coordinate
  26849. * @returns the face index if found (or null instead)
  26850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26851. */
  26852. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26853. /**
  26854. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26855. * @param projected sets as the (x,y,z) local projection on the facet
  26856. * @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
  26857. * @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
  26858. * @param x defines x coordinate
  26859. * @param y defines y coordinate
  26860. * @param z defines z coordinate
  26861. * @returns the face index if found (or null instead)
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26863. */
  26864. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26865. /**
  26866. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26867. * @returns the parameters
  26868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26869. */
  26870. getFacetDataParameters(): any;
  26871. /**
  26872. * Disables the feature FacetData and frees the related memory
  26873. * @returns the current mesh
  26874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26875. */
  26876. disableFacetData(): AbstractMesh;
  26877. /**
  26878. * Updates the AbstractMesh indices array
  26879. * @param indices defines the data source
  26880. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26881. * @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)
  26882. * @returns the current mesh
  26883. */
  26884. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26885. /**
  26886. * Creates new normals data for the mesh
  26887. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26888. * @returns the current mesh
  26889. */
  26890. createNormals(updatable: boolean): AbstractMesh;
  26891. /**
  26892. * Align the mesh with a normal
  26893. * @param normal defines the normal to use
  26894. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26895. * @returns the current mesh
  26896. */
  26897. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26898. /** @hidden */
  26899. _checkOcclusionQuery(): boolean;
  26900. /**
  26901. * Disables the mesh edge rendering mode
  26902. * @returns the currentAbstractMesh
  26903. */
  26904. disableEdgesRendering(): AbstractMesh;
  26905. /**
  26906. * Enables the edge rendering mode on the mesh.
  26907. * This mode makes the mesh edges visible
  26908. * @param epsilon defines the maximal distance between two angles to detect a face
  26909. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26910. * @returns the currentAbstractMesh
  26911. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26912. */
  26913. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26914. }
  26915. }
  26916. declare module BABYLON {
  26917. /**
  26918. * Interface used to define ActionEvent
  26919. */
  26920. export interface IActionEvent {
  26921. /** The mesh or sprite that triggered the action */
  26922. source: any;
  26923. /** The X mouse cursor position at the time of the event */
  26924. pointerX: number;
  26925. /** The Y mouse cursor position at the time of the event */
  26926. pointerY: number;
  26927. /** The mesh that is currently pointed at (can be null) */
  26928. meshUnderPointer: Nullable<AbstractMesh>;
  26929. /** the original (browser) event that triggered the ActionEvent */
  26930. sourceEvent?: any;
  26931. /** additional data for the event */
  26932. additionalData?: any;
  26933. }
  26934. /**
  26935. * ActionEvent is the event being sent when an action is triggered.
  26936. */
  26937. export class ActionEvent implements IActionEvent {
  26938. /** The mesh or sprite that triggered the action */
  26939. source: any;
  26940. /** The X mouse cursor position at the time of the event */
  26941. pointerX: number;
  26942. /** The Y mouse cursor position at the time of the event */
  26943. pointerY: number;
  26944. /** The mesh that is currently pointed at (can be null) */
  26945. meshUnderPointer: Nullable<AbstractMesh>;
  26946. /** the original (browser) event that triggered the ActionEvent */
  26947. sourceEvent?: any;
  26948. /** additional data for the event */
  26949. additionalData?: any;
  26950. /**
  26951. * Creates a new ActionEvent
  26952. * @param source The mesh or sprite that triggered the action
  26953. * @param pointerX The X mouse cursor position at the time of the event
  26954. * @param pointerY The Y mouse cursor position at the time of the event
  26955. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26956. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26957. * @param additionalData additional data for the event
  26958. */
  26959. constructor(
  26960. /** The mesh or sprite that triggered the action */
  26961. source: any,
  26962. /** The X mouse cursor position at the time of the event */
  26963. pointerX: number,
  26964. /** The Y mouse cursor position at the time of the event */
  26965. pointerY: number,
  26966. /** The mesh that is currently pointed at (can be null) */
  26967. meshUnderPointer: Nullable<AbstractMesh>,
  26968. /** the original (browser) event that triggered the ActionEvent */
  26969. sourceEvent?: any,
  26970. /** additional data for the event */
  26971. additionalData?: any);
  26972. /**
  26973. * Helper function to auto-create an ActionEvent from a source mesh.
  26974. * @param source The source mesh that triggered the event
  26975. * @param evt The original (browser) event
  26976. * @param additionalData additional data for the event
  26977. * @returns the new ActionEvent
  26978. */
  26979. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26980. /**
  26981. * Helper function to auto-create an ActionEvent from a source sprite
  26982. * @param source The source sprite that triggered the event
  26983. * @param scene Scene associated with the sprite
  26984. * @param evt The original (browser) event
  26985. * @param additionalData additional data for the event
  26986. * @returns the new ActionEvent
  26987. */
  26988. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26989. /**
  26990. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26991. * @param scene the scene where the event occurred
  26992. * @param evt The original (browser) event
  26993. * @returns the new ActionEvent
  26994. */
  26995. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26996. /**
  26997. * Helper function to auto-create an ActionEvent from a primitive
  26998. * @param prim defines the target primitive
  26999. * @param pointerPos defines the pointer position
  27000. * @param evt The original (browser) event
  27001. * @param additionalData additional data for the event
  27002. * @returns the new ActionEvent
  27003. */
  27004. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27005. }
  27006. }
  27007. declare module BABYLON {
  27008. /**
  27009. * Abstract class used to decouple action Manager from scene and meshes.
  27010. * Do not instantiate.
  27011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27012. */
  27013. export abstract class AbstractActionManager implements IDisposable {
  27014. /** Gets the list of active triggers */
  27015. static Triggers: {
  27016. [key: string]: number;
  27017. };
  27018. /** Gets the cursor to use when hovering items */
  27019. hoverCursor: string;
  27020. /** Gets the list of actions */
  27021. actions: IAction[];
  27022. /**
  27023. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27024. */
  27025. isRecursive: boolean;
  27026. /**
  27027. * Releases all associated resources
  27028. */
  27029. abstract dispose(): void;
  27030. /**
  27031. * Does this action manager has pointer triggers
  27032. */
  27033. abstract readonly hasPointerTriggers: boolean;
  27034. /**
  27035. * Does this action manager has pick triggers
  27036. */
  27037. abstract readonly hasPickTriggers: boolean;
  27038. /**
  27039. * Process a specific trigger
  27040. * @param trigger defines the trigger to process
  27041. * @param evt defines the event details to be processed
  27042. */
  27043. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27044. /**
  27045. * Does this action manager handles actions of any of the given triggers
  27046. * @param triggers defines the triggers to be tested
  27047. * @return a boolean indicating whether one (or more) of the triggers is handled
  27048. */
  27049. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27050. /**
  27051. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27052. * speed.
  27053. * @param triggerA defines the trigger to be tested
  27054. * @param triggerB defines the trigger to be tested
  27055. * @return a boolean indicating whether one (or more) of the triggers is handled
  27056. */
  27057. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27058. /**
  27059. * Does this action manager handles actions of a given trigger
  27060. * @param trigger defines the trigger to be tested
  27061. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27062. * @return whether the trigger is handled
  27063. */
  27064. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27065. /**
  27066. * Serialize this manager to a JSON object
  27067. * @param name defines the property name to store this manager
  27068. * @returns a JSON representation of this manager
  27069. */
  27070. abstract serialize(name: string): any;
  27071. /**
  27072. * Registers an action to this action manager
  27073. * @param action defines the action to be registered
  27074. * @return the action amended (prepared) after registration
  27075. */
  27076. abstract registerAction(action: IAction): Nullable<IAction>;
  27077. /**
  27078. * Unregisters an action to this action manager
  27079. * @param action defines the action to be unregistered
  27080. * @return a boolean indicating whether the action has been unregistered
  27081. */
  27082. abstract unregisterAction(action: IAction): Boolean;
  27083. /**
  27084. * Does exist one action manager with at least one trigger
  27085. **/
  27086. static readonly HasTriggers: boolean;
  27087. /**
  27088. * Does exist one action manager with at least one pick trigger
  27089. **/
  27090. static readonly HasPickTriggers: boolean;
  27091. /**
  27092. * Does exist one action manager that handles actions of a given trigger
  27093. * @param trigger defines the trigger to be tested
  27094. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27095. **/
  27096. static HasSpecificTrigger(trigger: number): boolean;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * Defines how a node can be built from a string name.
  27102. */
  27103. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27104. /**
  27105. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27106. */
  27107. export class Node implements IBehaviorAware<Node> {
  27108. /** @hidden */
  27109. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  27110. private static _NodeConstructors;
  27111. /**
  27112. * Add a new node constructor
  27113. * @param type defines the type name of the node to construct
  27114. * @param constructorFunc defines the constructor function
  27115. */
  27116. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27117. /**
  27118. * Returns a node constructor based on type name
  27119. * @param type defines the type name
  27120. * @param name defines the new node name
  27121. * @param scene defines the hosting scene
  27122. * @param options defines optional options to transmit to constructors
  27123. * @returns the new constructor or null
  27124. */
  27125. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27126. /**
  27127. * Gets or sets the name of the node
  27128. */
  27129. name: string;
  27130. /**
  27131. * Gets or sets the id of the node
  27132. */
  27133. id: string;
  27134. /**
  27135. * Gets or sets the unique id of the node
  27136. */
  27137. uniqueId: number;
  27138. /**
  27139. * Gets or sets a string used to store user defined state for the node
  27140. */
  27141. state: string;
  27142. /**
  27143. * Gets or sets an object used to store user defined information for the node
  27144. */
  27145. metadata: any;
  27146. /**
  27147. * For internal use only. Please do not use.
  27148. */
  27149. reservedDataStore: any;
  27150. /**
  27151. * List of inspectable custom properties (used by the Inspector)
  27152. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27153. */
  27154. inspectableCustomProperties: IInspectable[];
  27155. private _doNotSerialize;
  27156. /**
  27157. * Gets or sets a boolean used to define if the node must be serialized
  27158. */
  27159. doNotSerialize: boolean;
  27160. /** @hidden */
  27161. _isDisposed: boolean;
  27162. /**
  27163. * Gets a list of Animations associated with the node
  27164. */
  27165. animations: Animation[];
  27166. protected _ranges: {
  27167. [name: string]: Nullable<AnimationRange>;
  27168. };
  27169. /**
  27170. * Callback raised when the node is ready to be used
  27171. */
  27172. onReady: Nullable<(node: Node) => void>;
  27173. private _isEnabled;
  27174. private _isParentEnabled;
  27175. private _isReady;
  27176. /** @hidden */
  27177. _currentRenderId: number;
  27178. private _parentUpdateId;
  27179. /** @hidden */
  27180. _childUpdateId: number;
  27181. /** @hidden */
  27182. _waitingParentId: Nullable<string>;
  27183. /** @hidden */
  27184. _scene: Scene;
  27185. /** @hidden */
  27186. _cache: any;
  27187. private _parentNode;
  27188. private _children;
  27189. /** @hidden */
  27190. _worldMatrix: Matrix;
  27191. /** @hidden */
  27192. _worldMatrixDeterminant: number;
  27193. /** @hidden */
  27194. _worldMatrixDeterminantIsDirty: boolean;
  27195. /** @hidden */
  27196. private _sceneRootNodesIndex;
  27197. /**
  27198. * Gets a boolean indicating if the node has been disposed
  27199. * @returns true if the node was disposed
  27200. */
  27201. isDisposed(): boolean;
  27202. /**
  27203. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27204. * @see https://doc.babylonjs.com/how_to/parenting
  27205. */
  27206. parent: Nullable<Node>;
  27207. /** @hidden */
  27208. _addToSceneRootNodes(): void;
  27209. /** @hidden */
  27210. _removeFromSceneRootNodes(): void;
  27211. private _animationPropertiesOverride;
  27212. /**
  27213. * Gets or sets the animation properties override
  27214. */
  27215. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27216. /**
  27217. * Gets a string idenfifying the name of the class
  27218. * @returns "Node" string
  27219. */
  27220. getClassName(): string;
  27221. /** @hidden */
  27222. readonly _isNode: boolean;
  27223. /**
  27224. * An event triggered when the mesh is disposed
  27225. */
  27226. onDisposeObservable: Observable<Node>;
  27227. private _onDisposeObserver;
  27228. /**
  27229. * Sets a callback that will be raised when the node will be disposed
  27230. */
  27231. onDispose: () => void;
  27232. /**
  27233. * Creates a new Node
  27234. * @param name the name and id to be given to this node
  27235. * @param scene the scene this node will be added to
  27236. */
  27237. constructor(name: string, scene?: Nullable<Scene>);
  27238. /**
  27239. * Gets the scene of the node
  27240. * @returns a scene
  27241. */
  27242. getScene(): Scene;
  27243. /**
  27244. * Gets the engine of the node
  27245. * @returns a Engine
  27246. */
  27247. getEngine(): Engine;
  27248. private _behaviors;
  27249. /**
  27250. * Attach a behavior to the node
  27251. * @see http://doc.babylonjs.com/features/behaviour
  27252. * @param behavior defines the behavior to attach
  27253. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27254. * @returns the current Node
  27255. */
  27256. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27257. /**
  27258. * Remove an attached behavior
  27259. * @see http://doc.babylonjs.com/features/behaviour
  27260. * @param behavior defines the behavior to attach
  27261. * @returns the current Node
  27262. */
  27263. removeBehavior(behavior: Behavior<Node>): Node;
  27264. /**
  27265. * Gets the list of attached behaviors
  27266. * @see http://doc.babylonjs.com/features/behaviour
  27267. */
  27268. readonly behaviors: Behavior<Node>[];
  27269. /**
  27270. * Gets an attached behavior by name
  27271. * @param name defines the name of the behavior to look for
  27272. * @see http://doc.babylonjs.com/features/behaviour
  27273. * @returns null if behavior was not found else the requested behavior
  27274. */
  27275. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27276. /**
  27277. * Returns the latest update of the World matrix
  27278. * @returns a Matrix
  27279. */
  27280. getWorldMatrix(): Matrix;
  27281. /** @hidden */
  27282. _getWorldMatrixDeterminant(): number;
  27283. /**
  27284. * Returns directly the latest state of the mesh World matrix.
  27285. * A Matrix is returned.
  27286. */
  27287. readonly worldMatrixFromCache: Matrix;
  27288. /** @hidden */
  27289. _initCache(): void;
  27290. /** @hidden */
  27291. updateCache(force?: boolean): void;
  27292. /** @hidden */
  27293. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27294. /** @hidden */
  27295. _updateCache(ignoreParentClass?: boolean): void;
  27296. /** @hidden */
  27297. _isSynchronized(): boolean;
  27298. /** @hidden */
  27299. _markSyncedWithParent(): void;
  27300. /** @hidden */
  27301. isSynchronizedWithParent(): boolean;
  27302. /** @hidden */
  27303. isSynchronized(): boolean;
  27304. /**
  27305. * Is this node ready to be used/rendered
  27306. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27307. * @return true if the node is ready
  27308. */
  27309. isReady(completeCheck?: boolean): boolean;
  27310. /**
  27311. * Is this node enabled?
  27312. * 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
  27313. * @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
  27314. * @return whether this node (and its parent) is enabled
  27315. */
  27316. isEnabled(checkAncestors?: boolean): boolean;
  27317. /** @hidden */
  27318. protected _syncParentEnabledState(): void;
  27319. /**
  27320. * Set the enabled state of this node
  27321. * @param value defines the new enabled state
  27322. */
  27323. setEnabled(value: boolean): void;
  27324. /**
  27325. * Is this node a descendant of the given node?
  27326. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27327. * @param ancestor defines the parent node to inspect
  27328. * @returns a boolean indicating if this node is a descendant of the given node
  27329. */
  27330. isDescendantOf(ancestor: Node): boolean;
  27331. /** @hidden */
  27332. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27333. /**
  27334. * Will return all nodes that have this node as ascendant
  27335. * @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
  27336. * @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
  27337. * @return all children nodes of all types
  27338. */
  27339. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27340. /**
  27341. * Get all child-meshes of this node
  27342. * @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)
  27343. * @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
  27344. * @returns an array of AbstractMesh
  27345. */
  27346. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27347. /**
  27348. * Get all direct children of this node
  27349. * @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
  27350. * @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)
  27351. * @returns an array of Node
  27352. */
  27353. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27354. /** @hidden */
  27355. _setReady(state: boolean): void;
  27356. /**
  27357. * Get an animation by name
  27358. * @param name defines the name of the animation to look for
  27359. * @returns null if not found else the requested animation
  27360. */
  27361. getAnimationByName(name: string): Nullable<Animation>;
  27362. /**
  27363. * Creates an animation range for this node
  27364. * @param name defines the name of the range
  27365. * @param from defines the starting key
  27366. * @param to defines the end key
  27367. */
  27368. createAnimationRange(name: string, from: number, to: number): void;
  27369. /**
  27370. * Delete a specific animation range
  27371. * @param name defines the name of the range to delete
  27372. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27373. */
  27374. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27375. /**
  27376. * Get an animation range by name
  27377. * @param name defines the name of the animation range to look for
  27378. * @returns null if not found else the requested animation range
  27379. */
  27380. getAnimationRange(name: string): Nullable<AnimationRange>;
  27381. /**
  27382. * Gets the list of all animation ranges defined on this node
  27383. * @returns an array
  27384. */
  27385. getAnimationRanges(): Nullable<AnimationRange>[];
  27386. /**
  27387. * Will start the animation sequence
  27388. * @param name defines the range frames for animation sequence
  27389. * @param loop defines if the animation should loop (false by default)
  27390. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27391. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27392. * @returns the object created for this animation. If range does not exist, it will return null
  27393. */
  27394. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27395. /**
  27396. * Serialize animation ranges into a JSON compatible object
  27397. * @returns serialization object
  27398. */
  27399. serializeAnimationRanges(): any;
  27400. /**
  27401. * Computes the world matrix of the node
  27402. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27403. * @returns the world matrix
  27404. */
  27405. computeWorldMatrix(force?: boolean): Matrix;
  27406. /**
  27407. * Releases resources associated with this node.
  27408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27410. */
  27411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27412. /**
  27413. * Parse animation range data from a serialization object and store them into a given node
  27414. * @param node defines where to store the animation ranges
  27415. * @param parsedNode defines the serialization object to read data from
  27416. * @param scene defines the hosting scene
  27417. */
  27418. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27419. /**
  27420. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27421. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27422. * @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
  27423. * @returns the new bounding vectors
  27424. */
  27425. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27426. min: Vector3;
  27427. max: Vector3;
  27428. };
  27429. }
  27430. }
  27431. declare module BABYLON {
  27432. /**
  27433. * @hidden
  27434. */
  27435. export class _IAnimationState {
  27436. key: number;
  27437. repeatCount: number;
  27438. workValue?: any;
  27439. loopMode?: number;
  27440. offsetValue?: any;
  27441. highLimitValue?: any;
  27442. }
  27443. /**
  27444. * Class used to store any kind of animation
  27445. */
  27446. export class Animation {
  27447. /**Name of the animation */
  27448. name: string;
  27449. /**Property to animate */
  27450. targetProperty: string;
  27451. /**The frames per second of the animation */
  27452. framePerSecond: number;
  27453. /**The data type of the animation */
  27454. dataType: number;
  27455. /**The loop mode of the animation */
  27456. loopMode?: number | undefined;
  27457. /**Specifies if blending should be enabled */
  27458. enableBlending?: boolean | undefined;
  27459. /**
  27460. * Use matrix interpolation instead of using direct key value when animating matrices
  27461. */
  27462. static AllowMatricesInterpolation: boolean;
  27463. /**
  27464. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27465. */
  27466. static AllowMatrixDecomposeForInterpolation: boolean;
  27467. /**
  27468. * Stores the key frames of the animation
  27469. */
  27470. private _keys;
  27471. /**
  27472. * Stores the easing function of the animation
  27473. */
  27474. private _easingFunction;
  27475. /**
  27476. * @hidden Internal use only
  27477. */
  27478. _runtimeAnimations: RuntimeAnimation[];
  27479. /**
  27480. * The set of event that will be linked to this animation
  27481. */
  27482. private _events;
  27483. /**
  27484. * Stores an array of target property paths
  27485. */
  27486. targetPropertyPath: string[];
  27487. /**
  27488. * Stores the blending speed of the animation
  27489. */
  27490. blendingSpeed: number;
  27491. /**
  27492. * Stores the animation ranges for the animation
  27493. */
  27494. private _ranges;
  27495. /**
  27496. * @hidden Internal use
  27497. */
  27498. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27499. /**
  27500. * Sets up an animation
  27501. * @param property The property to animate
  27502. * @param animationType The animation type to apply
  27503. * @param framePerSecond The frames per second of the animation
  27504. * @param easingFunction The easing function used in the animation
  27505. * @returns The created animation
  27506. */
  27507. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27508. /**
  27509. * Create and start an animation on a node
  27510. * @param name defines the name of the global animation that will be run on all nodes
  27511. * @param node defines the root node where the animation will take place
  27512. * @param targetProperty defines property to animate
  27513. * @param framePerSecond defines the number of frame per second yo use
  27514. * @param totalFrame defines the number of frames in total
  27515. * @param from defines the initial value
  27516. * @param to defines the final value
  27517. * @param loopMode defines which loop mode you want to use (off by default)
  27518. * @param easingFunction defines the easing function to use (linear by default)
  27519. * @param onAnimationEnd defines the callback to call when animation end
  27520. * @returns the animatable created for this animation
  27521. */
  27522. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27523. /**
  27524. * Create and start an animation on a node and its descendants
  27525. * @param name defines the name of the global animation that will be run on all nodes
  27526. * @param node defines the root node where the animation will take place
  27527. * @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
  27528. * @param targetProperty defines property to animate
  27529. * @param framePerSecond defines the number of frame per second to use
  27530. * @param totalFrame defines the number of frames in total
  27531. * @param from defines the initial value
  27532. * @param to defines the final value
  27533. * @param loopMode defines which loop mode you want to use (off by default)
  27534. * @param easingFunction defines the easing function to use (linear by default)
  27535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27536. * @returns the list of animatables created for all nodes
  27537. * @example https://www.babylonjs-playground.com/#MH0VLI
  27538. */
  27539. 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[]>;
  27540. /**
  27541. * Creates a new animation, merges it with the existing animations and starts it
  27542. * @param name Name of the animation
  27543. * @param node Node which contains the scene that begins the animations
  27544. * @param targetProperty Specifies which property to animate
  27545. * @param framePerSecond The frames per second of the animation
  27546. * @param totalFrame The total number of frames
  27547. * @param from The frame at the beginning of the animation
  27548. * @param to The frame at the end of the animation
  27549. * @param loopMode Specifies the loop mode of the animation
  27550. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27551. * @param onAnimationEnd Callback to run once the animation is complete
  27552. * @returns Nullable animation
  27553. */
  27554. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27555. /**
  27556. * Transition property of an host to the target Value
  27557. * @param property The property to transition
  27558. * @param targetValue The target Value of the property
  27559. * @param host The object where the property to animate belongs
  27560. * @param scene Scene used to run the animation
  27561. * @param frameRate Framerate (in frame/s) to use
  27562. * @param transition The transition type we want to use
  27563. * @param duration The duration of the animation, in milliseconds
  27564. * @param onAnimationEnd Callback trigger at the end of the animation
  27565. * @returns Nullable animation
  27566. */
  27567. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27568. /**
  27569. * Return the array of runtime animations currently using this animation
  27570. */
  27571. readonly runtimeAnimations: RuntimeAnimation[];
  27572. /**
  27573. * Specifies if any of the runtime animations are currently running
  27574. */
  27575. readonly hasRunningRuntimeAnimations: boolean;
  27576. /**
  27577. * Initializes the animation
  27578. * @param name Name of the animation
  27579. * @param targetProperty Property to animate
  27580. * @param framePerSecond The frames per second of the animation
  27581. * @param dataType The data type of the animation
  27582. * @param loopMode The loop mode of the animation
  27583. * @param enableBlending Specifies if blending should be enabled
  27584. */
  27585. constructor(
  27586. /**Name of the animation */
  27587. name: string,
  27588. /**Property to animate */
  27589. targetProperty: string,
  27590. /**The frames per second of the animation */
  27591. framePerSecond: number,
  27592. /**The data type of the animation */
  27593. dataType: number,
  27594. /**The loop mode of the animation */
  27595. loopMode?: number | undefined,
  27596. /**Specifies if blending should be enabled */
  27597. enableBlending?: boolean | undefined);
  27598. /**
  27599. * Converts the animation to a string
  27600. * @param fullDetails support for multiple levels of logging within scene loading
  27601. * @returns String form of the animation
  27602. */
  27603. toString(fullDetails?: boolean): string;
  27604. /**
  27605. * Add an event to this animation
  27606. * @param event Event to add
  27607. */
  27608. addEvent(event: AnimationEvent): void;
  27609. /**
  27610. * Remove all events found at the given frame
  27611. * @param frame The frame to remove events from
  27612. */
  27613. removeEvents(frame: number): void;
  27614. /**
  27615. * Retrieves all the events from the animation
  27616. * @returns Events from the animation
  27617. */
  27618. getEvents(): AnimationEvent[];
  27619. /**
  27620. * Creates an animation range
  27621. * @param name Name of the animation range
  27622. * @param from Starting frame of the animation range
  27623. * @param to Ending frame of the animation
  27624. */
  27625. createRange(name: string, from: number, to: number): void;
  27626. /**
  27627. * Deletes an animation range by name
  27628. * @param name Name of the animation range to delete
  27629. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27630. */
  27631. deleteRange(name: string, deleteFrames?: boolean): void;
  27632. /**
  27633. * Gets the animation range by name, or null if not defined
  27634. * @param name Name of the animation range
  27635. * @returns Nullable animation range
  27636. */
  27637. getRange(name: string): Nullable<AnimationRange>;
  27638. /**
  27639. * Gets the key frames from the animation
  27640. * @returns The key frames of the animation
  27641. */
  27642. getKeys(): Array<IAnimationKey>;
  27643. /**
  27644. * Gets the highest frame rate of the animation
  27645. * @returns Highest frame rate of the animation
  27646. */
  27647. getHighestFrame(): number;
  27648. /**
  27649. * Gets the easing function of the animation
  27650. * @returns Easing function of the animation
  27651. */
  27652. getEasingFunction(): IEasingFunction;
  27653. /**
  27654. * Sets the easing function of the animation
  27655. * @param easingFunction A custom mathematical formula for animation
  27656. */
  27657. setEasingFunction(easingFunction: EasingFunction): void;
  27658. /**
  27659. * Interpolates a scalar linearly
  27660. * @param startValue Start value of the animation curve
  27661. * @param endValue End value of the animation curve
  27662. * @param gradient Scalar amount to interpolate
  27663. * @returns Interpolated scalar value
  27664. */
  27665. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27666. /**
  27667. * Interpolates a scalar cubically
  27668. * @param startValue Start value of the animation curve
  27669. * @param outTangent End tangent of the animation
  27670. * @param endValue End value of the animation curve
  27671. * @param inTangent Start tangent of the animation curve
  27672. * @param gradient Scalar amount to interpolate
  27673. * @returns Interpolated scalar value
  27674. */
  27675. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27676. /**
  27677. * Interpolates a quaternion using a spherical linear interpolation
  27678. * @param startValue Start value of the animation curve
  27679. * @param endValue End value of the animation curve
  27680. * @param gradient Scalar amount to interpolate
  27681. * @returns Interpolated quaternion value
  27682. */
  27683. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27684. /**
  27685. * Interpolates a quaternion cubically
  27686. * @param startValue Start value of the animation curve
  27687. * @param outTangent End tangent of the animation curve
  27688. * @param endValue End value of the animation curve
  27689. * @param inTangent Start tangent of the animation curve
  27690. * @param gradient Scalar amount to interpolate
  27691. * @returns Interpolated quaternion value
  27692. */
  27693. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27694. /**
  27695. * Interpolates a Vector3 linearl
  27696. * @param startValue Start value of the animation curve
  27697. * @param endValue End value of the animation curve
  27698. * @param gradient Scalar amount to interpolate
  27699. * @returns Interpolated scalar value
  27700. */
  27701. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27702. /**
  27703. * Interpolates a Vector3 cubically
  27704. * @param startValue Start value of the animation curve
  27705. * @param outTangent End tangent of the animation
  27706. * @param endValue End value of the animation curve
  27707. * @param inTangent Start tangent of the animation curve
  27708. * @param gradient Scalar amount to interpolate
  27709. * @returns InterpolatedVector3 value
  27710. */
  27711. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27712. /**
  27713. * Interpolates a Vector2 linearly
  27714. * @param startValue Start value of the animation curve
  27715. * @param endValue End value of the animation curve
  27716. * @param gradient Scalar amount to interpolate
  27717. * @returns Interpolated Vector2 value
  27718. */
  27719. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27720. /**
  27721. * Interpolates a Vector2 cubically
  27722. * @param startValue Start value of the animation curve
  27723. * @param outTangent End tangent of the animation
  27724. * @param endValue End value of the animation curve
  27725. * @param inTangent Start tangent of the animation curve
  27726. * @param gradient Scalar amount to interpolate
  27727. * @returns Interpolated Vector2 value
  27728. */
  27729. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27730. /**
  27731. * Interpolates a size linearly
  27732. * @param startValue Start value of the animation curve
  27733. * @param endValue End value of the animation curve
  27734. * @param gradient Scalar amount to interpolate
  27735. * @returns Interpolated Size value
  27736. */
  27737. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27738. /**
  27739. * Interpolates a Color3 linearly
  27740. * @param startValue Start value of the animation curve
  27741. * @param endValue End value of the animation curve
  27742. * @param gradient Scalar amount to interpolate
  27743. * @returns Interpolated Color3 value
  27744. */
  27745. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27746. /**
  27747. * Interpolates a Color4 linearly
  27748. * @param startValue Start value of the animation curve
  27749. * @param endValue End value of the animation curve
  27750. * @param gradient Scalar amount to interpolate
  27751. * @returns Interpolated Color3 value
  27752. */
  27753. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  27754. /**
  27755. * @hidden Internal use only
  27756. */
  27757. _getKeyValue(value: any): any;
  27758. /**
  27759. * @hidden Internal use only
  27760. */
  27761. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27762. /**
  27763. * Defines the function to use to interpolate matrices
  27764. * @param startValue defines the start matrix
  27765. * @param endValue defines the end matrix
  27766. * @param gradient defines the gradient between both matrices
  27767. * @param result defines an optional target matrix where to store the interpolation
  27768. * @returns the interpolated matrix
  27769. */
  27770. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27771. /**
  27772. * Makes a copy of the animation
  27773. * @returns Cloned animation
  27774. */
  27775. clone(): Animation;
  27776. /**
  27777. * Sets the key frames of the animation
  27778. * @param values The animation key frames to set
  27779. */
  27780. setKeys(values: Array<IAnimationKey>): void;
  27781. /**
  27782. * Serializes the animation to an object
  27783. * @returns Serialized object
  27784. */
  27785. serialize(): any;
  27786. /**
  27787. * Float animation type
  27788. */
  27789. static readonly ANIMATIONTYPE_FLOAT: number;
  27790. /**
  27791. * Vector3 animation type
  27792. */
  27793. static readonly ANIMATIONTYPE_VECTOR3: number;
  27794. /**
  27795. * Quaternion animation type
  27796. */
  27797. static readonly ANIMATIONTYPE_QUATERNION: number;
  27798. /**
  27799. * Matrix animation type
  27800. */
  27801. static readonly ANIMATIONTYPE_MATRIX: number;
  27802. /**
  27803. * Color3 animation type
  27804. */
  27805. static readonly ANIMATIONTYPE_COLOR3: number;
  27806. /**
  27807. * Color3 animation type
  27808. */
  27809. static readonly ANIMATIONTYPE_COLOR4: number;
  27810. /**
  27811. * Vector2 animation type
  27812. */
  27813. static readonly ANIMATIONTYPE_VECTOR2: number;
  27814. /**
  27815. * Size animation type
  27816. */
  27817. static readonly ANIMATIONTYPE_SIZE: number;
  27818. /**
  27819. * Relative Loop Mode
  27820. */
  27821. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27822. /**
  27823. * Cycle Loop Mode
  27824. */
  27825. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27826. /**
  27827. * Constant Loop Mode
  27828. */
  27829. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27830. /** @hidden */
  27831. static _UniversalLerp(left: any, right: any, amount: number): any;
  27832. /**
  27833. * Parses an animation object and creates an animation
  27834. * @param parsedAnimation Parsed animation object
  27835. * @returns Animation object
  27836. */
  27837. static Parse(parsedAnimation: any): Animation;
  27838. /**
  27839. * Appends the serialized animations from the source animations
  27840. * @param source Source containing the animations
  27841. * @param destination Target to store the animations
  27842. */
  27843. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27844. }
  27845. }
  27846. declare module BABYLON {
  27847. /**
  27848. * Interface containing an array of animations
  27849. */
  27850. export interface IAnimatable {
  27851. /**
  27852. * Array of animations
  27853. */
  27854. animations: Nullable<Array<Animation>>;
  27855. }
  27856. }
  27857. declare module BABYLON {
  27858. /**
  27859. * This represents all the required information to add a fresnel effect on a material:
  27860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27861. */
  27862. export class FresnelParameters {
  27863. private _isEnabled;
  27864. /**
  27865. * Define if the fresnel effect is enable or not.
  27866. */
  27867. isEnabled: boolean;
  27868. /**
  27869. * Define the color used on edges (grazing angle)
  27870. */
  27871. leftColor: Color3;
  27872. /**
  27873. * Define the color used on center
  27874. */
  27875. rightColor: Color3;
  27876. /**
  27877. * Define bias applied to computed fresnel term
  27878. */
  27879. bias: number;
  27880. /**
  27881. * Defined the power exponent applied to fresnel term
  27882. */
  27883. power: number;
  27884. /**
  27885. * Clones the current fresnel and its valuues
  27886. * @returns a clone fresnel configuration
  27887. */
  27888. clone(): FresnelParameters;
  27889. /**
  27890. * Serializes the current fresnel parameters to a JSON representation.
  27891. * @return the JSON serialization
  27892. */
  27893. serialize(): any;
  27894. /**
  27895. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27896. * @param parsedFresnelParameters Define the JSON representation
  27897. * @returns the parsed parameters
  27898. */
  27899. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27900. }
  27901. }
  27902. declare module BABYLON {
  27903. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27904. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27905. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27906. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27907. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27908. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27909. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27910. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27911. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27912. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27913. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27914. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27915. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27916. /**
  27917. * Decorator used to define property that can be serialized as reference to a camera
  27918. * @param sourceName defines the name of the property to decorate
  27919. */
  27920. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27921. /**
  27922. * Class used to help serialization objects
  27923. */
  27924. export class SerializationHelper {
  27925. /** @hidden */
  27926. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27927. /** @hidden */
  27928. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27929. /** @hidden */
  27930. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27931. /** @hidden */
  27932. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27933. /**
  27934. * Appends the serialized animations from the source animations
  27935. * @param source Source containing the animations
  27936. * @param destination Target to store the animations
  27937. */
  27938. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27939. /**
  27940. * Static function used to serialized a specific entity
  27941. * @param entity defines the entity to serialize
  27942. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27943. * @returns a JSON compatible object representing the serialization of the entity
  27944. */
  27945. static Serialize<T>(entity: T, serializationObject?: any): any;
  27946. /**
  27947. * Creates a new entity from a serialization data object
  27948. * @param creationFunction defines a function used to instanciated the new entity
  27949. * @param source defines the source serialization data
  27950. * @param scene defines the hosting scene
  27951. * @param rootUrl defines the root url for resources
  27952. * @returns a new entity
  27953. */
  27954. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27955. /**
  27956. * Clones an object
  27957. * @param creationFunction defines the function used to instanciate the new object
  27958. * @param source defines the source object
  27959. * @returns the cloned object
  27960. */
  27961. static Clone<T>(creationFunction: () => T, source: T): T;
  27962. /**
  27963. * Instanciates a new object based on a source one (some data will be shared between both object)
  27964. * @param creationFunction defines the function used to instanciate the new object
  27965. * @param source defines the source object
  27966. * @returns the new object
  27967. */
  27968. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27969. }
  27970. }
  27971. declare module BABYLON {
  27972. /**
  27973. * Class used to manipulate GUIDs
  27974. */
  27975. export class GUID {
  27976. /**
  27977. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27978. * Be aware Math.random() could cause collisions, but:
  27979. * "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"
  27980. * @returns a pseudo random id
  27981. */
  27982. static RandomId(): string;
  27983. }
  27984. }
  27985. declare module BABYLON {
  27986. /**
  27987. * Base class of all the textures in babylon.
  27988. * It groups all the common properties the materials, post process, lights... might need
  27989. * in order to make a correct use of the texture.
  27990. */
  27991. export class BaseTexture implements IAnimatable {
  27992. /**
  27993. * Default anisotropic filtering level for the application.
  27994. * It is set to 4 as a good tradeoff between perf and quality.
  27995. */
  27996. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27997. /**
  27998. * Gets or sets the unique id of the texture
  27999. */
  28000. uniqueId: number;
  28001. /**
  28002. * Define the name of the texture.
  28003. */
  28004. name: string;
  28005. /**
  28006. * Gets or sets an object used to store user defined information.
  28007. */
  28008. metadata: any;
  28009. /**
  28010. * For internal use only. Please do not use.
  28011. */
  28012. reservedDataStore: any;
  28013. private _hasAlpha;
  28014. /**
  28015. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28016. */
  28017. hasAlpha: boolean;
  28018. /**
  28019. * Defines if the alpha value should be determined via the rgb values.
  28020. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28021. */
  28022. getAlphaFromRGB: boolean;
  28023. /**
  28024. * Intensity or strength of the texture.
  28025. * It is commonly used by materials to fine tune the intensity of the texture
  28026. */
  28027. level: number;
  28028. /**
  28029. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28030. * This is part of the texture as textures usually maps to one uv set.
  28031. */
  28032. coordinatesIndex: number;
  28033. private _coordinatesMode;
  28034. /**
  28035. * How a texture is mapped.
  28036. *
  28037. * | Value | Type | Description |
  28038. * | ----- | ----------------------------------- | ----------- |
  28039. * | 0 | EXPLICIT_MODE | |
  28040. * | 1 | SPHERICAL_MODE | |
  28041. * | 2 | PLANAR_MODE | |
  28042. * | 3 | CUBIC_MODE | |
  28043. * | 4 | PROJECTION_MODE | |
  28044. * | 5 | SKYBOX_MODE | |
  28045. * | 6 | INVCUBIC_MODE | |
  28046. * | 7 | EQUIRECTANGULAR_MODE | |
  28047. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28048. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28049. */
  28050. coordinatesMode: number;
  28051. /**
  28052. * | Value | Type | Description |
  28053. * | ----- | ------------------ | ----------- |
  28054. * | 0 | CLAMP_ADDRESSMODE | |
  28055. * | 1 | WRAP_ADDRESSMODE | |
  28056. * | 2 | MIRROR_ADDRESSMODE | |
  28057. */
  28058. wrapU: number;
  28059. /**
  28060. * | Value | Type | Description |
  28061. * | ----- | ------------------ | ----------- |
  28062. * | 0 | CLAMP_ADDRESSMODE | |
  28063. * | 1 | WRAP_ADDRESSMODE | |
  28064. * | 2 | MIRROR_ADDRESSMODE | |
  28065. */
  28066. wrapV: number;
  28067. /**
  28068. * | Value | Type | Description |
  28069. * | ----- | ------------------ | ----------- |
  28070. * | 0 | CLAMP_ADDRESSMODE | |
  28071. * | 1 | WRAP_ADDRESSMODE | |
  28072. * | 2 | MIRROR_ADDRESSMODE | |
  28073. */
  28074. wrapR: number;
  28075. /**
  28076. * With compliant hardware and browser (supporting anisotropic filtering)
  28077. * this defines the level of anisotropic filtering in the texture.
  28078. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28079. */
  28080. anisotropicFilteringLevel: number;
  28081. /**
  28082. * Define if the texture is a cube texture or if false a 2d texture.
  28083. */
  28084. isCube: boolean;
  28085. /**
  28086. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28087. */
  28088. is3D: boolean;
  28089. /**
  28090. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  28091. */
  28092. is2DArray: boolean;
  28093. /**
  28094. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28095. * HDR texture are usually stored in linear space.
  28096. * This only impacts the PBR and Background materials
  28097. */
  28098. gammaSpace: boolean;
  28099. /**
  28100. * Gets or sets whether or not the texture contains RGBD data.
  28101. */
  28102. isRGBD: boolean;
  28103. /**
  28104. * Is Z inverted in the texture (useful in a cube texture).
  28105. */
  28106. invertZ: boolean;
  28107. /**
  28108. * Are mip maps generated for this texture or not.
  28109. */
  28110. readonly noMipmap: boolean;
  28111. /**
  28112. * @hidden
  28113. */
  28114. lodLevelInAlpha: boolean;
  28115. /**
  28116. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28117. */
  28118. lodGenerationOffset: number;
  28119. /**
  28120. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28121. */
  28122. lodGenerationScale: number;
  28123. /**
  28124. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28125. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28126. * average roughness values.
  28127. */
  28128. linearSpecularLOD: boolean;
  28129. /**
  28130. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28131. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28132. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28133. */
  28134. irradianceTexture: Nullable<BaseTexture>;
  28135. /**
  28136. * Define if the texture is a render target.
  28137. */
  28138. isRenderTarget: boolean;
  28139. /**
  28140. * Define the unique id of the texture in the scene.
  28141. */
  28142. readonly uid: string;
  28143. /**
  28144. * Return a string representation of the texture.
  28145. * @returns the texture as a string
  28146. */
  28147. toString(): string;
  28148. /**
  28149. * Get the class name of the texture.
  28150. * @returns "BaseTexture"
  28151. */
  28152. getClassName(): string;
  28153. /**
  28154. * Define the list of animation attached to the texture.
  28155. */
  28156. animations: Animation[];
  28157. /**
  28158. * An event triggered when the texture is disposed.
  28159. */
  28160. onDisposeObservable: Observable<BaseTexture>;
  28161. private _onDisposeObserver;
  28162. /**
  28163. * Callback triggered when the texture has been disposed.
  28164. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28165. */
  28166. onDispose: () => void;
  28167. /**
  28168. * Define the current state of the loading sequence when in delayed load mode.
  28169. */
  28170. delayLoadState: number;
  28171. private _scene;
  28172. /** @hidden */
  28173. _texture: Nullable<InternalTexture>;
  28174. private _uid;
  28175. /**
  28176. * Define if the texture is preventinga material to render or not.
  28177. * If not and the texture is not ready, the engine will use a default black texture instead.
  28178. */
  28179. readonly isBlocking: boolean;
  28180. /**
  28181. * Instantiates a new BaseTexture.
  28182. * Base class of all the textures in babylon.
  28183. * It groups all the common properties the materials, post process, lights... might need
  28184. * in order to make a correct use of the texture.
  28185. * @param scene Define the scene the texture blongs to
  28186. */
  28187. constructor(scene: Nullable<Scene>);
  28188. /**
  28189. * Get the scene the texture belongs to.
  28190. * @returns the scene or null if undefined
  28191. */
  28192. getScene(): Nullable<Scene>;
  28193. /**
  28194. * Get the texture transform matrix used to offset tile the texture for istance.
  28195. * @returns the transformation matrix
  28196. */
  28197. getTextureMatrix(): Matrix;
  28198. /**
  28199. * Get the texture reflection matrix used to rotate/transform the reflection.
  28200. * @returns the reflection matrix
  28201. */
  28202. getReflectionTextureMatrix(): Matrix;
  28203. /**
  28204. * Get the underlying lower level texture from Babylon.
  28205. * @returns the insternal texture
  28206. */
  28207. getInternalTexture(): Nullable<InternalTexture>;
  28208. /**
  28209. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28210. * @returns true if ready or not blocking
  28211. */
  28212. isReadyOrNotBlocking(): boolean;
  28213. /**
  28214. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28215. * @returns true if fully ready
  28216. */
  28217. isReady(): boolean;
  28218. private _cachedSize;
  28219. /**
  28220. * Get the size of the texture.
  28221. * @returns the texture size.
  28222. */
  28223. getSize(): ISize;
  28224. /**
  28225. * Get the base size of the texture.
  28226. * It can be different from the size if the texture has been resized for POT for instance
  28227. * @returns the base size
  28228. */
  28229. getBaseSize(): ISize;
  28230. /**
  28231. * Update the sampling mode of the texture.
  28232. * Default is Trilinear mode.
  28233. *
  28234. * | Value | Type | Description |
  28235. * | ----- | ------------------ | ----------- |
  28236. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28237. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28238. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28239. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28240. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28241. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28242. * | 7 | NEAREST_LINEAR | |
  28243. * | 8 | NEAREST_NEAREST | |
  28244. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28245. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28246. * | 11 | LINEAR_LINEAR | |
  28247. * | 12 | LINEAR_NEAREST | |
  28248. *
  28249. * > _mag_: magnification filter (close to the viewer)
  28250. * > _min_: minification filter (far from the viewer)
  28251. * > _mip_: filter used between mip map levels
  28252. *@param samplingMode Define the new sampling mode of the texture
  28253. */
  28254. updateSamplingMode(samplingMode: number): void;
  28255. /**
  28256. * Scales the texture if is `canRescale()`
  28257. * @param ratio the resize factor we want to use to rescale
  28258. */
  28259. scale(ratio: number): void;
  28260. /**
  28261. * Get if the texture can rescale.
  28262. */
  28263. readonly canRescale: boolean;
  28264. /** @hidden */
  28265. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28266. /** @hidden */
  28267. _rebuild(): void;
  28268. /**
  28269. * Triggers the load sequence in delayed load mode.
  28270. */
  28271. delayLoad(): void;
  28272. /**
  28273. * Clones the texture.
  28274. * @returns the cloned texture
  28275. */
  28276. clone(): Nullable<BaseTexture>;
  28277. /**
  28278. * Get the texture underlying type (INT, FLOAT...)
  28279. */
  28280. readonly textureType: number;
  28281. /**
  28282. * Get the texture underlying format (RGB, RGBA...)
  28283. */
  28284. readonly textureFormat: number;
  28285. /**
  28286. * Indicates that textures need to be re-calculated for all materials
  28287. */
  28288. protected _markAllSubMeshesAsTexturesDirty(): void;
  28289. /**
  28290. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28291. * This will returns an RGBA array buffer containing either in values (0-255) or
  28292. * float values (0-1) depending of the underlying buffer type.
  28293. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28294. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28295. * @param buffer defines a user defined buffer to fill with data (can be null)
  28296. * @returns The Array buffer containing the pixels data.
  28297. */
  28298. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28299. /**
  28300. * Release and destroy the underlying lower level texture aka internalTexture.
  28301. */
  28302. releaseInternalTexture(): void;
  28303. /** @hidden */
  28304. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28305. /** @hidden */
  28306. readonly _lodTextureMid: Nullable<BaseTexture>;
  28307. /** @hidden */
  28308. readonly _lodTextureLow: Nullable<BaseTexture>;
  28309. /**
  28310. * Dispose the texture and release its associated resources.
  28311. */
  28312. dispose(): void;
  28313. /**
  28314. * Serialize the texture into a JSON representation that can be parsed later on.
  28315. * @returns the JSON representation of the texture
  28316. */
  28317. serialize(): any;
  28318. /**
  28319. * Helper function to be called back once a list of texture contains only ready textures.
  28320. * @param textures Define the list of textures to wait for
  28321. * @param callback Define the callback triggered once the entire list will be ready
  28322. */
  28323. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28324. }
  28325. }
  28326. declare module BABYLON {
  28327. /**
  28328. * Options to be used when creating an effect.
  28329. */
  28330. export interface IEffectCreationOptions {
  28331. /**
  28332. * Atrributes that will be used in the shader.
  28333. */
  28334. attributes: string[];
  28335. /**
  28336. * Uniform varible names that will be set in the shader.
  28337. */
  28338. uniformsNames: string[];
  28339. /**
  28340. * Uniform buffer varible names that will be set in the shader.
  28341. */
  28342. uniformBuffersNames: string[];
  28343. /**
  28344. * Sampler texture variable names that will be set in the shader.
  28345. */
  28346. samplers: string[];
  28347. /**
  28348. * Define statements that will be set in the shader.
  28349. */
  28350. defines: any;
  28351. /**
  28352. * Possible fallbacks for this effect to improve performance when needed.
  28353. */
  28354. fallbacks: Nullable<IEffectFallbacks>;
  28355. /**
  28356. * Callback that will be called when the shader is compiled.
  28357. */
  28358. onCompiled: Nullable<(effect: Effect) => void>;
  28359. /**
  28360. * Callback that will be called if an error occurs during shader compilation.
  28361. */
  28362. onError: Nullable<(effect: Effect, errors: string) => void>;
  28363. /**
  28364. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28365. */
  28366. indexParameters?: any;
  28367. /**
  28368. * Max number of lights that can be used in the shader.
  28369. */
  28370. maxSimultaneousLights?: number;
  28371. /**
  28372. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28373. */
  28374. transformFeedbackVaryings?: Nullable<string[]>;
  28375. }
  28376. /**
  28377. * Effect containing vertex and fragment shader that can be executed on an object.
  28378. */
  28379. export class Effect implements IDisposable {
  28380. /**
  28381. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28382. */
  28383. static ShadersRepository: string;
  28384. /**
  28385. * Name of the effect.
  28386. */
  28387. name: any;
  28388. /**
  28389. * String container all the define statements that should be set on the shader.
  28390. */
  28391. defines: string;
  28392. /**
  28393. * Callback that will be called when the shader is compiled.
  28394. */
  28395. onCompiled: Nullable<(effect: Effect) => void>;
  28396. /**
  28397. * Callback that will be called if an error occurs during shader compilation.
  28398. */
  28399. onError: Nullable<(effect: Effect, errors: string) => void>;
  28400. /**
  28401. * Callback that will be called when effect is bound.
  28402. */
  28403. onBind: Nullable<(effect: Effect) => void>;
  28404. /**
  28405. * Unique ID of the effect.
  28406. */
  28407. uniqueId: number;
  28408. /**
  28409. * Observable that will be called when the shader is compiled.
  28410. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28411. */
  28412. onCompileObservable: Observable<Effect>;
  28413. /**
  28414. * Observable that will be called if an error occurs during shader compilation.
  28415. */
  28416. onErrorObservable: Observable<Effect>;
  28417. /** @hidden */
  28418. _onBindObservable: Nullable<Observable<Effect>>;
  28419. /**
  28420. * Observable that will be called when effect is bound.
  28421. */
  28422. readonly onBindObservable: Observable<Effect>;
  28423. /** @hidden */
  28424. _bonesComputationForcedToCPU: boolean;
  28425. private static _uniqueIdSeed;
  28426. private _engine;
  28427. private _uniformBuffersNames;
  28428. private _uniformsNames;
  28429. private _samplerList;
  28430. private _samplers;
  28431. private _isReady;
  28432. private _compilationError;
  28433. private _allFallbacksProcessed;
  28434. private _attributesNames;
  28435. private _attributes;
  28436. private _uniforms;
  28437. /**
  28438. * Key for the effect.
  28439. * @hidden
  28440. */
  28441. _key: string;
  28442. private _indexParameters;
  28443. private _fallbacks;
  28444. private _vertexSourceCode;
  28445. private _fragmentSourceCode;
  28446. private _vertexSourceCodeOverride;
  28447. private _fragmentSourceCodeOverride;
  28448. private _transformFeedbackVaryings;
  28449. /**
  28450. * Compiled shader to webGL program.
  28451. * @hidden
  28452. */
  28453. _pipelineContext: Nullable<IPipelineContext>;
  28454. private _valueCache;
  28455. private static _baseCache;
  28456. /**
  28457. * Instantiates an effect.
  28458. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28459. * @param baseName Name of the effect.
  28460. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28461. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28462. * @param samplers List of sampler variables that will be passed to the shader.
  28463. * @param engine Engine to be used to render the effect
  28464. * @param defines Define statements to be added to the shader.
  28465. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28466. * @param onCompiled Callback that will be called when the shader is compiled.
  28467. * @param onError Callback that will be called if an error occurs during shader compilation.
  28468. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28469. */
  28470. 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);
  28471. private _useFinalCode;
  28472. /**
  28473. * Unique key for this effect
  28474. */
  28475. readonly key: string;
  28476. /**
  28477. * If the effect has been compiled and prepared.
  28478. * @returns if the effect is compiled and prepared.
  28479. */
  28480. isReady(): boolean;
  28481. private _isReadyInternal;
  28482. /**
  28483. * The engine the effect was initialized with.
  28484. * @returns the engine.
  28485. */
  28486. getEngine(): Engine;
  28487. /**
  28488. * The pipeline context for this effect
  28489. * @returns the associated pipeline context
  28490. */
  28491. getPipelineContext(): Nullable<IPipelineContext>;
  28492. /**
  28493. * The set of names of attribute variables for the shader.
  28494. * @returns An array of attribute names.
  28495. */
  28496. getAttributesNames(): string[];
  28497. /**
  28498. * Returns the attribute at the given index.
  28499. * @param index The index of the attribute.
  28500. * @returns The location of the attribute.
  28501. */
  28502. getAttributeLocation(index: number): number;
  28503. /**
  28504. * Returns the attribute based on the name of the variable.
  28505. * @param name of the attribute to look up.
  28506. * @returns the attribute location.
  28507. */
  28508. getAttributeLocationByName(name: string): number;
  28509. /**
  28510. * The number of attributes.
  28511. * @returns the numnber of attributes.
  28512. */
  28513. getAttributesCount(): number;
  28514. /**
  28515. * Gets the index of a uniform variable.
  28516. * @param uniformName of the uniform to look up.
  28517. * @returns the index.
  28518. */
  28519. getUniformIndex(uniformName: string): number;
  28520. /**
  28521. * Returns the attribute based on the name of the variable.
  28522. * @param uniformName of the uniform to look up.
  28523. * @returns the location of the uniform.
  28524. */
  28525. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28526. /**
  28527. * Returns an array of sampler variable names
  28528. * @returns The array of sampler variable neames.
  28529. */
  28530. getSamplers(): string[];
  28531. /**
  28532. * The error from the last compilation.
  28533. * @returns the error string.
  28534. */
  28535. getCompilationError(): string;
  28536. /**
  28537. * Gets a boolean indicating that all fallbacks were used during compilation
  28538. * @returns true if all fallbacks were used
  28539. */
  28540. allFallbacksProcessed(): boolean;
  28541. /**
  28542. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28543. * @param func The callback to be used.
  28544. */
  28545. executeWhenCompiled(func: (effect: Effect) => void): void;
  28546. private _checkIsReady;
  28547. private _loadShader;
  28548. /**
  28549. * Recompiles the webGL program
  28550. * @param vertexSourceCode The source code for the vertex shader.
  28551. * @param fragmentSourceCode The source code for the fragment shader.
  28552. * @param onCompiled Callback called when completed.
  28553. * @param onError Callback called on error.
  28554. * @hidden
  28555. */
  28556. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28557. /**
  28558. * Prepares the effect
  28559. * @hidden
  28560. */
  28561. _prepareEffect(): void;
  28562. private _processCompilationErrors;
  28563. /**
  28564. * Checks if the effect is supported. (Must be called after compilation)
  28565. */
  28566. readonly isSupported: boolean;
  28567. /**
  28568. * Binds a texture to the engine to be used as output of the shader.
  28569. * @param channel Name of the output variable.
  28570. * @param texture Texture to bind.
  28571. * @hidden
  28572. */
  28573. _bindTexture(channel: string, texture: InternalTexture): void;
  28574. /**
  28575. * Sets a texture on the engine to be used in the shader.
  28576. * @param channel Name of the sampler variable.
  28577. * @param texture Texture to set.
  28578. */
  28579. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28580. /**
  28581. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28582. * @param channel Name of the sampler variable.
  28583. * @param texture Texture to set.
  28584. */
  28585. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28586. /**
  28587. * Sets an array of textures on the engine to be used in the shader.
  28588. * @param channel Name of the variable.
  28589. * @param textures Textures to set.
  28590. */
  28591. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28592. /**
  28593. * 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)
  28594. * @param channel Name of the sampler variable.
  28595. * @param postProcess Post process to get the input texture from.
  28596. */
  28597. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28598. /**
  28599. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28600. * 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)
  28601. * @param channel Name of the sampler variable.
  28602. * @param postProcess Post process to get the output texture from.
  28603. */
  28604. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28605. /** @hidden */
  28606. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28607. /** @hidden */
  28608. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28609. /** @hidden */
  28610. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28611. /** @hidden */
  28612. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28613. /**
  28614. * Binds a buffer to a uniform.
  28615. * @param buffer Buffer to bind.
  28616. * @param name Name of the uniform variable to bind to.
  28617. */
  28618. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28619. /**
  28620. * Binds block to a uniform.
  28621. * @param blockName Name of the block to bind.
  28622. * @param index Index to bind.
  28623. */
  28624. bindUniformBlock(blockName: string, index: number): void;
  28625. /**
  28626. * Sets an interger value on a uniform variable.
  28627. * @param uniformName Name of the variable.
  28628. * @param value Value to be set.
  28629. * @returns this effect.
  28630. */
  28631. setInt(uniformName: string, value: number): Effect;
  28632. /**
  28633. * Sets an int array on a uniform variable.
  28634. * @param uniformName Name of the variable.
  28635. * @param array array to be set.
  28636. * @returns this effect.
  28637. */
  28638. setIntArray(uniformName: string, array: Int32Array): Effect;
  28639. /**
  28640. * 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)
  28641. * @param uniformName Name of the variable.
  28642. * @param array array to be set.
  28643. * @returns this effect.
  28644. */
  28645. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28646. /**
  28647. * 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)
  28648. * @param uniformName Name of the variable.
  28649. * @param array array to be set.
  28650. * @returns this effect.
  28651. */
  28652. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28653. /**
  28654. * 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)
  28655. * @param uniformName Name of the variable.
  28656. * @param array array to be set.
  28657. * @returns this effect.
  28658. */
  28659. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28660. /**
  28661. * Sets an float array on a uniform variable.
  28662. * @param uniformName Name of the variable.
  28663. * @param array array to be set.
  28664. * @returns this effect.
  28665. */
  28666. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28667. /**
  28668. * 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)
  28669. * @param uniformName Name of the variable.
  28670. * @param array array to be set.
  28671. * @returns this effect.
  28672. */
  28673. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28674. /**
  28675. * 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)
  28676. * @param uniformName Name of the variable.
  28677. * @param array array to be set.
  28678. * @returns this effect.
  28679. */
  28680. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28681. /**
  28682. * 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)
  28683. * @param uniformName Name of the variable.
  28684. * @param array array to be set.
  28685. * @returns this effect.
  28686. */
  28687. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28688. /**
  28689. * Sets an array on a uniform variable.
  28690. * @param uniformName Name of the variable.
  28691. * @param array array to be set.
  28692. * @returns this effect.
  28693. */
  28694. setArray(uniformName: string, array: number[]): Effect;
  28695. /**
  28696. * 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)
  28697. * @param uniformName Name of the variable.
  28698. * @param array array to be set.
  28699. * @returns this effect.
  28700. */
  28701. setArray2(uniformName: string, array: number[]): Effect;
  28702. /**
  28703. * 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)
  28704. * @param uniformName Name of the variable.
  28705. * @param array array to be set.
  28706. * @returns this effect.
  28707. */
  28708. setArray3(uniformName: string, array: number[]): Effect;
  28709. /**
  28710. * 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)
  28711. * @param uniformName Name of the variable.
  28712. * @param array array to be set.
  28713. * @returns this effect.
  28714. */
  28715. setArray4(uniformName: string, array: number[]): Effect;
  28716. /**
  28717. * Sets matrices on a uniform variable.
  28718. * @param uniformName Name of the variable.
  28719. * @param matrices matrices to be set.
  28720. * @returns this effect.
  28721. */
  28722. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28723. /**
  28724. * Sets matrix on a uniform variable.
  28725. * @param uniformName Name of the variable.
  28726. * @param matrix matrix to be set.
  28727. * @returns this effect.
  28728. */
  28729. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28730. /**
  28731. * 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)
  28732. * @param uniformName Name of the variable.
  28733. * @param matrix matrix to be set.
  28734. * @returns this effect.
  28735. */
  28736. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28737. /**
  28738. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28739. * @param uniformName Name of the variable.
  28740. * @param matrix matrix to be set.
  28741. * @returns this effect.
  28742. */
  28743. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28744. /**
  28745. * Sets a float on a uniform variable.
  28746. * @param uniformName Name of the variable.
  28747. * @param value value to be set.
  28748. * @returns this effect.
  28749. */
  28750. setFloat(uniformName: string, value: number): Effect;
  28751. /**
  28752. * Sets a boolean on a uniform variable.
  28753. * @param uniformName Name of the variable.
  28754. * @param bool value to be set.
  28755. * @returns this effect.
  28756. */
  28757. setBool(uniformName: string, bool: boolean): Effect;
  28758. /**
  28759. * Sets a Vector2 on a uniform variable.
  28760. * @param uniformName Name of the variable.
  28761. * @param vector2 vector2 to be set.
  28762. * @returns this effect.
  28763. */
  28764. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28765. /**
  28766. * Sets a float2 on a uniform variable.
  28767. * @param uniformName Name of the variable.
  28768. * @param x First float in float2.
  28769. * @param y Second float in float2.
  28770. * @returns this effect.
  28771. */
  28772. setFloat2(uniformName: string, x: number, y: number): Effect;
  28773. /**
  28774. * Sets a Vector3 on a uniform variable.
  28775. * @param uniformName Name of the variable.
  28776. * @param vector3 Value to be set.
  28777. * @returns this effect.
  28778. */
  28779. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28780. /**
  28781. * Sets a float3 on a uniform variable.
  28782. * @param uniformName Name of the variable.
  28783. * @param x First float in float3.
  28784. * @param y Second float in float3.
  28785. * @param z Third float in float3.
  28786. * @returns this effect.
  28787. */
  28788. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28789. /**
  28790. * Sets a Vector4 on a uniform variable.
  28791. * @param uniformName Name of the variable.
  28792. * @param vector4 Value to be set.
  28793. * @returns this effect.
  28794. */
  28795. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28796. /**
  28797. * Sets a float4 on a uniform variable.
  28798. * @param uniformName Name of the variable.
  28799. * @param x First float in float4.
  28800. * @param y Second float in float4.
  28801. * @param z Third float in float4.
  28802. * @param w Fourth float in float4.
  28803. * @returns this effect.
  28804. */
  28805. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28806. /**
  28807. * Sets a Color3 on a uniform variable.
  28808. * @param uniformName Name of the variable.
  28809. * @param color3 Value to be set.
  28810. * @returns this effect.
  28811. */
  28812. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28813. /**
  28814. * Sets a Color4 on a uniform variable.
  28815. * @param uniformName Name of the variable.
  28816. * @param color3 Value to be set.
  28817. * @param alpha Alpha value to be set.
  28818. * @returns this effect.
  28819. */
  28820. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28821. /**
  28822. * Sets a Color4 on a uniform variable
  28823. * @param uniformName defines the name of the variable
  28824. * @param color4 defines the value to be set
  28825. * @returns this effect.
  28826. */
  28827. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28828. /** Release all associated resources */
  28829. dispose(): void;
  28830. /**
  28831. * This function will add a new shader to the shader store
  28832. * @param name the name of the shader
  28833. * @param pixelShader optional pixel shader content
  28834. * @param vertexShader optional vertex shader content
  28835. */
  28836. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28837. /**
  28838. * Store of each shader (The can be looked up using effect.key)
  28839. */
  28840. static ShadersStore: {
  28841. [key: string]: string;
  28842. };
  28843. /**
  28844. * Store of each included file for a shader (The can be looked up using effect.key)
  28845. */
  28846. static IncludesShadersStore: {
  28847. [key: string]: string;
  28848. };
  28849. /**
  28850. * Resets the cache of effects.
  28851. */
  28852. static ResetCache(): void;
  28853. }
  28854. }
  28855. declare module BABYLON {
  28856. /**
  28857. * Interface used to describe the capabilities of the engine relatively to the current browser
  28858. */
  28859. export interface EngineCapabilities {
  28860. /** Maximum textures units per fragment shader */
  28861. maxTexturesImageUnits: number;
  28862. /** Maximum texture units per vertex shader */
  28863. maxVertexTextureImageUnits: number;
  28864. /** Maximum textures units in the entire pipeline */
  28865. maxCombinedTexturesImageUnits: number;
  28866. /** Maximum texture size */
  28867. maxTextureSize: number;
  28868. /** Maximum cube texture size */
  28869. maxCubemapTextureSize: number;
  28870. /** Maximum render texture size */
  28871. maxRenderTextureSize: number;
  28872. /** Maximum number of vertex attributes */
  28873. maxVertexAttribs: number;
  28874. /** Maximum number of varyings */
  28875. maxVaryingVectors: number;
  28876. /** Maximum number of uniforms per vertex shader */
  28877. maxVertexUniformVectors: number;
  28878. /** Maximum number of uniforms per fragment shader */
  28879. maxFragmentUniformVectors: number;
  28880. /** Defines if standard derivates (dx/dy) are supported */
  28881. standardDerivatives: boolean;
  28882. /** Defines if s3tc texture compression is supported */
  28883. s3tc?: WEBGL_compressed_texture_s3tc;
  28884. /** Defines if pvrtc texture compression is supported */
  28885. pvrtc: any;
  28886. /** Defines if etc1 texture compression is supported */
  28887. etc1: any;
  28888. /** Defines if etc2 texture compression is supported */
  28889. etc2: any;
  28890. /** Defines if astc texture compression is supported */
  28891. astc: any;
  28892. /** Defines if float textures are supported */
  28893. textureFloat: boolean;
  28894. /** Defines if vertex array objects are supported */
  28895. vertexArrayObject: boolean;
  28896. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28897. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  28898. /** Gets the maximum level of anisotropy supported */
  28899. maxAnisotropy: number;
  28900. /** Defines if instancing is supported */
  28901. instancedArrays: boolean;
  28902. /** Defines if 32 bits indices are supported */
  28903. uintIndices: boolean;
  28904. /** Defines if high precision shaders are supported */
  28905. highPrecisionShaderSupported: boolean;
  28906. /** Defines if depth reading in the fragment shader is supported */
  28907. fragmentDepthSupported: boolean;
  28908. /** Defines if float texture linear filtering is supported*/
  28909. textureFloatLinearFiltering: boolean;
  28910. /** Defines if rendering to float textures is supported */
  28911. textureFloatRender: boolean;
  28912. /** Defines if half float textures are supported*/
  28913. textureHalfFloat: boolean;
  28914. /** Defines if half float texture linear filtering is supported*/
  28915. textureHalfFloatLinearFiltering: boolean;
  28916. /** Defines if rendering to half float textures is supported */
  28917. textureHalfFloatRender: boolean;
  28918. /** Defines if textureLOD shader command is supported */
  28919. textureLOD: boolean;
  28920. /** Defines if draw buffers extension is supported */
  28921. drawBuffersExtension: boolean;
  28922. /** Defines if depth textures are supported */
  28923. depthTextureExtension: boolean;
  28924. /** Defines if float color buffer are supported */
  28925. colorBufferFloat: boolean;
  28926. /** Gets disjoint timer query extension (null if not supported) */
  28927. timerQuery?: EXT_disjoint_timer_query;
  28928. /** Defines if timestamp can be used with timer query */
  28929. canUseTimestampForTimerQuery: boolean;
  28930. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28931. multiview?: any;
  28932. /** Function used to let the system compiles shaders in background */
  28933. parallelShaderCompile?: {
  28934. COMPLETION_STATUS_KHR: number;
  28935. };
  28936. /** Max number of texture samples for MSAA */
  28937. maxMSAASamples: number;
  28938. /** Defines if the blend min max extension is supported */
  28939. blendMinMax: boolean;
  28940. }
  28941. }
  28942. declare module BABYLON {
  28943. /**
  28944. * @hidden
  28945. **/
  28946. export class DepthCullingState {
  28947. private _isDepthTestDirty;
  28948. private _isDepthMaskDirty;
  28949. private _isDepthFuncDirty;
  28950. private _isCullFaceDirty;
  28951. private _isCullDirty;
  28952. private _isZOffsetDirty;
  28953. private _isFrontFaceDirty;
  28954. private _depthTest;
  28955. private _depthMask;
  28956. private _depthFunc;
  28957. private _cull;
  28958. private _cullFace;
  28959. private _zOffset;
  28960. private _frontFace;
  28961. /**
  28962. * Initializes the state.
  28963. */
  28964. constructor();
  28965. readonly isDirty: boolean;
  28966. zOffset: number;
  28967. cullFace: Nullable<number>;
  28968. cull: Nullable<boolean>;
  28969. depthFunc: Nullable<number>;
  28970. depthMask: boolean;
  28971. depthTest: boolean;
  28972. frontFace: Nullable<number>;
  28973. reset(): void;
  28974. apply(gl: WebGLRenderingContext): void;
  28975. }
  28976. }
  28977. declare module BABYLON {
  28978. /**
  28979. * @hidden
  28980. **/
  28981. export class StencilState {
  28982. /** 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 */
  28983. static readonly ALWAYS: number;
  28984. /** Passed to stencilOperation to specify that stencil value must be kept */
  28985. static readonly KEEP: number;
  28986. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28987. static readonly REPLACE: number;
  28988. private _isStencilTestDirty;
  28989. private _isStencilMaskDirty;
  28990. private _isStencilFuncDirty;
  28991. private _isStencilOpDirty;
  28992. private _stencilTest;
  28993. private _stencilMask;
  28994. private _stencilFunc;
  28995. private _stencilFuncRef;
  28996. private _stencilFuncMask;
  28997. private _stencilOpStencilFail;
  28998. private _stencilOpDepthFail;
  28999. private _stencilOpStencilDepthPass;
  29000. readonly isDirty: boolean;
  29001. stencilFunc: number;
  29002. stencilFuncRef: number;
  29003. stencilFuncMask: number;
  29004. stencilOpStencilFail: number;
  29005. stencilOpDepthFail: number;
  29006. stencilOpStencilDepthPass: number;
  29007. stencilMask: number;
  29008. stencilTest: boolean;
  29009. constructor();
  29010. reset(): void;
  29011. apply(gl: WebGLRenderingContext): void;
  29012. }
  29013. }
  29014. declare module BABYLON {
  29015. /**
  29016. * @hidden
  29017. **/
  29018. export class AlphaState {
  29019. private _isAlphaBlendDirty;
  29020. private _isBlendFunctionParametersDirty;
  29021. private _isBlendEquationParametersDirty;
  29022. private _isBlendConstantsDirty;
  29023. private _alphaBlend;
  29024. private _blendFunctionParameters;
  29025. private _blendEquationParameters;
  29026. private _blendConstants;
  29027. /**
  29028. * Initializes the state.
  29029. */
  29030. constructor();
  29031. readonly isDirty: boolean;
  29032. alphaBlend: boolean;
  29033. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29034. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29035. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29036. reset(): void;
  29037. apply(gl: WebGLRenderingContext): void;
  29038. }
  29039. }
  29040. declare module BABYLON {
  29041. /** @hidden */
  29042. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29043. attributeProcessor(attribute: string): string;
  29044. varyingProcessor(varying: string, isFragment: boolean): string;
  29045. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29046. }
  29047. }
  29048. declare module BABYLON {
  29049. /**
  29050. * Interface for attribute information associated with buffer instanciation
  29051. */
  29052. export interface InstancingAttributeInfo {
  29053. /**
  29054. * Index/offset of the attribute in the vertex shader
  29055. */
  29056. index: number;
  29057. /**
  29058. * size of the attribute, 1, 2, 3 or 4
  29059. */
  29060. attributeSize: number;
  29061. /**
  29062. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29063. * default is FLOAT
  29064. */
  29065. attributeType: number;
  29066. /**
  29067. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29068. */
  29069. normalized: boolean;
  29070. /**
  29071. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29072. */
  29073. offset: number;
  29074. /**
  29075. * Name of the GLSL attribute, for debugging purpose only
  29076. */
  29077. attributeName: string;
  29078. }
  29079. }
  29080. declare module BABYLON {
  29081. interface ThinEngine {
  29082. /**
  29083. * Update a video texture
  29084. * @param texture defines the texture to update
  29085. * @param video defines the video element to use
  29086. * @param invertY defines if data must be stored with Y axis inverted
  29087. */
  29088. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29089. }
  29090. }
  29091. declare module BABYLON {
  29092. /**
  29093. * Settings for finer control over video usage
  29094. */
  29095. export interface VideoTextureSettings {
  29096. /**
  29097. * Applies `autoplay` to video, if specified
  29098. */
  29099. autoPlay?: boolean;
  29100. /**
  29101. * Applies `loop` to video, if specified
  29102. */
  29103. loop?: boolean;
  29104. /**
  29105. * Automatically updates internal texture from video at every frame in the render loop
  29106. */
  29107. autoUpdateTexture: boolean;
  29108. /**
  29109. * Image src displayed during the video loading or until the user interacts with the video.
  29110. */
  29111. poster?: string;
  29112. }
  29113. /**
  29114. * If you want to display a video in your scene, this is the special texture for that.
  29115. * This special texture works similar to other textures, with the exception of a few parameters.
  29116. * @see https://doc.babylonjs.com/how_to/video_texture
  29117. */
  29118. export class VideoTexture extends Texture {
  29119. /**
  29120. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29121. */
  29122. readonly autoUpdateTexture: boolean;
  29123. /**
  29124. * The video instance used by the texture internally
  29125. */
  29126. readonly video: HTMLVideoElement;
  29127. private _onUserActionRequestedObservable;
  29128. /**
  29129. * Event triggerd when a dom action is required by the user to play the video.
  29130. * This happens due to recent changes in browser policies preventing video to auto start.
  29131. */
  29132. readonly onUserActionRequestedObservable: Observable<Texture>;
  29133. private _generateMipMaps;
  29134. private _engine;
  29135. private _stillImageCaptured;
  29136. private _displayingPosterTexture;
  29137. private _settings;
  29138. private _createInternalTextureOnEvent;
  29139. private _frameId;
  29140. /**
  29141. * Creates a video texture.
  29142. * If you want to display a video in your scene, this is the special texture for that.
  29143. * This special texture works similar to other textures, with the exception of a few parameters.
  29144. * @see https://doc.babylonjs.com/how_to/video_texture
  29145. * @param name optional name, will detect from video source, if not defined
  29146. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29147. * @param scene is obviously the current scene.
  29148. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29149. * @param invertY is false by default but can be used to invert video on Y axis
  29150. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29151. * @param settings allows finer control over video usage
  29152. */
  29153. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29154. private _getName;
  29155. private _getVideo;
  29156. private _createInternalTexture;
  29157. private reset;
  29158. /**
  29159. * @hidden Internal method to initiate `update`.
  29160. */
  29161. _rebuild(): void;
  29162. /**
  29163. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29164. */
  29165. update(): void;
  29166. /**
  29167. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29168. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29169. */
  29170. updateTexture(isVisible: boolean): void;
  29171. protected _updateInternalTexture: () => void;
  29172. /**
  29173. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29174. * @param url New url.
  29175. */
  29176. updateURL(url: string): void;
  29177. /**
  29178. * Dispose the texture and release its associated resources.
  29179. */
  29180. dispose(): void;
  29181. /**
  29182. * Creates a video texture straight from a stream.
  29183. * @param scene Define the scene the texture should be created in
  29184. * @param stream Define the stream the texture should be created from
  29185. * @returns The created video texture as a promise
  29186. */
  29187. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29188. /**
  29189. * Creates a video texture straight from your WebCam video feed.
  29190. * @param scene Define the scene the texture should be created in
  29191. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29192. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29193. * @returns The created video texture as a promise
  29194. */
  29195. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29196. minWidth: number;
  29197. maxWidth: number;
  29198. minHeight: number;
  29199. maxHeight: number;
  29200. deviceId: string;
  29201. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29202. /**
  29203. * Creates a video texture straight from your WebCam video feed.
  29204. * @param scene Define the scene the texture should be created in
  29205. * @param onReady Define a callback to triggered once the texture will be ready
  29206. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29207. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29208. */
  29209. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29210. minWidth: number;
  29211. maxWidth: number;
  29212. minHeight: number;
  29213. maxHeight: number;
  29214. deviceId: string;
  29215. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29216. }
  29217. }
  29218. declare module BABYLON {
  29219. /**
  29220. * Defines the interface used by objects working like Scene
  29221. * @hidden
  29222. */
  29223. interface ISceneLike {
  29224. _addPendingData(data: any): void;
  29225. _removePendingData(data: any): void;
  29226. offlineProvider: IOfflineProvider;
  29227. }
  29228. /** Interface defining initialization parameters for Engine class */
  29229. export interface EngineOptions extends WebGLContextAttributes {
  29230. /**
  29231. * Defines if the engine should no exceed a specified device ratio
  29232. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29233. */
  29234. limitDeviceRatio?: number;
  29235. /**
  29236. * Defines if webvr should be enabled automatically
  29237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29238. */
  29239. autoEnableWebVR?: boolean;
  29240. /**
  29241. * Defines if webgl2 should be turned off even if supported
  29242. * @see http://doc.babylonjs.com/features/webgl2
  29243. */
  29244. disableWebGL2Support?: boolean;
  29245. /**
  29246. * Defines if webaudio should be initialized as well
  29247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29248. */
  29249. audioEngine?: boolean;
  29250. /**
  29251. * Defines if animations should run using a deterministic lock step
  29252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29253. */
  29254. deterministicLockstep?: boolean;
  29255. /** Defines the maximum steps to use with deterministic lock step mode */
  29256. lockstepMaxSteps?: number;
  29257. /**
  29258. * Defines that engine should ignore context lost events
  29259. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29260. */
  29261. doNotHandleContextLost?: boolean;
  29262. /**
  29263. * Defines that engine should ignore modifying touch action attribute and style
  29264. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29265. */
  29266. doNotHandleTouchAction?: boolean;
  29267. /**
  29268. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29269. */
  29270. useHighPrecisionFloats?: boolean;
  29271. }
  29272. /**
  29273. * The base engine class (root of all engines)
  29274. */
  29275. export class ThinEngine {
  29276. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29277. static ExceptionList: ({
  29278. key: string;
  29279. capture: string;
  29280. captureConstraint: number;
  29281. targets: string[];
  29282. } | {
  29283. key: string;
  29284. capture: null;
  29285. captureConstraint: null;
  29286. targets: string[];
  29287. })[];
  29288. /** @hidden */
  29289. static _TextureLoaders: IInternalTextureLoader[];
  29290. /**
  29291. * Returns the current npm package of the sdk
  29292. */
  29293. static readonly NpmPackage: string;
  29294. /**
  29295. * Returns the current version of the framework
  29296. */
  29297. static readonly Version: string;
  29298. /**
  29299. * Returns a string describing the current engine
  29300. */
  29301. readonly description: string;
  29302. /**
  29303. * Gets or sets the epsilon value used by collision engine
  29304. */
  29305. static CollisionsEpsilon: number;
  29306. /**
  29307. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29308. */
  29309. static ShadersRepository: string;
  29310. /** @hidden */
  29311. _shaderProcessor: IShaderProcessor;
  29312. /**
  29313. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29314. */
  29315. forcePOTTextures: boolean;
  29316. /**
  29317. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29318. */
  29319. isFullscreen: boolean;
  29320. /**
  29321. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29322. */
  29323. cullBackFaces: boolean;
  29324. /**
  29325. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29326. */
  29327. renderEvenInBackground: boolean;
  29328. /**
  29329. * Gets or sets a boolean indicating that cache can be kept between frames
  29330. */
  29331. preventCacheWipeBetweenFrames: boolean;
  29332. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29333. validateShaderPrograms: boolean;
  29334. /**
  29335. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29336. */
  29337. disableUniformBuffers: boolean;
  29338. /** @hidden */
  29339. _uniformBuffers: UniformBuffer[];
  29340. /**
  29341. * Gets a boolean indicating that the engine supports uniform buffers
  29342. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29343. */
  29344. readonly supportsUniformBuffers: boolean;
  29345. /** @hidden */
  29346. _gl: WebGLRenderingContext;
  29347. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29348. protected _windowIsBackground: boolean;
  29349. protected _webGLVersion: number;
  29350. protected _creationOptions: EngineOptions;
  29351. protected _highPrecisionShadersAllowed: boolean;
  29352. /** @hidden */
  29353. readonly _shouldUseHighPrecisionShader: boolean;
  29354. /**
  29355. * Gets a boolean indicating that only power of 2 textures are supported
  29356. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29357. */
  29358. readonly needPOTTextures: boolean;
  29359. /** @hidden */
  29360. _badOS: boolean;
  29361. /** @hidden */
  29362. _badDesktopOS: boolean;
  29363. private _hardwareScalingLevel;
  29364. /** @hidden */
  29365. _caps: EngineCapabilities;
  29366. private _isStencilEnable;
  29367. protected _colorWrite: boolean;
  29368. private _glVersion;
  29369. private _glRenderer;
  29370. private _glVendor;
  29371. /** @hidden */
  29372. _videoTextureSupported: boolean;
  29373. protected _renderingQueueLaunched: boolean;
  29374. protected _activeRenderLoops: (() => void)[];
  29375. /**
  29376. * Observable signaled when a context lost event is raised
  29377. */
  29378. onContextLostObservable: Observable<ThinEngine>;
  29379. /**
  29380. * Observable signaled when a context restored event is raised
  29381. */
  29382. onContextRestoredObservable: Observable<ThinEngine>;
  29383. private _onContextLost;
  29384. private _onContextRestored;
  29385. protected _contextWasLost: boolean;
  29386. /** @hidden */
  29387. _doNotHandleContextLost: boolean;
  29388. /**
  29389. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29391. */
  29392. doNotHandleContextLost: boolean;
  29393. /**
  29394. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29395. */
  29396. disableVertexArrayObjects: boolean;
  29397. /** @hidden */
  29398. protected _depthCullingState: DepthCullingState;
  29399. /** @hidden */
  29400. protected _stencilState: StencilState;
  29401. /** @hidden */
  29402. protected _alphaState: AlphaState;
  29403. /** @hidden */
  29404. _internalTexturesCache: InternalTexture[];
  29405. /** @hidden */
  29406. protected _activeChannel: number;
  29407. private _currentTextureChannel;
  29408. /** @hidden */
  29409. protected _boundTexturesCache: {
  29410. [key: string]: Nullable<InternalTexture>;
  29411. };
  29412. /** @hidden */
  29413. protected _currentEffect: Nullable<Effect>;
  29414. /** @hidden */
  29415. protected _currentProgram: Nullable<WebGLProgram>;
  29416. private _compiledEffects;
  29417. private _vertexAttribArraysEnabled;
  29418. /** @hidden */
  29419. protected _cachedViewport: Nullable<IViewportLike>;
  29420. private _cachedVertexArrayObject;
  29421. /** @hidden */
  29422. protected _cachedVertexBuffers: any;
  29423. /** @hidden */
  29424. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29425. /** @hidden */
  29426. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29427. /** @hidden */
  29428. _currentRenderTarget: Nullable<InternalTexture>;
  29429. private _uintIndicesCurrentlySet;
  29430. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29431. /** @hidden */
  29432. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29433. private _currentBufferPointers;
  29434. private _currentInstanceLocations;
  29435. private _currentInstanceBuffers;
  29436. private _textureUnits;
  29437. /** @hidden */
  29438. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29439. /** @hidden */
  29440. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29441. /** @hidden */
  29442. _boundRenderFunction: any;
  29443. private _vaoRecordInProgress;
  29444. private _mustWipeVertexAttributes;
  29445. private _emptyTexture;
  29446. private _emptyCubeTexture;
  29447. private _emptyTexture3D;
  29448. private _emptyTexture2DArray;
  29449. /** @hidden */
  29450. _frameHandler: number;
  29451. private _nextFreeTextureSlots;
  29452. private _maxSimultaneousTextures;
  29453. private _activeRequests;
  29454. protected _texturesSupported: string[];
  29455. /** @hidden */
  29456. _textureFormatInUse: Nullable<string>;
  29457. protected readonly _supportsHardwareTextureRescaling: boolean;
  29458. /**
  29459. * Gets the list of texture formats supported
  29460. */
  29461. readonly texturesSupported: Array<string>;
  29462. /**
  29463. * Gets the list of texture formats in use
  29464. */
  29465. readonly textureFormatInUse: Nullable<string>;
  29466. /**
  29467. * Gets the current viewport
  29468. */
  29469. readonly currentViewport: Nullable<IViewportLike>;
  29470. /**
  29471. * Gets the default empty texture
  29472. */
  29473. readonly emptyTexture: InternalTexture;
  29474. /**
  29475. * Gets the default empty 3D texture
  29476. */
  29477. readonly emptyTexture3D: InternalTexture;
  29478. /**
  29479. * Gets the default empty 2D array texture
  29480. */
  29481. readonly emptyTexture2DArray: InternalTexture;
  29482. /**
  29483. * Gets the default empty cube texture
  29484. */
  29485. readonly emptyCubeTexture: InternalTexture;
  29486. /**
  29487. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29488. */
  29489. readonly premultipliedAlpha: boolean;
  29490. /**
  29491. * Observable event triggered before each texture is initialized
  29492. */
  29493. onBeforeTextureInitObservable: Observable<Texture>;
  29494. /**
  29495. * Creates a new engine
  29496. * @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
  29497. * @param antialias defines enable antialiasing (default: false)
  29498. * @param options defines further options to be sent to the getContext() function
  29499. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29500. */
  29501. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29502. private _rebuildInternalTextures;
  29503. private _rebuildEffects;
  29504. /**
  29505. * Gets a boolean indicating if all created effects are ready
  29506. * @returns true if all effects are ready
  29507. */
  29508. areAllEffectsReady(): boolean;
  29509. protected _rebuildBuffers(): void;
  29510. private _initGLContext;
  29511. /**
  29512. * Gets version of the current webGL context
  29513. */
  29514. readonly webGLVersion: number;
  29515. /**
  29516. * Gets a string idenfifying the name of the class
  29517. * @returns "Engine" string
  29518. */
  29519. getClassName(): string;
  29520. /**
  29521. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29522. */
  29523. readonly isStencilEnable: boolean;
  29524. /** @hidden */
  29525. _prepareWorkingCanvas(): void;
  29526. /**
  29527. * Reset the texture cache to empty state
  29528. */
  29529. resetTextureCache(): void;
  29530. /**
  29531. * Gets an object containing information about the current webGL context
  29532. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29533. */
  29534. getGlInfo(): {
  29535. vendor: string;
  29536. renderer: string;
  29537. version: string;
  29538. };
  29539. /**
  29540. * Defines the hardware scaling level.
  29541. * By default the hardware scaling level is computed from the window device ratio.
  29542. * 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.
  29543. * @param level defines the level to use
  29544. */
  29545. setHardwareScalingLevel(level: number): void;
  29546. /**
  29547. * Gets the current hardware scaling level.
  29548. * By default the hardware scaling level is computed from the window device ratio.
  29549. * 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.
  29550. * @returns a number indicating the current hardware scaling level
  29551. */
  29552. getHardwareScalingLevel(): number;
  29553. /**
  29554. * Gets the list of loaded textures
  29555. * @returns an array containing all loaded textures
  29556. */
  29557. getLoadedTexturesCache(): InternalTexture[];
  29558. /**
  29559. * Gets the object containing all engine capabilities
  29560. * @returns the EngineCapabilities object
  29561. */
  29562. getCaps(): EngineCapabilities;
  29563. /**
  29564. * stop executing a render loop function and remove it from the execution array
  29565. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29566. */
  29567. stopRenderLoop(renderFunction?: () => void): void;
  29568. /** @hidden */
  29569. _renderLoop(): void;
  29570. /**
  29571. * Gets the HTML canvas attached with the current webGL context
  29572. * @returns a HTML canvas
  29573. */
  29574. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29575. /**
  29576. * Gets host window
  29577. * @returns the host window object
  29578. */
  29579. getHostWindow(): Nullable<Window>;
  29580. /**
  29581. * Gets the current render width
  29582. * @param useScreen defines if screen size must be used (or the current render target if any)
  29583. * @returns a number defining the current render width
  29584. */
  29585. getRenderWidth(useScreen?: boolean): number;
  29586. /**
  29587. * Gets the current render height
  29588. * @param useScreen defines if screen size must be used (or the current render target if any)
  29589. * @returns a number defining the current render height
  29590. */
  29591. getRenderHeight(useScreen?: boolean): number;
  29592. /**
  29593. * Can be used to override the current requestAnimationFrame requester.
  29594. * @hidden
  29595. */
  29596. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29597. /**
  29598. * Register and execute a render loop. The engine can have more than one render function
  29599. * @param renderFunction defines the function to continuously execute
  29600. */
  29601. runRenderLoop(renderFunction: () => void): void;
  29602. /**
  29603. * Clear the current render buffer or the current render target (if any is set up)
  29604. * @param color defines the color to use
  29605. * @param backBuffer defines if the back buffer must be cleared
  29606. * @param depth defines if the depth buffer must be cleared
  29607. * @param stencil defines if the stencil buffer must be cleared
  29608. */
  29609. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29610. private _viewportCached;
  29611. /** @hidden */
  29612. _viewport(x: number, y: number, width: number, height: number): void;
  29613. /**
  29614. * Set the WebGL's viewport
  29615. * @param viewport defines the viewport element to be used
  29616. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29617. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29618. */
  29619. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29620. /**
  29621. * Begin a new frame
  29622. */
  29623. beginFrame(): void;
  29624. /**
  29625. * Enf the current frame
  29626. */
  29627. endFrame(): void;
  29628. /**
  29629. * Resize the view according to the canvas' size
  29630. */
  29631. resize(): void;
  29632. /**
  29633. * Force a specific size of the canvas
  29634. * @param width defines the new canvas' width
  29635. * @param height defines the new canvas' height
  29636. */
  29637. setSize(width: number, height: number): void;
  29638. /**
  29639. * Binds the frame buffer to the specified texture.
  29640. * @param texture The texture to render to or null for the default canvas
  29641. * @param faceIndex The face of the texture to render to in case of cube texture
  29642. * @param requiredWidth The width of the target to render to
  29643. * @param requiredHeight The height of the target to render to
  29644. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29645. * @param depthStencilTexture The depth stencil texture to use to render
  29646. * @param lodLevel defines le lod level to bind to the frame buffer
  29647. */
  29648. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29649. /** @hidden */
  29650. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29651. /**
  29652. * Unbind the current render target texture from the webGL context
  29653. * @param texture defines the render target texture to unbind
  29654. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29655. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29656. */
  29657. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29658. /**
  29659. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29660. */
  29661. flushFramebuffer(): void;
  29662. /**
  29663. * Unbind the current render target and bind the default framebuffer
  29664. */
  29665. restoreDefaultFramebuffer(): void;
  29666. /** @hidden */
  29667. protected _resetVertexBufferBinding(): void;
  29668. /**
  29669. * Creates a vertex buffer
  29670. * @param data the data for the vertex buffer
  29671. * @returns the new WebGL static buffer
  29672. */
  29673. createVertexBuffer(data: DataArray): DataBuffer;
  29674. private _createVertexBuffer;
  29675. /**
  29676. * Creates a dynamic vertex buffer
  29677. * @param data the data for the dynamic vertex buffer
  29678. * @returns the new WebGL dynamic buffer
  29679. */
  29680. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29681. protected _resetIndexBufferBinding(): void;
  29682. /**
  29683. * Creates a new index buffer
  29684. * @param indices defines the content of the index buffer
  29685. * @param updatable defines if the index buffer must be updatable
  29686. * @returns a new webGL buffer
  29687. */
  29688. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29689. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29690. /**
  29691. * Bind a webGL buffer to the webGL context
  29692. * @param buffer defines the buffer to bind
  29693. */
  29694. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29695. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29696. private bindBuffer;
  29697. /**
  29698. * update the bound buffer with the given data
  29699. * @param data defines the data to update
  29700. */
  29701. updateArrayBuffer(data: Float32Array): void;
  29702. private _vertexAttribPointer;
  29703. private _bindIndexBufferWithCache;
  29704. private _bindVertexBuffersAttributes;
  29705. /**
  29706. * Records a vertex array object
  29707. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29708. * @param vertexBuffers defines the list of vertex buffers to store
  29709. * @param indexBuffer defines the index buffer to store
  29710. * @param effect defines the effect to store
  29711. * @returns the new vertex array object
  29712. */
  29713. recordVertexArrayObject(vertexBuffers: {
  29714. [key: string]: VertexBuffer;
  29715. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29716. /**
  29717. * Bind a specific vertex array object
  29718. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29719. * @param vertexArrayObject defines the vertex array object to bind
  29720. * @param indexBuffer defines the index buffer to bind
  29721. */
  29722. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29723. /**
  29724. * Bind webGl buffers directly to the webGL context
  29725. * @param vertexBuffer defines the vertex buffer to bind
  29726. * @param indexBuffer defines the index buffer to bind
  29727. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29728. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29729. * @param effect defines the effect associated with the vertex buffer
  29730. */
  29731. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29732. private _unbindVertexArrayObject;
  29733. /**
  29734. * Bind a list of vertex buffers to the webGL context
  29735. * @param vertexBuffers defines the list of vertex buffers to bind
  29736. * @param indexBuffer defines the index buffer to bind
  29737. * @param effect defines the effect associated with the vertex buffers
  29738. */
  29739. bindBuffers(vertexBuffers: {
  29740. [key: string]: Nullable<VertexBuffer>;
  29741. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29742. /**
  29743. * Unbind all instance attributes
  29744. */
  29745. unbindInstanceAttributes(): void;
  29746. /**
  29747. * Release and free the memory of a vertex array object
  29748. * @param vao defines the vertex array object to delete
  29749. */
  29750. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29751. /** @hidden */
  29752. _releaseBuffer(buffer: DataBuffer): boolean;
  29753. protected _deleteBuffer(buffer: DataBuffer): void;
  29754. /**
  29755. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29756. * @param instancesBuffer defines the webGL buffer to update and bind
  29757. * @param data defines the data to store in the buffer
  29758. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29759. */
  29760. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29761. /**
  29762. * Apply all cached states (depth, culling, stencil and alpha)
  29763. */
  29764. applyStates(): void;
  29765. /**
  29766. * Send a draw order
  29767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29768. * @param indexStart defines the starting index
  29769. * @param indexCount defines the number of index to draw
  29770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29771. */
  29772. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29773. /**
  29774. * Draw a list of points
  29775. * @param verticesStart defines the index of first vertex to draw
  29776. * @param verticesCount defines the count of vertices to draw
  29777. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29778. */
  29779. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29780. /**
  29781. * Draw a list of unindexed primitives
  29782. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29783. * @param verticesStart defines the index of first vertex to draw
  29784. * @param verticesCount defines the count of vertices to draw
  29785. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29786. */
  29787. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29788. /**
  29789. * Draw a list of indexed primitives
  29790. * @param fillMode defines the primitive to use
  29791. * @param indexStart defines the starting index
  29792. * @param indexCount defines the number of index to draw
  29793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29794. */
  29795. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29796. /**
  29797. * Draw a list of unindexed primitives
  29798. * @param fillMode defines the primitive to use
  29799. * @param verticesStart defines the index of first vertex to draw
  29800. * @param verticesCount defines the count of vertices to draw
  29801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29802. */
  29803. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29804. private _drawMode;
  29805. /** @hidden */
  29806. protected _reportDrawCall(): void;
  29807. /** @hidden */
  29808. _releaseEffect(effect: Effect): void;
  29809. /** @hidden */
  29810. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29811. /**
  29812. * Create a new effect (used to store vertex/fragment shaders)
  29813. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29814. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29815. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29816. * @param samplers defines an array of string used to represent textures
  29817. * @param defines defines the string containing the defines to use to compile the shaders
  29818. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29819. * @param onCompiled defines a function to call when the effect creation is successful
  29820. * @param onError defines a function to call when the effect creation has failed
  29821. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29822. * @returns the new Effect
  29823. */
  29824. 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;
  29825. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29826. private _compileShader;
  29827. private _compileRawShader;
  29828. /**
  29829. * Directly creates a webGL program
  29830. * @param pipelineContext defines the pipeline context to attach to
  29831. * @param vertexCode defines the vertex shader code to use
  29832. * @param fragmentCode defines the fragment shader code to use
  29833. * @param context defines the webGL context to use (if not set, the current one will be used)
  29834. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29835. * @returns the new webGL program
  29836. */
  29837. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29838. /**
  29839. * Creates a webGL program
  29840. * @param pipelineContext defines the pipeline context to attach to
  29841. * @param vertexCode defines the vertex shader code to use
  29842. * @param fragmentCode defines the fragment shader code to use
  29843. * @param defines defines the string containing the defines to use to compile the shaders
  29844. * @param context defines the webGL context to use (if not set, the current one will be used)
  29845. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29846. * @returns the new webGL program
  29847. */
  29848. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29849. /**
  29850. * Creates a new pipeline context
  29851. * @returns the new pipeline
  29852. */
  29853. createPipelineContext(): IPipelineContext;
  29854. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29855. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29856. /** @hidden */
  29857. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29858. /** @hidden */
  29859. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29860. /** @hidden */
  29861. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29862. /**
  29863. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29864. * @param pipelineContext defines the pipeline context to use
  29865. * @param uniformsNames defines the list of uniform names
  29866. * @returns an array of webGL uniform locations
  29867. */
  29868. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29869. /**
  29870. * Gets the lsit of active attributes for a given webGL program
  29871. * @param pipelineContext defines the pipeline context to use
  29872. * @param attributesNames defines the list of attribute names to get
  29873. * @returns an array of indices indicating the offset of each attribute
  29874. */
  29875. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29876. /**
  29877. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29878. * @param effect defines the effect to activate
  29879. */
  29880. enableEffect(effect: Nullable<Effect>): void;
  29881. /**
  29882. * Set the value of an uniform to a number (int)
  29883. * @param uniform defines the webGL uniform location where to store the value
  29884. * @param value defines the int number to store
  29885. */
  29886. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29887. /**
  29888. * Set the value of an uniform to an array of int32
  29889. * @param uniform defines the webGL uniform location where to store the value
  29890. * @param array defines the array of int32 to store
  29891. */
  29892. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29893. /**
  29894. * Set the value of an uniform to an array of int32 (stored as vec2)
  29895. * @param uniform defines the webGL uniform location where to store the value
  29896. * @param array defines the array of int32 to store
  29897. */
  29898. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29899. /**
  29900. * Set the value of an uniform to an array of int32 (stored as vec3)
  29901. * @param uniform defines the webGL uniform location where to store the value
  29902. * @param array defines the array of int32 to store
  29903. */
  29904. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29905. /**
  29906. * Set the value of an uniform to an array of int32 (stored as vec4)
  29907. * @param uniform defines the webGL uniform location where to store the value
  29908. * @param array defines the array of int32 to store
  29909. */
  29910. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29911. /**
  29912. * Set the value of an uniform to an array of number
  29913. * @param uniform defines the webGL uniform location where to store the value
  29914. * @param array defines the array of number to store
  29915. */
  29916. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29917. /**
  29918. * Set the value of an uniform to an array of number (stored as vec2)
  29919. * @param uniform defines the webGL uniform location where to store the value
  29920. * @param array defines the array of number to store
  29921. */
  29922. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29923. /**
  29924. * Set the value of an uniform to an array of number (stored as vec3)
  29925. * @param uniform defines the webGL uniform location where to store the value
  29926. * @param array defines the array of number to store
  29927. */
  29928. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29929. /**
  29930. * Set the value of an uniform to an array of number (stored as vec4)
  29931. * @param uniform defines the webGL uniform location where to store the value
  29932. * @param array defines the array of number to store
  29933. */
  29934. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  29935. /**
  29936. * Set the value of an uniform to an array of float32 (stored as matrices)
  29937. * @param uniform defines the webGL uniform location where to store the value
  29938. * @param matrices defines the array of float32 to store
  29939. */
  29940. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29941. /**
  29942. * Set the value of an uniform to a matrix (3x3)
  29943. * @param uniform defines the webGL uniform location where to store the value
  29944. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29945. */
  29946. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29947. /**
  29948. * Set the value of an uniform to a matrix (2x2)
  29949. * @param uniform defines the webGL uniform location where to store the value
  29950. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29951. */
  29952. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29953. /**
  29954. * Set the value of an uniform to a number (float)
  29955. * @param uniform defines the webGL uniform location where to store the value
  29956. * @param value defines the float number to store
  29957. */
  29958. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29959. /**
  29960. * Set the value of an uniform to a vec2
  29961. * @param uniform defines the webGL uniform location where to store the value
  29962. * @param x defines the 1st component of the value
  29963. * @param y defines the 2nd component of the value
  29964. */
  29965. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29966. /**
  29967. * Set the value of an uniform to a vec3
  29968. * @param uniform defines the webGL uniform location where to store the value
  29969. * @param x defines the 1st component of the value
  29970. * @param y defines the 2nd component of the value
  29971. * @param z defines the 3rd component of the value
  29972. */
  29973. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29974. /**
  29975. * Set the value of an uniform to a vec4
  29976. * @param uniform defines the webGL uniform location where to store the value
  29977. * @param x defines the 1st component of the value
  29978. * @param y defines the 2nd component of the value
  29979. * @param z defines the 3rd component of the value
  29980. * @param w defines the 4th component of the value
  29981. */
  29982. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29983. /**
  29984. * Gets the depth culling state manager
  29985. */
  29986. readonly depthCullingState: DepthCullingState;
  29987. /**
  29988. * Gets the alpha state manager
  29989. */
  29990. readonly alphaState: AlphaState;
  29991. /**
  29992. * Gets the stencil state manager
  29993. */
  29994. readonly stencilState: StencilState;
  29995. /**
  29996. * Clears the list of texture accessible through engine.
  29997. * This can help preventing texture load conflict due to name collision.
  29998. */
  29999. clearInternalTexturesCache(): void;
  30000. /**
  30001. * Force the entire cache to be cleared
  30002. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30003. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30004. */
  30005. wipeCaches(bruteForce?: boolean): void;
  30006. /** @hidden */
  30007. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30008. min: number;
  30009. mag: number;
  30010. };
  30011. /** @hidden */
  30012. _createTexture(): WebGLTexture;
  30013. /**
  30014. * Usually called from Texture.ts.
  30015. * Passed information to create a WebGLTexture
  30016. * @param urlArg defines a value which contains one of the following:
  30017. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30018. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30019. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30020. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30021. * @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)
  30022. * @param scene needed for loading to the correct scene
  30023. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30024. * @param onLoad optional callback to be called upon successful completion
  30025. * @param onError optional callback to be called upon failure
  30026. * @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
  30027. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30028. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30029. * @param forcedExtension defines the extension to use to pick the right loader
  30030. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30031. * @param mimeType defines an optional mime type
  30032. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30033. */
  30034. 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;
  30035. /**
  30036. * @hidden
  30037. */
  30038. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30039. /**
  30040. * Creates a raw texture
  30041. * @param data defines the data to store in the texture
  30042. * @param width defines the width of the texture
  30043. * @param height defines the height of the texture
  30044. * @param format defines the format of the data
  30045. * @param generateMipMaps defines if the engine should generate the mip levels
  30046. * @param invertY defines if data must be stored with Y axis inverted
  30047. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30048. * @param compression defines the compression used (null by default)
  30049. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30050. * @returns the raw texture inside an InternalTexture
  30051. */
  30052. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30053. /**
  30054. * Creates a new raw cube texture
  30055. * @param data defines the array of data to use to create each face
  30056. * @param size defines the size of the textures
  30057. * @param format defines the format of the data
  30058. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30059. * @param generateMipMaps defines if the engine should generate the mip levels
  30060. * @param invertY defines if data must be stored with Y axis inverted
  30061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30062. * @param compression defines the compression used (null by default)
  30063. * @returns the cube texture as an InternalTexture
  30064. */
  30065. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30066. /**
  30067. * Creates a new raw 3D texture
  30068. * @param data defines the data used to create the texture
  30069. * @param width defines the width of the texture
  30070. * @param height defines the height of the texture
  30071. * @param depth defines the depth of the texture
  30072. * @param format defines the format of the texture
  30073. * @param generateMipMaps defines if the engine must generate mip levels
  30074. * @param invertY defines if data must be stored with Y axis inverted
  30075. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30076. * @param compression defines the compressed used (can be null)
  30077. * @param textureType defines the compressed used (can be null)
  30078. * @returns a new raw 3D texture (stored in an InternalTexture)
  30079. */
  30080. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30081. /**
  30082. * Creates a new raw 2D array texture
  30083. * @param data defines the data used to create the texture
  30084. * @param width defines the width of the texture
  30085. * @param height defines the height of the texture
  30086. * @param depth defines the number of layers of the texture
  30087. * @param format defines the format of the texture
  30088. * @param generateMipMaps defines if the engine must generate mip levels
  30089. * @param invertY defines if data must be stored with Y axis inverted
  30090. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30091. * @param compression defines the compressed used (can be null)
  30092. * @param textureType defines the compressed used (can be null)
  30093. * @returns a new raw 2D array texture (stored in an InternalTexture)
  30094. */
  30095. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30096. private _unpackFlipYCached;
  30097. /**
  30098. * In case you are sharing the context with other applications, it might
  30099. * be interested to not cache the unpack flip y state to ensure a consistent
  30100. * value would be set.
  30101. */
  30102. enableUnpackFlipYCached: boolean;
  30103. /** @hidden */
  30104. _unpackFlipY(value: boolean): void;
  30105. /** @hidden */
  30106. _getUnpackAlignement(): number;
  30107. /**
  30108. * Update the sampling mode of a given texture
  30109. * @param samplingMode defines the required sampling mode
  30110. * @param texture defines the texture to update
  30111. */
  30112. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30113. /** @hidden */
  30114. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30115. width: number;
  30116. height: number;
  30117. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30118. /** @hidden */
  30119. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30120. /** @hidden */
  30121. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30122. /** @hidden */
  30123. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30124. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30125. private _prepareWebGLTexture;
  30126. /** @hidden */
  30127. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30128. /** @hidden */
  30129. _releaseFramebufferObjects(texture: InternalTexture): void;
  30130. /** @hidden */
  30131. _releaseTexture(texture: InternalTexture): void;
  30132. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30133. protected _setProgram(program: WebGLProgram): void;
  30134. protected _boundUniforms: {
  30135. [key: number]: WebGLUniformLocation;
  30136. };
  30137. /**
  30138. * Binds an effect to the webGL context
  30139. * @param effect defines the effect to bind
  30140. */
  30141. bindSamplers(effect: Effect): void;
  30142. private _activateCurrentTexture;
  30143. /** @hidden */
  30144. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30145. /** @hidden */
  30146. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30147. /**
  30148. * Unbind all textures from the webGL context
  30149. */
  30150. unbindAllTextures(): void;
  30151. /**
  30152. * Sets a texture to the according uniform.
  30153. * @param channel The texture channel
  30154. * @param uniform The uniform to set
  30155. * @param texture The texture to apply
  30156. */
  30157. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30158. private _bindSamplerUniformToChannel;
  30159. private _getTextureWrapMode;
  30160. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30161. /**
  30162. * Sets an array of texture to the webGL context
  30163. * @param channel defines the channel where the texture array must be set
  30164. * @param uniform defines the associated uniform location
  30165. * @param textures defines the array of textures to bind
  30166. */
  30167. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30168. /** @hidden */
  30169. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30170. private _setTextureParameterFloat;
  30171. private _setTextureParameterInteger;
  30172. /**
  30173. * Unbind all vertex attributes from the webGL context
  30174. */
  30175. unbindAllAttributes(): void;
  30176. /**
  30177. * 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
  30178. */
  30179. releaseEffects(): void;
  30180. /**
  30181. * Dispose and release all associated resources
  30182. */
  30183. dispose(): void;
  30184. /**
  30185. * Attach a new callback raised when context lost event is fired
  30186. * @param callback defines the callback to call
  30187. */
  30188. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30189. /**
  30190. * Attach a new callback raised when context restored event is fired
  30191. * @param callback defines the callback to call
  30192. */
  30193. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30194. /**
  30195. * Get the current error code of the webGL context
  30196. * @returns the error code
  30197. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30198. */
  30199. getError(): number;
  30200. private _canRenderToFloatFramebuffer;
  30201. private _canRenderToHalfFloatFramebuffer;
  30202. private _canRenderToFramebuffer;
  30203. /** @hidden */
  30204. _getWebGLTextureType(type: number): number;
  30205. /** @hidden */
  30206. _getInternalFormat(format: number): number;
  30207. /** @hidden */
  30208. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30209. /** @hidden */
  30210. _getRGBAMultiSampleBufferFormat(type: number): number;
  30211. /** @hidden */
  30212. _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;
  30213. /**
  30214. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30215. * @returns true if the engine can be created
  30216. * @ignorenaming
  30217. */
  30218. static isSupported(): boolean;
  30219. /**
  30220. * Find the next highest power of two.
  30221. * @param x Number to start search from.
  30222. * @return Next highest power of two.
  30223. */
  30224. static CeilingPOT(x: number): number;
  30225. /**
  30226. * Find the next lowest power of two.
  30227. * @param x Number to start search from.
  30228. * @return Next lowest power of two.
  30229. */
  30230. static FloorPOT(x: number): number;
  30231. /**
  30232. * Find the nearest power of two.
  30233. * @param x Number to start search from.
  30234. * @return Next nearest power of two.
  30235. */
  30236. static NearestPOT(x: number): number;
  30237. /**
  30238. * Get the closest exponent of two
  30239. * @param value defines the value to approximate
  30240. * @param max defines the maximum value to return
  30241. * @param mode defines how to define the closest value
  30242. * @returns closest exponent of two of the given value
  30243. */
  30244. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30245. /**
  30246. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30247. * @param func - the function to be called
  30248. * @param requester - the object that will request the next frame. Falls back to window.
  30249. * @returns frame number
  30250. */
  30251. static QueueNewFrame(func: () => void, requester?: any): number;
  30252. }
  30253. }
  30254. declare module BABYLON {
  30255. /**
  30256. * Class representing spherical harmonics coefficients to the 3rd degree
  30257. */
  30258. export class SphericalHarmonics {
  30259. /**
  30260. * Defines whether or not the harmonics have been prescaled for rendering.
  30261. */
  30262. preScaled: boolean;
  30263. /**
  30264. * The l0,0 coefficients of the spherical harmonics
  30265. */
  30266. l00: Vector3;
  30267. /**
  30268. * The l1,-1 coefficients of the spherical harmonics
  30269. */
  30270. l1_1: Vector3;
  30271. /**
  30272. * The l1,0 coefficients of the spherical harmonics
  30273. */
  30274. l10: Vector3;
  30275. /**
  30276. * The l1,1 coefficients of the spherical harmonics
  30277. */
  30278. l11: Vector3;
  30279. /**
  30280. * The l2,-2 coefficients of the spherical harmonics
  30281. */
  30282. l2_2: Vector3;
  30283. /**
  30284. * The l2,-1 coefficients of the spherical harmonics
  30285. */
  30286. l2_1: Vector3;
  30287. /**
  30288. * The l2,0 coefficients of the spherical harmonics
  30289. */
  30290. l20: Vector3;
  30291. /**
  30292. * The l2,1 coefficients of the spherical harmonics
  30293. */
  30294. l21: Vector3;
  30295. /**
  30296. * The l2,2 coefficients of the spherical harmonics
  30297. */
  30298. l22: Vector3;
  30299. /**
  30300. * Adds a light to the spherical harmonics
  30301. * @param direction the direction of the light
  30302. * @param color the color of the light
  30303. * @param deltaSolidAngle the delta solid angle of the light
  30304. */
  30305. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30306. /**
  30307. * Scales the spherical harmonics by the given amount
  30308. * @param scale the amount to scale
  30309. */
  30310. scaleInPlace(scale: number): void;
  30311. /**
  30312. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30313. *
  30314. * ```
  30315. * E_lm = A_l * L_lm
  30316. * ```
  30317. *
  30318. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30319. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30320. * the scaling factors are given in equation 9.
  30321. */
  30322. convertIncidentRadianceToIrradiance(): void;
  30323. /**
  30324. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30325. *
  30326. * ```
  30327. * L = (1/pi) * E * rho
  30328. * ```
  30329. *
  30330. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30331. */
  30332. convertIrradianceToLambertianRadiance(): void;
  30333. /**
  30334. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30335. * required operations at run time.
  30336. *
  30337. * This is simply done by scaling back the SH with Ylm constants parameter.
  30338. * The trigonometric part being applied by the shader at run time.
  30339. */
  30340. preScaleForRendering(): void;
  30341. /**
  30342. * Constructs a spherical harmonics from an array.
  30343. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30344. * @returns the spherical harmonics
  30345. */
  30346. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30347. /**
  30348. * Gets the spherical harmonics from polynomial
  30349. * @param polynomial the spherical polynomial
  30350. * @returns the spherical harmonics
  30351. */
  30352. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30353. }
  30354. /**
  30355. * Class representing spherical polynomial coefficients to the 3rd degree
  30356. */
  30357. export class SphericalPolynomial {
  30358. private _harmonics;
  30359. /**
  30360. * The spherical harmonics used to create the polynomials.
  30361. */
  30362. readonly preScaledHarmonics: SphericalHarmonics;
  30363. /**
  30364. * The x coefficients of the spherical polynomial
  30365. */
  30366. x: Vector3;
  30367. /**
  30368. * The y coefficients of the spherical polynomial
  30369. */
  30370. y: Vector3;
  30371. /**
  30372. * The z coefficients of the spherical polynomial
  30373. */
  30374. z: Vector3;
  30375. /**
  30376. * The xx coefficients of the spherical polynomial
  30377. */
  30378. xx: Vector3;
  30379. /**
  30380. * The yy coefficients of the spherical polynomial
  30381. */
  30382. yy: Vector3;
  30383. /**
  30384. * The zz coefficients of the spherical polynomial
  30385. */
  30386. zz: Vector3;
  30387. /**
  30388. * The xy coefficients of the spherical polynomial
  30389. */
  30390. xy: Vector3;
  30391. /**
  30392. * The yz coefficients of the spherical polynomial
  30393. */
  30394. yz: Vector3;
  30395. /**
  30396. * The zx coefficients of the spherical polynomial
  30397. */
  30398. zx: Vector3;
  30399. /**
  30400. * Adds an ambient color to the spherical polynomial
  30401. * @param color the color to add
  30402. */
  30403. addAmbient(color: Color3): void;
  30404. /**
  30405. * Scales the spherical polynomial by the given amount
  30406. * @param scale the amount to scale
  30407. */
  30408. scaleInPlace(scale: number): void;
  30409. /**
  30410. * Gets the spherical polynomial from harmonics
  30411. * @param harmonics the spherical harmonics
  30412. * @returns the spherical polynomial
  30413. */
  30414. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30415. /**
  30416. * Constructs a spherical polynomial from an array.
  30417. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30418. * @returns the spherical polynomial
  30419. */
  30420. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30421. }
  30422. }
  30423. declare module BABYLON {
  30424. /**
  30425. * Defines the source of the internal texture
  30426. */
  30427. export enum InternalTextureSource {
  30428. /**
  30429. * The source of the texture data is unknown
  30430. */
  30431. Unknown = 0,
  30432. /**
  30433. * Texture data comes from an URL
  30434. */
  30435. Url = 1,
  30436. /**
  30437. * Texture data is only used for temporary storage
  30438. */
  30439. Temp = 2,
  30440. /**
  30441. * Texture data comes from raw data (ArrayBuffer)
  30442. */
  30443. Raw = 3,
  30444. /**
  30445. * Texture content is dynamic (video or dynamic texture)
  30446. */
  30447. Dynamic = 4,
  30448. /**
  30449. * Texture content is generated by rendering to it
  30450. */
  30451. RenderTarget = 5,
  30452. /**
  30453. * Texture content is part of a multi render target process
  30454. */
  30455. MultiRenderTarget = 6,
  30456. /**
  30457. * Texture data comes from a cube data file
  30458. */
  30459. Cube = 7,
  30460. /**
  30461. * Texture data comes from a raw cube data
  30462. */
  30463. CubeRaw = 8,
  30464. /**
  30465. * Texture data come from a prefiltered cube data file
  30466. */
  30467. CubePrefiltered = 9,
  30468. /**
  30469. * Texture content is raw 3D data
  30470. */
  30471. Raw3D = 10,
  30472. /**
  30473. * Texture content is raw 2D array data
  30474. */
  30475. Raw2DArray = 11,
  30476. /**
  30477. * Texture content is a depth texture
  30478. */
  30479. Depth = 12,
  30480. /**
  30481. * Texture data comes from a raw cube data encoded with RGBD
  30482. */
  30483. CubeRawRGBD = 13
  30484. }
  30485. /**
  30486. * Class used to store data associated with WebGL texture data for the engine
  30487. * This class should not be used directly
  30488. */
  30489. export class InternalTexture {
  30490. /** @hidden */
  30491. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30492. /**
  30493. * Defines if the texture is ready
  30494. */
  30495. isReady: boolean;
  30496. /**
  30497. * Defines if the texture is a cube texture
  30498. */
  30499. isCube: boolean;
  30500. /**
  30501. * Defines if the texture contains 3D data
  30502. */
  30503. is3D: boolean;
  30504. /**
  30505. * Defines if the texture contains 2D array data
  30506. */
  30507. is2DArray: boolean;
  30508. /**
  30509. * Defines if the texture contains multiview data
  30510. */
  30511. isMultiview: boolean;
  30512. /**
  30513. * Gets the URL used to load this texture
  30514. */
  30515. url: string;
  30516. /**
  30517. * Gets the sampling mode of the texture
  30518. */
  30519. samplingMode: number;
  30520. /**
  30521. * Gets a boolean indicating if the texture needs mipmaps generation
  30522. */
  30523. generateMipMaps: boolean;
  30524. /**
  30525. * Gets the number of samples used by the texture (WebGL2+ only)
  30526. */
  30527. samples: number;
  30528. /**
  30529. * Gets the type of the texture (int, float...)
  30530. */
  30531. type: number;
  30532. /**
  30533. * Gets the format of the texture (RGB, RGBA...)
  30534. */
  30535. format: number;
  30536. /**
  30537. * Observable called when the texture is loaded
  30538. */
  30539. onLoadedObservable: Observable<InternalTexture>;
  30540. /**
  30541. * Gets the width of the texture
  30542. */
  30543. width: number;
  30544. /**
  30545. * Gets the height of the texture
  30546. */
  30547. height: number;
  30548. /**
  30549. * Gets the depth of the texture
  30550. */
  30551. depth: number;
  30552. /**
  30553. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30554. */
  30555. baseWidth: number;
  30556. /**
  30557. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30558. */
  30559. baseHeight: number;
  30560. /**
  30561. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30562. */
  30563. baseDepth: number;
  30564. /**
  30565. * Gets a boolean indicating if the texture is inverted on Y axis
  30566. */
  30567. invertY: boolean;
  30568. /** @hidden */
  30569. _invertVScale: boolean;
  30570. /** @hidden */
  30571. _associatedChannel: number;
  30572. /** @hidden */
  30573. _source: InternalTextureSource;
  30574. /** @hidden */
  30575. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30576. /** @hidden */
  30577. _bufferView: Nullable<ArrayBufferView>;
  30578. /** @hidden */
  30579. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30580. /** @hidden */
  30581. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30582. /** @hidden */
  30583. _size: number;
  30584. /** @hidden */
  30585. _extension: string;
  30586. /** @hidden */
  30587. _files: Nullable<string[]>;
  30588. /** @hidden */
  30589. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30590. /** @hidden */
  30591. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30592. /** @hidden */
  30593. _framebuffer: Nullable<WebGLFramebuffer>;
  30594. /** @hidden */
  30595. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30596. /** @hidden */
  30597. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30598. /** @hidden */
  30599. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30600. /** @hidden */
  30601. _attachments: Nullable<number[]>;
  30602. /** @hidden */
  30603. _cachedCoordinatesMode: Nullable<number>;
  30604. /** @hidden */
  30605. _cachedWrapU: Nullable<number>;
  30606. /** @hidden */
  30607. _cachedWrapV: Nullable<number>;
  30608. /** @hidden */
  30609. _cachedWrapR: Nullable<number>;
  30610. /** @hidden */
  30611. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30612. /** @hidden */
  30613. _isDisabled: boolean;
  30614. /** @hidden */
  30615. _compression: Nullable<string>;
  30616. /** @hidden */
  30617. _generateStencilBuffer: boolean;
  30618. /** @hidden */
  30619. _generateDepthBuffer: boolean;
  30620. /** @hidden */
  30621. _comparisonFunction: number;
  30622. /** @hidden */
  30623. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30624. /** @hidden */
  30625. _lodGenerationScale: number;
  30626. /** @hidden */
  30627. _lodGenerationOffset: number;
  30628. /** @hidden */
  30629. _colorTextureArray: Nullable<WebGLTexture>;
  30630. /** @hidden */
  30631. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30632. /** @hidden */
  30633. _lodTextureHigh: Nullable<BaseTexture>;
  30634. /** @hidden */
  30635. _lodTextureMid: Nullable<BaseTexture>;
  30636. /** @hidden */
  30637. _lodTextureLow: Nullable<BaseTexture>;
  30638. /** @hidden */
  30639. _isRGBD: boolean;
  30640. /** @hidden */
  30641. _linearSpecularLOD: boolean;
  30642. /** @hidden */
  30643. _irradianceTexture: Nullable<BaseTexture>;
  30644. /** @hidden */
  30645. _webGLTexture: Nullable<WebGLTexture>;
  30646. /** @hidden */
  30647. _references: number;
  30648. private _engine;
  30649. /**
  30650. * Gets the Engine the texture belongs to.
  30651. * @returns The babylon engine
  30652. */
  30653. getEngine(): ThinEngine;
  30654. /**
  30655. * Gets the data source type of the texture
  30656. */
  30657. readonly source: InternalTextureSource;
  30658. /**
  30659. * Creates a new InternalTexture
  30660. * @param engine defines the engine to use
  30661. * @param source defines the type of data that will be used
  30662. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30663. */
  30664. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30665. /**
  30666. * Increments the number of references (ie. the number of Texture that point to it)
  30667. */
  30668. incrementReferences(): void;
  30669. /**
  30670. * Change the size of the texture (not the size of the content)
  30671. * @param width defines the new width
  30672. * @param height defines the new height
  30673. * @param depth defines the new depth (1 by default)
  30674. */
  30675. updateSize(width: int, height: int, depth?: int): void;
  30676. /** @hidden */
  30677. _rebuild(): void;
  30678. /** @hidden */
  30679. _swapAndDie(target: InternalTexture): void;
  30680. /**
  30681. * Dispose the current allocated resources
  30682. */
  30683. dispose(): void;
  30684. }
  30685. }
  30686. declare module BABYLON {
  30687. /**
  30688. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30690. */
  30691. export class Analyser {
  30692. /**
  30693. * Gets or sets the smoothing
  30694. * @ignorenaming
  30695. */
  30696. SMOOTHING: number;
  30697. /**
  30698. * Gets or sets the FFT table size
  30699. * @ignorenaming
  30700. */
  30701. FFT_SIZE: number;
  30702. /**
  30703. * Gets or sets the bar graph amplitude
  30704. * @ignorenaming
  30705. */
  30706. BARGRAPHAMPLITUDE: number;
  30707. /**
  30708. * Gets or sets the position of the debug canvas
  30709. * @ignorenaming
  30710. */
  30711. DEBUGCANVASPOS: {
  30712. x: number;
  30713. y: number;
  30714. };
  30715. /**
  30716. * Gets or sets the debug canvas size
  30717. * @ignorenaming
  30718. */
  30719. DEBUGCANVASSIZE: {
  30720. width: number;
  30721. height: number;
  30722. };
  30723. private _byteFreqs;
  30724. private _byteTime;
  30725. private _floatFreqs;
  30726. private _webAudioAnalyser;
  30727. private _debugCanvas;
  30728. private _debugCanvasContext;
  30729. private _scene;
  30730. private _registerFunc;
  30731. private _audioEngine;
  30732. /**
  30733. * Creates a new analyser
  30734. * @param scene defines hosting scene
  30735. */
  30736. constructor(scene: Scene);
  30737. /**
  30738. * Get the number of data values you will have to play with for the visualization
  30739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30740. * @returns a number
  30741. */
  30742. getFrequencyBinCount(): number;
  30743. /**
  30744. * Gets the current frequency data as a byte array
  30745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30746. * @returns a Uint8Array
  30747. */
  30748. getByteFrequencyData(): Uint8Array;
  30749. /**
  30750. * Gets the current waveform as a byte array
  30751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30752. * @returns a Uint8Array
  30753. */
  30754. getByteTimeDomainData(): Uint8Array;
  30755. /**
  30756. * Gets the current frequency data as a float array
  30757. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30758. * @returns a Float32Array
  30759. */
  30760. getFloatFrequencyData(): Float32Array;
  30761. /**
  30762. * Renders the debug canvas
  30763. */
  30764. drawDebugCanvas(): void;
  30765. /**
  30766. * Stops rendering the debug canvas and removes it
  30767. */
  30768. stopDebugCanvas(): void;
  30769. /**
  30770. * Connects two audio nodes
  30771. * @param inputAudioNode defines first node to connect
  30772. * @param outputAudioNode defines second node to connect
  30773. */
  30774. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30775. /**
  30776. * Releases all associated resources
  30777. */
  30778. dispose(): void;
  30779. }
  30780. }
  30781. declare module BABYLON {
  30782. /**
  30783. * This represents an audio engine and it is responsible
  30784. * to play, synchronize and analyse sounds throughout the application.
  30785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30786. */
  30787. export interface IAudioEngine extends IDisposable {
  30788. /**
  30789. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30790. */
  30791. readonly canUseWebAudio: boolean;
  30792. /**
  30793. * Gets the current AudioContext if available.
  30794. */
  30795. readonly audioContext: Nullable<AudioContext>;
  30796. /**
  30797. * The master gain node defines the global audio volume of your audio engine.
  30798. */
  30799. readonly masterGain: GainNode;
  30800. /**
  30801. * Gets whether or not mp3 are supported by your browser.
  30802. */
  30803. readonly isMP3supported: boolean;
  30804. /**
  30805. * Gets whether or not ogg are supported by your browser.
  30806. */
  30807. readonly isOGGsupported: boolean;
  30808. /**
  30809. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30810. * @ignoreNaming
  30811. */
  30812. WarnedWebAudioUnsupported: boolean;
  30813. /**
  30814. * Defines if the audio engine relies on a custom unlocked button.
  30815. * In this case, the embedded button will not be displayed.
  30816. */
  30817. useCustomUnlockedButton: boolean;
  30818. /**
  30819. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30820. */
  30821. readonly unlocked: boolean;
  30822. /**
  30823. * Event raised when audio has been unlocked on the browser.
  30824. */
  30825. onAudioUnlockedObservable: Observable<AudioEngine>;
  30826. /**
  30827. * Event raised when audio has been locked on the browser.
  30828. */
  30829. onAudioLockedObservable: Observable<AudioEngine>;
  30830. /**
  30831. * Flags the audio engine in Locked state.
  30832. * This happens due to new browser policies preventing audio to autoplay.
  30833. */
  30834. lock(): void;
  30835. /**
  30836. * Unlocks the audio engine once a user action has been done on the dom.
  30837. * This is helpful to resume play once browser policies have been satisfied.
  30838. */
  30839. unlock(): void;
  30840. }
  30841. /**
  30842. * This represents the default audio engine used in babylon.
  30843. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30845. */
  30846. export class AudioEngine implements IAudioEngine {
  30847. private _audioContext;
  30848. private _audioContextInitialized;
  30849. private _muteButton;
  30850. private _hostElement;
  30851. /**
  30852. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30853. */
  30854. canUseWebAudio: boolean;
  30855. /**
  30856. * The master gain node defines the global audio volume of your audio engine.
  30857. */
  30858. masterGain: GainNode;
  30859. /**
  30860. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30861. * @ignoreNaming
  30862. */
  30863. WarnedWebAudioUnsupported: boolean;
  30864. /**
  30865. * Gets whether or not mp3 are supported by your browser.
  30866. */
  30867. isMP3supported: boolean;
  30868. /**
  30869. * Gets whether or not ogg are supported by your browser.
  30870. */
  30871. isOGGsupported: boolean;
  30872. /**
  30873. * Gets whether audio has been unlocked on the device.
  30874. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30875. * a user interaction has happened.
  30876. */
  30877. unlocked: boolean;
  30878. /**
  30879. * Defines if the audio engine relies on a custom unlocked button.
  30880. * In this case, the embedded button will not be displayed.
  30881. */
  30882. useCustomUnlockedButton: boolean;
  30883. /**
  30884. * Event raised when audio has been unlocked on the browser.
  30885. */
  30886. onAudioUnlockedObservable: Observable<AudioEngine>;
  30887. /**
  30888. * Event raised when audio has been locked on the browser.
  30889. */
  30890. onAudioLockedObservable: Observable<AudioEngine>;
  30891. /**
  30892. * Gets the current AudioContext if available.
  30893. */
  30894. readonly audioContext: Nullable<AudioContext>;
  30895. private _connectedAnalyser;
  30896. /**
  30897. * Instantiates a new audio engine.
  30898. *
  30899. * There should be only one per page as some browsers restrict the number
  30900. * of audio contexts you can create.
  30901. * @param hostElement defines the host element where to display the mute icon if necessary
  30902. */
  30903. constructor(hostElement?: Nullable<HTMLElement>);
  30904. /**
  30905. * Flags the audio engine in Locked state.
  30906. * This happens due to new browser policies preventing audio to autoplay.
  30907. */
  30908. lock(): void;
  30909. /**
  30910. * Unlocks the audio engine once a user action has been done on the dom.
  30911. * This is helpful to resume play once browser policies have been satisfied.
  30912. */
  30913. unlock(): void;
  30914. private _resumeAudioContext;
  30915. private _initializeAudioContext;
  30916. private _tryToRun;
  30917. private _triggerRunningState;
  30918. private _triggerSuspendedState;
  30919. private _displayMuteButton;
  30920. private _moveButtonToTopLeft;
  30921. private _onResize;
  30922. private _hideMuteButton;
  30923. /**
  30924. * Destroy and release the resources associated with the audio ccontext.
  30925. */
  30926. dispose(): void;
  30927. /**
  30928. * Gets the global volume sets on the master gain.
  30929. * @returns the global volume if set or -1 otherwise
  30930. */
  30931. getGlobalVolume(): number;
  30932. /**
  30933. * Sets the global volume of your experience (sets on the master gain).
  30934. * @param newVolume Defines the new global volume of the application
  30935. */
  30936. setGlobalVolume(newVolume: number): void;
  30937. /**
  30938. * Connect the audio engine to an audio analyser allowing some amazing
  30939. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30941. * @param analyser The analyser to connect to the engine
  30942. */
  30943. connectToAnalyser(analyser: Analyser): void;
  30944. }
  30945. }
  30946. declare module BABYLON {
  30947. /**
  30948. * Interface used to present a loading screen while loading a scene
  30949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30950. */
  30951. export interface ILoadingScreen {
  30952. /**
  30953. * Function called to display the loading screen
  30954. */
  30955. displayLoadingUI: () => void;
  30956. /**
  30957. * Function called to hide the loading screen
  30958. */
  30959. hideLoadingUI: () => void;
  30960. /**
  30961. * Gets or sets the color to use for the background
  30962. */
  30963. loadingUIBackgroundColor: string;
  30964. /**
  30965. * Gets or sets the text to display while loading
  30966. */
  30967. loadingUIText: string;
  30968. }
  30969. /**
  30970. * Class used for the default loading screen
  30971. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30972. */
  30973. export class DefaultLoadingScreen implements ILoadingScreen {
  30974. private _renderingCanvas;
  30975. private _loadingText;
  30976. private _loadingDivBackgroundColor;
  30977. private _loadingDiv;
  30978. private _loadingTextDiv;
  30979. /** Gets or sets the logo url to use for the default loading screen */
  30980. static DefaultLogoUrl: string;
  30981. /** Gets or sets the spinner url to use for the default loading screen */
  30982. static DefaultSpinnerUrl: string;
  30983. /**
  30984. * Creates a new default loading screen
  30985. * @param _renderingCanvas defines the canvas used to render the scene
  30986. * @param _loadingText defines the default text to display
  30987. * @param _loadingDivBackgroundColor defines the default background color
  30988. */
  30989. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30990. /**
  30991. * Function called to display the loading screen
  30992. */
  30993. displayLoadingUI(): void;
  30994. /**
  30995. * Function called to hide the loading screen
  30996. */
  30997. hideLoadingUI(): void;
  30998. /**
  30999. * Gets or sets the text to display while loading
  31000. */
  31001. loadingUIText: string;
  31002. /**
  31003. * Gets or sets the color to use for the background
  31004. */
  31005. loadingUIBackgroundColor: string;
  31006. private _resizeLoadingUI;
  31007. }
  31008. }
  31009. declare module BABYLON {
  31010. /**
  31011. * Interface for any object that can request an animation frame
  31012. */
  31013. export interface ICustomAnimationFrameRequester {
  31014. /**
  31015. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31016. */
  31017. renderFunction?: Function;
  31018. /**
  31019. * Called to request the next frame to render to
  31020. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31021. */
  31022. requestAnimationFrame: Function;
  31023. /**
  31024. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31025. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31026. */
  31027. requestID?: number;
  31028. }
  31029. }
  31030. declare module BABYLON {
  31031. /**
  31032. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31033. */
  31034. export class PerformanceMonitor {
  31035. private _enabled;
  31036. private _rollingFrameTime;
  31037. private _lastFrameTimeMs;
  31038. /**
  31039. * constructor
  31040. * @param frameSampleSize The number of samples required to saturate the sliding window
  31041. */
  31042. constructor(frameSampleSize?: number);
  31043. /**
  31044. * Samples current frame
  31045. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31046. */
  31047. sampleFrame(timeMs?: number): void;
  31048. /**
  31049. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31050. */
  31051. readonly averageFrameTime: number;
  31052. /**
  31053. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31054. */
  31055. readonly averageFrameTimeVariance: number;
  31056. /**
  31057. * Returns the frame time of the most recent frame
  31058. */
  31059. readonly instantaneousFrameTime: number;
  31060. /**
  31061. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31062. */
  31063. readonly averageFPS: number;
  31064. /**
  31065. * Returns the average framerate in frames per second using the most recent frame time
  31066. */
  31067. readonly instantaneousFPS: number;
  31068. /**
  31069. * Returns true if enough samples have been taken to completely fill the sliding window
  31070. */
  31071. readonly isSaturated: boolean;
  31072. /**
  31073. * Enables contributions to the sliding window sample set
  31074. */
  31075. enable(): void;
  31076. /**
  31077. * Disables contributions to the sliding window sample set
  31078. * Samples will not be interpolated over the disabled period
  31079. */
  31080. disable(): void;
  31081. /**
  31082. * Returns true if sampling is enabled
  31083. */
  31084. readonly isEnabled: boolean;
  31085. /**
  31086. * Resets performance monitor
  31087. */
  31088. reset(): void;
  31089. }
  31090. /**
  31091. * RollingAverage
  31092. *
  31093. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31094. */
  31095. export class RollingAverage {
  31096. /**
  31097. * Current average
  31098. */
  31099. average: number;
  31100. /**
  31101. * Current variance
  31102. */
  31103. variance: number;
  31104. protected _samples: Array<number>;
  31105. protected _sampleCount: number;
  31106. protected _pos: number;
  31107. protected _m2: number;
  31108. /**
  31109. * constructor
  31110. * @param length The number of samples required to saturate the sliding window
  31111. */
  31112. constructor(length: number);
  31113. /**
  31114. * Adds a sample to the sample set
  31115. * @param v The sample value
  31116. */
  31117. add(v: number): void;
  31118. /**
  31119. * Returns previously added values or null if outside of history or outside the sliding window domain
  31120. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31121. * @return Value previously recorded with add() or null if outside of range
  31122. */
  31123. history(i: number): number;
  31124. /**
  31125. * Returns true if enough samples have been taken to completely fill the sliding window
  31126. * @return true if sample-set saturated
  31127. */
  31128. isSaturated(): boolean;
  31129. /**
  31130. * Resets the rolling average (equivalent to 0 samples taken so far)
  31131. */
  31132. reset(): void;
  31133. /**
  31134. * Wraps a value around the sample range boundaries
  31135. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31136. * @return Wrapped position in sample range
  31137. */
  31138. protected _wrapPosition(i: number): number;
  31139. }
  31140. }
  31141. declare module BABYLON {
  31142. /**
  31143. * This class is used to track a performance counter which is number based.
  31144. * The user has access to many properties which give statistics of different nature.
  31145. *
  31146. * The implementer can track two kinds of Performance Counter: time and count.
  31147. * 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.
  31148. * 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.
  31149. */
  31150. export class PerfCounter {
  31151. /**
  31152. * Gets or sets a global boolean to turn on and off all the counters
  31153. */
  31154. static Enabled: boolean;
  31155. /**
  31156. * Returns the smallest value ever
  31157. */
  31158. readonly min: number;
  31159. /**
  31160. * Returns the biggest value ever
  31161. */
  31162. readonly max: number;
  31163. /**
  31164. * Returns the average value since the performance counter is running
  31165. */
  31166. readonly average: number;
  31167. /**
  31168. * Returns the average value of the last second the counter was monitored
  31169. */
  31170. readonly lastSecAverage: number;
  31171. /**
  31172. * Returns the current value
  31173. */
  31174. readonly current: number;
  31175. /**
  31176. * Gets the accumulated total
  31177. */
  31178. readonly total: number;
  31179. /**
  31180. * Gets the total value count
  31181. */
  31182. readonly count: number;
  31183. /**
  31184. * Creates a new counter
  31185. */
  31186. constructor();
  31187. /**
  31188. * Call this method to start monitoring a new frame.
  31189. * 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.
  31190. */
  31191. fetchNewFrame(): void;
  31192. /**
  31193. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31194. * @param newCount the count value to add to the monitored count
  31195. * @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.
  31196. */
  31197. addCount(newCount: number, fetchResult: boolean): void;
  31198. /**
  31199. * Start monitoring this performance counter
  31200. */
  31201. beginMonitoring(): void;
  31202. /**
  31203. * Compute the time lapsed since the previous beginMonitoring() call.
  31204. * @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
  31205. */
  31206. endMonitoring(newFrame?: boolean): void;
  31207. private _fetchResult;
  31208. private _startMonitoringTime;
  31209. private _min;
  31210. private _max;
  31211. private _average;
  31212. private _current;
  31213. private _totalValueCount;
  31214. private _totalAccumulated;
  31215. private _lastSecAverage;
  31216. private _lastSecAccumulated;
  31217. private _lastSecTime;
  31218. private _lastSecValueCount;
  31219. }
  31220. }
  31221. declare module BABYLON {
  31222. /**
  31223. * Defines the interface used by display changed events
  31224. */
  31225. export interface IDisplayChangedEventArgs {
  31226. /** Gets the vrDisplay object (if any) */
  31227. vrDisplay: Nullable<any>;
  31228. /** Gets a boolean indicating if webVR is supported */
  31229. vrSupported: boolean;
  31230. }
  31231. /**
  31232. * Defines the interface used by objects containing a viewport (like a camera)
  31233. */
  31234. interface IViewportOwnerLike {
  31235. /**
  31236. * Gets or sets the viewport
  31237. */
  31238. viewport: IViewportLike;
  31239. }
  31240. /**
  31241. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31242. */
  31243. export class Engine extends ThinEngine {
  31244. /** Defines that alpha blending is disabled */
  31245. static readonly ALPHA_DISABLE: number;
  31246. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31247. static readonly ALPHA_ADD: number;
  31248. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31249. static readonly ALPHA_COMBINE: number;
  31250. /** Defines that alpha blending to DEST - SRC * DEST */
  31251. static readonly ALPHA_SUBTRACT: number;
  31252. /** Defines that alpha blending to SRC * DEST */
  31253. static readonly ALPHA_MULTIPLY: number;
  31254. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31255. static readonly ALPHA_MAXIMIZED: number;
  31256. /** Defines that alpha blending to SRC + DEST */
  31257. static readonly ALPHA_ONEONE: number;
  31258. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31259. static readonly ALPHA_PREMULTIPLIED: number;
  31260. /**
  31261. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31262. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31263. */
  31264. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31265. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31266. static readonly ALPHA_INTERPOLATE: number;
  31267. /**
  31268. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31269. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31270. */
  31271. static readonly ALPHA_SCREENMODE: number;
  31272. /** Defines that the ressource is not delayed*/
  31273. static readonly DELAYLOADSTATE_NONE: number;
  31274. /** Defines that the ressource was successfully delay loaded */
  31275. static readonly DELAYLOADSTATE_LOADED: number;
  31276. /** Defines that the ressource is currently delay loading */
  31277. static readonly DELAYLOADSTATE_LOADING: number;
  31278. /** Defines that the ressource is delayed and has not started loading */
  31279. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31281. static readonly NEVER: number;
  31282. /** 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 */
  31283. static readonly ALWAYS: number;
  31284. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31285. static readonly LESS: number;
  31286. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31287. static readonly EQUAL: number;
  31288. /** 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 */
  31289. static readonly LEQUAL: number;
  31290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31291. static readonly GREATER: number;
  31292. /** 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 */
  31293. static readonly GEQUAL: number;
  31294. /** 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 */
  31295. static readonly NOTEQUAL: number;
  31296. /** Passed to stencilOperation to specify that stencil value must be kept */
  31297. static readonly KEEP: number;
  31298. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31299. static readonly REPLACE: number;
  31300. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31301. static readonly INCR: number;
  31302. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31303. static readonly DECR: number;
  31304. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31305. static readonly INVERT: number;
  31306. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31307. static readonly INCR_WRAP: number;
  31308. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31309. static readonly DECR_WRAP: number;
  31310. /** Texture is not repeating outside of 0..1 UVs */
  31311. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31312. /** Texture is repeating outside of 0..1 UVs */
  31313. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31314. /** Texture is repeating and mirrored */
  31315. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31316. /** ALPHA */
  31317. static readonly TEXTUREFORMAT_ALPHA: number;
  31318. /** LUMINANCE */
  31319. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31320. /** LUMINANCE_ALPHA */
  31321. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31322. /** RGB */
  31323. static readonly TEXTUREFORMAT_RGB: number;
  31324. /** RGBA */
  31325. static readonly TEXTUREFORMAT_RGBA: number;
  31326. /** RED */
  31327. static readonly TEXTUREFORMAT_RED: number;
  31328. /** RED (2nd reference) */
  31329. static readonly TEXTUREFORMAT_R: number;
  31330. /** RG */
  31331. static readonly TEXTUREFORMAT_RG: number;
  31332. /** RED_INTEGER */
  31333. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31334. /** RED_INTEGER (2nd reference) */
  31335. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31336. /** RG_INTEGER */
  31337. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31338. /** RGB_INTEGER */
  31339. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31340. /** RGBA_INTEGER */
  31341. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31342. /** UNSIGNED_BYTE */
  31343. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31344. /** UNSIGNED_BYTE (2nd reference) */
  31345. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31346. /** FLOAT */
  31347. static readonly TEXTURETYPE_FLOAT: number;
  31348. /** HALF_FLOAT */
  31349. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31350. /** BYTE */
  31351. static readonly TEXTURETYPE_BYTE: number;
  31352. /** SHORT */
  31353. static readonly TEXTURETYPE_SHORT: number;
  31354. /** UNSIGNED_SHORT */
  31355. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31356. /** INT */
  31357. static readonly TEXTURETYPE_INT: number;
  31358. /** UNSIGNED_INT */
  31359. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31360. /** UNSIGNED_SHORT_4_4_4_4 */
  31361. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31362. /** UNSIGNED_SHORT_5_5_5_1 */
  31363. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31364. /** UNSIGNED_SHORT_5_6_5 */
  31365. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31366. /** UNSIGNED_INT_2_10_10_10_REV */
  31367. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31368. /** UNSIGNED_INT_24_8 */
  31369. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31370. /** UNSIGNED_INT_10F_11F_11F_REV */
  31371. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31372. /** UNSIGNED_INT_5_9_9_9_REV */
  31373. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31374. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31375. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31376. /** nearest is mag = nearest and min = nearest and mip = linear */
  31377. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31379. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31380. /** Trilinear is mag = linear and min = linear and mip = linear */
  31381. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31382. /** nearest is mag = nearest and min = nearest and mip = linear */
  31383. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31384. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31385. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31386. /** Trilinear is mag = linear and min = linear and mip = linear */
  31387. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31388. /** mag = nearest and min = nearest and mip = nearest */
  31389. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31390. /** mag = nearest and min = linear and mip = nearest */
  31391. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31392. /** mag = nearest and min = linear and mip = linear */
  31393. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31394. /** mag = nearest and min = linear and mip = none */
  31395. static readonly TEXTURE_NEAREST_LINEAR: number;
  31396. /** mag = nearest and min = nearest and mip = none */
  31397. static readonly TEXTURE_NEAREST_NEAREST: number;
  31398. /** mag = linear and min = nearest and mip = nearest */
  31399. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31400. /** mag = linear and min = nearest and mip = linear */
  31401. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31402. /** mag = linear and min = linear and mip = none */
  31403. static readonly TEXTURE_LINEAR_LINEAR: number;
  31404. /** mag = linear and min = nearest and mip = none */
  31405. static readonly TEXTURE_LINEAR_NEAREST: number;
  31406. /** Explicit coordinates mode */
  31407. static readonly TEXTURE_EXPLICIT_MODE: number;
  31408. /** Spherical coordinates mode */
  31409. static readonly TEXTURE_SPHERICAL_MODE: number;
  31410. /** Planar coordinates mode */
  31411. static readonly TEXTURE_PLANAR_MODE: number;
  31412. /** Cubic coordinates mode */
  31413. static readonly TEXTURE_CUBIC_MODE: number;
  31414. /** Projection coordinates mode */
  31415. static readonly TEXTURE_PROJECTION_MODE: number;
  31416. /** Skybox coordinates mode */
  31417. static readonly TEXTURE_SKYBOX_MODE: number;
  31418. /** Inverse Cubic coordinates mode */
  31419. static readonly TEXTURE_INVCUBIC_MODE: number;
  31420. /** Equirectangular coordinates mode */
  31421. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31422. /** Equirectangular Fixed coordinates mode */
  31423. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31424. /** Equirectangular Fixed Mirrored coordinates mode */
  31425. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31426. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31427. static readonly SCALEMODE_FLOOR: number;
  31428. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31429. static readonly SCALEMODE_NEAREST: number;
  31430. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31431. static readonly SCALEMODE_CEILING: number;
  31432. /**
  31433. * Returns the current npm package of the sdk
  31434. */
  31435. static readonly NpmPackage: string;
  31436. /**
  31437. * Returns the current version of the framework
  31438. */
  31439. static readonly Version: string;
  31440. /** Gets the list of created engines */
  31441. static readonly Instances: Engine[];
  31442. /**
  31443. * Gets the latest created engine
  31444. */
  31445. static readonly LastCreatedEngine: Nullable<Engine>;
  31446. /**
  31447. * Gets the latest created scene
  31448. */
  31449. static readonly LastCreatedScene: Nullable<Scene>;
  31450. /**
  31451. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31452. * @param flag defines which part of the materials must be marked as dirty
  31453. * @param predicate defines a predicate used to filter which materials should be affected
  31454. */
  31455. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31456. /**
  31457. * Method called to create the default loading screen.
  31458. * This can be overriden in your own app.
  31459. * @param canvas The rendering canvas element
  31460. * @returns The loading screen
  31461. */
  31462. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31463. /**
  31464. * Method called to create the default rescale post process on each engine.
  31465. */
  31466. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31467. /**
  31468. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31469. **/
  31470. enableOfflineSupport: boolean;
  31471. /**
  31472. * 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)
  31473. **/
  31474. disableManifestCheck: boolean;
  31475. /**
  31476. * Gets the list of created scenes
  31477. */
  31478. scenes: Scene[];
  31479. /**
  31480. * Event raised when a new scene is created
  31481. */
  31482. onNewSceneAddedObservable: Observable<Scene>;
  31483. /**
  31484. * Gets the list of created postprocesses
  31485. */
  31486. postProcesses: PostProcess[];
  31487. /**
  31488. * Gets a boolean indicating if the pointer is currently locked
  31489. */
  31490. isPointerLock: boolean;
  31491. /**
  31492. * Observable event triggered each time the rendering canvas is resized
  31493. */
  31494. onResizeObservable: Observable<Engine>;
  31495. /**
  31496. * Observable event triggered each time the canvas loses focus
  31497. */
  31498. onCanvasBlurObservable: Observable<Engine>;
  31499. /**
  31500. * Observable event triggered each time the canvas gains focus
  31501. */
  31502. onCanvasFocusObservable: Observable<Engine>;
  31503. /**
  31504. * Observable event triggered each time the canvas receives pointerout event
  31505. */
  31506. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31507. /**
  31508. * Observable raised when the engine begins a new frame
  31509. */
  31510. onBeginFrameObservable: Observable<Engine>;
  31511. /**
  31512. * If set, will be used to request the next animation frame for the render loop
  31513. */
  31514. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31515. /**
  31516. * Observable raised when the engine ends the current frame
  31517. */
  31518. onEndFrameObservable: Observable<Engine>;
  31519. /**
  31520. * Observable raised when the engine is about to compile a shader
  31521. */
  31522. onBeforeShaderCompilationObservable: Observable<Engine>;
  31523. /**
  31524. * Observable raised when the engine has jsut compiled a shader
  31525. */
  31526. onAfterShaderCompilationObservable: Observable<Engine>;
  31527. /**
  31528. * Gets the audio engine
  31529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31530. * @ignorenaming
  31531. */
  31532. static audioEngine: IAudioEngine;
  31533. /**
  31534. * Default AudioEngine factory responsible of creating the Audio Engine.
  31535. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31536. */
  31537. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31538. /**
  31539. * Default offline support factory responsible of creating a tool used to store data locally.
  31540. * By default, this will create a Database object if the workload has been embedded.
  31541. */
  31542. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31543. private _loadingScreen;
  31544. private _pointerLockRequested;
  31545. private _dummyFramebuffer;
  31546. private _rescalePostProcess;
  31547. /** @hidden */
  31548. protected _alphaMode: number;
  31549. /** @hidden */
  31550. protected _alphaEquation: number;
  31551. private _deterministicLockstep;
  31552. private _lockstepMaxSteps;
  31553. protected readonly _supportsHardwareTextureRescaling: boolean;
  31554. private _fps;
  31555. private _deltaTime;
  31556. /** @hidden */
  31557. _drawCalls: PerfCounter;
  31558. /**
  31559. * Turn this value on if you want to pause FPS computation when in background
  31560. */
  31561. disablePerformanceMonitorInBackground: boolean;
  31562. private _performanceMonitor;
  31563. /**
  31564. * Gets the performance monitor attached to this engine
  31565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31566. */
  31567. readonly performanceMonitor: PerformanceMonitor;
  31568. private _onFocus;
  31569. private _onBlur;
  31570. private _onCanvasPointerOut;
  31571. private _onCanvasBlur;
  31572. private _onCanvasFocus;
  31573. private _onFullscreenChange;
  31574. private _onPointerLockChange;
  31575. /**
  31576. * Gets the HTML element used to attach event listeners
  31577. * @returns a HTML element
  31578. */
  31579. getInputElement(): Nullable<HTMLElement>;
  31580. /**
  31581. * Creates a new engine
  31582. * @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
  31583. * @param antialias defines enable antialiasing (default: false)
  31584. * @param options defines further options to be sent to the getContext() function
  31585. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31586. */
  31587. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31588. /**
  31589. * Gets current aspect ratio
  31590. * @param viewportOwner defines the camera to use to get the aspect ratio
  31591. * @param useScreen defines if screen size must be used (or the current render target if any)
  31592. * @returns a number defining the aspect ratio
  31593. */
  31594. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31595. /**
  31596. * Gets current screen aspect ratio
  31597. * @returns a number defining the aspect ratio
  31598. */
  31599. getScreenAspectRatio(): number;
  31600. /**
  31601. * Gets host document
  31602. * @returns the host document object
  31603. */
  31604. getHostDocument(): Document;
  31605. /**
  31606. * Gets the client rect of the HTML canvas attached with the current webGL context
  31607. * @returns a client rectanglee
  31608. */
  31609. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31610. /**
  31611. * Gets the client rect of the HTML element used for events
  31612. * @returns a client rectanglee
  31613. */
  31614. getInputElementClientRect(): Nullable<ClientRect>;
  31615. /**
  31616. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31618. * @returns true if engine is in deterministic lock step mode
  31619. */
  31620. isDeterministicLockStep(): boolean;
  31621. /**
  31622. * Gets the max steps when engine is running in deterministic lock step
  31623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31624. * @returns the max steps
  31625. */
  31626. getLockstepMaxSteps(): number;
  31627. /**
  31628. * Force the mipmap generation for the given render target texture
  31629. * @param texture defines the render target texture to use
  31630. */
  31631. generateMipMapsForCubemap(texture: InternalTexture): void;
  31632. /** States */
  31633. /**
  31634. * Set various states to the webGL context
  31635. * @param culling defines backface culling state
  31636. * @param zOffset defines the value to apply to zOffset (0 by default)
  31637. * @param force defines if states must be applied even if cache is up to date
  31638. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31639. */
  31640. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31641. /**
  31642. * Set the z offset to apply to current rendering
  31643. * @param value defines the offset to apply
  31644. */
  31645. setZOffset(value: number): void;
  31646. /**
  31647. * Gets the current value of the zOffset
  31648. * @returns the current zOffset state
  31649. */
  31650. getZOffset(): number;
  31651. /**
  31652. * Enable or disable depth buffering
  31653. * @param enable defines the state to set
  31654. */
  31655. setDepthBuffer(enable: boolean): void;
  31656. /**
  31657. * Gets a boolean indicating if depth writing is enabled
  31658. * @returns the current depth writing state
  31659. */
  31660. getDepthWrite(): boolean;
  31661. /**
  31662. * Enable or disable depth writing
  31663. * @param enable defines the state to set
  31664. */
  31665. setDepthWrite(enable: boolean): void;
  31666. /**
  31667. * Enable or disable color writing
  31668. * @param enable defines the state to set
  31669. */
  31670. setColorWrite(enable: boolean): void;
  31671. /**
  31672. * Gets a boolean indicating if color writing is enabled
  31673. * @returns the current color writing state
  31674. */
  31675. getColorWrite(): boolean;
  31676. /**
  31677. * Sets alpha constants used by some alpha blending modes
  31678. * @param r defines the red component
  31679. * @param g defines the green component
  31680. * @param b defines the blue component
  31681. * @param a defines the alpha component
  31682. */
  31683. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31684. /**
  31685. * Sets the current alpha mode
  31686. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31687. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31688. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31689. */
  31690. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31691. /**
  31692. * Gets the current alpha mode
  31693. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31694. * @returns the current alpha mode
  31695. */
  31696. getAlphaMode(): number;
  31697. /**
  31698. * Sets the current alpha equation
  31699. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31700. */
  31701. setAlphaEquation(equation: number): void;
  31702. /**
  31703. * Gets the current alpha equation.
  31704. * @returns the current alpha equation
  31705. */
  31706. getAlphaEquation(): number;
  31707. /**
  31708. * Gets a boolean indicating if stencil buffer is enabled
  31709. * @returns the current stencil buffer state
  31710. */
  31711. getStencilBuffer(): boolean;
  31712. /**
  31713. * Enable or disable the stencil buffer
  31714. * @param enable defines if the stencil buffer must be enabled or disabled
  31715. */
  31716. setStencilBuffer(enable: boolean): void;
  31717. /**
  31718. * Gets the current stencil mask
  31719. * @returns a number defining the new stencil mask to use
  31720. */
  31721. getStencilMask(): number;
  31722. /**
  31723. * Sets the current stencil mask
  31724. * @param mask defines the new stencil mask to use
  31725. */
  31726. setStencilMask(mask: number): void;
  31727. /**
  31728. * Gets the current stencil function
  31729. * @returns a number defining the stencil function to use
  31730. */
  31731. getStencilFunction(): number;
  31732. /**
  31733. * Gets the current stencil reference value
  31734. * @returns a number defining the stencil reference value to use
  31735. */
  31736. getStencilFunctionReference(): number;
  31737. /**
  31738. * Gets the current stencil mask
  31739. * @returns a number defining the stencil mask to use
  31740. */
  31741. getStencilFunctionMask(): number;
  31742. /**
  31743. * Sets the current stencil function
  31744. * @param stencilFunc defines the new stencil function to use
  31745. */
  31746. setStencilFunction(stencilFunc: number): void;
  31747. /**
  31748. * Sets the current stencil reference
  31749. * @param reference defines the new stencil reference to use
  31750. */
  31751. setStencilFunctionReference(reference: number): void;
  31752. /**
  31753. * Sets the current stencil mask
  31754. * @param mask defines the new stencil mask to use
  31755. */
  31756. setStencilFunctionMask(mask: number): void;
  31757. /**
  31758. * Gets the current stencil operation when stencil fails
  31759. * @returns a number defining stencil operation to use when stencil fails
  31760. */
  31761. getStencilOperationFail(): number;
  31762. /**
  31763. * Gets the current stencil operation when depth fails
  31764. * @returns a number defining stencil operation to use when depth fails
  31765. */
  31766. getStencilOperationDepthFail(): number;
  31767. /**
  31768. * Gets the current stencil operation when stencil passes
  31769. * @returns a number defining stencil operation to use when stencil passes
  31770. */
  31771. getStencilOperationPass(): number;
  31772. /**
  31773. * Sets the stencil operation to use when stencil fails
  31774. * @param operation defines the stencil operation to use when stencil fails
  31775. */
  31776. setStencilOperationFail(operation: number): void;
  31777. /**
  31778. * Sets the stencil operation to use when depth fails
  31779. * @param operation defines the stencil operation to use when depth fails
  31780. */
  31781. setStencilOperationDepthFail(operation: number): void;
  31782. /**
  31783. * Sets the stencil operation to use when stencil passes
  31784. * @param operation defines the stencil operation to use when stencil passes
  31785. */
  31786. setStencilOperationPass(operation: number): void;
  31787. /**
  31788. * Sets a boolean indicating if the dithering state is enabled or disabled
  31789. * @param value defines the dithering state
  31790. */
  31791. setDitheringState(value: boolean): void;
  31792. /**
  31793. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31794. * @param value defines the rasterizer state
  31795. */
  31796. setRasterizerState(value: boolean): void;
  31797. /**
  31798. * Gets the current depth function
  31799. * @returns a number defining the depth function
  31800. */
  31801. getDepthFunction(): Nullable<number>;
  31802. /**
  31803. * Sets the current depth function
  31804. * @param depthFunc defines the function to use
  31805. */
  31806. setDepthFunction(depthFunc: number): void;
  31807. /**
  31808. * Sets the current depth function to GREATER
  31809. */
  31810. setDepthFunctionToGreater(): void;
  31811. /**
  31812. * Sets the current depth function to GEQUAL
  31813. */
  31814. setDepthFunctionToGreaterOrEqual(): void;
  31815. /**
  31816. * Sets the current depth function to LESS
  31817. */
  31818. setDepthFunctionToLess(): void;
  31819. /**
  31820. * Sets the current depth function to LEQUAL
  31821. */
  31822. setDepthFunctionToLessOrEqual(): void;
  31823. private _cachedStencilBuffer;
  31824. private _cachedStencilFunction;
  31825. private _cachedStencilMask;
  31826. private _cachedStencilOperationPass;
  31827. private _cachedStencilOperationFail;
  31828. private _cachedStencilOperationDepthFail;
  31829. private _cachedStencilReference;
  31830. /**
  31831. * Caches the the state of the stencil buffer
  31832. */
  31833. cacheStencilState(): void;
  31834. /**
  31835. * Restores the state of the stencil buffer
  31836. */
  31837. restoreStencilState(): void;
  31838. /**
  31839. * Directly set the WebGL Viewport
  31840. * @param x defines the x coordinate of the viewport (in screen space)
  31841. * @param y defines the y coordinate of the viewport (in screen space)
  31842. * @param width defines the width of the viewport (in screen space)
  31843. * @param height defines the height of the viewport (in screen space)
  31844. * @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
  31845. */
  31846. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31847. /**
  31848. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31849. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31850. * @param y defines the y-coordinate of the corner of the clear rectangle
  31851. * @param width defines the width of the clear rectangle
  31852. * @param height defines the height of the clear rectangle
  31853. * @param clearColor defines the clear color
  31854. */
  31855. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31856. /**
  31857. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31858. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31859. * @param y defines the y-coordinate of the corner of the clear rectangle
  31860. * @param width defines the width of the clear rectangle
  31861. * @param height defines the height of the clear rectangle
  31862. */
  31863. enableScissor(x: number, y: number, width: number, height: number): void;
  31864. /**
  31865. * Disable previously set scissor test rectangle
  31866. */
  31867. disableScissor(): void;
  31868. protected _reportDrawCall(): void;
  31869. /**
  31870. * Initializes a webVR display and starts listening to display change events
  31871. * The onVRDisplayChangedObservable will be notified upon these changes
  31872. * @returns The onVRDisplayChangedObservable
  31873. */
  31874. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31875. /** @hidden */
  31876. _prepareVRComponent(): void;
  31877. /** @hidden */
  31878. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31879. /** @hidden */
  31880. _submitVRFrame(): void;
  31881. /**
  31882. * Call this function to leave webVR mode
  31883. * Will do nothing if webVR is not supported or if there is no webVR device
  31884. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31885. */
  31886. disableVR(): void;
  31887. /**
  31888. * Gets a boolean indicating that the system is in VR mode and is presenting
  31889. * @returns true if VR mode is engaged
  31890. */
  31891. isVRPresenting(): boolean;
  31892. /** @hidden */
  31893. _requestVRFrame(): void;
  31894. /** @hidden */
  31895. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31896. /**
  31897. * Gets the source code of the vertex shader associated with a specific webGL program
  31898. * @param program defines the program to use
  31899. * @returns a string containing the source code of the vertex shader associated with the program
  31900. */
  31901. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31902. /**
  31903. * Gets the source code of the fragment shader associated with a specific webGL program
  31904. * @param program defines the program to use
  31905. * @returns a string containing the source code of the fragment shader associated with the program
  31906. */
  31907. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31908. /**
  31909. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31910. * @param x defines the x coordinate of the rectangle where pixels must be read
  31911. * @param y defines the y coordinate of the rectangle where pixels must be read
  31912. * @param width defines the width of the rectangle where pixels must be read
  31913. * @param height defines the height of the rectangle where pixels must be read
  31914. * @returns a Uint8Array containing RGBA colors
  31915. */
  31916. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31917. /**
  31918. * Sets a depth stencil texture from a render target to the according uniform.
  31919. * @param channel The texture channel
  31920. * @param uniform The uniform to set
  31921. * @param texture The render target texture containing the depth stencil texture to apply
  31922. */
  31923. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31924. /**
  31925. * Sets a texture to the webGL context from a postprocess
  31926. * @param channel defines the channel to use
  31927. * @param postProcess defines the source postprocess
  31928. */
  31929. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31930. /**
  31931. * Binds the output of the passed in post process to the texture channel specified
  31932. * @param channel The channel the texture should be bound to
  31933. * @param postProcess The post process which's output should be bound
  31934. */
  31935. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31936. /** @hidden */
  31937. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31938. protected _rebuildBuffers(): void;
  31939. /** @hidden */
  31940. _renderFrame(): void;
  31941. _renderLoop(): void;
  31942. /** @hidden */
  31943. _renderViews(): boolean;
  31944. /**
  31945. * Toggle full screen mode
  31946. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31947. */
  31948. switchFullscreen(requestPointerLock: boolean): void;
  31949. /**
  31950. * Enters full screen mode
  31951. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31952. */
  31953. enterFullscreen(requestPointerLock: boolean): void;
  31954. /**
  31955. * Exits full screen mode
  31956. */
  31957. exitFullscreen(): void;
  31958. /**
  31959. * Enters Pointerlock mode
  31960. */
  31961. enterPointerlock(): void;
  31962. /**
  31963. * Exits Pointerlock mode
  31964. */
  31965. exitPointerlock(): void;
  31966. /**
  31967. * Begin a new frame
  31968. */
  31969. beginFrame(): void;
  31970. /**
  31971. * Enf the current frame
  31972. */
  31973. endFrame(): void;
  31974. resize(): void;
  31975. /**
  31976. * Set the compressed texture format to use, based on the formats you have, and the formats
  31977. * supported by the hardware / browser.
  31978. *
  31979. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31980. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31981. * to API arguments needed to compressed textures. This puts the burden on the container
  31982. * generator to house the arcane code for determining these for current & future formats.
  31983. *
  31984. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31985. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31986. *
  31987. * Note: The result of this call is not taken into account when a texture is base64.
  31988. *
  31989. * @param formatsAvailable defines the list of those format families you have created
  31990. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31991. *
  31992. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31993. * @returns The extension selected.
  31994. */
  31995. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31996. /**
  31997. * Force a specific size of the canvas
  31998. * @param width defines the new canvas' width
  31999. * @param height defines the new canvas' height
  32000. */
  32001. setSize(width: number, height: number): void;
  32002. /**
  32003. * Updates a dynamic vertex buffer.
  32004. * @param vertexBuffer the vertex buffer to update
  32005. * @param data the data used to update the vertex buffer
  32006. * @param byteOffset the byte offset of the data
  32007. * @param byteLength the byte length of the data
  32008. */
  32009. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32010. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32011. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32012. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32013. _releaseTexture(texture: InternalTexture): void;
  32014. /**
  32015. * @hidden
  32016. * Rescales a texture
  32017. * @param source input texutre
  32018. * @param destination destination texture
  32019. * @param scene scene to use to render the resize
  32020. * @param internalFormat format to use when resizing
  32021. * @param onComplete callback to be called when resize has completed
  32022. */
  32023. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32024. /**
  32025. * Gets the current framerate
  32026. * @returns a number representing the framerate
  32027. */
  32028. getFps(): number;
  32029. /**
  32030. * Gets the time spent between current and previous frame
  32031. * @returns a number representing the delta time in ms
  32032. */
  32033. getDeltaTime(): number;
  32034. private _measureFps;
  32035. /** @hidden */
  32036. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32037. /**
  32038. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32039. * @param renderTarget The render target to set the frame buffer for
  32040. */
  32041. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32042. /**
  32043. * Update a dynamic index buffer
  32044. * @param indexBuffer defines the target index buffer
  32045. * @param indices defines the data to update
  32046. * @param offset defines the offset in the target index buffer where update should start
  32047. */
  32048. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32049. /**
  32050. * Updates the sample count of a render target texture
  32051. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32052. * @param texture defines the texture to update
  32053. * @param samples defines the sample count to set
  32054. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32055. */
  32056. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32057. /**
  32058. * Updates a depth texture Comparison Mode and Function.
  32059. * If the comparison Function is equal to 0, the mode will be set to none.
  32060. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32061. * @param texture The texture to set the comparison function for
  32062. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32063. */
  32064. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32065. /**
  32066. * Creates a webGL buffer to use with instanciation
  32067. * @param capacity defines the size of the buffer
  32068. * @returns the webGL buffer
  32069. */
  32070. createInstancesBuffer(capacity: number): DataBuffer;
  32071. /**
  32072. * Delete a webGL buffer used with instanciation
  32073. * @param buffer defines the webGL buffer to delete
  32074. */
  32075. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32076. /** @hidden */
  32077. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32078. dispose(): void;
  32079. private _disableTouchAction;
  32080. /**
  32081. * Display the loading screen
  32082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32083. */
  32084. displayLoadingUI(): void;
  32085. /**
  32086. * Hide the loading screen
  32087. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32088. */
  32089. hideLoadingUI(): void;
  32090. /**
  32091. * Gets the current loading screen object
  32092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32093. */
  32094. /**
  32095. * Sets the current loading screen object
  32096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32097. */
  32098. loadingScreen: ILoadingScreen;
  32099. /**
  32100. * Sets the current loading screen text
  32101. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32102. */
  32103. loadingUIText: string;
  32104. /**
  32105. * Sets the current loading screen background color
  32106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32107. */
  32108. loadingUIBackgroundColor: string;
  32109. /** Pointerlock and fullscreen */
  32110. /**
  32111. * Ask the browser to promote the current element to pointerlock mode
  32112. * @param element defines the DOM element to promote
  32113. */
  32114. static _RequestPointerlock(element: HTMLElement): void;
  32115. /**
  32116. * Asks the browser to exit pointerlock mode
  32117. */
  32118. static _ExitPointerlock(): void;
  32119. /**
  32120. * Ask the browser to promote the current element to fullscreen rendering mode
  32121. * @param element defines the DOM element to promote
  32122. */
  32123. static _RequestFullscreen(element: HTMLElement): void;
  32124. /**
  32125. * Asks the browser to exit fullscreen mode
  32126. */
  32127. static _ExitFullscreen(): void;
  32128. }
  32129. }
  32130. declare module BABYLON {
  32131. /**
  32132. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32133. * during the life time of the application.
  32134. */
  32135. export class EngineStore {
  32136. /** Gets the list of created engines */
  32137. static Instances: Engine[];
  32138. /** @hidden */
  32139. static _LastCreatedScene: Nullable<Scene>;
  32140. /**
  32141. * Gets the latest created engine
  32142. */
  32143. static readonly LastCreatedEngine: Nullable<Engine>;
  32144. /**
  32145. * Gets the latest created scene
  32146. */
  32147. static readonly LastCreatedScene: Nullable<Scene>;
  32148. /**
  32149. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32150. * @ignorenaming
  32151. */
  32152. static UseFallbackTexture: boolean;
  32153. /**
  32154. * Texture content used if a texture cannot loaded
  32155. * @ignorenaming
  32156. */
  32157. static FallbackTexture: string;
  32158. }
  32159. }
  32160. declare module BABYLON {
  32161. /**
  32162. * Helper class that provides a small promise polyfill
  32163. */
  32164. export class PromisePolyfill {
  32165. /**
  32166. * Static function used to check if the polyfill is required
  32167. * If this is the case then the function will inject the polyfill to window.Promise
  32168. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32169. */
  32170. static Apply(force?: boolean): void;
  32171. }
  32172. }
  32173. declare module BABYLON {
  32174. /**
  32175. * Interface for screenshot methods with describe argument called `size` as object with options
  32176. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32177. */
  32178. export interface IScreenshotSize {
  32179. /**
  32180. * number in pixels for canvas height
  32181. */
  32182. height?: number;
  32183. /**
  32184. * multiplier allowing render at a higher or lower resolution
  32185. * If value is defined then height and width will be ignored and taken from camera
  32186. */
  32187. precision?: number;
  32188. /**
  32189. * number in pixels for canvas width
  32190. */
  32191. width?: number;
  32192. }
  32193. }
  32194. declare module BABYLON {
  32195. interface IColor4Like {
  32196. r: float;
  32197. g: float;
  32198. b: float;
  32199. a: float;
  32200. }
  32201. /**
  32202. * Class containing a set of static utilities functions
  32203. */
  32204. export class Tools {
  32205. /**
  32206. * Gets or sets the base URL to use to load assets
  32207. */
  32208. static BaseUrl: string;
  32209. /**
  32210. * Enable/Disable Custom HTTP Request Headers globally.
  32211. * default = false
  32212. * @see CustomRequestHeaders
  32213. */
  32214. static UseCustomRequestHeaders: boolean;
  32215. /**
  32216. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32217. * i.e. when loading files, where the server/service expects an Authorization header
  32218. */
  32219. static CustomRequestHeaders: {
  32220. [key: string]: string;
  32221. };
  32222. /**
  32223. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32224. */
  32225. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32226. /**
  32227. * Default behaviour for cors in the application.
  32228. * It can be a string if the expected behavior is identical in the entire app.
  32229. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32230. */
  32231. static CorsBehavior: string | ((url: string | string[]) => string);
  32232. /**
  32233. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32234. * @ignorenaming
  32235. */
  32236. static UseFallbackTexture: boolean;
  32237. /**
  32238. * Use this object to register external classes like custom textures or material
  32239. * to allow the laoders to instantiate them
  32240. */
  32241. static RegisteredExternalClasses: {
  32242. [key: string]: Object;
  32243. };
  32244. /**
  32245. * Texture content used if a texture cannot loaded
  32246. * @ignorenaming
  32247. */
  32248. static fallbackTexture: string;
  32249. /**
  32250. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32251. * @param u defines the coordinate on X axis
  32252. * @param v defines the coordinate on Y axis
  32253. * @param width defines the width of the source data
  32254. * @param height defines the height of the source data
  32255. * @param pixels defines the source byte array
  32256. * @param color defines the output color
  32257. */
  32258. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32259. /**
  32260. * Interpolates between a and b via alpha
  32261. * @param a The lower value (returned when alpha = 0)
  32262. * @param b The upper value (returned when alpha = 1)
  32263. * @param alpha The interpolation-factor
  32264. * @return The mixed value
  32265. */
  32266. static Mix(a: number, b: number, alpha: number): number;
  32267. /**
  32268. * Tries to instantiate a new object from a given class name
  32269. * @param className defines the class name to instantiate
  32270. * @returns the new object or null if the system was not able to do the instantiation
  32271. */
  32272. static Instantiate(className: string): any;
  32273. /**
  32274. * Provides a slice function that will work even on IE
  32275. * @param data defines the array to slice
  32276. * @param start defines the start of the data (optional)
  32277. * @param end defines the end of the data (optional)
  32278. * @returns the new sliced array
  32279. */
  32280. static Slice<T>(data: T, start?: number, end?: number): T;
  32281. /**
  32282. * Polyfill for setImmediate
  32283. * @param action defines the action to execute after the current execution block
  32284. */
  32285. static SetImmediate(action: () => void): void;
  32286. /**
  32287. * Function indicating if a number is an exponent of 2
  32288. * @param value defines the value to test
  32289. * @returns true if the value is an exponent of 2
  32290. */
  32291. static IsExponentOfTwo(value: number): boolean;
  32292. private static _tmpFloatArray;
  32293. /**
  32294. * Returns the nearest 32-bit single precision float representation of a Number
  32295. * @param value A Number. If the parameter is of a different type, it will get converted
  32296. * to a number or to NaN if it cannot be converted
  32297. * @returns number
  32298. */
  32299. static FloatRound(value: number): number;
  32300. /**
  32301. * Extracts the filename from a path
  32302. * @param path defines the path to use
  32303. * @returns the filename
  32304. */
  32305. static GetFilename(path: string): string;
  32306. /**
  32307. * Extracts the "folder" part of a path (everything before the filename).
  32308. * @param uri The URI to extract the info from
  32309. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32310. * @returns The "folder" part of the path
  32311. */
  32312. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32313. /**
  32314. * Extracts text content from a DOM element hierarchy
  32315. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32316. */
  32317. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32318. /**
  32319. * Convert an angle in radians to degrees
  32320. * @param angle defines the angle to convert
  32321. * @returns the angle in degrees
  32322. */
  32323. static ToDegrees(angle: number): number;
  32324. /**
  32325. * Convert an angle in degrees to radians
  32326. * @param angle defines the angle to convert
  32327. * @returns the angle in radians
  32328. */
  32329. static ToRadians(angle: number): number;
  32330. /**
  32331. * Returns an array if obj is not an array
  32332. * @param obj defines the object to evaluate as an array
  32333. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32334. * @returns either obj directly if obj is an array or a new array containing obj
  32335. */
  32336. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32337. /**
  32338. * Gets the pointer prefix to use
  32339. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32340. */
  32341. static GetPointerPrefix(): string;
  32342. /**
  32343. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32344. * @param url define the url we are trying
  32345. * @param element define the dom element where to configure the cors policy
  32346. */
  32347. static SetCorsBehavior(url: string | string[], element: {
  32348. crossOrigin: string | null;
  32349. }): void;
  32350. /**
  32351. * Removes unwanted characters from an url
  32352. * @param url defines the url to clean
  32353. * @returns the cleaned url
  32354. */
  32355. static CleanUrl(url: string): string;
  32356. /**
  32357. * Gets or sets a function used to pre-process url before using them to load assets
  32358. */
  32359. static PreprocessUrl: (url: string) => string;
  32360. /**
  32361. * Loads an image as an HTMLImageElement.
  32362. * @param input url string, ArrayBuffer, or Blob to load
  32363. * @param onLoad callback called when the image successfully loads
  32364. * @param onError callback called when the image fails to load
  32365. * @param offlineProvider offline provider for caching
  32366. * @param mimeType optional mime type
  32367. * @returns the HTMLImageElement of the loaded image
  32368. */
  32369. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32370. /**
  32371. * Loads a file from a url
  32372. * @param url url string, ArrayBuffer, or Blob to load
  32373. * @param onSuccess callback called when the file successfully loads
  32374. * @param onProgress callback called while file is loading (if the server supports this mode)
  32375. * @param offlineProvider defines the offline provider for caching
  32376. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32377. * @param onError callback called when the file fails to load
  32378. * @returns a file request object
  32379. */
  32380. 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;
  32381. /**
  32382. * Loads a file from a url
  32383. * @param url the file url to load
  32384. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32385. */
  32386. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32387. /**
  32388. * Load a script (identified by an url). When the url returns, the
  32389. * content of this file is added into a new script element, attached to the DOM (body element)
  32390. * @param scriptUrl defines the url of the script to laod
  32391. * @param onSuccess defines the callback called when the script is loaded
  32392. * @param onError defines the callback to call if an error occurs
  32393. * @param scriptId defines the id of the script element
  32394. */
  32395. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32396. /**
  32397. * Load an asynchronous script (identified by an url). When the url returns, the
  32398. * content of this file is added into a new script element, attached to the DOM (body element)
  32399. * @param scriptUrl defines the url of the script to laod
  32400. * @param scriptId defines the id of the script element
  32401. * @returns a promise request object
  32402. */
  32403. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32404. /**
  32405. * Loads a file from a blob
  32406. * @param fileToLoad defines the blob to use
  32407. * @param callback defines the callback to call when data is loaded
  32408. * @param progressCallback defines the callback to call during loading process
  32409. * @returns a file request object
  32410. */
  32411. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32412. /**
  32413. * Reads a file from a File object
  32414. * @param file defines the file to load
  32415. * @param onSuccess defines the callback to call when data is loaded
  32416. * @param onProgress defines the callback to call during loading process
  32417. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32418. * @param onError defines the callback to call when an error occurs
  32419. * @returns a file request object
  32420. */
  32421. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32422. /**
  32423. * Creates a data url from a given string content
  32424. * @param content defines the content to convert
  32425. * @returns the new data url link
  32426. */
  32427. static FileAsURL(content: string): string;
  32428. /**
  32429. * Format the given number to a specific decimal format
  32430. * @param value defines the number to format
  32431. * @param decimals defines the number of decimals to use
  32432. * @returns the formatted string
  32433. */
  32434. static Format(value: number, decimals?: number): string;
  32435. /**
  32436. * Tries to copy an object by duplicating every property
  32437. * @param source defines the source object
  32438. * @param destination defines the target object
  32439. * @param doNotCopyList defines a list of properties to avoid
  32440. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32441. */
  32442. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32443. /**
  32444. * Gets a boolean indicating if the given object has no own property
  32445. * @param obj defines the object to test
  32446. * @returns true if object has no own property
  32447. */
  32448. static IsEmpty(obj: any): boolean;
  32449. /**
  32450. * Function used to register events at window level
  32451. * @param windowElement defines the Window object to use
  32452. * @param events defines the events to register
  32453. */
  32454. static RegisterTopRootEvents(windowElement: Window, events: {
  32455. name: string;
  32456. handler: Nullable<(e: FocusEvent) => any>;
  32457. }[]): void;
  32458. /**
  32459. * Function used to unregister events from window level
  32460. * @param windowElement defines the Window object to use
  32461. * @param events defines the events to unregister
  32462. */
  32463. static UnregisterTopRootEvents(windowElement: Window, events: {
  32464. name: string;
  32465. handler: Nullable<(e: FocusEvent) => any>;
  32466. }[]): void;
  32467. /**
  32468. * @ignore
  32469. */
  32470. static _ScreenshotCanvas: HTMLCanvasElement;
  32471. /**
  32472. * Dumps the current bound framebuffer
  32473. * @param width defines the rendering width
  32474. * @param height defines the rendering height
  32475. * @param engine defines the hosting engine
  32476. * @param successCallback defines the callback triggered once the data are available
  32477. * @param mimeType defines the mime type of the result
  32478. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32479. */
  32480. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32481. /**
  32482. * Converts the canvas data to blob.
  32483. * This acts as a polyfill for browsers not supporting the to blob function.
  32484. * @param canvas Defines the canvas to extract the data from
  32485. * @param successCallback Defines the callback triggered once the data are available
  32486. * @param mimeType Defines the mime type of the result
  32487. */
  32488. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32489. /**
  32490. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32491. * @param successCallback defines the callback triggered once the data are available
  32492. * @param mimeType defines the mime type of the result
  32493. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32494. */
  32495. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32496. /**
  32497. * Downloads a blob in the browser
  32498. * @param blob defines the blob to download
  32499. * @param fileName defines the name of the downloaded file
  32500. */
  32501. static Download(blob: Blob, fileName: string): void;
  32502. /**
  32503. * Captures a screenshot of the current rendering
  32504. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32505. * @param engine defines the rendering engine
  32506. * @param camera defines the source camera
  32507. * @param size This parameter can be set to a single number or to an object with the
  32508. * following (optional) properties: precision, width, height. If a single number is passed,
  32509. * it will be used for both width and height. If an object is passed, the screenshot size
  32510. * will be derived from the parameters. The precision property is a multiplier allowing
  32511. * rendering at a higher or lower resolution
  32512. * @param successCallback defines the callback receives a single parameter which contains the
  32513. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32514. * src parameter of an <img> to display it
  32515. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32516. * Check your browser for supported MIME types
  32517. */
  32518. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32519. /**
  32520. * Captures a screenshot of the current rendering
  32521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32522. * @param engine defines the rendering engine
  32523. * @param camera defines the source camera
  32524. * @param size This parameter can be set to a single number or to an object with the
  32525. * following (optional) properties: precision, width, height. If a single number is passed,
  32526. * it will be used for both width and height. If an object is passed, the screenshot size
  32527. * will be derived from the parameters. The precision property is a multiplier allowing
  32528. * rendering at a higher or lower resolution
  32529. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32530. * Check your browser for supported MIME types
  32531. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32532. * to the src parameter of an <img> to display it
  32533. */
  32534. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32535. /**
  32536. * Generates an image screenshot from the specified camera.
  32537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32538. * @param engine The engine to use for rendering
  32539. * @param camera The camera to use for rendering
  32540. * @param size This parameter can be set to a single number or to an object with the
  32541. * following (optional) properties: precision, width, height. If a single number is passed,
  32542. * it will be used for both width and height. If an object is passed, the screenshot size
  32543. * will be derived from the parameters. The precision property is a multiplier allowing
  32544. * rendering at a higher or lower resolution
  32545. * @param successCallback The callback receives a single parameter which contains the
  32546. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32547. * src parameter of an <img> to display it
  32548. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32549. * Check your browser for supported MIME types
  32550. * @param samples Texture samples (default: 1)
  32551. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32552. * @param fileName A name for for the downloaded file.
  32553. */
  32554. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32555. /**
  32556. * Generates an image screenshot from the specified camera.
  32557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32558. * @param engine The engine to use for rendering
  32559. * @param camera The camera to use for rendering
  32560. * @param size This parameter can be set to a single number or to an object with the
  32561. * following (optional) properties: precision, width, height. If a single number is passed,
  32562. * it will be used for both width and height. If an object is passed, the screenshot size
  32563. * will be derived from the parameters. The precision property is a multiplier allowing
  32564. * rendering at a higher or lower resolution
  32565. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32566. * Check your browser for supported MIME types
  32567. * @param samples Texture samples (default: 1)
  32568. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32569. * @param fileName A name for for the downloaded file.
  32570. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32571. * to the src parameter of an <img> to display it
  32572. */
  32573. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32574. /**
  32575. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32576. * Be aware Math.random() could cause collisions, but:
  32577. * "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"
  32578. * @returns a pseudo random id
  32579. */
  32580. static RandomId(): string;
  32581. /**
  32582. * Test if the given uri is a base64 string
  32583. * @param uri The uri to test
  32584. * @return True if the uri is a base64 string or false otherwise
  32585. */
  32586. static IsBase64(uri: string): boolean;
  32587. /**
  32588. * Decode the given base64 uri.
  32589. * @param uri The uri to decode
  32590. * @return The decoded base64 data.
  32591. */
  32592. static DecodeBase64(uri: string): ArrayBuffer;
  32593. /**
  32594. * Gets the absolute url.
  32595. * @param url the input url
  32596. * @return the absolute url
  32597. */
  32598. static GetAbsoluteUrl(url: string): string;
  32599. /**
  32600. * No log
  32601. */
  32602. static readonly NoneLogLevel: number;
  32603. /**
  32604. * Only message logs
  32605. */
  32606. static readonly MessageLogLevel: number;
  32607. /**
  32608. * Only warning logs
  32609. */
  32610. static readonly WarningLogLevel: number;
  32611. /**
  32612. * Only error logs
  32613. */
  32614. static readonly ErrorLogLevel: number;
  32615. /**
  32616. * All logs
  32617. */
  32618. static readonly AllLogLevel: number;
  32619. /**
  32620. * Gets a value indicating the number of loading errors
  32621. * @ignorenaming
  32622. */
  32623. static readonly errorsCount: number;
  32624. /**
  32625. * Callback called when a new log is added
  32626. */
  32627. static OnNewCacheEntry: (entry: string) => void;
  32628. /**
  32629. * Log a message to the console
  32630. * @param message defines the message to log
  32631. */
  32632. static Log(message: string): void;
  32633. /**
  32634. * Write a warning message to the console
  32635. * @param message defines the message to log
  32636. */
  32637. static Warn(message: string): void;
  32638. /**
  32639. * Write an error message to the console
  32640. * @param message defines the message to log
  32641. */
  32642. static Error(message: string): void;
  32643. /**
  32644. * Gets current log cache (list of logs)
  32645. */
  32646. static readonly LogCache: string;
  32647. /**
  32648. * Clears the log cache
  32649. */
  32650. static ClearLogCache(): void;
  32651. /**
  32652. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32653. */
  32654. static LogLevels: number;
  32655. /**
  32656. * Checks if the window object exists
  32657. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32658. */
  32659. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32660. /**
  32661. * No performance log
  32662. */
  32663. static readonly PerformanceNoneLogLevel: number;
  32664. /**
  32665. * Use user marks to log performance
  32666. */
  32667. static readonly PerformanceUserMarkLogLevel: number;
  32668. /**
  32669. * Log performance to the console
  32670. */
  32671. static readonly PerformanceConsoleLogLevel: number;
  32672. private static _performance;
  32673. /**
  32674. * Sets the current performance log level
  32675. */
  32676. static PerformanceLogLevel: number;
  32677. private static _StartPerformanceCounterDisabled;
  32678. private static _EndPerformanceCounterDisabled;
  32679. private static _StartUserMark;
  32680. private static _EndUserMark;
  32681. private static _StartPerformanceConsole;
  32682. private static _EndPerformanceConsole;
  32683. /**
  32684. * Starts a performance counter
  32685. */
  32686. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32687. /**
  32688. * Ends a specific performance coutner
  32689. */
  32690. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32691. /**
  32692. * Gets either window.performance.now() if supported or Date.now() else
  32693. */
  32694. static readonly Now: number;
  32695. /**
  32696. * This method will return the name of the class used to create the instance of the given object.
  32697. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32698. * @param object the object to get the class name from
  32699. * @param isType defines if the object is actually a type
  32700. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32701. */
  32702. static GetClassName(object: any, isType?: boolean): string;
  32703. /**
  32704. * Gets the first element of an array satisfying a given predicate
  32705. * @param array defines the array to browse
  32706. * @param predicate defines the predicate to use
  32707. * @returns null if not found or the element
  32708. */
  32709. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32710. /**
  32711. * This method will return the name of the full name of the class, including its owning module (if any).
  32712. * 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).
  32713. * @param object the object to get the class name from
  32714. * @param isType defines if the object is actually a type
  32715. * @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.
  32716. * @ignorenaming
  32717. */
  32718. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32719. /**
  32720. * Returns a promise that resolves after the given amount of time.
  32721. * @param delay Number of milliseconds to delay
  32722. * @returns Promise that resolves after the given amount of time
  32723. */
  32724. static DelayAsync(delay: number): Promise<void>;
  32725. }
  32726. /**
  32727. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32728. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32729. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32730. * @param name The name of the class, case should be preserved
  32731. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32732. */
  32733. export function className(name: string, module?: string): (target: Object) => void;
  32734. /**
  32735. * An implementation of a loop for asynchronous functions.
  32736. */
  32737. export class AsyncLoop {
  32738. /**
  32739. * Defines the number of iterations for the loop
  32740. */
  32741. iterations: number;
  32742. /**
  32743. * Defines the current index of the loop.
  32744. */
  32745. index: number;
  32746. private _done;
  32747. private _fn;
  32748. private _successCallback;
  32749. /**
  32750. * Constructor.
  32751. * @param iterations the number of iterations.
  32752. * @param func the function to run each iteration
  32753. * @param successCallback the callback that will be called upon succesful execution
  32754. * @param offset starting offset.
  32755. */
  32756. constructor(
  32757. /**
  32758. * Defines the number of iterations for the loop
  32759. */
  32760. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32761. /**
  32762. * Execute the next iteration. Must be called after the last iteration was finished.
  32763. */
  32764. executeNext(): void;
  32765. /**
  32766. * Break the loop and run the success callback.
  32767. */
  32768. breakLoop(): void;
  32769. /**
  32770. * Create and run an async loop.
  32771. * @param iterations the number of iterations.
  32772. * @param fn the function to run each iteration
  32773. * @param successCallback the callback that will be called upon succesful execution
  32774. * @param offset starting offset.
  32775. * @returns the created async loop object
  32776. */
  32777. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32778. /**
  32779. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32780. * @param iterations total number of iterations
  32781. * @param syncedIterations number of synchronous iterations in each async iteration.
  32782. * @param fn the function to call each iteration.
  32783. * @param callback a success call back that will be called when iterating stops.
  32784. * @param breakFunction a break condition (optional)
  32785. * @param timeout timeout settings for the setTimeout function. default - 0.
  32786. * @returns the created async loop object
  32787. */
  32788. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32789. }
  32790. }
  32791. declare module BABYLON {
  32792. /**
  32793. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32794. * The underlying implementation relies on an associative array to ensure the best performances.
  32795. * The value can be anything including 'null' but except 'undefined'
  32796. */
  32797. export class StringDictionary<T> {
  32798. /**
  32799. * This will clear this dictionary and copy the content from the 'source' one.
  32800. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32801. * @param source the dictionary to take the content from and copy to this dictionary
  32802. */
  32803. copyFrom(source: StringDictionary<T>): void;
  32804. /**
  32805. * Get a value based from its key
  32806. * @param key the given key to get the matching value from
  32807. * @return the value if found, otherwise undefined is returned
  32808. */
  32809. get(key: string): T | undefined;
  32810. /**
  32811. * Get a value from its key or add it if it doesn't exist.
  32812. * This method will ensure you that a given key/data will be present in the dictionary.
  32813. * @param key the given key to get the matching value from
  32814. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32815. * The factory will only be invoked if there's no data for the given key.
  32816. * @return the value corresponding to the key.
  32817. */
  32818. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32819. /**
  32820. * Get a value from its key if present in the dictionary otherwise add it
  32821. * @param key the key to get the value from
  32822. * @param val if there's no such key/value pair in the dictionary add it with this value
  32823. * @return the value corresponding to the key
  32824. */
  32825. getOrAdd(key: string, val: T): T;
  32826. /**
  32827. * Check if there's a given key in the dictionary
  32828. * @param key the key to check for
  32829. * @return true if the key is present, false otherwise
  32830. */
  32831. contains(key: string): boolean;
  32832. /**
  32833. * Add a new key and its corresponding value
  32834. * @param key the key to add
  32835. * @param value the value corresponding to the key
  32836. * @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
  32837. */
  32838. add(key: string, value: T): boolean;
  32839. /**
  32840. * Update a specific value associated to a key
  32841. * @param key defines the key to use
  32842. * @param value defines the value to store
  32843. * @returns true if the value was updated (or false if the key was not found)
  32844. */
  32845. set(key: string, value: T): boolean;
  32846. /**
  32847. * Get the element of the given key and remove it from the dictionary
  32848. * @param key defines the key to search
  32849. * @returns the value associated with the key or null if not found
  32850. */
  32851. getAndRemove(key: string): Nullable<T>;
  32852. /**
  32853. * Remove a key/value from the dictionary.
  32854. * @param key the key to remove
  32855. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32856. */
  32857. remove(key: string): boolean;
  32858. /**
  32859. * Clear the whole content of the dictionary
  32860. */
  32861. clear(): void;
  32862. /**
  32863. * Gets the current count
  32864. */
  32865. readonly count: number;
  32866. /**
  32867. * Execute a callback on each key/val of the dictionary.
  32868. * Note that you can remove any element in this dictionary in the callback implementation
  32869. * @param callback the callback to execute on a given key/value pair
  32870. */
  32871. forEach(callback: (key: string, val: T) => void): void;
  32872. /**
  32873. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32874. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32875. * Note that you can remove any element in this dictionary in the callback implementation
  32876. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32877. * @returns the first item
  32878. */
  32879. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32880. private _count;
  32881. private _data;
  32882. }
  32883. }
  32884. declare module BABYLON {
  32885. /** @hidden */
  32886. export interface ICollisionCoordinator {
  32887. createCollider(): Collider;
  32888. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32889. init(scene: Scene): void;
  32890. }
  32891. /** @hidden */
  32892. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32893. private _scene;
  32894. private _scaledPosition;
  32895. private _scaledVelocity;
  32896. private _finalPosition;
  32897. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32898. createCollider(): Collider;
  32899. init(scene: Scene): void;
  32900. private _collideWithWorld;
  32901. }
  32902. }
  32903. declare module BABYLON {
  32904. /**
  32905. * Class used to manage all inputs for the scene.
  32906. */
  32907. export class InputManager {
  32908. /** The distance in pixel that you have to move to prevent some events */
  32909. static DragMovementThreshold: number;
  32910. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32911. static LongPressDelay: number;
  32912. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32913. static DoubleClickDelay: number;
  32914. /** If you need to check double click without raising a single click at first click, enable this flag */
  32915. static ExclusiveDoubleClickMode: boolean;
  32916. private _wheelEventName;
  32917. private _onPointerMove;
  32918. private _onPointerDown;
  32919. private _onPointerUp;
  32920. private _initClickEvent;
  32921. private _initActionManager;
  32922. private _delayedSimpleClick;
  32923. private _delayedSimpleClickTimeout;
  32924. private _previousDelayedSimpleClickTimeout;
  32925. private _meshPickProceed;
  32926. private _previousButtonPressed;
  32927. private _currentPickResult;
  32928. private _previousPickResult;
  32929. private _totalPointersPressed;
  32930. private _doubleClickOccured;
  32931. private _pointerOverMesh;
  32932. private _pickedDownMesh;
  32933. private _pickedUpMesh;
  32934. private _pointerX;
  32935. private _pointerY;
  32936. private _unTranslatedPointerX;
  32937. private _unTranslatedPointerY;
  32938. private _startingPointerPosition;
  32939. private _previousStartingPointerPosition;
  32940. private _startingPointerTime;
  32941. private _previousStartingPointerTime;
  32942. private _pointerCaptures;
  32943. private _onKeyDown;
  32944. private _onKeyUp;
  32945. private _onCanvasFocusObserver;
  32946. private _onCanvasBlurObserver;
  32947. private _scene;
  32948. /**
  32949. * Creates a new InputManager
  32950. * @param scene defines the hosting scene
  32951. */
  32952. constructor(scene: Scene);
  32953. /**
  32954. * Gets the mesh that is currently under the pointer
  32955. */
  32956. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32957. /**
  32958. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32959. */
  32960. readonly unTranslatedPointer: Vector2;
  32961. /**
  32962. * Gets or sets the current on-screen X position of the pointer
  32963. */
  32964. pointerX: number;
  32965. /**
  32966. * Gets or sets the current on-screen Y position of the pointer
  32967. */
  32968. pointerY: number;
  32969. private _updatePointerPosition;
  32970. private _processPointerMove;
  32971. private _setRayOnPointerInfo;
  32972. private _checkPrePointerObservable;
  32973. /**
  32974. * Use this method to simulate a pointer move on a mesh
  32975. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32976. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32977. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32978. */
  32979. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32980. /**
  32981. * Use this method to simulate a pointer down on a mesh
  32982. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32983. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32984. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32985. */
  32986. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32987. private _processPointerDown;
  32988. /** @hidden */
  32989. _isPointerSwiping(): boolean;
  32990. /**
  32991. * Use this method to simulate a pointer up on a mesh
  32992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32995. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32996. */
  32997. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32998. private _processPointerUp;
  32999. /**
  33000. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33001. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33002. * @returns true if the pointer was captured
  33003. */
  33004. isPointerCaptured(pointerId?: number): boolean;
  33005. /**
  33006. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33007. * @param attachUp defines if you want to attach events to pointerup
  33008. * @param attachDown defines if you want to attach events to pointerdown
  33009. * @param attachMove defines if you want to attach events to pointermove
  33010. */
  33011. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33012. /**
  33013. * Detaches all event handlers
  33014. */
  33015. detachControl(): void;
  33016. /**
  33017. * Force the value of meshUnderPointer
  33018. * @param mesh defines the mesh to use
  33019. */
  33020. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33021. /**
  33022. * Gets the mesh under the pointer
  33023. * @returns a Mesh or null if no mesh is under the pointer
  33024. */
  33025. getPointerOverMesh(): Nullable<AbstractMesh>;
  33026. }
  33027. }
  33028. declare module BABYLON {
  33029. /**
  33030. * Helper class used to generate session unique ID
  33031. */
  33032. export class UniqueIdGenerator {
  33033. private static _UniqueIdCounter;
  33034. /**
  33035. * Gets an unique (relatively to the current scene) Id
  33036. */
  33037. static readonly UniqueId: number;
  33038. }
  33039. }
  33040. declare module BABYLON {
  33041. /**
  33042. * This class defines the direct association between an animation and a target
  33043. */
  33044. export class TargetedAnimation {
  33045. /**
  33046. * Animation to perform
  33047. */
  33048. animation: Animation;
  33049. /**
  33050. * Target to animate
  33051. */
  33052. target: any;
  33053. /**
  33054. * Serialize the object
  33055. * @returns the JSON object representing the current entity
  33056. */
  33057. serialize(): any;
  33058. }
  33059. /**
  33060. * Use this class to create coordinated animations on multiple targets
  33061. */
  33062. export class AnimationGroup implements IDisposable {
  33063. /** The name of the animation group */
  33064. name: string;
  33065. private _scene;
  33066. private _targetedAnimations;
  33067. private _animatables;
  33068. private _from;
  33069. private _to;
  33070. private _isStarted;
  33071. private _isPaused;
  33072. private _speedRatio;
  33073. private _loopAnimation;
  33074. /**
  33075. * Gets or sets the unique id of the node
  33076. */
  33077. uniqueId: number;
  33078. /**
  33079. * This observable will notify when one animation have ended
  33080. */
  33081. onAnimationEndObservable: Observable<TargetedAnimation>;
  33082. /**
  33083. * Observer raised when one animation loops
  33084. */
  33085. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33086. /**
  33087. * Observer raised when all animations have looped
  33088. */
  33089. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33090. /**
  33091. * This observable will notify when all animations have ended.
  33092. */
  33093. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33094. /**
  33095. * This observable will notify when all animations have paused.
  33096. */
  33097. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33098. /**
  33099. * This observable will notify when all animations are playing.
  33100. */
  33101. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33102. /**
  33103. * Gets the first frame
  33104. */
  33105. readonly from: number;
  33106. /**
  33107. * Gets the last frame
  33108. */
  33109. readonly to: number;
  33110. /**
  33111. * Define if the animations are started
  33112. */
  33113. readonly isStarted: boolean;
  33114. /**
  33115. * Gets a value indicating that the current group is playing
  33116. */
  33117. readonly isPlaying: boolean;
  33118. /**
  33119. * Gets or sets the speed ratio to use for all animations
  33120. */
  33121. /**
  33122. * Gets or sets the speed ratio to use for all animations
  33123. */
  33124. speedRatio: number;
  33125. /**
  33126. * Gets or sets if all animations should loop or not
  33127. */
  33128. loopAnimation: boolean;
  33129. /**
  33130. * Gets the targeted animations for this animation group
  33131. */
  33132. readonly targetedAnimations: Array<TargetedAnimation>;
  33133. /**
  33134. * returning the list of animatables controlled by this animation group.
  33135. */
  33136. readonly animatables: Array<Animatable>;
  33137. /**
  33138. * Instantiates a new Animation Group.
  33139. * This helps managing several animations at once.
  33140. * @see http://doc.babylonjs.com/how_to/group
  33141. * @param name Defines the name of the group
  33142. * @param scene Defines the scene the group belongs to
  33143. */
  33144. constructor(
  33145. /** The name of the animation group */
  33146. name: string, scene?: Nullable<Scene>);
  33147. /**
  33148. * Add an animation (with its target) in the group
  33149. * @param animation defines the animation we want to add
  33150. * @param target defines the target of the animation
  33151. * @returns the TargetedAnimation object
  33152. */
  33153. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33154. /**
  33155. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33156. * It can add constant keys at begin or end
  33157. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33158. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33159. * @returns the animation group
  33160. */
  33161. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33162. private _animationLoopCount;
  33163. private _animationLoopFlags;
  33164. private _processLoop;
  33165. /**
  33166. * Start all animations on given targets
  33167. * @param loop defines if animations must loop
  33168. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33169. * @param from defines the from key (optional)
  33170. * @param to defines the to key (optional)
  33171. * @returns the current animation group
  33172. */
  33173. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33174. /**
  33175. * Pause all animations
  33176. * @returns the animation group
  33177. */
  33178. pause(): AnimationGroup;
  33179. /**
  33180. * Play all animations to initial state
  33181. * This function will start() the animations if they were not started or will restart() them if they were paused
  33182. * @param loop defines if animations must loop
  33183. * @returns the animation group
  33184. */
  33185. play(loop?: boolean): AnimationGroup;
  33186. /**
  33187. * Reset all animations to initial state
  33188. * @returns the animation group
  33189. */
  33190. reset(): AnimationGroup;
  33191. /**
  33192. * Restart animations from key 0
  33193. * @returns the animation group
  33194. */
  33195. restart(): AnimationGroup;
  33196. /**
  33197. * Stop all animations
  33198. * @returns the animation group
  33199. */
  33200. stop(): AnimationGroup;
  33201. /**
  33202. * Set animation weight for all animatables
  33203. * @param weight defines the weight to use
  33204. * @return the animationGroup
  33205. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33206. */
  33207. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33208. /**
  33209. * Synchronize and normalize all animatables with a source animatable
  33210. * @param root defines the root animatable to synchronize with
  33211. * @return the animationGroup
  33212. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33213. */
  33214. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33215. /**
  33216. * Goes to a specific frame in this animation group
  33217. * @param frame the frame number to go to
  33218. * @return the animationGroup
  33219. */
  33220. goToFrame(frame: number): AnimationGroup;
  33221. /**
  33222. * Dispose all associated resources
  33223. */
  33224. dispose(): void;
  33225. private _checkAnimationGroupEnded;
  33226. /**
  33227. * Clone the current animation group and returns a copy
  33228. * @param newName defines the name of the new group
  33229. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33230. * @returns the new aniamtion group
  33231. */
  33232. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33233. /**
  33234. * Serializes the animationGroup to an object
  33235. * @returns Serialized object
  33236. */
  33237. serialize(): any;
  33238. /**
  33239. * Returns a new AnimationGroup object parsed from the source provided.
  33240. * @param parsedAnimationGroup defines the source
  33241. * @param scene defines the scene that will receive the animationGroup
  33242. * @returns a new AnimationGroup
  33243. */
  33244. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33245. /**
  33246. * Returns the string "AnimationGroup"
  33247. * @returns "AnimationGroup"
  33248. */
  33249. getClassName(): string;
  33250. /**
  33251. * Creates a detailled string about the object
  33252. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33253. * @returns a string representing the object
  33254. */
  33255. toString(fullDetails?: boolean): string;
  33256. }
  33257. }
  33258. declare module BABYLON {
  33259. /**
  33260. * Define an interface for all classes that will hold resources
  33261. */
  33262. export interface IDisposable {
  33263. /**
  33264. * Releases all held resources
  33265. */
  33266. dispose(): void;
  33267. }
  33268. /** Interface defining initialization parameters for Scene class */
  33269. export interface SceneOptions {
  33270. /**
  33271. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33272. * It will improve performance when the number of geometries becomes important.
  33273. */
  33274. useGeometryUniqueIdsMap?: boolean;
  33275. /**
  33276. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33277. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33278. */
  33279. useMaterialMeshMap?: boolean;
  33280. /**
  33281. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33282. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33283. */
  33284. useClonedMeshhMap?: boolean;
  33285. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33286. virtual?: boolean;
  33287. }
  33288. /**
  33289. * Represents a scene to be rendered by the engine.
  33290. * @see http://doc.babylonjs.com/features/scene
  33291. */
  33292. export class Scene extends AbstractScene implements IAnimatable {
  33293. /** The fog is deactivated */
  33294. static readonly FOGMODE_NONE: number;
  33295. /** The fog density is following an exponential function */
  33296. static readonly FOGMODE_EXP: number;
  33297. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33298. static readonly FOGMODE_EXP2: number;
  33299. /** The fog density is following a linear function. */
  33300. static readonly FOGMODE_LINEAR: number;
  33301. /**
  33302. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33304. */
  33305. static MinDeltaTime: number;
  33306. /**
  33307. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33309. */
  33310. static MaxDeltaTime: number;
  33311. /**
  33312. * Factory used to create the default material.
  33313. * @param name The name of the material to create
  33314. * @param scene The scene to create the material for
  33315. * @returns The default material
  33316. */
  33317. static DefaultMaterialFactory(scene: Scene): Material;
  33318. /**
  33319. * Factory used to create the a collision coordinator.
  33320. * @returns The collision coordinator
  33321. */
  33322. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33323. /** @hidden */
  33324. _inputManager: InputManager;
  33325. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33326. cameraToUseForPointers: Nullable<Camera>;
  33327. /** @hidden */
  33328. readonly _isScene: boolean;
  33329. /**
  33330. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33331. */
  33332. autoClear: boolean;
  33333. /**
  33334. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33335. */
  33336. autoClearDepthAndStencil: boolean;
  33337. /**
  33338. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33339. */
  33340. clearColor: Color4;
  33341. /**
  33342. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33343. */
  33344. ambientColor: Color3;
  33345. /**
  33346. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33347. * It should only be one of the following (if not the default embedded one):
  33348. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33349. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33350. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33351. * The material properties need to be setup according to the type of texture in use.
  33352. */
  33353. environmentBRDFTexture: BaseTexture;
  33354. /** @hidden */
  33355. protected _environmentTexture: Nullable<BaseTexture>;
  33356. /**
  33357. * Texture used in all pbr material as the reflection texture.
  33358. * As in the majority of the scene they are the same (exception for multi room and so on),
  33359. * this is easier to reference from here than from all the materials.
  33360. */
  33361. /**
  33362. * Texture used in all pbr material as the reflection texture.
  33363. * As in the majority of the scene they are the same (exception for multi room and so on),
  33364. * this is easier to set here than in all the materials.
  33365. */
  33366. environmentTexture: Nullable<BaseTexture>;
  33367. /** @hidden */
  33368. protected _environmentIntensity: number;
  33369. /**
  33370. * Intensity of the environment in all pbr material.
  33371. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33372. * As in the majority of the scene they are the same (exception for multi room and so on),
  33373. * this is easier to reference from here than from all the materials.
  33374. */
  33375. /**
  33376. * Intensity of the environment in all pbr material.
  33377. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33378. * As in the majority of the scene they are the same (exception for multi room and so on),
  33379. * this is easier to set here than in all the materials.
  33380. */
  33381. environmentIntensity: number;
  33382. /** @hidden */
  33383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33384. /**
  33385. * Default image processing configuration used either in the rendering
  33386. * Forward main pass or through the imageProcessingPostProcess if present.
  33387. * As in the majority of the scene they are the same (exception for multi camera),
  33388. * this is easier to reference from here than from all the materials and post process.
  33389. *
  33390. * No setter as we it is a shared configuration, you can set the values instead.
  33391. */
  33392. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33393. private _forceWireframe;
  33394. /**
  33395. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33396. */
  33397. forceWireframe: boolean;
  33398. private _forcePointsCloud;
  33399. /**
  33400. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33401. */
  33402. forcePointsCloud: boolean;
  33403. /**
  33404. * Gets or sets the active clipplane 1
  33405. */
  33406. clipPlane: Nullable<Plane>;
  33407. /**
  33408. * Gets or sets the active clipplane 2
  33409. */
  33410. clipPlane2: Nullable<Plane>;
  33411. /**
  33412. * Gets or sets the active clipplane 3
  33413. */
  33414. clipPlane3: Nullable<Plane>;
  33415. /**
  33416. * Gets or sets the active clipplane 4
  33417. */
  33418. clipPlane4: Nullable<Plane>;
  33419. /**
  33420. * Gets or sets a boolean indicating if animations are enabled
  33421. */
  33422. animationsEnabled: boolean;
  33423. private _animationPropertiesOverride;
  33424. /**
  33425. * Gets or sets the animation properties override
  33426. */
  33427. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33428. /**
  33429. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33430. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33431. */
  33432. useConstantAnimationDeltaTime: boolean;
  33433. /**
  33434. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33435. * Please note that it requires to run a ray cast through the scene on every frame
  33436. */
  33437. constantlyUpdateMeshUnderPointer: boolean;
  33438. /**
  33439. * Defines the HTML cursor to use when hovering over interactive elements
  33440. */
  33441. hoverCursor: string;
  33442. /**
  33443. * Defines the HTML default cursor to use (empty by default)
  33444. */
  33445. defaultCursor: string;
  33446. /**
  33447. * Defines wether cursors are handled by the scene.
  33448. */
  33449. doNotHandleCursors: boolean;
  33450. /**
  33451. * This is used to call preventDefault() on pointer down
  33452. * in order to block unwanted artifacts like system double clicks
  33453. */
  33454. preventDefaultOnPointerDown: boolean;
  33455. /**
  33456. * This is used to call preventDefault() on pointer up
  33457. * in order to block unwanted artifacts like system double clicks
  33458. */
  33459. preventDefaultOnPointerUp: boolean;
  33460. /**
  33461. * Gets or sets user defined metadata
  33462. */
  33463. metadata: any;
  33464. /**
  33465. * For internal use only. Please do not use.
  33466. */
  33467. reservedDataStore: any;
  33468. /**
  33469. * Gets the name of the plugin used to load this scene (null by default)
  33470. */
  33471. loadingPluginName: string;
  33472. /**
  33473. * Use this array to add regular expressions used to disable offline support for specific urls
  33474. */
  33475. disableOfflineSupportExceptionRules: RegExp[];
  33476. /**
  33477. * An event triggered when the scene is disposed.
  33478. */
  33479. onDisposeObservable: Observable<Scene>;
  33480. private _onDisposeObserver;
  33481. /** Sets a function to be executed when this scene is disposed. */
  33482. onDispose: () => void;
  33483. /**
  33484. * An event triggered before rendering the scene (right after animations and physics)
  33485. */
  33486. onBeforeRenderObservable: Observable<Scene>;
  33487. private _onBeforeRenderObserver;
  33488. /** Sets a function to be executed before rendering this scene */
  33489. beforeRender: Nullable<() => void>;
  33490. /**
  33491. * An event triggered after rendering the scene
  33492. */
  33493. onAfterRenderObservable: Observable<Scene>;
  33494. /**
  33495. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33496. */
  33497. onAfterRenderCameraObservable: Observable<Camera>;
  33498. private _onAfterRenderObserver;
  33499. /** Sets a function to be executed after rendering this scene */
  33500. afterRender: Nullable<() => void>;
  33501. /**
  33502. * An event triggered before animating the scene
  33503. */
  33504. onBeforeAnimationsObservable: Observable<Scene>;
  33505. /**
  33506. * An event triggered after animations processing
  33507. */
  33508. onAfterAnimationsObservable: Observable<Scene>;
  33509. /**
  33510. * An event triggered before draw calls are ready to be sent
  33511. */
  33512. onBeforeDrawPhaseObservable: Observable<Scene>;
  33513. /**
  33514. * An event triggered after draw calls have been sent
  33515. */
  33516. onAfterDrawPhaseObservable: Observable<Scene>;
  33517. /**
  33518. * An event triggered when the scene is ready
  33519. */
  33520. onReadyObservable: Observable<Scene>;
  33521. /**
  33522. * An event triggered before rendering a camera
  33523. */
  33524. onBeforeCameraRenderObservable: Observable<Camera>;
  33525. private _onBeforeCameraRenderObserver;
  33526. /** Sets a function to be executed before rendering a camera*/
  33527. beforeCameraRender: () => void;
  33528. /**
  33529. * An event triggered after rendering a camera
  33530. */
  33531. onAfterCameraRenderObservable: Observable<Camera>;
  33532. private _onAfterCameraRenderObserver;
  33533. /** Sets a function to be executed after rendering a camera*/
  33534. afterCameraRender: () => void;
  33535. /**
  33536. * An event triggered when active meshes evaluation is about to start
  33537. */
  33538. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33539. /**
  33540. * An event triggered when active meshes evaluation is done
  33541. */
  33542. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33543. /**
  33544. * An event triggered when particles rendering is about to start
  33545. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33546. */
  33547. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33548. /**
  33549. * An event triggered when particles rendering is done
  33550. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33551. */
  33552. onAfterParticlesRenderingObservable: Observable<Scene>;
  33553. /**
  33554. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33555. */
  33556. onDataLoadedObservable: Observable<Scene>;
  33557. /**
  33558. * An event triggered when a camera is created
  33559. */
  33560. onNewCameraAddedObservable: Observable<Camera>;
  33561. /**
  33562. * An event triggered when a camera is removed
  33563. */
  33564. onCameraRemovedObservable: Observable<Camera>;
  33565. /**
  33566. * An event triggered when a light is created
  33567. */
  33568. onNewLightAddedObservable: Observable<Light>;
  33569. /**
  33570. * An event triggered when a light is removed
  33571. */
  33572. onLightRemovedObservable: Observable<Light>;
  33573. /**
  33574. * An event triggered when a geometry is created
  33575. */
  33576. onNewGeometryAddedObservable: Observable<Geometry>;
  33577. /**
  33578. * An event triggered when a geometry is removed
  33579. */
  33580. onGeometryRemovedObservable: Observable<Geometry>;
  33581. /**
  33582. * An event triggered when a transform node is created
  33583. */
  33584. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33585. /**
  33586. * An event triggered when a transform node is removed
  33587. */
  33588. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33589. /**
  33590. * An event triggered when a mesh is created
  33591. */
  33592. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33593. /**
  33594. * An event triggered when a mesh is removed
  33595. */
  33596. onMeshRemovedObservable: Observable<AbstractMesh>;
  33597. /**
  33598. * An event triggered when a skeleton is created
  33599. */
  33600. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33601. /**
  33602. * An event triggered when a skeleton is removed
  33603. */
  33604. onSkeletonRemovedObservable: Observable<Skeleton>;
  33605. /**
  33606. * An event triggered when a material is created
  33607. */
  33608. onNewMaterialAddedObservable: Observable<Material>;
  33609. /**
  33610. * An event triggered when a material is removed
  33611. */
  33612. onMaterialRemovedObservable: Observable<Material>;
  33613. /**
  33614. * An event triggered when a texture is created
  33615. */
  33616. onNewTextureAddedObservable: Observable<BaseTexture>;
  33617. /**
  33618. * An event triggered when a texture is removed
  33619. */
  33620. onTextureRemovedObservable: Observable<BaseTexture>;
  33621. /**
  33622. * An event triggered when render targets are about to be rendered
  33623. * Can happen multiple times per frame.
  33624. */
  33625. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33626. /**
  33627. * An event triggered when render targets were rendered.
  33628. * Can happen multiple times per frame.
  33629. */
  33630. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33631. /**
  33632. * An event triggered before calculating deterministic simulation step
  33633. */
  33634. onBeforeStepObservable: Observable<Scene>;
  33635. /**
  33636. * An event triggered after calculating deterministic simulation step
  33637. */
  33638. onAfterStepObservable: Observable<Scene>;
  33639. /**
  33640. * An event triggered when the activeCamera property is updated
  33641. */
  33642. onActiveCameraChanged: Observable<Scene>;
  33643. /**
  33644. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33645. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33646. * 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)
  33647. */
  33648. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33649. /**
  33650. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33651. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33652. * 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)
  33653. */
  33654. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33655. /**
  33656. * This Observable will when a mesh has been imported into the scene.
  33657. */
  33658. onMeshImportedObservable: Observable<AbstractMesh>;
  33659. /**
  33660. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33661. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33662. */
  33663. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33664. /** @hidden */
  33665. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33666. /**
  33667. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33668. */
  33669. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33670. /**
  33671. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33672. */
  33673. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33674. /**
  33675. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33676. */
  33677. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33678. /** Callback called when a pointer move is detected */
  33679. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33680. /** Callback called when a pointer down is detected */
  33681. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33682. /** Callback called when a pointer up is detected */
  33683. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33684. /** Callback called when a pointer pick is detected */
  33685. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33686. /**
  33687. * 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).
  33688. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33689. */
  33690. onPrePointerObservable: Observable<PointerInfoPre>;
  33691. /**
  33692. * Observable event triggered each time an input event is received from the rendering canvas
  33693. */
  33694. onPointerObservable: Observable<PointerInfo>;
  33695. /**
  33696. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33697. */
  33698. readonly unTranslatedPointer: Vector2;
  33699. /**
  33700. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33701. */
  33702. static DragMovementThreshold: number;
  33703. /**
  33704. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33705. */
  33706. static LongPressDelay: number;
  33707. /**
  33708. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33709. */
  33710. static DoubleClickDelay: number;
  33711. /** If you need to check double click without raising a single click at first click, enable this flag */
  33712. static ExclusiveDoubleClickMode: boolean;
  33713. /** @hidden */
  33714. _mirroredCameraPosition: Nullable<Vector3>;
  33715. /**
  33716. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33717. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33718. */
  33719. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33720. /**
  33721. * Observable event triggered each time an keyboard event is received from the hosting window
  33722. */
  33723. onKeyboardObservable: Observable<KeyboardInfo>;
  33724. private _useRightHandedSystem;
  33725. /**
  33726. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33727. */
  33728. useRightHandedSystem: boolean;
  33729. private _timeAccumulator;
  33730. private _currentStepId;
  33731. private _currentInternalStep;
  33732. /**
  33733. * Sets the step Id used by deterministic lock step
  33734. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33735. * @param newStepId defines the step Id
  33736. */
  33737. setStepId(newStepId: number): void;
  33738. /**
  33739. * Gets the step Id used by deterministic lock step
  33740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33741. * @returns the step Id
  33742. */
  33743. getStepId(): number;
  33744. /**
  33745. * Gets the internal step used by deterministic lock step
  33746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33747. * @returns the internal step
  33748. */
  33749. getInternalStep(): number;
  33750. private _fogEnabled;
  33751. /**
  33752. * Gets or sets a boolean indicating if fog is enabled on this scene
  33753. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33754. * (Default is true)
  33755. */
  33756. fogEnabled: boolean;
  33757. private _fogMode;
  33758. /**
  33759. * Gets or sets the fog mode to use
  33760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33761. * | mode | value |
  33762. * | --- | --- |
  33763. * | FOGMODE_NONE | 0 |
  33764. * | FOGMODE_EXP | 1 |
  33765. * | FOGMODE_EXP2 | 2 |
  33766. * | FOGMODE_LINEAR | 3 |
  33767. */
  33768. fogMode: number;
  33769. /**
  33770. * Gets or sets the fog color to use
  33771. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33772. * (Default is Color3(0.2, 0.2, 0.3))
  33773. */
  33774. fogColor: Color3;
  33775. /**
  33776. * Gets or sets the fog density to use
  33777. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33778. * (Default is 0.1)
  33779. */
  33780. fogDensity: number;
  33781. /**
  33782. * Gets or sets the fog start distance to use
  33783. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33784. * (Default is 0)
  33785. */
  33786. fogStart: number;
  33787. /**
  33788. * Gets or sets the fog end distance to use
  33789. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33790. * (Default is 1000)
  33791. */
  33792. fogEnd: number;
  33793. private _shadowsEnabled;
  33794. /**
  33795. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33796. */
  33797. shadowsEnabled: boolean;
  33798. private _lightsEnabled;
  33799. /**
  33800. * Gets or sets a boolean indicating if lights are enabled on this scene
  33801. */
  33802. lightsEnabled: boolean;
  33803. /** All of the active cameras added to this scene. */
  33804. activeCameras: Camera[];
  33805. /** @hidden */
  33806. _activeCamera: Nullable<Camera>;
  33807. /** Gets or sets the current active camera */
  33808. activeCamera: Nullable<Camera>;
  33809. private _defaultMaterial;
  33810. /** The default material used on meshes when no material is affected */
  33811. /** The default material used on meshes when no material is affected */
  33812. defaultMaterial: Material;
  33813. private _texturesEnabled;
  33814. /**
  33815. * Gets or sets a boolean indicating if textures are enabled on this scene
  33816. */
  33817. texturesEnabled: boolean;
  33818. /**
  33819. * Gets or sets a boolean indicating if particles are enabled on this scene
  33820. */
  33821. particlesEnabled: boolean;
  33822. /**
  33823. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33824. */
  33825. spritesEnabled: boolean;
  33826. private _skeletonsEnabled;
  33827. /**
  33828. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33829. */
  33830. skeletonsEnabled: boolean;
  33831. /**
  33832. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33833. */
  33834. lensFlaresEnabled: boolean;
  33835. /**
  33836. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33838. */
  33839. collisionsEnabled: boolean;
  33840. private _collisionCoordinator;
  33841. /** @hidden */
  33842. readonly collisionCoordinator: ICollisionCoordinator;
  33843. /**
  33844. * Defines the gravity applied to this scene (used only for collisions)
  33845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33846. */
  33847. gravity: Vector3;
  33848. /**
  33849. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33850. */
  33851. postProcessesEnabled: boolean;
  33852. /**
  33853. * The list of postprocesses added to the scene
  33854. */
  33855. postProcesses: PostProcess[];
  33856. /**
  33857. * Gets the current postprocess manager
  33858. */
  33859. postProcessManager: PostProcessManager;
  33860. /**
  33861. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33862. */
  33863. renderTargetsEnabled: boolean;
  33864. /**
  33865. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33866. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33867. */
  33868. dumpNextRenderTargets: boolean;
  33869. /**
  33870. * The list of user defined render targets added to the scene
  33871. */
  33872. customRenderTargets: RenderTargetTexture[];
  33873. /**
  33874. * Defines if texture loading must be delayed
  33875. * If true, textures will only be loaded when they need to be rendered
  33876. */
  33877. useDelayedTextureLoading: boolean;
  33878. /**
  33879. * Gets the list of meshes imported to the scene through SceneLoader
  33880. */
  33881. importedMeshesFiles: String[];
  33882. /**
  33883. * Gets or sets a boolean indicating if probes are enabled on this scene
  33884. */
  33885. probesEnabled: boolean;
  33886. /**
  33887. * Gets or sets the current offline provider to use to store scene data
  33888. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33889. */
  33890. offlineProvider: IOfflineProvider;
  33891. /**
  33892. * Gets or sets the action manager associated with the scene
  33893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33894. */
  33895. actionManager: AbstractActionManager;
  33896. private _meshesForIntersections;
  33897. /**
  33898. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33899. */
  33900. proceduralTexturesEnabled: boolean;
  33901. private _engine;
  33902. private _totalVertices;
  33903. /** @hidden */
  33904. _activeIndices: PerfCounter;
  33905. /** @hidden */
  33906. _activeParticles: PerfCounter;
  33907. /** @hidden */
  33908. _activeBones: PerfCounter;
  33909. private _animationRatio;
  33910. /** @hidden */
  33911. _animationTimeLast: number;
  33912. /** @hidden */
  33913. _animationTime: number;
  33914. /**
  33915. * Gets or sets a general scale for animation speed
  33916. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33917. */
  33918. animationTimeScale: number;
  33919. /** @hidden */
  33920. _cachedMaterial: Nullable<Material>;
  33921. /** @hidden */
  33922. _cachedEffect: Nullable<Effect>;
  33923. /** @hidden */
  33924. _cachedVisibility: Nullable<number>;
  33925. private _renderId;
  33926. private _frameId;
  33927. private _executeWhenReadyTimeoutId;
  33928. private _intermediateRendering;
  33929. private _viewUpdateFlag;
  33930. private _projectionUpdateFlag;
  33931. /** @hidden */
  33932. _toBeDisposed: Nullable<IDisposable>[];
  33933. private _activeRequests;
  33934. /** @hidden */
  33935. _pendingData: any[];
  33936. private _isDisposed;
  33937. /**
  33938. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33939. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33940. */
  33941. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33942. private _activeMeshes;
  33943. private _processedMaterials;
  33944. private _renderTargets;
  33945. /** @hidden */
  33946. _activeParticleSystems: SmartArray<IParticleSystem>;
  33947. private _activeSkeletons;
  33948. private _softwareSkinnedMeshes;
  33949. private _renderingManager;
  33950. /** @hidden */
  33951. _activeAnimatables: Animatable[];
  33952. private _transformMatrix;
  33953. private _sceneUbo;
  33954. /** @hidden */
  33955. _viewMatrix: Matrix;
  33956. private _projectionMatrix;
  33957. /** @hidden */
  33958. _forcedViewPosition: Nullable<Vector3>;
  33959. /** @hidden */
  33960. _frustumPlanes: Plane[];
  33961. /**
  33962. * Gets the list of frustum planes (built from the active camera)
  33963. */
  33964. readonly frustumPlanes: Plane[];
  33965. /**
  33966. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33967. * This is useful if there are more lights that the maximum simulteanous authorized
  33968. */
  33969. requireLightSorting: boolean;
  33970. /** @hidden */
  33971. readonly useMaterialMeshMap: boolean;
  33972. /** @hidden */
  33973. readonly useClonedMeshhMap: boolean;
  33974. private _externalData;
  33975. private _uid;
  33976. /**
  33977. * @hidden
  33978. * Backing store of defined scene components.
  33979. */
  33980. _components: ISceneComponent[];
  33981. /**
  33982. * @hidden
  33983. * Backing store of defined scene components.
  33984. */
  33985. _serializableComponents: ISceneSerializableComponent[];
  33986. /**
  33987. * List of components to register on the next registration step.
  33988. */
  33989. private _transientComponents;
  33990. /**
  33991. * Registers the transient components if needed.
  33992. */
  33993. private _registerTransientComponents;
  33994. /**
  33995. * @hidden
  33996. * Add a component to the scene.
  33997. * Note that the ccomponent could be registered on th next frame if this is called after
  33998. * the register component stage.
  33999. * @param component Defines the component to add to the scene
  34000. */
  34001. _addComponent(component: ISceneComponent): void;
  34002. /**
  34003. * @hidden
  34004. * Gets a component from the scene.
  34005. * @param name defines the name of the component to retrieve
  34006. * @returns the component or null if not present
  34007. */
  34008. _getComponent(name: string): Nullable<ISceneComponent>;
  34009. /**
  34010. * @hidden
  34011. * Defines the actions happening before camera updates.
  34012. */
  34013. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34014. /**
  34015. * @hidden
  34016. * Defines the actions happening before clear the canvas.
  34017. */
  34018. _beforeClearStage: Stage<SimpleStageAction>;
  34019. /**
  34020. * @hidden
  34021. * Defines the actions when collecting render targets for the frame.
  34022. */
  34023. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34024. /**
  34025. * @hidden
  34026. * Defines the actions happening for one camera in the frame.
  34027. */
  34028. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34029. /**
  34030. * @hidden
  34031. * Defines the actions happening during the per mesh ready checks.
  34032. */
  34033. _isReadyForMeshStage: Stage<MeshStageAction>;
  34034. /**
  34035. * @hidden
  34036. * Defines the actions happening before evaluate active mesh checks.
  34037. */
  34038. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34039. /**
  34040. * @hidden
  34041. * Defines the actions happening during the evaluate sub mesh checks.
  34042. */
  34043. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34044. /**
  34045. * @hidden
  34046. * Defines the actions happening during the active mesh stage.
  34047. */
  34048. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34049. /**
  34050. * @hidden
  34051. * Defines the actions happening during the per camera render target step.
  34052. */
  34053. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34054. /**
  34055. * @hidden
  34056. * Defines the actions happening just before the active camera is drawing.
  34057. */
  34058. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34059. /**
  34060. * @hidden
  34061. * Defines the actions happening just before a render target is drawing.
  34062. */
  34063. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34064. /**
  34065. * @hidden
  34066. * Defines the actions happening just before a rendering group is drawing.
  34067. */
  34068. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34069. /**
  34070. * @hidden
  34071. * Defines the actions happening just before a mesh is drawing.
  34072. */
  34073. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34074. /**
  34075. * @hidden
  34076. * Defines the actions happening just after a mesh has been drawn.
  34077. */
  34078. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34079. /**
  34080. * @hidden
  34081. * Defines the actions happening just after a rendering group has been drawn.
  34082. */
  34083. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34084. /**
  34085. * @hidden
  34086. * Defines the actions happening just after the active camera has been drawn.
  34087. */
  34088. _afterCameraDrawStage: Stage<CameraStageAction>;
  34089. /**
  34090. * @hidden
  34091. * Defines the actions happening just after a render target has been drawn.
  34092. */
  34093. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34094. /**
  34095. * @hidden
  34096. * Defines the actions happening just after rendering all cameras and computing intersections.
  34097. */
  34098. _afterRenderStage: Stage<SimpleStageAction>;
  34099. /**
  34100. * @hidden
  34101. * Defines the actions happening when a pointer move event happens.
  34102. */
  34103. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34104. /**
  34105. * @hidden
  34106. * Defines the actions happening when a pointer down event happens.
  34107. */
  34108. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34109. /**
  34110. * @hidden
  34111. * Defines the actions happening when a pointer up event happens.
  34112. */
  34113. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34114. /**
  34115. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34116. */
  34117. private geometriesByUniqueId;
  34118. /**
  34119. * Creates a new Scene
  34120. * @param engine defines the engine to use to render this scene
  34121. * @param options defines the scene options
  34122. */
  34123. constructor(engine: Engine, options?: SceneOptions);
  34124. /**
  34125. * Gets a string idenfifying the name of the class
  34126. * @returns "Scene" string
  34127. */
  34128. getClassName(): string;
  34129. private _defaultMeshCandidates;
  34130. /**
  34131. * @hidden
  34132. */
  34133. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34134. private _defaultSubMeshCandidates;
  34135. /**
  34136. * @hidden
  34137. */
  34138. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34139. /**
  34140. * Sets the default candidate providers for the scene.
  34141. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34142. * and getCollidingSubMeshCandidates to their default function
  34143. */
  34144. setDefaultCandidateProviders(): void;
  34145. /**
  34146. * Gets the mesh that is currently under the pointer
  34147. */
  34148. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34149. /**
  34150. * Gets or sets the current on-screen X position of the pointer
  34151. */
  34152. pointerX: number;
  34153. /**
  34154. * Gets or sets the current on-screen Y position of the pointer
  34155. */
  34156. pointerY: number;
  34157. /**
  34158. * Gets the cached material (ie. the latest rendered one)
  34159. * @returns the cached material
  34160. */
  34161. getCachedMaterial(): Nullable<Material>;
  34162. /**
  34163. * Gets the cached effect (ie. the latest rendered one)
  34164. * @returns the cached effect
  34165. */
  34166. getCachedEffect(): Nullable<Effect>;
  34167. /**
  34168. * Gets the cached visibility state (ie. the latest rendered one)
  34169. * @returns the cached visibility state
  34170. */
  34171. getCachedVisibility(): Nullable<number>;
  34172. /**
  34173. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34174. * @param material defines the current material
  34175. * @param effect defines the current effect
  34176. * @param visibility defines the current visibility state
  34177. * @returns true if one parameter is not cached
  34178. */
  34179. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34180. /**
  34181. * Gets the engine associated with the scene
  34182. * @returns an Engine
  34183. */
  34184. getEngine(): Engine;
  34185. /**
  34186. * Gets the total number of vertices rendered per frame
  34187. * @returns the total number of vertices rendered per frame
  34188. */
  34189. getTotalVertices(): number;
  34190. /**
  34191. * Gets the performance counter for total vertices
  34192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34193. */
  34194. readonly totalVerticesPerfCounter: PerfCounter;
  34195. /**
  34196. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34197. * @returns the total number of active indices rendered per frame
  34198. */
  34199. getActiveIndices(): number;
  34200. /**
  34201. * Gets the performance counter for active indices
  34202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34203. */
  34204. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34205. /**
  34206. * Gets the total number of active particles rendered per frame
  34207. * @returns the total number of active particles rendered per frame
  34208. */
  34209. getActiveParticles(): number;
  34210. /**
  34211. * Gets the performance counter for active particles
  34212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34213. */
  34214. readonly activeParticlesPerfCounter: PerfCounter;
  34215. /**
  34216. * Gets the total number of active bones rendered per frame
  34217. * @returns the total number of active bones rendered per frame
  34218. */
  34219. getActiveBones(): number;
  34220. /**
  34221. * Gets the performance counter for active bones
  34222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34223. */
  34224. readonly activeBonesPerfCounter: PerfCounter;
  34225. /**
  34226. * Gets the array of active meshes
  34227. * @returns an array of AbstractMesh
  34228. */
  34229. getActiveMeshes(): SmartArray<AbstractMesh>;
  34230. /**
  34231. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34232. * @returns a number
  34233. */
  34234. getAnimationRatio(): number;
  34235. /**
  34236. * Gets an unique Id for the current render phase
  34237. * @returns a number
  34238. */
  34239. getRenderId(): number;
  34240. /**
  34241. * Gets an unique Id for the current frame
  34242. * @returns a number
  34243. */
  34244. getFrameId(): number;
  34245. /** Call this function if you want to manually increment the render Id*/
  34246. incrementRenderId(): void;
  34247. private _createUbo;
  34248. /**
  34249. * Use this method to simulate a pointer move on a mesh
  34250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34253. * @returns the current scene
  34254. */
  34255. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34256. /**
  34257. * Use this method to simulate a pointer down on a mesh
  34258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34261. * @returns the current scene
  34262. */
  34263. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34264. /**
  34265. * Use this method to simulate a pointer up on a mesh
  34266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34269. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34270. * @returns the current scene
  34271. */
  34272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34273. /**
  34274. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34275. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34276. * @returns true if the pointer was captured
  34277. */
  34278. isPointerCaptured(pointerId?: number): boolean;
  34279. /**
  34280. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34281. * @param attachUp defines if you want to attach events to pointerup
  34282. * @param attachDown defines if you want to attach events to pointerdown
  34283. * @param attachMove defines if you want to attach events to pointermove
  34284. */
  34285. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34286. /** Detaches all event handlers*/
  34287. detachControl(): void;
  34288. /**
  34289. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34290. * Delay loaded resources are not taking in account
  34291. * @return true if all required resources are ready
  34292. */
  34293. isReady(): boolean;
  34294. /** Resets all cached information relative to material (including effect and visibility) */
  34295. resetCachedMaterial(): void;
  34296. /**
  34297. * Registers a function to be called before every frame render
  34298. * @param func defines the function to register
  34299. */
  34300. registerBeforeRender(func: () => void): void;
  34301. /**
  34302. * Unregisters a function called before every frame render
  34303. * @param func defines the function to unregister
  34304. */
  34305. unregisterBeforeRender(func: () => void): void;
  34306. /**
  34307. * Registers a function to be called after every frame render
  34308. * @param func defines the function to register
  34309. */
  34310. registerAfterRender(func: () => void): void;
  34311. /**
  34312. * Unregisters a function called after every frame render
  34313. * @param func defines the function to unregister
  34314. */
  34315. unregisterAfterRender(func: () => void): void;
  34316. private _executeOnceBeforeRender;
  34317. /**
  34318. * The provided function will run before render once and will be disposed afterwards.
  34319. * A timeout delay can be provided so that the function will be executed in N ms.
  34320. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34321. * @param func The function to be executed.
  34322. * @param timeout optional delay in ms
  34323. */
  34324. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34325. /** @hidden */
  34326. _addPendingData(data: any): void;
  34327. /** @hidden */
  34328. _removePendingData(data: any): void;
  34329. /**
  34330. * Returns the number of items waiting to be loaded
  34331. * @returns the number of items waiting to be loaded
  34332. */
  34333. getWaitingItemsCount(): number;
  34334. /**
  34335. * Returns a boolean indicating if the scene is still loading data
  34336. */
  34337. readonly isLoading: boolean;
  34338. /**
  34339. * Registers a function to be executed when the scene is ready
  34340. * @param {Function} func - the function to be executed
  34341. */
  34342. executeWhenReady(func: () => void): void;
  34343. /**
  34344. * Returns a promise that resolves when the scene is ready
  34345. * @returns A promise that resolves when the scene is ready
  34346. */
  34347. whenReadyAsync(): Promise<void>;
  34348. /** @hidden */
  34349. _checkIsReady(): void;
  34350. /**
  34351. * Gets all animatable attached to the scene
  34352. */
  34353. readonly animatables: Animatable[];
  34354. /**
  34355. * Resets the last animation time frame.
  34356. * Useful to override when animations start running when loading a scene for the first time.
  34357. */
  34358. resetLastAnimationTimeFrame(): void;
  34359. /**
  34360. * Gets the current view matrix
  34361. * @returns a Matrix
  34362. */
  34363. getViewMatrix(): Matrix;
  34364. /**
  34365. * Gets the current projection matrix
  34366. * @returns a Matrix
  34367. */
  34368. getProjectionMatrix(): Matrix;
  34369. /**
  34370. * Gets the current transform matrix
  34371. * @returns a Matrix made of View * Projection
  34372. */
  34373. getTransformMatrix(): Matrix;
  34374. /**
  34375. * Sets the current transform matrix
  34376. * @param viewL defines the View matrix to use
  34377. * @param projectionL defines the Projection matrix to use
  34378. * @param viewR defines the right View matrix to use (if provided)
  34379. * @param projectionR defines the right Projection matrix to use (if provided)
  34380. */
  34381. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34382. /**
  34383. * Gets the uniform buffer used to store scene data
  34384. * @returns a UniformBuffer
  34385. */
  34386. getSceneUniformBuffer(): UniformBuffer;
  34387. /**
  34388. * Gets an unique (relatively to the current scene) Id
  34389. * @returns an unique number for the scene
  34390. */
  34391. getUniqueId(): number;
  34392. /**
  34393. * Add a mesh to the list of scene's meshes
  34394. * @param newMesh defines the mesh to add
  34395. * @param recursive if all child meshes should also be added to the scene
  34396. */
  34397. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34398. /**
  34399. * Remove a mesh for the list of scene's meshes
  34400. * @param toRemove defines the mesh to remove
  34401. * @param recursive if all child meshes should also be removed from the scene
  34402. * @returns the index where the mesh was in the mesh list
  34403. */
  34404. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34405. /**
  34406. * Add a transform node to the list of scene's transform nodes
  34407. * @param newTransformNode defines the transform node to add
  34408. */
  34409. addTransformNode(newTransformNode: TransformNode): void;
  34410. /**
  34411. * Remove a transform node for the list of scene's transform nodes
  34412. * @param toRemove defines the transform node to remove
  34413. * @returns the index where the transform node was in the transform node list
  34414. */
  34415. removeTransformNode(toRemove: TransformNode): number;
  34416. /**
  34417. * Remove a skeleton for the list of scene's skeletons
  34418. * @param toRemove defines the skeleton to remove
  34419. * @returns the index where the skeleton was in the skeleton list
  34420. */
  34421. removeSkeleton(toRemove: Skeleton): number;
  34422. /**
  34423. * Remove a morph target for the list of scene's morph targets
  34424. * @param toRemove defines the morph target to remove
  34425. * @returns the index where the morph target was in the morph target list
  34426. */
  34427. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34428. /**
  34429. * Remove a light for the list of scene's lights
  34430. * @param toRemove defines the light to remove
  34431. * @returns the index where the light was in the light list
  34432. */
  34433. removeLight(toRemove: Light): number;
  34434. /**
  34435. * Remove a camera for the list of scene's cameras
  34436. * @param toRemove defines the camera to remove
  34437. * @returns the index where the camera was in the camera list
  34438. */
  34439. removeCamera(toRemove: Camera): number;
  34440. /**
  34441. * Remove a particle system for the list of scene's particle systems
  34442. * @param toRemove defines the particle system to remove
  34443. * @returns the index where the particle system was in the particle system list
  34444. */
  34445. removeParticleSystem(toRemove: IParticleSystem): number;
  34446. /**
  34447. * Remove a animation for the list of scene's animations
  34448. * @param toRemove defines the animation to remove
  34449. * @returns the index where the animation was in the animation list
  34450. */
  34451. removeAnimation(toRemove: Animation): number;
  34452. /**
  34453. * Will stop the animation of the given target
  34454. * @param target - the target
  34455. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34456. * @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)
  34457. */
  34458. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34459. /**
  34460. * Removes the given animation group from this scene.
  34461. * @param toRemove The animation group to remove
  34462. * @returns The index of the removed animation group
  34463. */
  34464. removeAnimationGroup(toRemove: AnimationGroup): number;
  34465. /**
  34466. * Removes the given multi-material from this scene.
  34467. * @param toRemove The multi-material to remove
  34468. * @returns The index of the removed multi-material
  34469. */
  34470. removeMultiMaterial(toRemove: MultiMaterial): number;
  34471. /**
  34472. * Removes the given material from this scene.
  34473. * @param toRemove The material to remove
  34474. * @returns The index of the removed material
  34475. */
  34476. removeMaterial(toRemove: Material): number;
  34477. /**
  34478. * Removes the given action manager from this scene.
  34479. * @param toRemove The action manager to remove
  34480. * @returns The index of the removed action manager
  34481. */
  34482. removeActionManager(toRemove: AbstractActionManager): number;
  34483. /**
  34484. * Removes the given texture from this scene.
  34485. * @param toRemove The texture to remove
  34486. * @returns The index of the removed texture
  34487. */
  34488. removeTexture(toRemove: BaseTexture): number;
  34489. /**
  34490. * Adds the given light to this scene
  34491. * @param newLight The light to add
  34492. */
  34493. addLight(newLight: Light): void;
  34494. /**
  34495. * Sorts the list list based on light priorities
  34496. */
  34497. sortLightsByPriority(): void;
  34498. /**
  34499. * Adds the given camera to this scene
  34500. * @param newCamera The camera to add
  34501. */
  34502. addCamera(newCamera: Camera): void;
  34503. /**
  34504. * Adds the given skeleton to this scene
  34505. * @param newSkeleton The skeleton to add
  34506. */
  34507. addSkeleton(newSkeleton: Skeleton): void;
  34508. /**
  34509. * Adds the given particle system to this scene
  34510. * @param newParticleSystem The particle system to add
  34511. */
  34512. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34513. /**
  34514. * Adds the given animation to this scene
  34515. * @param newAnimation The animation to add
  34516. */
  34517. addAnimation(newAnimation: Animation): void;
  34518. /**
  34519. * Adds the given animation group to this scene.
  34520. * @param newAnimationGroup The animation group to add
  34521. */
  34522. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34523. /**
  34524. * Adds the given multi-material to this scene
  34525. * @param newMultiMaterial The multi-material to add
  34526. */
  34527. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34528. /**
  34529. * Adds the given material to this scene
  34530. * @param newMaterial The material to add
  34531. */
  34532. addMaterial(newMaterial: Material): void;
  34533. /**
  34534. * Adds the given morph target to this scene
  34535. * @param newMorphTargetManager The morph target to add
  34536. */
  34537. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34538. /**
  34539. * Adds the given geometry to this scene
  34540. * @param newGeometry The geometry to add
  34541. */
  34542. addGeometry(newGeometry: Geometry): void;
  34543. /**
  34544. * Adds the given action manager to this scene
  34545. * @param newActionManager The action manager to add
  34546. */
  34547. addActionManager(newActionManager: AbstractActionManager): void;
  34548. /**
  34549. * Adds the given texture to this scene.
  34550. * @param newTexture The texture to add
  34551. */
  34552. addTexture(newTexture: BaseTexture): void;
  34553. /**
  34554. * Switch active camera
  34555. * @param newCamera defines the new active camera
  34556. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34557. */
  34558. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34559. /**
  34560. * sets the active camera of the scene using its ID
  34561. * @param id defines the camera's ID
  34562. * @return the new active camera or null if none found.
  34563. */
  34564. setActiveCameraByID(id: string): Nullable<Camera>;
  34565. /**
  34566. * sets the active camera of the scene using its name
  34567. * @param name defines the camera's name
  34568. * @returns the new active camera or null if none found.
  34569. */
  34570. setActiveCameraByName(name: string): Nullable<Camera>;
  34571. /**
  34572. * get an animation group using its name
  34573. * @param name defines the material's name
  34574. * @return the animation group or null if none found.
  34575. */
  34576. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34577. /**
  34578. * Get a material using its unique id
  34579. * @param uniqueId defines the material's unique id
  34580. * @return the material or null if none found.
  34581. */
  34582. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34583. /**
  34584. * get a material using its id
  34585. * @param id defines the material's ID
  34586. * @return the material or null if none found.
  34587. */
  34588. getMaterialByID(id: string): Nullable<Material>;
  34589. /**
  34590. * Gets a the last added material using a given id
  34591. * @param id defines the material's ID
  34592. * @return the last material with the given id or null if none found.
  34593. */
  34594. getLastMaterialByID(id: string): Nullable<Material>;
  34595. /**
  34596. * Gets a material using its name
  34597. * @param name defines the material's name
  34598. * @return the material or null if none found.
  34599. */
  34600. getMaterialByName(name: string): Nullable<Material>;
  34601. /**
  34602. * Get a texture using its unique id
  34603. * @param uniqueId defines the texture's unique id
  34604. * @return the texture or null if none found.
  34605. */
  34606. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34607. /**
  34608. * Gets a camera using its id
  34609. * @param id defines the id to look for
  34610. * @returns the camera or null if not found
  34611. */
  34612. getCameraByID(id: string): Nullable<Camera>;
  34613. /**
  34614. * Gets a camera using its unique id
  34615. * @param uniqueId defines the unique id to look for
  34616. * @returns the camera or null if not found
  34617. */
  34618. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34619. /**
  34620. * Gets a camera using its name
  34621. * @param name defines the camera's name
  34622. * @return the camera or null if none found.
  34623. */
  34624. getCameraByName(name: string): Nullable<Camera>;
  34625. /**
  34626. * Gets a bone using its id
  34627. * @param id defines the bone's id
  34628. * @return the bone or null if not found
  34629. */
  34630. getBoneByID(id: string): Nullable<Bone>;
  34631. /**
  34632. * Gets a bone using its id
  34633. * @param name defines the bone's name
  34634. * @return the bone or null if not found
  34635. */
  34636. getBoneByName(name: string): Nullable<Bone>;
  34637. /**
  34638. * Gets a light node using its name
  34639. * @param name defines the the light's name
  34640. * @return the light or null if none found.
  34641. */
  34642. getLightByName(name: string): Nullable<Light>;
  34643. /**
  34644. * Gets a light node using its id
  34645. * @param id defines the light's id
  34646. * @return the light or null if none found.
  34647. */
  34648. getLightByID(id: string): Nullable<Light>;
  34649. /**
  34650. * Gets a light node using its scene-generated unique ID
  34651. * @param uniqueId defines the light's unique id
  34652. * @return the light or null if none found.
  34653. */
  34654. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34655. /**
  34656. * Gets a particle system by id
  34657. * @param id defines the particle system id
  34658. * @return the corresponding system or null if none found
  34659. */
  34660. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34661. /**
  34662. * Gets a geometry using its ID
  34663. * @param id defines the geometry's id
  34664. * @return the geometry or null if none found.
  34665. */
  34666. getGeometryByID(id: string): Nullable<Geometry>;
  34667. private _getGeometryByUniqueID;
  34668. /**
  34669. * Add a new geometry to this scene
  34670. * @param geometry defines the geometry to be added to the scene.
  34671. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34672. * @return a boolean defining if the geometry was added or not
  34673. */
  34674. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34675. /**
  34676. * Removes an existing geometry
  34677. * @param geometry defines the geometry to be removed from the scene
  34678. * @return a boolean defining if the geometry was removed or not
  34679. */
  34680. removeGeometry(geometry: Geometry): boolean;
  34681. /**
  34682. * Gets the list of geometries attached to the scene
  34683. * @returns an array of Geometry
  34684. */
  34685. getGeometries(): Geometry[];
  34686. /**
  34687. * Gets the first added mesh found of a given ID
  34688. * @param id defines the id to search for
  34689. * @return the mesh found or null if not found at all
  34690. */
  34691. getMeshByID(id: string): Nullable<AbstractMesh>;
  34692. /**
  34693. * Gets a list of meshes using their id
  34694. * @param id defines the id to search for
  34695. * @returns a list of meshes
  34696. */
  34697. getMeshesByID(id: string): Array<AbstractMesh>;
  34698. /**
  34699. * Gets the first added transform node found of a given ID
  34700. * @param id defines the id to search for
  34701. * @return the found transform node or null if not found at all.
  34702. */
  34703. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34704. /**
  34705. * Gets a transform node with its auto-generated unique id
  34706. * @param uniqueId efines the unique id to search for
  34707. * @return the found transform node or null if not found at all.
  34708. */
  34709. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34710. /**
  34711. * Gets a list of transform nodes using their id
  34712. * @param id defines the id to search for
  34713. * @returns a list of transform nodes
  34714. */
  34715. getTransformNodesByID(id: string): Array<TransformNode>;
  34716. /**
  34717. * Gets a mesh with its auto-generated unique id
  34718. * @param uniqueId defines the unique id to search for
  34719. * @return the found mesh or null if not found at all.
  34720. */
  34721. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34722. /**
  34723. * Gets a the last added mesh using a given id
  34724. * @param id defines the id to search for
  34725. * @return the found mesh or null if not found at all.
  34726. */
  34727. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34728. /**
  34729. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34730. * @param id defines the id to search for
  34731. * @return the found node or null if not found at all
  34732. */
  34733. getLastEntryByID(id: string): Nullable<Node>;
  34734. /**
  34735. * Gets a node (Mesh, Camera, Light) using a given id
  34736. * @param id defines the id to search for
  34737. * @return the found node or null if not found at all
  34738. */
  34739. getNodeByID(id: string): Nullable<Node>;
  34740. /**
  34741. * Gets a node (Mesh, Camera, Light) using a given name
  34742. * @param name defines the name to search for
  34743. * @return the found node or null if not found at all.
  34744. */
  34745. getNodeByName(name: string): Nullable<Node>;
  34746. /**
  34747. * Gets a mesh using a given name
  34748. * @param name defines the name to search for
  34749. * @return the found mesh or null if not found at all.
  34750. */
  34751. getMeshByName(name: string): Nullable<AbstractMesh>;
  34752. /**
  34753. * Gets a transform node using a given name
  34754. * @param name defines the name to search for
  34755. * @return the found transform node or null if not found at all.
  34756. */
  34757. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34758. /**
  34759. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34760. * @param id defines the id to search for
  34761. * @return the found skeleton or null if not found at all.
  34762. */
  34763. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34764. /**
  34765. * Gets a skeleton using a given auto generated unique id
  34766. * @param uniqueId defines the unique id to search for
  34767. * @return the found skeleton or null if not found at all.
  34768. */
  34769. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34770. /**
  34771. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34772. * @param id defines the id to search for
  34773. * @return the found skeleton or null if not found at all.
  34774. */
  34775. getSkeletonById(id: string): Nullable<Skeleton>;
  34776. /**
  34777. * Gets a skeleton using a given name
  34778. * @param name defines the name to search for
  34779. * @return the found skeleton or null if not found at all.
  34780. */
  34781. getSkeletonByName(name: string): Nullable<Skeleton>;
  34782. /**
  34783. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34784. * @param id defines the id to search for
  34785. * @return the found morph target manager or null if not found at all.
  34786. */
  34787. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34788. /**
  34789. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34790. * @param id defines the id to search for
  34791. * @return the found morph target or null if not found at all.
  34792. */
  34793. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34794. /**
  34795. * Gets a boolean indicating if the given mesh is active
  34796. * @param mesh defines the mesh to look for
  34797. * @returns true if the mesh is in the active list
  34798. */
  34799. isActiveMesh(mesh: AbstractMesh): boolean;
  34800. /**
  34801. * Return a unique id as a string which can serve as an identifier for the scene
  34802. */
  34803. readonly uid: string;
  34804. /**
  34805. * Add an externaly attached data from its key.
  34806. * This method call will fail and return false, if such key already exists.
  34807. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34808. * @param key the unique key that identifies the data
  34809. * @param data the data object to associate to the key for this Engine instance
  34810. * @return true if no such key were already present and the data was added successfully, false otherwise
  34811. */
  34812. addExternalData<T>(key: string, data: T): boolean;
  34813. /**
  34814. * Get an externaly attached data from its key
  34815. * @param key the unique key that identifies the data
  34816. * @return the associated data, if present (can be null), or undefined if not present
  34817. */
  34818. getExternalData<T>(key: string): Nullable<T>;
  34819. /**
  34820. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34821. * @param key the unique key that identifies the data
  34822. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34823. * @return the associated data, can be null if the factory returned null.
  34824. */
  34825. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34826. /**
  34827. * Remove an externaly attached data from the Engine instance
  34828. * @param key the unique key that identifies the data
  34829. * @return true if the data was successfully removed, false if it doesn't exist
  34830. */
  34831. removeExternalData(key: string): boolean;
  34832. private _evaluateSubMesh;
  34833. /**
  34834. * Clear the processed materials smart array preventing retention point in material dispose.
  34835. */
  34836. freeProcessedMaterials(): void;
  34837. private _preventFreeActiveMeshesAndRenderingGroups;
  34838. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34839. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34840. * when disposing several meshes in a row or a hierarchy of meshes.
  34841. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34842. */
  34843. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34844. /**
  34845. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34846. */
  34847. freeActiveMeshes(): void;
  34848. /**
  34849. * Clear the info related to rendering groups preventing retention points during dispose.
  34850. */
  34851. freeRenderingGroups(): void;
  34852. /** @hidden */
  34853. _isInIntermediateRendering(): boolean;
  34854. /**
  34855. * Lambda returning the list of potentially active meshes.
  34856. */
  34857. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34858. /**
  34859. * Lambda returning the list of potentially active sub meshes.
  34860. */
  34861. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34862. /**
  34863. * Lambda returning the list of potentially intersecting sub meshes.
  34864. */
  34865. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34866. /**
  34867. * Lambda returning the list of potentially colliding sub meshes.
  34868. */
  34869. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34870. private _activeMeshesFrozen;
  34871. /**
  34872. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34873. * @returns the current scene
  34874. */
  34875. freezeActiveMeshes(): Scene;
  34876. /**
  34877. * Use this function to restart evaluating active meshes on every frame
  34878. * @returns the current scene
  34879. */
  34880. unfreezeActiveMeshes(): Scene;
  34881. private _evaluateActiveMeshes;
  34882. private _activeMesh;
  34883. /**
  34884. * Update the transform matrix to update from the current active camera
  34885. * @param force defines a boolean used to force the update even if cache is up to date
  34886. */
  34887. updateTransformMatrix(force?: boolean): void;
  34888. private _bindFrameBuffer;
  34889. /** @hidden */
  34890. _allowPostProcessClearColor: boolean;
  34891. /** @hidden */
  34892. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34893. private _processSubCameras;
  34894. private _checkIntersections;
  34895. /** @hidden */
  34896. _advancePhysicsEngineStep(step: number): void;
  34897. /**
  34898. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34899. */
  34900. getDeterministicFrameTime: () => number;
  34901. /** @hidden */
  34902. _animate(): void;
  34903. /** Execute all animations (for a frame) */
  34904. animate(): void;
  34905. /**
  34906. * Render the scene
  34907. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34908. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34909. */
  34910. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34911. /**
  34912. * Freeze all materials
  34913. * A frozen material will not be updatable but should be faster to render
  34914. */
  34915. freezeMaterials(): void;
  34916. /**
  34917. * Unfreeze all materials
  34918. * A frozen material will not be updatable but should be faster to render
  34919. */
  34920. unfreezeMaterials(): void;
  34921. /**
  34922. * Releases all held ressources
  34923. */
  34924. dispose(): void;
  34925. /**
  34926. * Gets if the scene is already disposed
  34927. */
  34928. readonly isDisposed: boolean;
  34929. /**
  34930. * Call this function to reduce memory footprint of the scene.
  34931. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34932. */
  34933. clearCachedVertexData(): void;
  34934. /**
  34935. * This function will remove the local cached buffer data from texture.
  34936. * It will save memory but will prevent the texture from being rebuilt
  34937. */
  34938. cleanCachedTextureBuffer(): void;
  34939. /**
  34940. * Get the world extend vectors with an optional filter
  34941. *
  34942. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34943. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34944. */
  34945. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34946. min: Vector3;
  34947. max: Vector3;
  34948. };
  34949. /**
  34950. * Creates a ray that can be used to pick in the scene
  34951. * @param x defines the x coordinate of the origin (on-screen)
  34952. * @param y defines the y coordinate of the origin (on-screen)
  34953. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34954. * @param camera defines the camera to use for the picking
  34955. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34956. * @returns a Ray
  34957. */
  34958. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34959. /**
  34960. * Creates a ray that can be used to pick in the scene
  34961. * @param x defines the x coordinate of the origin (on-screen)
  34962. * @param y defines the y coordinate of the origin (on-screen)
  34963. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34964. * @param result defines the ray where to store the picking ray
  34965. * @param camera defines the camera to use for the picking
  34966. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34967. * @returns the current scene
  34968. */
  34969. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34970. /**
  34971. * Creates a ray that can be used to pick in the scene
  34972. * @param x defines the x coordinate of the origin (on-screen)
  34973. * @param y defines the y coordinate of the origin (on-screen)
  34974. * @param camera defines the camera to use for the picking
  34975. * @returns a Ray
  34976. */
  34977. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34978. /**
  34979. * Creates a ray that can be used to pick in the scene
  34980. * @param x defines the x coordinate of the origin (on-screen)
  34981. * @param y defines the y coordinate of the origin (on-screen)
  34982. * @param result defines the ray where to store the picking ray
  34983. * @param camera defines the camera to use for the picking
  34984. * @returns the current scene
  34985. */
  34986. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34987. /** Launch a ray to try to pick a mesh in the scene
  34988. * @param x position on screen
  34989. * @param y position on screen
  34990. * @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
  34991. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34992. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34993. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34994. * @returns a PickingInfo
  34995. */
  34996. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34997. /** Use the given ray to pick a mesh in the scene
  34998. * @param ray The ray to use to pick meshes
  34999. * @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
  35000. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35001. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35002. * @returns a PickingInfo
  35003. */
  35004. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35005. /**
  35006. * Launch a ray to try to pick a mesh in the scene
  35007. * @param x X position on screen
  35008. * @param y Y position on screen
  35009. * @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
  35010. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35011. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35012. * @returns an array of PickingInfo
  35013. */
  35014. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35015. /**
  35016. * Launch a ray to try to pick a mesh in the scene
  35017. * @param ray Ray to use
  35018. * @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
  35019. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35020. * @returns an array of PickingInfo
  35021. */
  35022. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35023. /**
  35024. * Force the value of meshUnderPointer
  35025. * @param mesh defines the mesh to use
  35026. */
  35027. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35028. /**
  35029. * Gets the mesh under the pointer
  35030. * @returns a Mesh or null if no mesh is under the pointer
  35031. */
  35032. getPointerOverMesh(): Nullable<AbstractMesh>;
  35033. /** @hidden */
  35034. _rebuildGeometries(): void;
  35035. /** @hidden */
  35036. _rebuildTextures(): void;
  35037. private _getByTags;
  35038. /**
  35039. * Get a list of meshes by tags
  35040. * @param tagsQuery defines the tags query to use
  35041. * @param forEach defines a predicate used to filter results
  35042. * @returns an array of Mesh
  35043. */
  35044. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35045. /**
  35046. * Get a list of cameras by tags
  35047. * @param tagsQuery defines the tags query to use
  35048. * @param forEach defines a predicate used to filter results
  35049. * @returns an array of Camera
  35050. */
  35051. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35052. /**
  35053. * Get a list of lights by tags
  35054. * @param tagsQuery defines the tags query to use
  35055. * @param forEach defines a predicate used to filter results
  35056. * @returns an array of Light
  35057. */
  35058. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35059. /**
  35060. * Get a list of materials by tags
  35061. * @param tagsQuery defines the tags query to use
  35062. * @param forEach defines a predicate used to filter results
  35063. * @returns an array of Material
  35064. */
  35065. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35066. /**
  35067. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35068. * This allowed control for front to back rendering or reversly depending of the special needs.
  35069. *
  35070. * @param renderingGroupId The rendering group id corresponding to its index
  35071. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35072. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35073. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35074. */
  35075. 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;
  35076. /**
  35077. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35078. *
  35079. * @param renderingGroupId The rendering group id corresponding to its index
  35080. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35081. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35082. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35083. */
  35084. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35085. /**
  35086. * Gets the current auto clear configuration for one rendering group of the rendering
  35087. * manager.
  35088. * @param index the rendering group index to get the information for
  35089. * @returns The auto clear setup for the requested rendering group
  35090. */
  35091. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35092. private _blockMaterialDirtyMechanism;
  35093. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35094. blockMaterialDirtyMechanism: boolean;
  35095. /**
  35096. * Will flag all materials as dirty to trigger new shader compilation
  35097. * @param flag defines the flag used to specify which material part must be marked as dirty
  35098. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35099. */
  35100. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35101. /** @hidden */
  35102. _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;
  35103. /** @hidden */
  35104. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35105. /** @hidden */
  35106. _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;
  35107. /** @hidden */
  35108. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35109. /** @hidden */
  35110. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35111. /** @hidden */
  35112. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35113. }
  35114. }
  35115. declare module BABYLON {
  35116. /**
  35117. * Set of assets to keep when moving a scene into an asset container.
  35118. */
  35119. export class KeepAssets extends AbstractScene {
  35120. }
  35121. /**
  35122. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35123. */
  35124. export class InstantiatedEntries {
  35125. /**
  35126. * List of new root nodes (eg. nodes with no parent)
  35127. */
  35128. rootNodes: TransformNode[];
  35129. /**
  35130. * List of new skeletons
  35131. */
  35132. skeletons: Skeleton[];
  35133. /**
  35134. * List of new animation groups
  35135. */
  35136. animationGroups: AnimationGroup[];
  35137. }
  35138. /**
  35139. * Container with a set of assets that can be added or removed from a scene.
  35140. */
  35141. export class AssetContainer extends AbstractScene {
  35142. /**
  35143. * The scene the AssetContainer belongs to.
  35144. */
  35145. scene: Scene;
  35146. /**
  35147. * Instantiates an AssetContainer.
  35148. * @param scene The scene the AssetContainer belongs to.
  35149. */
  35150. constructor(scene: Scene);
  35151. /**
  35152. * Instantiate or clone all meshes and add the new ones to the scene.
  35153. * Skeletons and animation groups will all be cloned
  35154. * @param nameFunction defines an optional function used to get new names for clones
  35155. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  35156. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35157. */
  35158. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  35159. /**
  35160. * Adds all the assets from the container to the scene.
  35161. */
  35162. addAllToScene(): void;
  35163. /**
  35164. * Removes all the assets in the container from the scene
  35165. */
  35166. removeAllFromScene(): void;
  35167. /**
  35168. * Disposes all the assets in the container
  35169. */
  35170. dispose(): void;
  35171. private _moveAssets;
  35172. /**
  35173. * Removes all the assets contained in the scene and adds them to the container.
  35174. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35175. */
  35176. moveAllFromScene(keepAssets?: KeepAssets): void;
  35177. /**
  35178. * 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.
  35179. * @returns the root mesh
  35180. */
  35181. createRootMesh(): Mesh;
  35182. }
  35183. }
  35184. declare module BABYLON {
  35185. /**
  35186. * Defines how the parser contract is defined.
  35187. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35188. */
  35189. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35190. /**
  35191. * Defines how the individual parser contract is defined.
  35192. * These parser can parse an individual asset
  35193. */
  35194. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35195. /**
  35196. * Base class of the scene acting as a container for the different elements composing a scene.
  35197. * This class is dynamically extended by the different components of the scene increasing
  35198. * flexibility and reducing coupling
  35199. */
  35200. export abstract class AbstractScene {
  35201. /**
  35202. * Stores the list of available parsers in the application.
  35203. */
  35204. private static _BabylonFileParsers;
  35205. /**
  35206. * Stores the list of available individual parsers in the application.
  35207. */
  35208. private static _IndividualBabylonFileParsers;
  35209. /**
  35210. * Adds a parser in the list of available ones
  35211. * @param name Defines the name of the parser
  35212. * @param parser Defines the parser to add
  35213. */
  35214. static AddParser(name: string, parser: BabylonFileParser): void;
  35215. /**
  35216. * Gets a general parser from the list of avaialble ones
  35217. * @param name Defines the name of the parser
  35218. * @returns the requested parser or null
  35219. */
  35220. static GetParser(name: string): Nullable<BabylonFileParser>;
  35221. /**
  35222. * Adds n individual parser in the list of available ones
  35223. * @param name Defines the name of the parser
  35224. * @param parser Defines the parser to add
  35225. */
  35226. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35227. /**
  35228. * Gets an individual parser from the list of avaialble ones
  35229. * @param name Defines the name of the parser
  35230. * @returns the requested parser or null
  35231. */
  35232. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35233. /**
  35234. * Parser json data and populate both a scene and its associated container object
  35235. * @param jsonData Defines the data to parse
  35236. * @param scene Defines the scene to parse the data for
  35237. * @param container Defines the container attached to the parsing sequence
  35238. * @param rootUrl Defines the root url of the data
  35239. */
  35240. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35241. /**
  35242. * Gets the list of root nodes (ie. nodes with no parent)
  35243. */
  35244. rootNodes: Node[];
  35245. /** All of the cameras added to this scene
  35246. * @see http://doc.babylonjs.com/babylon101/cameras
  35247. */
  35248. cameras: Camera[];
  35249. /**
  35250. * All of the lights added to this scene
  35251. * @see http://doc.babylonjs.com/babylon101/lights
  35252. */
  35253. lights: Light[];
  35254. /**
  35255. * All of the (abstract) meshes added to this scene
  35256. */
  35257. meshes: AbstractMesh[];
  35258. /**
  35259. * The list of skeletons added to the scene
  35260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35261. */
  35262. skeletons: Skeleton[];
  35263. /**
  35264. * All of the particle systems added to this scene
  35265. * @see http://doc.babylonjs.com/babylon101/particles
  35266. */
  35267. particleSystems: IParticleSystem[];
  35268. /**
  35269. * Gets a list of Animations associated with the scene
  35270. */
  35271. animations: Animation[];
  35272. /**
  35273. * All of the animation groups added to this scene
  35274. * @see http://doc.babylonjs.com/how_to/group
  35275. */
  35276. animationGroups: AnimationGroup[];
  35277. /**
  35278. * All of the multi-materials added to this scene
  35279. * @see http://doc.babylonjs.com/how_to/multi_materials
  35280. */
  35281. multiMaterials: MultiMaterial[];
  35282. /**
  35283. * All of the materials added to this scene
  35284. * In the context of a Scene, it is not supposed to be modified manually.
  35285. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  35286. * Note also that the order of the Material within the array is not significant and might change.
  35287. * @see http://doc.babylonjs.com/babylon101/materials
  35288. */
  35289. materials: Material[];
  35290. /**
  35291. * The list of morph target managers added to the scene
  35292. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35293. */
  35294. morphTargetManagers: MorphTargetManager[];
  35295. /**
  35296. * The list of geometries used in the scene.
  35297. */
  35298. geometries: Geometry[];
  35299. /**
  35300. * All of the tranform nodes added to this scene
  35301. * In the context of a Scene, it is not supposed to be modified manually.
  35302. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35303. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35304. * @see http://doc.babylonjs.com/how_to/transformnode
  35305. */
  35306. transformNodes: TransformNode[];
  35307. /**
  35308. * ActionManagers available on the scene.
  35309. */
  35310. actionManagers: AbstractActionManager[];
  35311. /**
  35312. * Textures to keep.
  35313. */
  35314. textures: BaseTexture[];
  35315. /**
  35316. * Environment texture for the scene
  35317. */
  35318. environmentTexture: Nullable<BaseTexture>;
  35319. }
  35320. }
  35321. declare module BABYLON {
  35322. /**
  35323. * Interface used to define options for Sound class
  35324. */
  35325. export interface ISoundOptions {
  35326. /**
  35327. * Does the sound autoplay once loaded.
  35328. */
  35329. autoplay?: boolean;
  35330. /**
  35331. * Does the sound loop after it finishes playing once.
  35332. */
  35333. loop?: boolean;
  35334. /**
  35335. * Sound's volume
  35336. */
  35337. volume?: number;
  35338. /**
  35339. * Is it a spatial sound?
  35340. */
  35341. spatialSound?: boolean;
  35342. /**
  35343. * Maximum distance to hear that sound
  35344. */
  35345. maxDistance?: number;
  35346. /**
  35347. * Uses user defined attenuation function
  35348. */
  35349. useCustomAttenuation?: boolean;
  35350. /**
  35351. * Define the roll off factor of spatial sounds.
  35352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35353. */
  35354. rolloffFactor?: number;
  35355. /**
  35356. * Define the reference distance the sound should be heard perfectly.
  35357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35358. */
  35359. refDistance?: number;
  35360. /**
  35361. * Define the distance attenuation model the sound will follow.
  35362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35363. */
  35364. distanceModel?: string;
  35365. /**
  35366. * Defines the playback speed (1 by default)
  35367. */
  35368. playbackRate?: number;
  35369. /**
  35370. * Defines if the sound is from a streaming source
  35371. */
  35372. streaming?: boolean;
  35373. /**
  35374. * Defines an optional length (in seconds) inside the sound file
  35375. */
  35376. length?: number;
  35377. /**
  35378. * Defines an optional offset (in seconds) inside the sound file
  35379. */
  35380. offset?: number;
  35381. /**
  35382. * If true, URLs will not be required to state the audio file codec to use.
  35383. */
  35384. skipCodecCheck?: boolean;
  35385. }
  35386. /**
  35387. * Defines a sound that can be played in the application.
  35388. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35390. */
  35391. export class Sound {
  35392. /**
  35393. * The name of the sound in the scene.
  35394. */
  35395. name: string;
  35396. /**
  35397. * Does the sound autoplay once loaded.
  35398. */
  35399. autoplay: boolean;
  35400. /**
  35401. * Does the sound loop after it finishes playing once.
  35402. */
  35403. loop: boolean;
  35404. /**
  35405. * Does the sound use a custom attenuation curve to simulate the falloff
  35406. * happening when the source gets further away from the camera.
  35407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35408. */
  35409. useCustomAttenuation: boolean;
  35410. /**
  35411. * The sound track id this sound belongs to.
  35412. */
  35413. soundTrackId: number;
  35414. /**
  35415. * Is this sound currently played.
  35416. */
  35417. isPlaying: boolean;
  35418. /**
  35419. * Is this sound currently paused.
  35420. */
  35421. isPaused: boolean;
  35422. /**
  35423. * Does this sound enables spatial sound.
  35424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35425. */
  35426. spatialSound: boolean;
  35427. /**
  35428. * Define the reference distance the sound should be heard perfectly.
  35429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35430. */
  35431. refDistance: number;
  35432. /**
  35433. * Define the roll off factor of spatial sounds.
  35434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35435. */
  35436. rolloffFactor: number;
  35437. /**
  35438. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35440. */
  35441. maxDistance: number;
  35442. /**
  35443. * Define the distance attenuation model the sound will follow.
  35444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35445. */
  35446. distanceModel: string;
  35447. /**
  35448. * @hidden
  35449. * Back Compat
  35450. **/
  35451. onended: () => any;
  35452. /**
  35453. * Observable event when the current playing sound finishes.
  35454. */
  35455. onEndedObservable: Observable<Sound>;
  35456. private _panningModel;
  35457. private _playbackRate;
  35458. private _streaming;
  35459. private _startTime;
  35460. private _startOffset;
  35461. private _position;
  35462. /** @hidden */
  35463. _positionInEmitterSpace: boolean;
  35464. private _localDirection;
  35465. private _volume;
  35466. private _isReadyToPlay;
  35467. private _isDirectional;
  35468. private _readyToPlayCallback;
  35469. private _audioBuffer;
  35470. private _soundSource;
  35471. private _streamingSource;
  35472. private _soundPanner;
  35473. private _soundGain;
  35474. private _inputAudioNode;
  35475. private _outputAudioNode;
  35476. private _coneInnerAngle;
  35477. private _coneOuterAngle;
  35478. private _coneOuterGain;
  35479. private _scene;
  35480. private _connectedTransformNode;
  35481. private _customAttenuationFunction;
  35482. private _registerFunc;
  35483. private _isOutputConnected;
  35484. private _htmlAudioElement;
  35485. private _urlType;
  35486. private _length?;
  35487. private _offset?;
  35488. /** @hidden */
  35489. static _SceneComponentInitialization: (scene: Scene) => void;
  35490. /**
  35491. * Create a sound and attach it to a scene
  35492. * @param name Name of your sound
  35493. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35494. * @param scene defines the scene the sound belongs to
  35495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35497. */
  35498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35499. /**
  35500. * Release the sound and its associated resources
  35501. */
  35502. dispose(): void;
  35503. /**
  35504. * Gets if the sounds is ready to be played or not.
  35505. * @returns true if ready, otherwise false
  35506. */
  35507. isReady(): boolean;
  35508. private _soundLoaded;
  35509. /**
  35510. * Sets the data of the sound from an audiobuffer
  35511. * @param audioBuffer The audioBuffer containing the data
  35512. */
  35513. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35514. /**
  35515. * Updates the current sounds options such as maxdistance, loop...
  35516. * @param options A JSON object containing values named as the object properties
  35517. */
  35518. updateOptions(options: ISoundOptions): void;
  35519. private _createSpatialParameters;
  35520. private _updateSpatialParameters;
  35521. /**
  35522. * Switch the panning model to HRTF:
  35523. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35525. */
  35526. switchPanningModelToHRTF(): void;
  35527. /**
  35528. * Switch the panning model to Equal Power:
  35529. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35531. */
  35532. switchPanningModelToEqualPower(): void;
  35533. private _switchPanningModel;
  35534. /**
  35535. * Connect this sound to a sound track audio node like gain...
  35536. * @param soundTrackAudioNode the sound track audio node to connect to
  35537. */
  35538. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35539. /**
  35540. * Transform this sound into a directional source
  35541. * @param coneInnerAngle Size of the inner cone in degree
  35542. * @param coneOuterAngle Size of the outer cone in degree
  35543. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35544. */
  35545. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35546. /**
  35547. * Gets or sets the inner angle for the directional cone.
  35548. */
  35549. /**
  35550. * Gets or sets the inner angle for the directional cone.
  35551. */
  35552. directionalConeInnerAngle: number;
  35553. /**
  35554. * Gets or sets the outer angle for the directional cone.
  35555. */
  35556. /**
  35557. * Gets or sets the outer angle for the directional cone.
  35558. */
  35559. directionalConeOuterAngle: number;
  35560. /**
  35561. * Sets the position of the emitter if spatial sound is enabled
  35562. * @param newPosition Defines the new posisiton
  35563. */
  35564. setPosition(newPosition: Vector3): void;
  35565. /**
  35566. * Sets the local direction of the emitter if spatial sound is enabled
  35567. * @param newLocalDirection Defines the new local direction
  35568. */
  35569. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35570. private _updateDirection;
  35571. /** @hidden */
  35572. updateDistanceFromListener(): void;
  35573. /**
  35574. * Sets a new custom attenuation function for the sound.
  35575. * @param callback Defines the function used for the attenuation
  35576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35577. */
  35578. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35579. /**
  35580. * Play the sound
  35581. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35582. * @param offset (optional) Start the sound at a specific time in seconds
  35583. * @param length (optional) Sound duration (in seconds)
  35584. */
  35585. play(time?: number, offset?: number, length?: number): void;
  35586. private _onended;
  35587. /**
  35588. * Stop the sound
  35589. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35590. */
  35591. stop(time?: number): void;
  35592. /**
  35593. * Put the sound in pause
  35594. */
  35595. pause(): void;
  35596. /**
  35597. * Sets a dedicated volume for this sounds
  35598. * @param newVolume Define the new volume of the sound
  35599. * @param time Define time for gradual change to new volume
  35600. */
  35601. setVolume(newVolume: number, time?: number): void;
  35602. /**
  35603. * Set the sound play back rate
  35604. * @param newPlaybackRate Define the playback rate the sound should be played at
  35605. */
  35606. setPlaybackRate(newPlaybackRate: number): void;
  35607. /**
  35608. * Gets the volume of the sound.
  35609. * @returns the volume of the sound
  35610. */
  35611. getVolume(): number;
  35612. /**
  35613. * Attach the sound to a dedicated mesh
  35614. * @param transformNode The transform node to connect the sound with
  35615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35616. */
  35617. attachToMesh(transformNode: TransformNode): void;
  35618. /**
  35619. * Detach the sound from the previously attached mesh
  35620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35621. */
  35622. detachFromMesh(): void;
  35623. private _onRegisterAfterWorldMatrixUpdate;
  35624. /**
  35625. * Clone the current sound in the scene.
  35626. * @returns the new sound clone
  35627. */
  35628. clone(): Nullable<Sound>;
  35629. /**
  35630. * Gets the current underlying audio buffer containing the data
  35631. * @returns the audio buffer
  35632. */
  35633. getAudioBuffer(): Nullable<AudioBuffer>;
  35634. /**
  35635. * Serializes the Sound in a JSON representation
  35636. * @returns the JSON representation of the sound
  35637. */
  35638. serialize(): any;
  35639. /**
  35640. * Parse a JSON representation of a sound to innstantiate in a given scene
  35641. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35642. * @param scene Define the scene the new parsed sound should be created in
  35643. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35644. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35645. * @returns the newly parsed sound
  35646. */
  35647. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35648. }
  35649. }
  35650. declare module BABYLON {
  35651. /**
  35652. * This defines an action helpful to play a defined sound on a triggered action.
  35653. */
  35654. export class PlaySoundAction extends Action {
  35655. private _sound;
  35656. /**
  35657. * Instantiate the action
  35658. * @param triggerOptions defines the trigger options
  35659. * @param sound defines the sound to play
  35660. * @param condition defines the trigger related conditions
  35661. */
  35662. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35663. /** @hidden */
  35664. _prepare(): void;
  35665. /**
  35666. * Execute the action and play the sound.
  35667. */
  35668. execute(): void;
  35669. /**
  35670. * Serializes the actions and its related information.
  35671. * @param parent defines the object to serialize in
  35672. * @returns the serialized object
  35673. */
  35674. serialize(parent: any): any;
  35675. }
  35676. /**
  35677. * This defines an action helpful to stop a defined sound on a triggered action.
  35678. */
  35679. export class StopSoundAction extends Action {
  35680. private _sound;
  35681. /**
  35682. * Instantiate the action
  35683. * @param triggerOptions defines the trigger options
  35684. * @param sound defines the sound to stop
  35685. * @param condition defines the trigger related conditions
  35686. */
  35687. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35688. /** @hidden */
  35689. _prepare(): void;
  35690. /**
  35691. * Execute the action and stop the sound.
  35692. */
  35693. execute(): void;
  35694. /**
  35695. * Serializes the actions and its related information.
  35696. * @param parent defines the object to serialize in
  35697. * @returns the serialized object
  35698. */
  35699. serialize(parent: any): any;
  35700. }
  35701. }
  35702. declare module BABYLON {
  35703. /**
  35704. * This defines an action responsible to change the value of a property
  35705. * by interpolating between its current value and the newly set one once triggered.
  35706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35707. */
  35708. export class InterpolateValueAction extends Action {
  35709. /**
  35710. * Defines the path of the property where the value should be interpolated
  35711. */
  35712. propertyPath: string;
  35713. /**
  35714. * Defines the target value at the end of the interpolation.
  35715. */
  35716. value: any;
  35717. /**
  35718. * Defines the time it will take for the property to interpolate to the value.
  35719. */
  35720. duration: number;
  35721. /**
  35722. * Defines if the other scene animations should be stopped when the action has been triggered
  35723. */
  35724. stopOtherAnimations?: boolean;
  35725. /**
  35726. * Defines a callback raised once the interpolation animation has been done.
  35727. */
  35728. onInterpolationDone?: () => void;
  35729. /**
  35730. * Observable triggered once the interpolation animation has been done.
  35731. */
  35732. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35733. private _target;
  35734. private _effectiveTarget;
  35735. private _property;
  35736. /**
  35737. * Instantiate the action
  35738. * @param triggerOptions defines the trigger options
  35739. * @param target defines the object containing the value to interpolate
  35740. * @param propertyPath defines the path to the property in the target object
  35741. * @param value defines the target value at the end of the interpolation
  35742. * @param duration deines the time it will take for the property to interpolate to the value.
  35743. * @param condition defines the trigger related conditions
  35744. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35745. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35746. */
  35747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35748. /** @hidden */
  35749. _prepare(): void;
  35750. /**
  35751. * Execute the action starts the value interpolation.
  35752. */
  35753. execute(): void;
  35754. /**
  35755. * Serializes the actions and its related information.
  35756. * @param parent defines the object to serialize in
  35757. * @returns the serialized object
  35758. */
  35759. serialize(parent: any): any;
  35760. }
  35761. }
  35762. declare module BABYLON {
  35763. /**
  35764. * Options allowed during the creation of a sound track.
  35765. */
  35766. export interface ISoundTrackOptions {
  35767. /**
  35768. * The volume the sound track should take during creation
  35769. */
  35770. volume?: number;
  35771. /**
  35772. * Define if the sound track is the main sound track of the scene
  35773. */
  35774. mainTrack?: boolean;
  35775. }
  35776. /**
  35777. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35778. * It will be also used in a future release to apply effects on a specific track.
  35779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35780. */
  35781. export class SoundTrack {
  35782. /**
  35783. * The unique identifier of the sound track in the scene.
  35784. */
  35785. id: number;
  35786. /**
  35787. * The list of sounds included in the sound track.
  35788. */
  35789. soundCollection: Array<Sound>;
  35790. private _outputAudioNode;
  35791. private _scene;
  35792. private _connectedAnalyser;
  35793. private _options;
  35794. private _isInitialized;
  35795. /**
  35796. * Creates a new sound track.
  35797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35798. * @param scene Define the scene the sound track belongs to
  35799. * @param options
  35800. */
  35801. constructor(scene: Scene, options?: ISoundTrackOptions);
  35802. private _initializeSoundTrackAudioGraph;
  35803. /**
  35804. * Release the sound track and its associated resources
  35805. */
  35806. dispose(): void;
  35807. /**
  35808. * Adds a sound to this sound track
  35809. * @param sound define the cound to add
  35810. * @ignoreNaming
  35811. */
  35812. AddSound(sound: Sound): void;
  35813. /**
  35814. * Removes a sound to this sound track
  35815. * @param sound define the cound to remove
  35816. * @ignoreNaming
  35817. */
  35818. RemoveSound(sound: Sound): void;
  35819. /**
  35820. * Set a global volume for the full sound track.
  35821. * @param newVolume Define the new volume of the sound track
  35822. */
  35823. setVolume(newVolume: number): void;
  35824. /**
  35825. * Switch the panning model to HRTF:
  35826. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35828. */
  35829. switchPanningModelToHRTF(): void;
  35830. /**
  35831. * Switch the panning model to Equal Power:
  35832. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35834. */
  35835. switchPanningModelToEqualPower(): void;
  35836. /**
  35837. * Connect the sound track to an audio analyser allowing some amazing
  35838. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35840. * @param analyser The analyser to connect to the engine
  35841. */
  35842. connectToAnalyser(analyser: Analyser): void;
  35843. }
  35844. }
  35845. declare module BABYLON {
  35846. interface AbstractScene {
  35847. /**
  35848. * The list of sounds used in the scene.
  35849. */
  35850. sounds: Nullable<Array<Sound>>;
  35851. }
  35852. interface Scene {
  35853. /**
  35854. * @hidden
  35855. * Backing field
  35856. */
  35857. _mainSoundTrack: SoundTrack;
  35858. /**
  35859. * The main sound track played by the scene.
  35860. * It cotains your primary collection of sounds.
  35861. */
  35862. mainSoundTrack: SoundTrack;
  35863. /**
  35864. * The list of sound tracks added to the scene
  35865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35866. */
  35867. soundTracks: Nullable<Array<SoundTrack>>;
  35868. /**
  35869. * Gets a sound using a given name
  35870. * @param name defines the name to search for
  35871. * @return the found sound or null if not found at all.
  35872. */
  35873. getSoundByName(name: string): Nullable<Sound>;
  35874. /**
  35875. * Gets or sets if audio support is enabled
  35876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35877. */
  35878. audioEnabled: boolean;
  35879. /**
  35880. * Gets or sets if audio will be output to headphones
  35881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35882. */
  35883. headphone: boolean;
  35884. /**
  35885. * Gets or sets custom audio listener position provider
  35886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35887. */
  35888. audioListenerPositionProvider: Nullable<() => Vector3>;
  35889. /**
  35890. * Gets or sets a refresh rate when using 3D audio positioning
  35891. */
  35892. audioPositioningRefreshRate: number;
  35893. }
  35894. /**
  35895. * Defines the sound scene component responsible to manage any sounds
  35896. * in a given scene.
  35897. */
  35898. export class AudioSceneComponent implements ISceneSerializableComponent {
  35899. /**
  35900. * The component name helpfull to identify the component in the list of scene components.
  35901. */
  35902. readonly name: string;
  35903. /**
  35904. * The scene the component belongs to.
  35905. */
  35906. scene: Scene;
  35907. private _audioEnabled;
  35908. /**
  35909. * Gets whether audio is enabled or not.
  35910. * Please use related enable/disable method to switch state.
  35911. */
  35912. readonly audioEnabled: boolean;
  35913. private _headphone;
  35914. /**
  35915. * Gets whether audio is outputing to headphone or not.
  35916. * Please use the according Switch methods to change output.
  35917. */
  35918. readonly headphone: boolean;
  35919. /**
  35920. * Gets or sets a refresh rate when using 3D audio positioning
  35921. */
  35922. audioPositioningRefreshRate: number;
  35923. private _audioListenerPositionProvider;
  35924. /**
  35925. * Gets the current audio listener position provider
  35926. */
  35927. /**
  35928. * Sets a custom listener position for all sounds in the scene
  35929. * By default, this is the position of the first active camera
  35930. */
  35931. audioListenerPositionProvider: Nullable<() => Vector3>;
  35932. /**
  35933. * Creates a new instance of the component for the given scene
  35934. * @param scene Defines the scene to register the component in
  35935. */
  35936. constructor(scene: Scene);
  35937. /**
  35938. * Registers the component in a given scene
  35939. */
  35940. register(): void;
  35941. /**
  35942. * Rebuilds the elements related to this component in case of
  35943. * context lost for instance.
  35944. */
  35945. rebuild(): void;
  35946. /**
  35947. * Serializes the component data to the specified json object
  35948. * @param serializationObject The object to serialize to
  35949. */
  35950. serialize(serializationObject: any): void;
  35951. /**
  35952. * Adds all the elements from the container to the scene
  35953. * @param container the container holding the elements
  35954. */
  35955. addFromContainer(container: AbstractScene): void;
  35956. /**
  35957. * Removes all the elements in the container from the scene
  35958. * @param container contains the elements to remove
  35959. * @param dispose if the removed element should be disposed (default: false)
  35960. */
  35961. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35962. /**
  35963. * Disposes the component and the associated ressources.
  35964. */
  35965. dispose(): void;
  35966. /**
  35967. * Disables audio in the associated scene.
  35968. */
  35969. disableAudio(): void;
  35970. /**
  35971. * Enables audio in the associated scene.
  35972. */
  35973. enableAudio(): void;
  35974. /**
  35975. * Switch audio to headphone output.
  35976. */
  35977. switchAudioModeForHeadphones(): void;
  35978. /**
  35979. * Switch audio to normal speakers.
  35980. */
  35981. switchAudioModeForNormalSpeakers(): void;
  35982. private _cachedCameraDirection;
  35983. private _cachedCameraPosition;
  35984. private _lastCheck;
  35985. private _afterRender;
  35986. }
  35987. }
  35988. declare module BABYLON {
  35989. /**
  35990. * Wraps one or more Sound objects and selects one with random weight for playback.
  35991. */
  35992. export class WeightedSound {
  35993. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35994. loop: boolean;
  35995. private _coneInnerAngle;
  35996. private _coneOuterAngle;
  35997. private _volume;
  35998. /** A Sound is currently playing. */
  35999. isPlaying: boolean;
  36000. /** A Sound is currently paused. */
  36001. isPaused: boolean;
  36002. private _sounds;
  36003. private _weights;
  36004. private _currentIndex?;
  36005. /**
  36006. * Creates a new WeightedSound from the list of sounds given.
  36007. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36008. * @param sounds Array of Sounds that will be selected from.
  36009. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36010. */
  36011. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36012. /**
  36013. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36014. */
  36015. /**
  36016. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36017. */
  36018. directionalConeInnerAngle: number;
  36019. /**
  36020. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36021. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36022. */
  36023. /**
  36024. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36025. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36026. */
  36027. directionalConeOuterAngle: number;
  36028. /**
  36029. * Playback volume.
  36030. */
  36031. /**
  36032. * Playback volume.
  36033. */
  36034. volume: number;
  36035. private _onended;
  36036. /**
  36037. * Suspend playback
  36038. */
  36039. pause(): void;
  36040. /**
  36041. * Stop playback
  36042. */
  36043. stop(): void;
  36044. /**
  36045. * Start playback.
  36046. * @param startOffset Position the clip head at a specific time in seconds.
  36047. */
  36048. play(startOffset?: number): void;
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. /**
  36053. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36054. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36055. */
  36056. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36057. /**
  36058. * Gets the name of the behavior.
  36059. */
  36060. readonly name: string;
  36061. /**
  36062. * The easing function used by animations
  36063. */
  36064. static EasingFunction: BackEase;
  36065. /**
  36066. * The easing mode used by animations
  36067. */
  36068. static EasingMode: number;
  36069. /**
  36070. * The duration of the animation, in milliseconds
  36071. */
  36072. transitionDuration: number;
  36073. /**
  36074. * Length of the distance animated by the transition when lower radius is reached
  36075. */
  36076. lowerRadiusTransitionRange: number;
  36077. /**
  36078. * Length of the distance animated by the transition when upper radius is reached
  36079. */
  36080. upperRadiusTransitionRange: number;
  36081. private _autoTransitionRange;
  36082. /**
  36083. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36084. */
  36085. /**
  36086. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36087. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36088. */
  36089. autoTransitionRange: boolean;
  36090. private _attachedCamera;
  36091. private _onAfterCheckInputsObserver;
  36092. private _onMeshTargetChangedObserver;
  36093. /**
  36094. * Initializes the behavior.
  36095. */
  36096. init(): void;
  36097. /**
  36098. * Attaches the behavior to its arc rotate camera.
  36099. * @param camera Defines the camera to attach the behavior to
  36100. */
  36101. attach(camera: ArcRotateCamera): void;
  36102. /**
  36103. * Detaches the behavior from its current arc rotate camera.
  36104. */
  36105. detach(): void;
  36106. private _radiusIsAnimating;
  36107. private _radiusBounceTransition;
  36108. private _animatables;
  36109. private _cachedWheelPrecision;
  36110. /**
  36111. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36112. * @param radiusLimit The limit to check against.
  36113. * @return Bool to indicate if at limit.
  36114. */
  36115. private _isRadiusAtLimit;
  36116. /**
  36117. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36118. * @param radiusDelta The delta by which to animate to. Can be negative.
  36119. */
  36120. private _applyBoundRadiusAnimation;
  36121. /**
  36122. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36123. */
  36124. protected _clearAnimationLocks(): void;
  36125. /**
  36126. * Stops and removes all animations that have been applied to the camera
  36127. */
  36128. stopAllAnimations(): void;
  36129. }
  36130. }
  36131. declare module BABYLON {
  36132. /**
  36133. * 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.
  36134. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36135. */
  36136. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36137. /**
  36138. * Gets the name of the behavior.
  36139. */
  36140. readonly name: string;
  36141. private _mode;
  36142. private _radiusScale;
  36143. private _positionScale;
  36144. private _defaultElevation;
  36145. private _elevationReturnTime;
  36146. private _elevationReturnWaitTime;
  36147. private _zoomStopsAnimation;
  36148. private _framingTime;
  36149. /**
  36150. * The easing function used by animations
  36151. */
  36152. static EasingFunction: ExponentialEase;
  36153. /**
  36154. * The easing mode used by animations
  36155. */
  36156. static EasingMode: number;
  36157. /**
  36158. * Sets the current mode used by the behavior
  36159. */
  36160. /**
  36161. * Gets current mode used by the behavior.
  36162. */
  36163. mode: number;
  36164. /**
  36165. * Sets the scale applied to the radius (1 by default)
  36166. */
  36167. /**
  36168. * Gets the scale applied to the radius
  36169. */
  36170. radiusScale: number;
  36171. /**
  36172. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36173. */
  36174. /**
  36175. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36176. */
  36177. positionScale: number;
  36178. /**
  36179. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36180. * behaviour is triggered, in radians.
  36181. */
  36182. /**
  36183. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36184. * behaviour is triggered, in radians.
  36185. */
  36186. defaultElevation: number;
  36187. /**
  36188. * Sets the time (in milliseconds) taken to return to the default beta position.
  36189. * Negative value indicates camera should not return to default.
  36190. */
  36191. /**
  36192. * Gets the time (in milliseconds) taken to return to the default beta position.
  36193. * Negative value indicates camera should not return to default.
  36194. */
  36195. elevationReturnTime: number;
  36196. /**
  36197. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36198. */
  36199. /**
  36200. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36201. */
  36202. elevationReturnWaitTime: number;
  36203. /**
  36204. * Sets the flag that indicates if user zooming should stop animation.
  36205. */
  36206. /**
  36207. * Gets the flag that indicates if user zooming should stop animation.
  36208. */
  36209. zoomStopsAnimation: boolean;
  36210. /**
  36211. * Sets the transition time when framing the mesh, in milliseconds
  36212. */
  36213. /**
  36214. * Gets the transition time when framing the mesh, in milliseconds
  36215. */
  36216. framingTime: number;
  36217. /**
  36218. * Define if the behavior should automatically change the configured
  36219. * camera limits and sensibilities.
  36220. */
  36221. autoCorrectCameraLimitsAndSensibility: boolean;
  36222. private _onPrePointerObservableObserver;
  36223. private _onAfterCheckInputsObserver;
  36224. private _onMeshTargetChangedObserver;
  36225. private _attachedCamera;
  36226. private _isPointerDown;
  36227. private _lastInteractionTime;
  36228. /**
  36229. * Initializes the behavior.
  36230. */
  36231. init(): void;
  36232. /**
  36233. * Attaches the behavior to its arc rotate camera.
  36234. * @param camera Defines the camera to attach the behavior to
  36235. */
  36236. attach(camera: ArcRotateCamera): void;
  36237. /**
  36238. * Detaches the behavior from its current arc rotate camera.
  36239. */
  36240. detach(): void;
  36241. private _animatables;
  36242. private _betaIsAnimating;
  36243. private _betaTransition;
  36244. private _radiusTransition;
  36245. private _vectorTransition;
  36246. /**
  36247. * Targets the given mesh and updates zoom level accordingly.
  36248. * @param mesh The mesh to target.
  36249. * @param radius Optional. If a cached radius position already exists, overrides default.
  36250. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36251. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36252. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36253. */
  36254. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36255. /**
  36256. * Targets the given mesh with its children and updates zoom level accordingly.
  36257. * @param mesh The mesh to target.
  36258. * @param radius Optional. If a cached radius position already exists, overrides default.
  36259. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36260. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36261. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36262. */
  36263. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36264. /**
  36265. * Targets the given meshes with their children and updates zoom level accordingly.
  36266. * @param meshes The mesh to target.
  36267. * @param radius Optional. If a cached radius position already exists, overrides default.
  36268. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36269. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36270. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36271. */
  36272. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36273. /**
  36274. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36275. * @param minimumWorld Determines the smaller position of the bounding box extend
  36276. * @param maximumWorld Determines the bigger position of the bounding box extend
  36277. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36278. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36279. */
  36280. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36281. /**
  36282. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36283. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36284. * frustum width.
  36285. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36286. * to fully enclose the mesh in the viewing frustum.
  36287. */
  36288. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36289. /**
  36290. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36291. * is automatically returned to its default position (expected to be above ground plane).
  36292. */
  36293. private _maintainCameraAboveGround;
  36294. /**
  36295. * Returns the frustum slope based on the canvas ratio and camera FOV
  36296. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36297. */
  36298. private _getFrustumSlope;
  36299. /**
  36300. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36301. */
  36302. private _clearAnimationLocks;
  36303. /**
  36304. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36305. */
  36306. private _applyUserInteraction;
  36307. /**
  36308. * Stops and removes all animations that have been applied to the camera
  36309. */
  36310. stopAllAnimations(): void;
  36311. /**
  36312. * Gets a value indicating if the user is moving the camera
  36313. */
  36314. readonly isUserIsMoving: boolean;
  36315. /**
  36316. * The camera can move all the way towards the mesh.
  36317. */
  36318. static IgnoreBoundsSizeMode: number;
  36319. /**
  36320. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36321. */
  36322. static FitFrustumSidesMode: number;
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. /**
  36327. * Base class for Camera Pointer Inputs.
  36328. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36329. * for example usage.
  36330. */
  36331. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36332. /**
  36333. * Defines the camera the input is attached to.
  36334. */
  36335. abstract camera: Camera;
  36336. /**
  36337. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36338. */
  36339. protected _altKey: boolean;
  36340. protected _ctrlKey: boolean;
  36341. protected _metaKey: boolean;
  36342. protected _shiftKey: boolean;
  36343. /**
  36344. * Which mouse buttons were pressed at time of last mouse event.
  36345. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36346. */
  36347. protected _buttonsPressed: number;
  36348. /**
  36349. * Defines the buttons associated with the input to handle camera move.
  36350. */
  36351. buttons: number[];
  36352. /**
  36353. * Attach the input controls to a specific dom element to get the input from.
  36354. * @param element Defines the element the controls should be listened from
  36355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36356. */
  36357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36358. /**
  36359. * Detach the current controls from the specified dom element.
  36360. * @param element Defines the element to stop listening the inputs from
  36361. */
  36362. detachControl(element: Nullable<HTMLElement>): void;
  36363. /**
  36364. * Gets the class name of the current input.
  36365. * @returns the class name
  36366. */
  36367. getClassName(): string;
  36368. /**
  36369. * Get the friendly name associated with the input class.
  36370. * @returns the input friendly name
  36371. */
  36372. getSimpleName(): string;
  36373. /**
  36374. * Called on pointer POINTERDOUBLETAP event.
  36375. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36376. */
  36377. protected onDoubleTap(type: string): void;
  36378. /**
  36379. * Called on pointer POINTERMOVE event if only a single touch is active.
  36380. * Override this method to provide functionality.
  36381. */
  36382. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36383. /**
  36384. * Called on pointer POINTERMOVE event if multiple touches are active.
  36385. * Override this method to provide functionality.
  36386. */
  36387. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36388. /**
  36389. * Called on JS contextmenu event.
  36390. * Override this method to provide functionality.
  36391. */
  36392. protected onContextMenu(evt: PointerEvent): void;
  36393. /**
  36394. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36395. * press.
  36396. * Override this method to provide functionality.
  36397. */
  36398. protected onButtonDown(evt: PointerEvent): void;
  36399. /**
  36400. * Called each time a new POINTERUP event occurs. Ie, for each button
  36401. * release.
  36402. * Override this method to provide functionality.
  36403. */
  36404. protected onButtonUp(evt: PointerEvent): void;
  36405. /**
  36406. * Called when window becomes inactive.
  36407. * Override this method to provide functionality.
  36408. */
  36409. protected onLostFocus(): void;
  36410. private _pointerInput;
  36411. private _observer;
  36412. private _onLostFocus;
  36413. private pointA;
  36414. private pointB;
  36415. }
  36416. }
  36417. declare module BABYLON {
  36418. /**
  36419. * Manage the pointers inputs to control an arc rotate camera.
  36420. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36421. */
  36422. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36423. /**
  36424. * Defines the camera the input is attached to.
  36425. */
  36426. camera: ArcRotateCamera;
  36427. /**
  36428. * Gets the class name of the current input.
  36429. * @returns the class name
  36430. */
  36431. getClassName(): string;
  36432. /**
  36433. * Defines the buttons associated with the input to handle camera move.
  36434. */
  36435. buttons: number[];
  36436. /**
  36437. * Defines the pointer angular sensibility along the X axis or how fast is
  36438. * the camera rotating.
  36439. */
  36440. angularSensibilityX: number;
  36441. /**
  36442. * Defines the pointer angular sensibility along the Y axis or how fast is
  36443. * the camera rotating.
  36444. */
  36445. angularSensibilityY: number;
  36446. /**
  36447. * Defines the pointer pinch precision or how fast is the camera zooming.
  36448. */
  36449. pinchPrecision: number;
  36450. /**
  36451. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36452. * from 0.
  36453. * It defines the percentage of current camera.radius to use as delta when
  36454. * pinch zoom is used.
  36455. */
  36456. pinchDeltaPercentage: number;
  36457. /**
  36458. * Defines the pointer panning sensibility or how fast is the camera moving.
  36459. */
  36460. panningSensibility: number;
  36461. /**
  36462. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36463. */
  36464. multiTouchPanning: boolean;
  36465. /**
  36466. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36467. * zoom (pinch) through multitouch.
  36468. */
  36469. multiTouchPanAndZoom: boolean;
  36470. /**
  36471. * Revers pinch action direction.
  36472. */
  36473. pinchInwards: boolean;
  36474. private _isPanClick;
  36475. private _twoFingerActivityCount;
  36476. private _isPinching;
  36477. /**
  36478. * Called on pointer POINTERMOVE event if only a single touch is active.
  36479. */
  36480. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36481. /**
  36482. * Called on pointer POINTERDOUBLETAP event.
  36483. */
  36484. protected onDoubleTap(type: string): void;
  36485. /**
  36486. * Called on pointer POINTERMOVE event if multiple touches are active.
  36487. */
  36488. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36489. /**
  36490. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36491. * press.
  36492. */
  36493. protected onButtonDown(evt: PointerEvent): void;
  36494. /**
  36495. * Called each time a new POINTERUP event occurs. Ie, for each button
  36496. * release.
  36497. */
  36498. protected onButtonUp(evt: PointerEvent): void;
  36499. /**
  36500. * Called when window becomes inactive.
  36501. */
  36502. protected onLostFocus(): void;
  36503. }
  36504. }
  36505. declare module BABYLON {
  36506. /**
  36507. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36509. */
  36510. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36511. /**
  36512. * Defines the camera the input is attached to.
  36513. */
  36514. camera: ArcRotateCamera;
  36515. /**
  36516. * Defines the list of key codes associated with the up action (increase alpha)
  36517. */
  36518. keysUp: number[];
  36519. /**
  36520. * Defines the list of key codes associated with the down action (decrease alpha)
  36521. */
  36522. keysDown: number[];
  36523. /**
  36524. * Defines the list of key codes associated with the left action (increase beta)
  36525. */
  36526. keysLeft: number[];
  36527. /**
  36528. * Defines the list of key codes associated with the right action (decrease beta)
  36529. */
  36530. keysRight: number[];
  36531. /**
  36532. * Defines the list of key codes associated with the reset action.
  36533. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36534. */
  36535. keysReset: number[];
  36536. /**
  36537. * Defines the panning sensibility of the inputs.
  36538. * (How fast is the camera paning)
  36539. */
  36540. panningSensibility: number;
  36541. /**
  36542. * Defines the zooming sensibility of the inputs.
  36543. * (How fast is the camera zooming)
  36544. */
  36545. zoomingSensibility: number;
  36546. /**
  36547. * Defines wether maintaining the alt key down switch the movement mode from
  36548. * orientation to zoom.
  36549. */
  36550. useAltToZoom: boolean;
  36551. /**
  36552. * Rotation speed of the camera
  36553. */
  36554. angularSpeed: number;
  36555. private _keys;
  36556. private _ctrlPressed;
  36557. private _altPressed;
  36558. private _onCanvasBlurObserver;
  36559. private _onKeyboardObserver;
  36560. private _engine;
  36561. private _scene;
  36562. /**
  36563. * Attach the input controls to a specific dom element to get the input from.
  36564. * @param element Defines the element the controls should be listened from
  36565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36566. */
  36567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36568. /**
  36569. * Detach the current controls from the specified dom element.
  36570. * @param element Defines the element to stop listening the inputs from
  36571. */
  36572. detachControl(element: Nullable<HTMLElement>): void;
  36573. /**
  36574. * Update the current camera state depending on the inputs that have been used this frame.
  36575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36576. */
  36577. checkInputs(): void;
  36578. /**
  36579. * Gets the class name of the current intput.
  36580. * @returns the class name
  36581. */
  36582. getClassName(): string;
  36583. /**
  36584. * Get the friendly name associated with the input class.
  36585. * @returns the input friendly name
  36586. */
  36587. getSimpleName(): string;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * Manage the mouse wheel inputs to control an arc rotate camera.
  36593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36594. */
  36595. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36596. /**
  36597. * Defines the camera the input is attached to.
  36598. */
  36599. camera: ArcRotateCamera;
  36600. /**
  36601. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36602. */
  36603. wheelPrecision: number;
  36604. /**
  36605. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36606. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36607. */
  36608. wheelDeltaPercentage: number;
  36609. private _wheel;
  36610. private _observer;
  36611. private computeDeltaFromMouseWheelLegacyEvent;
  36612. /**
  36613. * Attach the input controls to a specific dom element to get the input from.
  36614. * @param element Defines the element the controls should be listened from
  36615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36616. */
  36617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36618. /**
  36619. * Detach the current controls from the specified dom element.
  36620. * @param element Defines the element to stop listening the inputs from
  36621. */
  36622. detachControl(element: Nullable<HTMLElement>): void;
  36623. /**
  36624. * Gets the class name of the current intput.
  36625. * @returns the class name
  36626. */
  36627. getClassName(): string;
  36628. /**
  36629. * Get the friendly name associated with the input class.
  36630. * @returns the input friendly name
  36631. */
  36632. getSimpleName(): string;
  36633. }
  36634. }
  36635. declare module BABYLON {
  36636. /**
  36637. * Default Inputs manager for the ArcRotateCamera.
  36638. * It groups all the default supported inputs for ease of use.
  36639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36640. */
  36641. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36642. /**
  36643. * Instantiates a new ArcRotateCameraInputsManager.
  36644. * @param camera Defines the camera the inputs belong to
  36645. */
  36646. constructor(camera: ArcRotateCamera);
  36647. /**
  36648. * Add mouse wheel input support to the input manager.
  36649. * @returns the current input manager
  36650. */
  36651. addMouseWheel(): ArcRotateCameraInputsManager;
  36652. /**
  36653. * Add pointers input support to the input manager.
  36654. * @returns the current input manager
  36655. */
  36656. addPointers(): ArcRotateCameraInputsManager;
  36657. /**
  36658. * Add keyboard input support to the input manager.
  36659. * @returns the current input manager
  36660. */
  36661. addKeyboard(): ArcRotateCameraInputsManager;
  36662. }
  36663. }
  36664. declare module BABYLON {
  36665. /**
  36666. * This represents an orbital type of camera.
  36667. *
  36668. * 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.
  36669. * 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.
  36670. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36671. */
  36672. export class ArcRotateCamera extends TargetCamera {
  36673. /**
  36674. * Defines the rotation angle of the camera along the longitudinal axis.
  36675. */
  36676. alpha: number;
  36677. /**
  36678. * Defines the rotation angle of the camera along the latitudinal axis.
  36679. */
  36680. beta: number;
  36681. /**
  36682. * Defines the radius of the camera from it s target point.
  36683. */
  36684. radius: number;
  36685. protected _target: Vector3;
  36686. protected _targetHost: Nullable<AbstractMesh>;
  36687. /**
  36688. * Defines the target point of the camera.
  36689. * The camera looks towards it form the radius distance.
  36690. */
  36691. target: Vector3;
  36692. /**
  36693. * Define the current local position of the camera in the scene
  36694. */
  36695. position: Vector3;
  36696. protected _upVector: Vector3;
  36697. protected _upToYMatrix: Matrix;
  36698. protected _YToUpMatrix: Matrix;
  36699. /**
  36700. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36701. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36702. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36703. */
  36704. upVector: Vector3;
  36705. /**
  36706. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36707. */
  36708. setMatUp(): void;
  36709. /**
  36710. * Current inertia value on the longitudinal axis.
  36711. * The bigger this number the longer it will take for the camera to stop.
  36712. */
  36713. inertialAlphaOffset: number;
  36714. /**
  36715. * Current inertia value on the latitudinal axis.
  36716. * The bigger this number the longer it will take for the camera to stop.
  36717. */
  36718. inertialBetaOffset: number;
  36719. /**
  36720. * Current inertia value on the radius axis.
  36721. * The bigger this number the longer it will take for the camera to stop.
  36722. */
  36723. inertialRadiusOffset: number;
  36724. /**
  36725. * Minimum allowed angle on the longitudinal axis.
  36726. * This can help limiting how the Camera is able to move in the scene.
  36727. */
  36728. lowerAlphaLimit: Nullable<number>;
  36729. /**
  36730. * Maximum allowed angle on the longitudinal axis.
  36731. * This can help limiting how the Camera is able to move in the scene.
  36732. */
  36733. upperAlphaLimit: Nullable<number>;
  36734. /**
  36735. * Minimum allowed angle on the latitudinal axis.
  36736. * This can help limiting how the Camera is able to move in the scene.
  36737. */
  36738. lowerBetaLimit: number;
  36739. /**
  36740. * Maximum allowed angle on the latitudinal axis.
  36741. * This can help limiting how the Camera is able to move in the scene.
  36742. */
  36743. upperBetaLimit: number;
  36744. /**
  36745. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36746. * This can help limiting how the Camera is able to move in the scene.
  36747. */
  36748. lowerRadiusLimit: Nullable<number>;
  36749. /**
  36750. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36751. * This can help limiting how the Camera is able to move in the scene.
  36752. */
  36753. upperRadiusLimit: Nullable<number>;
  36754. /**
  36755. * Defines the current inertia value used during panning of the camera along the X axis.
  36756. */
  36757. inertialPanningX: number;
  36758. /**
  36759. * Defines the current inertia value used during panning of the camera along the Y axis.
  36760. */
  36761. inertialPanningY: number;
  36762. /**
  36763. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36764. * Basically if your fingers moves away from more than this distance you will be considered
  36765. * in pinch mode.
  36766. */
  36767. pinchToPanMaxDistance: number;
  36768. /**
  36769. * Defines the maximum distance the camera can pan.
  36770. * This could help keeping the cammera always in your scene.
  36771. */
  36772. panningDistanceLimit: Nullable<number>;
  36773. /**
  36774. * Defines the target of the camera before paning.
  36775. */
  36776. panningOriginTarget: Vector3;
  36777. /**
  36778. * Defines the value of the inertia used during panning.
  36779. * 0 would mean stop inertia and one would mean no decelleration at all.
  36780. */
  36781. panningInertia: number;
  36782. /**
  36783. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36784. */
  36785. angularSensibilityX: number;
  36786. /**
  36787. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36788. */
  36789. angularSensibilityY: number;
  36790. /**
  36791. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36792. */
  36793. pinchPrecision: number;
  36794. /**
  36795. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36796. * It will be used instead of pinchDeltaPrecision if different from 0.
  36797. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36798. */
  36799. pinchDeltaPercentage: number;
  36800. /**
  36801. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36802. */
  36803. panningSensibility: number;
  36804. /**
  36805. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36806. */
  36807. keysUp: number[];
  36808. /**
  36809. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36810. */
  36811. keysDown: number[];
  36812. /**
  36813. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36814. */
  36815. keysLeft: number[];
  36816. /**
  36817. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36818. */
  36819. keysRight: number[];
  36820. /**
  36821. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36822. */
  36823. wheelPrecision: number;
  36824. /**
  36825. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36826. * It will be used instead of pinchDeltaPrecision if different from 0.
  36827. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36828. */
  36829. wheelDeltaPercentage: number;
  36830. /**
  36831. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36832. */
  36833. zoomOnFactor: number;
  36834. /**
  36835. * Defines a screen offset for the camera position.
  36836. */
  36837. targetScreenOffset: Vector2;
  36838. /**
  36839. * Allows the camera to be completely reversed.
  36840. * If false the camera can not arrive upside down.
  36841. */
  36842. allowUpsideDown: boolean;
  36843. /**
  36844. * Define if double tap/click is used to restore the previously saved state of the camera.
  36845. */
  36846. useInputToRestoreState: boolean;
  36847. /** @hidden */
  36848. _viewMatrix: Matrix;
  36849. /** @hidden */
  36850. _useCtrlForPanning: boolean;
  36851. /** @hidden */
  36852. _panningMouseButton: number;
  36853. /**
  36854. * Defines the input associated to the camera.
  36855. */
  36856. inputs: ArcRotateCameraInputsManager;
  36857. /** @hidden */
  36858. _reset: () => void;
  36859. /**
  36860. * Defines the allowed panning axis.
  36861. */
  36862. panningAxis: Vector3;
  36863. protected _localDirection: Vector3;
  36864. protected _transformedDirection: Vector3;
  36865. private _bouncingBehavior;
  36866. /**
  36867. * Gets the bouncing behavior of the camera if it has been enabled.
  36868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36869. */
  36870. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36871. /**
  36872. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36873. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36874. */
  36875. useBouncingBehavior: boolean;
  36876. private _framingBehavior;
  36877. /**
  36878. * Gets the framing behavior of the camera if it has been enabled.
  36879. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36880. */
  36881. readonly framingBehavior: Nullable<FramingBehavior>;
  36882. /**
  36883. * Defines if the framing behavior of the camera is enabled on the camera.
  36884. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36885. */
  36886. useFramingBehavior: boolean;
  36887. private _autoRotationBehavior;
  36888. /**
  36889. * Gets the auto rotation behavior of the camera if it has been enabled.
  36890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36891. */
  36892. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36893. /**
  36894. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36895. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36896. */
  36897. useAutoRotationBehavior: boolean;
  36898. /**
  36899. * Observable triggered when the mesh target has been changed on the camera.
  36900. */
  36901. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36902. /**
  36903. * Event raised when the camera is colliding with a mesh.
  36904. */
  36905. onCollide: (collidedMesh: AbstractMesh) => void;
  36906. /**
  36907. * Defines whether the camera should check collision with the objects oh the scene.
  36908. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36909. */
  36910. checkCollisions: boolean;
  36911. /**
  36912. * Defines the collision radius of the camera.
  36913. * This simulates a sphere around the camera.
  36914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36915. */
  36916. collisionRadius: Vector3;
  36917. protected _collider: Collider;
  36918. protected _previousPosition: Vector3;
  36919. protected _collisionVelocity: Vector3;
  36920. protected _newPosition: Vector3;
  36921. protected _previousAlpha: number;
  36922. protected _previousBeta: number;
  36923. protected _previousRadius: number;
  36924. protected _collisionTriggered: boolean;
  36925. protected _targetBoundingCenter: Nullable<Vector3>;
  36926. private _computationVector;
  36927. /**
  36928. * Instantiates a new ArcRotateCamera in a given scene
  36929. * @param name Defines the name of the camera
  36930. * @param alpha Defines the camera rotation along the logitudinal axis
  36931. * @param beta Defines the camera rotation along the latitudinal axis
  36932. * @param radius Defines the camera distance from its target
  36933. * @param target Defines the camera target
  36934. * @param scene Defines the scene the camera belongs to
  36935. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36936. */
  36937. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36938. /** @hidden */
  36939. _initCache(): void;
  36940. /** @hidden */
  36941. _updateCache(ignoreParentClass?: boolean): void;
  36942. protected _getTargetPosition(): Vector3;
  36943. private _storedAlpha;
  36944. private _storedBeta;
  36945. private _storedRadius;
  36946. private _storedTarget;
  36947. private _storedTargetScreenOffset;
  36948. /**
  36949. * Stores the current state of the camera (alpha, beta, radius and target)
  36950. * @returns the camera itself
  36951. */
  36952. storeState(): Camera;
  36953. /**
  36954. * @hidden
  36955. * Restored camera state. You must call storeState() first
  36956. */
  36957. _restoreStateValues(): boolean;
  36958. /** @hidden */
  36959. _isSynchronizedViewMatrix(): boolean;
  36960. /**
  36961. * Attached controls to the current camera.
  36962. * @param element Defines the element the controls should be listened from
  36963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36964. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36965. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36966. */
  36967. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36968. /**
  36969. * Detach the current controls from the camera.
  36970. * The camera will stop reacting to inputs.
  36971. * @param element Defines the element to stop listening the inputs from
  36972. */
  36973. detachControl(element: HTMLElement): void;
  36974. /** @hidden */
  36975. _checkInputs(): void;
  36976. protected _checkLimits(): void;
  36977. /**
  36978. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36979. */
  36980. rebuildAnglesAndRadius(): void;
  36981. /**
  36982. * Use a position to define the current camera related information like alpha, beta and radius
  36983. * @param position Defines the position to set the camera at
  36984. */
  36985. setPosition(position: Vector3): void;
  36986. /**
  36987. * Defines the target the camera should look at.
  36988. * This will automatically adapt alpha beta and radius to fit within the new target.
  36989. * @param target Defines the new target as a Vector or a mesh
  36990. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36991. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36992. */
  36993. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36994. /** @hidden */
  36995. _getViewMatrix(): Matrix;
  36996. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36997. /**
  36998. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36999. * @param meshes Defines the mesh to zoom on
  37000. * @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)
  37001. */
  37002. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37003. /**
  37004. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37005. * The target will be changed but the radius
  37006. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37007. * @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)
  37008. */
  37009. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37010. min: Vector3;
  37011. max: Vector3;
  37012. distance: number;
  37013. }, doNotUpdateMaxZ?: boolean): void;
  37014. /**
  37015. * @override
  37016. * Override Camera.createRigCamera
  37017. */
  37018. createRigCamera(name: string, cameraIndex: number): Camera;
  37019. /**
  37020. * @hidden
  37021. * @override
  37022. * Override Camera._updateRigCameras
  37023. */
  37024. _updateRigCameras(): void;
  37025. /**
  37026. * Destroy the camera and release the current resources hold by it.
  37027. */
  37028. dispose(): void;
  37029. /**
  37030. * Gets the current object class name.
  37031. * @return the class name
  37032. */
  37033. getClassName(): string;
  37034. }
  37035. }
  37036. declare module BABYLON {
  37037. /**
  37038. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37040. */
  37041. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37042. /**
  37043. * Gets the name of the behavior.
  37044. */
  37045. readonly name: string;
  37046. private _zoomStopsAnimation;
  37047. private _idleRotationSpeed;
  37048. private _idleRotationWaitTime;
  37049. private _idleRotationSpinupTime;
  37050. /**
  37051. * Sets the flag that indicates if user zooming should stop animation.
  37052. */
  37053. /**
  37054. * Gets the flag that indicates if user zooming should stop animation.
  37055. */
  37056. zoomStopsAnimation: boolean;
  37057. /**
  37058. * Sets the default speed at which the camera rotates around the model.
  37059. */
  37060. /**
  37061. * Gets the default speed at which the camera rotates around the model.
  37062. */
  37063. idleRotationSpeed: number;
  37064. /**
  37065. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37066. */
  37067. /**
  37068. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37069. */
  37070. idleRotationWaitTime: number;
  37071. /**
  37072. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37073. */
  37074. /**
  37075. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37076. */
  37077. idleRotationSpinupTime: number;
  37078. /**
  37079. * Gets a value indicating if the camera is currently rotating because of this behavior
  37080. */
  37081. readonly rotationInProgress: boolean;
  37082. private _onPrePointerObservableObserver;
  37083. private _onAfterCheckInputsObserver;
  37084. private _attachedCamera;
  37085. private _isPointerDown;
  37086. private _lastFrameTime;
  37087. private _lastInteractionTime;
  37088. private _cameraRotationSpeed;
  37089. /**
  37090. * Initializes the behavior.
  37091. */
  37092. init(): void;
  37093. /**
  37094. * Attaches the behavior to its arc rotate camera.
  37095. * @param camera Defines the camera to attach the behavior to
  37096. */
  37097. attach(camera: ArcRotateCamera): void;
  37098. /**
  37099. * Detaches the behavior from its current arc rotate camera.
  37100. */
  37101. detach(): void;
  37102. /**
  37103. * Returns true if user is scrolling.
  37104. * @return true if user is scrolling.
  37105. */
  37106. private _userIsZooming;
  37107. private _lastFrameRadius;
  37108. private _shouldAnimationStopForInteraction;
  37109. /**
  37110. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37111. */
  37112. private _applyUserInteraction;
  37113. private _userIsMoving;
  37114. }
  37115. }
  37116. declare module BABYLON {
  37117. /**
  37118. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37119. */
  37120. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37121. private ui;
  37122. /**
  37123. * The name of the behavior
  37124. */
  37125. name: string;
  37126. /**
  37127. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37128. */
  37129. distanceAwayFromFace: number;
  37130. /**
  37131. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37132. */
  37133. distanceAwayFromBottomOfFace: number;
  37134. private _faceVectors;
  37135. private _target;
  37136. private _scene;
  37137. private _onRenderObserver;
  37138. private _tmpMatrix;
  37139. private _tmpVector;
  37140. /**
  37141. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37142. * @param ui The transform node that should be attched to the mesh
  37143. */
  37144. constructor(ui: TransformNode);
  37145. /**
  37146. * Initializes the behavior
  37147. */
  37148. init(): void;
  37149. private _closestFace;
  37150. private _zeroVector;
  37151. private _lookAtTmpMatrix;
  37152. private _lookAtToRef;
  37153. /**
  37154. * Attaches the AttachToBoxBehavior to the passed in mesh
  37155. * @param target The mesh that the specified node will be attached to
  37156. */
  37157. attach(target: Mesh): void;
  37158. /**
  37159. * Detaches the behavior from the mesh
  37160. */
  37161. detach(): void;
  37162. }
  37163. }
  37164. declare module BABYLON {
  37165. /**
  37166. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37167. */
  37168. export class FadeInOutBehavior implements Behavior<Mesh> {
  37169. /**
  37170. * Time in milliseconds to delay before fading in (Default: 0)
  37171. */
  37172. delay: number;
  37173. /**
  37174. * Time in milliseconds for the mesh to fade in (Default: 300)
  37175. */
  37176. fadeInTime: number;
  37177. private _millisecondsPerFrame;
  37178. private _hovered;
  37179. private _hoverValue;
  37180. private _ownerNode;
  37181. /**
  37182. * Instatiates the FadeInOutBehavior
  37183. */
  37184. constructor();
  37185. /**
  37186. * The name of the behavior
  37187. */
  37188. readonly name: string;
  37189. /**
  37190. * Initializes the behavior
  37191. */
  37192. init(): void;
  37193. /**
  37194. * Attaches the fade behavior on the passed in mesh
  37195. * @param ownerNode The mesh that will be faded in/out once attached
  37196. */
  37197. attach(ownerNode: Mesh): void;
  37198. /**
  37199. * Detaches the behavior from the mesh
  37200. */
  37201. detach(): void;
  37202. /**
  37203. * Triggers the mesh to begin fading in or out
  37204. * @param value if the object should fade in or out (true to fade in)
  37205. */
  37206. fadeIn(value: boolean): void;
  37207. private _update;
  37208. private _setAllVisibility;
  37209. }
  37210. }
  37211. declare module BABYLON {
  37212. /**
  37213. * Class containing a set of static utilities functions for managing Pivots
  37214. * @hidden
  37215. */
  37216. export class PivotTools {
  37217. private static _PivotCached;
  37218. private static _OldPivotPoint;
  37219. private static _PivotTranslation;
  37220. private static _PivotTmpVector;
  37221. /** @hidden */
  37222. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37223. /** @hidden */
  37224. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37225. }
  37226. }
  37227. declare module BABYLON {
  37228. /**
  37229. * Class containing static functions to help procedurally build meshes
  37230. */
  37231. export class PlaneBuilder {
  37232. /**
  37233. * Creates a plane mesh
  37234. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37235. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37236. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37238. * * 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
  37239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37240. * @param name defines the name of the mesh
  37241. * @param options defines the options used to create the mesh
  37242. * @param scene defines the hosting scene
  37243. * @returns the plane mesh
  37244. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37245. */
  37246. static CreatePlane(name: string, options: {
  37247. size?: number;
  37248. width?: number;
  37249. height?: number;
  37250. sideOrientation?: number;
  37251. frontUVs?: Vector4;
  37252. backUVs?: Vector4;
  37253. updatable?: boolean;
  37254. sourcePlane?: Plane;
  37255. }, scene?: Nullable<Scene>): Mesh;
  37256. }
  37257. }
  37258. declare module BABYLON {
  37259. /**
  37260. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37261. */
  37262. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37263. private static _AnyMouseID;
  37264. /**
  37265. * Abstract mesh the behavior is set on
  37266. */
  37267. attachedNode: AbstractMesh;
  37268. private _dragPlane;
  37269. private _scene;
  37270. private _pointerObserver;
  37271. private _beforeRenderObserver;
  37272. private static _planeScene;
  37273. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37274. /**
  37275. * 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)
  37276. */
  37277. maxDragAngle: number;
  37278. /**
  37279. * @hidden
  37280. */
  37281. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37282. /**
  37283. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37284. */
  37285. currentDraggingPointerID: number;
  37286. /**
  37287. * The last position where the pointer hit the drag plane in world space
  37288. */
  37289. lastDragPosition: Vector3;
  37290. /**
  37291. * If the behavior is currently in a dragging state
  37292. */
  37293. dragging: boolean;
  37294. /**
  37295. * 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)
  37296. */
  37297. dragDeltaRatio: number;
  37298. /**
  37299. * If the drag plane orientation should be updated during the dragging (Default: true)
  37300. */
  37301. updateDragPlane: boolean;
  37302. private _debugMode;
  37303. private _moving;
  37304. /**
  37305. * Fires each time the attached mesh is dragged with the pointer
  37306. * * delta between last drag position and current drag position in world space
  37307. * * dragDistance along the drag axis
  37308. * * dragPlaneNormal normal of the current drag plane used during the drag
  37309. * * dragPlanePoint in world space where the drag intersects the drag plane
  37310. */
  37311. onDragObservable: Observable<{
  37312. delta: Vector3;
  37313. dragPlanePoint: Vector3;
  37314. dragPlaneNormal: Vector3;
  37315. dragDistance: number;
  37316. pointerId: number;
  37317. }>;
  37318. /**
  37319. * Fires each time a drag begins (eg. mouse down on mesh)
  37320. */
  37321. onDragStartObservable: Observable<{
  37322. dragPlanePoint: Vector3;
  37323. pointerId: number;
  37324. }>;
  37325. /**
  37326. * Fires each time a drag ends (eg. mouse release after drag)
  37327. */
  37328. onDragEndObservable: Observable<{
  37329. dragPlanePoint: Vector3;
  37330. pointerId: number;
  37331. }>;
  37332. /**
  37333. * If the attached mesh should be moved when dragged
  37334. */
  37335. moveAttached: boolean;
  37336. /**
  37337. * If the drag behavior will react to drag events (Default: true)
  37338. */
  37339. enabled: boolean;
  37340. /**
  37341. * If pointer events should start and release the drag (Default: true)
  37342. */
  37343. startAndReleaseDragOnPointerEvents: boolean;
  37344. /**
  37345. * If camera controls should be detached during the drag
  37346. */
  37347. detachCameraControls: boolean;
  37348. /**
  37349. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37350. */
  37351. useObjectOrienationForDragging: boolean;
  37352. private _options;
  37353. /**
  37354. * Creates a pointer drag behavior that can be attached to a mesh
  37355. * @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)
  37356. */
  37357. constructor(options?: {
  37358. dragAxis?: Vector3;
  37359. dragPlaneNormal?: Vector3;
  37360. });
  37361. /**
  37362. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37363. */
  37364. validateDrag: (targetPosition: Vector3) => boolean;
  37365. /**
  37366. * The name of the behavior
  37367. */
  37368. readonly name: string;
  37369. /**
  37370. * Initializes the behavior
  37371. */
  37372. init(): void;
  37373. private _tmpVector;
  37374. private _alternatePickedPoint;
  37375. private _worldDragAxis;
  37376. private _targetPosition;
  37377. private _attachedElement;
  37378. /**
  37379. * Attaches the drag behavior the passed in mesh
  37380. * @param ownerNode The mesh that will be dragged around once attached
  37381. * @param predicate Predicate to use for pick filtering
  37382. */
  37383. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37384. /**
  37385. * Force relase the drag action by code.
  37386. */
  37387. releaseDrag(): void;
  37388. private _startDragRay;
  37389. private _lastPointerRay;
  37390. /**
  37391. * Simulates the start of a pointer drag event on the behavior
  37392. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37393. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37394. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37395. */
  37396. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37397. private _startDrag;
  37398. private _dragDelta;
  37399. private _moveDrag;
  37400. private _pickWithRayOnDragPlane;
  37401. private _pointA;
  37402. private _pointB;
  37403. private _pointC;
  37404. private _lineA;
  37405. private _lineB;
  37406. private _localAxis;
  37407. private _lookAt;
  37408. private _updateDragPlanePosition;
  37409. /**
  37410. * Detaches the behavior from the mesh
  37411. */
  37412. detach(): void;
  37413. }
  37414. }
  37415. declare module BABYLON {
  37416. /**
  37417. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37418. */
  37419. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37420. private _dragBehaviorA;
  37421. private _dragBehaviorB;
  37422. private _startDistance;
  37423. private _initialScale;
  37424. private _targetScale;
  37425. private _ownerNode;
  37426. private _sceneRenderObserver;
  37427. /**
  37428. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37429. */
  37430. constructor();
  37431. /**
  37432. * The name of the behavior
  37433. */
  37434. readonly name: string;
  37435. /**
  37436. * Initializes the behavior
  37437. */
  37438. init(): void;
  37439. private _getCurrentDistance;
  37440. /**
  37441. * Attaches the scale behavior the passed in mesh
  37442. * @param ownerNode The mesh that will be scaled around once attached
  37443. */
  37444. attach(ownerNode: Mesh): void;
  37445. /**
  37446. * Detaches the behavior from the mesh
  37447. */
  37448. detach(): void;
  37449. }
  37450. }
  37451. declare module BABYLON {
  37452. /**
  37453. * 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
  37454. */
  37455. export class SixDofDragBehavior implements Behavior<Mesh> {
  37456. private static _virtualScene;
  37457. private _ownerNode;
  37458. private _sceneRenderObserver;
  37459. private _scene;
  37460. private _targetPosition;
  37461. private _virtualOriginMesh;
  37462. private _virtualDragMesh;
  37463. private _pointerObserver;
  37464. private _moving;
  37465. private _startingOrientation;
  37466. /**
  37467. * 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)
  37468. */
  37469. private zDragFactor;
  37470. /**
  37471. * If the object should rotate to face the drag origin
  37472. */
  37473. rotateDraggedObject: boolean;
  37474. /**
  37475. * If the behavior is currently in a dragging state
  37476. */
  37477. dragging: boolean;
  37478. /**
  37479. * 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)
  37480. */
  37481. dragDeltaRatio: number;
  37482. /**
  37483. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37484. */
  37485. currentDraggingPointerID: number;
  37486. /**
  37487. * If camera controls should be detached during the drag
  37488. */
  37489. detachCameraControls: boolean;
  37490. /**
  37491. * Fires each time a drag starts
  37492. */
  37493. onDragStartObservable: Observable<{}>;
  37494. /**
  37495. * Fires each time a drag ends (eg. mouse release after drag)
  37496. */
  37497. onDragEndObservable: Observable<{}>;
  37498. /**
  37499. * 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
  37500. */
  37501. constructor();
  37502. /**
  37503. * The name of the behavior
  37504. */
  37505. readonly name: string;
  37506. /**
  37507. * Initializes the behavior
  37508. */
  37509. init(): void;
  37510. /**
  37511. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37512. */
  37513. private readonly _pointerCamera;
  37514. /**
  37515. * Attaches the scale behavior the passed in mesh
  37516. * @param ownerNode The mesh that will be scaled around once attached
  37517. */
  37518. attach(ownerNode: Mesh): void;
  37519. /**
  37520. * Detaches the behavior from the mesh
  37521. */
  37522. detach(): void;
  37523. }
  37524. }
  37525. declare module BABYLON {
  37526. /**
  37527. * Class used to apply inverse kinematics to bones
  37528. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37529. */
  37530. export class BoneIKController {
  37531. private static _tmpVecs;
  37532. private static _tmpQuat;
  37533. private static _tmpMats;
  37534. /**
  37535. * Gets or sets the target mesh
  37536. */
  37537. targetMesh: AbstractMesh;
  37538. /** Gets or sets the mesh used as pole */
  37539. poleTargetMesh: AbstractMesh;
  37540. /**
  37541. * Gets or sets the bone used as pole
  37542. */
  37543. poleTargetBone: Nullable<Bone>;
  37544. /**
  37545. * Gets or sets the target position
  37546. */
  37547. targetPosition: Vector3;
  37548. /**
  37549. * Gets or sets the pole target position
  37550. */
  37551. poleTargetPosition: Vector3;
  37552. /**
  37553. * Gets or sets the pole target local offset
  37554. */
  37555. poleTargetLocalOffset: Vector3;
  37556. /**
  37557. * Gets or sets the pole angle
  37558. */
  37559. poleAngle: number;
  37560. /**
  37561. * Gets or sets the mesh associated with the controller
  37562. */
  37563. mesh: AbstractMesh;
  37564. /**
  37565. * 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)
  37566. */
  37567. slerpAmount: number;
  37568. private _bone1Quat;
  37569. private _bone1Mat;
  37570. private _bone2Ang;
  37571. private _bone1;
  37572. private _bone2;
  37573. private _bone1Length;
  37574. private _bone2Length;
  37575. private _maxAngle;
  37576. private _maxReach;
  37577. private _rightHandedSystem;
  37578. private _bendAxis;
  37579. private _slerping;
  37580. private _adjustRoll;
  37581. /**
  37582. * Gets or sets maximum allowed angle
  37583. */
  37584. maxAngle: number;
  37585. /**
  37586. * Creates a new BoneIKController
  37587. * @param mesh defines the mesh to control
  37588. * @param bone defines the bone to control
  37589. * @param options defines options to set up the controller
  37590. */
  37591. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37592. targetMesh?: AbstractMesh;
  37593. poleTargetMesh?: AbstractMesh;
  37594. poleTargetBone?: Bone;
  37595. poleTargetLocalOffset?: Vector3;
  37596. poleAngle?: number;
  37597. bendAxis?: Vector3;
  37598. maxAngle?: number;
  37599. slerpAmount?: number;
  37600. });
  37601. private _setMaxAngle;
  37602. /**
  37603. * Force the controller to update the bones
  37604. */
  37605. update(): void;
  37606. }
  37607. }
  37608. declare module BABYLON {
  37609. /**
  37610. * Class used to make a bone look toward a point in space
  37611. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37612. */
  37613. export class BoneLookController {
  37614. private static _tmpVecs;
  37615. private static _tmpQuat;
  37616. private static _tmpMats;
  37617. /**
  37618. * The target Vector3 that the bone will look at
  37619. */
  37620. target: Vector3;
  37621. /**
  37622. * The mesh that the bone is attached to
  37623. */
  37624. mesh: AbstractMesh;
  37625. /**
  37626. * The bone that will be looking to the target
  37627. */
  37628. bone: Bone;
  37629. /**
  37630. * The up axis of the coordinate system that is used when the bone is rotated
  37631. */
  37632. upAxis: Vector3;
  37633. /**
  37634. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37635. */
  37636. upAxisSpace: Space;
  37637. /**
  37638. * Used to make an adjustment to the yaw of the bone
  37639. */
  37640. adjustYaw: number;
  37641. /**
  37642. * Used to make an adjustment to the pitch of the bone
  37643. */
  37644. adjustPitch: number;
  37645. /**
  37646. * Used to make an adjustment to the roll of the bone
  37647. */
  37648. adjustRoll: number;
  37649. /**
  37650. * 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)
  37651. */
  37652. slerpAmount: number;
  37653. private _minYaw;
  37654. private _maxYaw;
  37655. private _minPitch;
  37656. private _maxPitch;
  37657. private _minYawSin;
  37658. private _minYawCos;
  37659. private _maxYawSin;
  37660. private _maxYawCos;
  37661. private _midYawConstraint;
  37662. private _minPitchTan;
  37663. private _maxPitchTan;
  37664. private _boneQuat;
  37665. private _slerping;
  37666. private _transformYawPitch;
  37667. private _transformYawPitchInv;
  37668. private _firstFrameSkipped;
  37669. private _yawRange;
  37670. private _fowardAxis;
  37671. /**
  37672. * Gets or sets the minimum yaw angle that the bone can look to
  37673. */
  37674. minYaw: number;
  37675. /**
  37676. * Gets or sets the maximum yaw angle that the bone can look to
  37677. */
  37678. maxYaw: number;
  37679. /**
  37680. * Gets or sets the minimum pitch angle that the bone can look to
  37681. */
  37682. minPitch: number;
  37683. /**
  37684. * Gets or sets the maximum pitch angle that the bone can look to
  37685. */
  37686. maxPitch: number;
  37687. /**
  37688. * Create a BoneLookController
  37689. * @param mesh the mesh that the bone belongs to
  37690. * @param bone the bone that will be looking to the target
  37691. * @param target the target Vector3 to look at
  37692. * @param options optional settings:
  37693. * * maxYaw: the maximum angle the bone will yaw to
  37694. * * minYaw: the minimum angle the bone will yaw to
  37695. * * maxPitch: the maximum angle the bone will pitch to
  37696. * * minPitch: the minimum angle the bone will yaw to
  37697. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37698. * * upAxis: the up axis of the coordinate system
  37699. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37700. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37701. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37702. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37703. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37704. * * adjustRoll: used to make an adjustment to the roll of the bone
  37705. **/
  37706. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37707. maxYaw?: number;
  37708. minYaw?: number;
  37709. maxPitch?: number;
  37710. minPitch?: number;
  37711. slerpAmount?: number;
  37712. upAxis?: Vector3;
  37713. upAxisSpace?: Space;
  37714. yawAxis?: Vector3;
  37715. pitchAxis?: Vector3;
  37716. adjustYaw?: number;
  37717. adjustPitch?: number;
  37718. adjustRoll?: number;
  37719. });
  37720. /**
  37721. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37722. */
  37723. update(): void;
  37724. private _getAngleDiff;
  37725. private _getAngleBetween;
  37726. private _isAngleBetween;
  37727. }
  37728. }
  37729. declare module BABYLON {
  37730. /**
  37731. * Manage the gamepad inputs to control an arc rotate camera.
  37732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37733. */
  37734. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37735. /**
  37736. * Defines the camera the input is attached to.
  37737. */
  37738. camera: ArcRotateCamera;
  37739. /**
  37740. * Defines the gamepad the input is gathering event from.
  37741. */
  37742. gamepad: Nullable<Gamepad>;
  37743. /**
  37744. * Defines the gamepad rotation sensiblity.
  37745. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37746. */
  37747. gamepadRotationSensibility: number;
  37748. /**
  37749. * Defines the gamepad move sensiblity.
  37750. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37751. */
  37752. gamepadMoveSensibility: number;
  37753. private _yAxisScale;
  37754. /**
  37755. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37756. */
  37757. invertYAxis: boolean;
  37758. private _onGamepadConnectedObserver;
  37759. private _onGamepadDisconnectedObserver;
  37760. /**
  37761. * Attach the input controls to a specific dom element to get the input from.
  37762. * @param element Defines the element the controls should be listened from
  37763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37764. */
  37765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37766. /**
  37767. * Detach the current controls from the specified dom element.
  37768. * @param element Defines the element to stop listening the inputs from
  37769. */
  37770. detachControl(element: Nullable<HTMLElement>): void;
  37771. /**
  37772. * Update the current camera state depending on the inputs that have been used this frame.
  37773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37774. */
  37775. checkInputs(): void;
  37776. /**
  37777. * Gets the class name of the current intput.
  37778. * @returns the class name
  37779. */
  37780. getClassName(): string;
  37781. /**
  37782. * Get the friendly name associated with the input class.
  37783. * @returns the input friendly name
  37784. */
  37785. getSimpleName(): string;
  37786. }
  37787. }
  37788. declare module BABYLON {
  37789. interface ArcRotateCameraInputsManager {
  37790. /**
  37791. * Add orientation input support to the input manager.
  37792. * @returns the current input manager
  37793. */
  37794. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37795. }
  37796. /**
  37797. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37799. */
  37800. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37801. /**
  37802. * Defines the camera the input is attached to.
  37803. */
  37804. camera: ArcRotateCamera;
  37805. /**
  37806. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37807. */
  37808. alphaCorrection: number;
  37809. /**
  37810. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37811. */
  37812. gammaCorrection: number;
  37813. private _alpha;
  37814. private _gamma;
  37815. private _dirty;
  37816. private _deviceOrientationHandler;
  37817. /**
  37818. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37819. */
  37820. constructor();
  37821. /**
  37822. * Attach the input controls to a specific dom element to get the input from.
  37823. * @param element Defines the element the controls should be listened from
  37824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37825. */
  37826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37827. /** @hidden */
  37828. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37829. /**
  37830. * Update the current camera state depending on the inputs that have been used this frame.
  37831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37832. */
  37833. checkInputs(): void;
  37834. /**
  37835. * Detach the current controls from the specified dom element.
  37836. * @param element Defines the element to stop listening the inputs from
  37837. */
  37838. detachControl(element: Nullable<HTMLElement>): void;
  37839. /**
  37840. * Gets the class name of the current intput.
  37841. * @returns the class name
  37842. */
  37843. getClassName(): string;
  37844. /**
  37845. * Get the friendly name associated with the input class.
  37846. * @returns the input friendly name
  37847. */
  37848. getSimpleName(): string;
  37849. }
  37850. }
  37851. declare module BABYLON {
  37852. /**
  37853. * Listen to mouse events to control the camera.
  37854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37855. */
  37856. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37857. /**
  37858. * Defines the camera the input is attached to.
  37859. */
  37860. camera: FlyCamera;
  37861. /**
  37862. * Defines if touch is enabled. (Default is true.)
  37863. */
  37864. touchEnabled: boolean;
  37865. /**
  37866. * Defines the buttons associated with the input to handle camera rotation.
  37867. */
  37868. buttons: number[];
  37869. /**
  37870. * Assign buttons for Yaw control.
  37871. */
  37872. buttonsYaw: number[];
  37873. /**
  37874. * Assign buttons for Pitch control.
  37875. */
  37876. buttonsPitch: number[];
  37877. /**
  37878. * Assign buttons for Roll control.
  37879. */
  37880. buttonsRoll: number[];
  37881. /**
  37882. * Detect if any button is being pressed while mouse is moved.
  37883. * -1 = Mouse locked.
  37884. * 0 = Left button.
  37885. * 1 = Middle Button.
  37886. * 2 = Right Button.
  37887. */
  37888. activeButton: number;
  37889. /**
  37890. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37891. * Higher values reduce its sensitivity.
  37892. */
  37893. angularSensibility: number;
  37894. private _mousemoveCallback;
  37895. private _observer;
  37896. private _rollObserver;
  37897. private previousPosition;
  37898. private noPreventDefault;
  37899. private element;
  37900. /**
  37901. * Listen to mouse events to control the camera.
  37902. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37904. */
  37905. constructor(touchEnabled?: boolean);
  37906. /**
  37907. * Attach the mouse control to the HTML DOM element.
  37908. * @param element Defines the element that listens to the input events.
  37909. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37910. */
  37911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37912. /**
  37913. * Detach the current controls from the specified dom element.
  37914. * @param element Defines the element to stop listening the inputs from
  37915. */
  37916. detachControl(element: Nullable<HTMLElement>): void;
  37917. /**
  37918. * Gets the class name of the current input.
  37919. * @returns the class name.
  37920. */
  37921. getClassName(): string;
  37922. /**
  37923. * Get the friendly name associated with the input class.
  37924. * @returns the input's friendly name.
  37925. */
  37926. getSimpleName(): string;
  37927. private _pointerInput;
  37928. private _onMouseMove;
  37929. /**
  37930. * Rotate camera by mouse offset.
  37931. */
  37932. private rotateCamera;
  37933. }
  37934. }
  37935. declare module BABYLON {
  37936. /**
  37937. * Default Inputs manager for the FlyCamera.
  37938. * It groups all the default supported inputs for ease of use.
  37939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37940. */
  37941. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37942. /**
  37943. * Instantiates a new FlyCameraInputsManager.
  37944. * @param camera Defines the camera the inputs belong to.
  37945. */
  37946. constructor(camera: FlyCamera);
  37947. /**
  37948. * Add keyboard input support to the input manager.
  37949. * @returns the new FlyCameraKeyboardMoveInput().
  37950. */
  37951. addKeyboard(): FlyCameraInputsManager;
  37952. /**
  37953. * Add mouse input support to the input manager.
  37954. * @param touchEnabled Enable touch screen support.
  37955. * @returns the new FlyCameraMouseInput().
  37956. */
  37957. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37958. }
  37959. }
  37960. declare module BABYLON {
  37961. /**
  37962. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37963. * such as in a 3D Space Shooter or a Flight Simulator.
  37964. */
  37965. export class FlyCamera extends TargetCamera {
  37966. /**
  37967. * Define the collision ellipsoid of the camera.
  37968. * This is helpful for simulating a camera body, like a player's body.
  37969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37970. */
  37971. ellipsoid: Vector3;
  37972. /**
  37973. * Define an offset for the position of the ellipsoid around the camera.
  37974. * This can be helpful if the camera is attached away from the player's body center,
  37975. * such as at its head.
  37976. */
  37977. ellipsoidOffset: Vector3;
  37978. /**
  37979. * Enable or disable collisions of the camera with the rest of the scene objects.
  37980. */
  37981. checkCollisions: boolean;
  37982. /**
  37983. * Enable or disable gravity on the camera.
  37984. */
  37985. applyGravity: boolean;
  37986. /**
  37987. * Define the current direction the camera is moving to.
  37988. */
  37989. cameraDirection: Vector3;
  37990. /**
  37991. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37992. * This overrides and empties cameraRotation.
  37993. */
  37994. rotationQuaternion: Quaternion;
  37995. /**
  37996. * Track Roll to maintain the wanted Rolling when looking around.
  37997. */
  37998. _trackRoll: number;
  37999. /**
  38000. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38001. */
  38002. rollCorrect: number;
  38003. /**
  38004. * Mimic a banked turn, Rolling the camera when Yawing.
  38005. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38006. */
  38007. bankedTurn: boolean;
  38008. /**
  38009. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38010. */
  38011. bankedTurnLimit: number;
  38012. /**
  38013. * Value of 0 disables the banked Roll.
  38014. * Value of 1 is equal to the Yaw angle in radians.
  38015. */
  38016. bankedTurnMultiplier: number;
  38017. /**
  38018. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38019. */
  38020. inputs: FlyCameraInputsManager;
  38021. /**
  38022. * Gets the input sensibility for mouse input.
  38023. * Higher values reduce sensitivity.
  38024. */
  38025. /**
  38026. * Sets the input sensibility for a mouse input.
  38027. * Higher values reduce sensitivity.
  38028. */
  38029. angularSensibility: number;
  38030. /**
  38031. * Get the keys for camera movement forward.
  38032. */
  38033. /**
  38034. * Set the keys for camera movement forward.
  38035. */
  38036. keysForward: number[];
  38037. /**
  38038. * Get the keys for camera movement backward.
  38039. */
  38040. keysBackward: number[];
  38041. /**
  38042. * Get the keys for camera movement up.
  38043. */
  38044. /**
  38045. * Set the keys for camera movement up.
  38046. */
  38047. keysUp: number[];
  38048. /**
  38049. * Get the keys for camera movement down.
  38050. */
  38051. /**
  38052. * Set the keys for camera movement down.
  38053. */
  38054. keysDown: number[];
  38055. /**
  38056. * Get the keys for camera movement left.
  38057. */
  38058. /**
  38059. * Set the keys for camera movement left.
  38060. */
  38061. keysLeft: number[];
  38062. /**
  38063. * Set the keys for camera movement right.
  38064. */
  38065. /**
  38066. * Set the keys for camera movement right.
  38067. */
  38068. keysRight: number[];
  38069. /**
  38070. * Event raised when the camera collides with a mesh in the scene.
  38071. */
  38072. onCollide: (collidedMesh: AbstractMesh) => void;
  38073. private _collider;
  38074. private _needMoveForGravity;
  38075. private _oldPosition;
  38076. private _diffPosition;
  38077. private _newPosition;
  38078. /** @hidden */
  38079. _localDirection: Vector3;
  38080. /** @hidden */
  38081. _transformedDirection: Vector3;
  38082. /**
  38083. * Instantiates a FlyCamera.
  38084. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38085. * such as in a 3D Space Shooter or a Flight Simulator.
  38086. * @param name Define the name of the camera in the scene.
  38087. * @param position Define the starting position of the camera in the scene.
  38088. * @param scene Define the scene the camera belongs to.
  38089. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38090. */
  38091. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38092. /**
  38093. * Attach a control to the HTML DOM element.
  38094. * @param element Defines the element that listens to the input events.
  38095. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38096. */
  38097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38098. /**
  38099. * Detach a control from the HTML DOM element.
  38100. * The camera will stop reacting to that input.
  38101. * @param element Defines the element that listens to the input events.
  38102. */
  38103. detachControl(element: HTMLElement): void;
  38104. private _collisionMask;
  38105. /**
  38106. * Get the mask that the camera ignores in collision events.
  38107. */
  38108. /**
  38109. * Set the mask that the camera ignores in collision events.
  38110. */
  38111. collisionMask: number;
  38112. /** @hidden */
  38113. _collideWithWorld(displacement: Vector3): void;
  38114. /** @hidden */
  38115. private _onCollisionPositionChange;
  38116. /** @hidden */
  38117. _checkInputs(): void;
  38118. /** @hidden */
  38119. _decideIfNeedsToMove(): boolean;
  38120. /** @hidden */
  38121. _updatePosition(): void;
  38122. /**
  38123. * Restore the Roll to its target value at the rate specified.
  38124. * @param rate - Higher means slower restoring.
  38125. * @hidden
  38126. */
  38127. restoreRoll(rate: number): void;
  38128. /**
  38129. * Destroy the camera and release the current resources held by it.
  38130. */
  38131. dispose(): void;
  38132. /**
  38133. * Get the current object class name.
  38134. * @returns the class name.
  38135. */
  38136. getClassName(): string;
  38137. }
  38138. }
  38139. declare module BABYLON {
  38140. /**
  38141. * Listen to keyboard events to control the camera.
  38142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38143. */
  38144. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38145. /**
  38146. * Defines the camera the input is attached to.
  38147. */
  38148. camera: FlyCamera;
  38149. /**
  38150. * The list of keyboard keys used to control the forward move of the camera.
  38151. */
  38152. keysForward: number[];
  38153. /**
  38154. * The list of keyboard keys used to control the backward move of the camera.
  38155. */
  38156. keysBackward: number[];
  38157. /**
  38158. * The list of keyboard keys used to control the forward move of the camera.
  38159. */
  38160. keysUp: number[];
  38161. /**
  38162. * The list of keyboard keys used to control the backward move of the camera.
  38163. */
  38164. keysDown: number[];
  38165. /**
  38166. * The list of keyboard keys used to control the right strafe move of the camera.
  38167. */
  38168. keysRight: number[];
  38169. /**
  38170. * The list of keyboard keys used to control the left strafe move of the camera.
  38171. */
  38172. keysLeft: number[];
  38173. private _keys;
  38174. private _onCanvasBlurObserver;
  38175. private _onKeyboardObserver;
  38176. private _engine;
  38177. private _scene;
  38178. /**
  38179. * Attach the input controls to a specific dom element to get the input from.
  38180. * @param element Defines the element the controls should be listened from
  38181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38182. */
  38183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38184. /**
  38185. * Detach the current controls from the specified dom element.
  38186. * @param element Defines the element to stop listening the inputs from
  38187. */
  38188. detachControl(element: Nullable<HTMLElement>): void;
  38189. /**
  38190. * Gets the class name of the current intput.
  38191. * @returns the class name
  38192. */
  38193. getClassName(): string;
  38194. /** @hidden */
  38195. _onLostFocus(e: FocusEvent): void;
  38196. /**
  38197. * Get the friendly name associated with the input class.
  38198. * @returns the input friendly name
  38199. */
  38200. getSimpleName(): string;
  38201. /**
  38202. * Update the current camera state depending on the inputs that have been used this frame.
  38203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38204. */
  38205. checkInputs(): void;
  38206. }
  38207. }
  38208. declare module BABYLON {
  38209. /**
  38210. * Manage the mouse wheel inputs to control a follow camera.
  38211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38212. */
  38213. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38214. /**
  38215. * Defines the camera the input is attached to.
  38216. */
  38217. camera: FollowCamera;
  38218. /**
  38219. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38220. */
  38221. axisControlRadius: boolean;
  38222. /**
  38223. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38224. */
  38225. axisControlHeight: boolean;
  38226. /**
  38227. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38228. */
  38229. axisControlRotation: boolean;
  38230. /**
  38231. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38232. * relation to mouseWheel events.
  38233. */
  38234. wheelPrecision: number;
  38235. /**
  38236. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38237. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38238. */
  38239. wheelDeltaPercentage: number;
  38240. private _wheel;
  38241. private _observer;
  38242. /**
  38243. * Attach the input controls to a specific dom element to get the input from.
  38244. * @param element Defines the element the controls should be listened from
  38245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38246. */
  38247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38248. /**
  38249. * Detach the current controls from the specified dom element.
  38250. * @param element Defines the element to stop listening the inputs from
  38251. */
  38252. detachControl(element: Nullable<HTMLElement>): void;
  38253. /**
  38254. * Gets the class name of the current intput.
  38255. * @returns the class name
  38256. */
  38257. getClassName(): string;
  38258. /**
  38259. * Get the friendly name associated with the input class.
  38260. * @returns the input friendly name
  38261. */
  38262. getSimpleName(): string;
  38263. }
  38264. }
  38265. declare module BABYLON {
  38266. /**
  38267. * Manage the pointers inputs to control an follow camera.
  38268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38269. */
  38270. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38271. /**
  38272. * Defines the camera the input is attached to.
  38273. */
  38274. camera: FollowCamera;
  38275. /**
  38276. * Gets the class name of the current input.
  38277. * @returns the class name
  38278. */
  38279. getClassName(): string;
  38280. /**
  38281. * Defines the pointer angular sensibility along the X axis or how fast is
  38282. * the camera rotating.
  38283. * A negative number will reverse the axis direction.
  38284. */
  38285. angularSensibilityX: number;
  38286. /**
  38287. * Defines the pointer angular sensibility along the Y axis or how fast is
  38288. * the camera rotating.
  38289. * A negative number will reverse the axis direction.
  38290. */
  38291. angularSensibilityY: number;
  38292. /**
  38293. * Defines the pointer pinch precision or how fast is the camera zooming.
  38294. * A negative number will reverse the axis direction.
  38295. */
  38296. pinchPrecision: number;
  38297. /**
  38298. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38299. * from 0.
  38300. * It defines the percentage of current camera.radius to use as delta when
  38301. * pinch zoom is used.
  38302. */
  38303. pinchDeltaPercentage: number;
  38304. /**
  38305. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38306. */
  38307. axisXControlRadius: boolean;
  38308. /**
  38309. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38310. */
  38311. axisXControlHeight: boolean;
  38312. /**
  38313. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38314. */
  38315. axisXControlRotation: boolean;
  38316. /**
  38317. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38318. */
  38319. axisYControlRadius: boolean;
  38320. /**
  38321. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38322. */
  38323. axisYControlHeight: boolean;
  38324. /**
  38325. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38326. */
  38327. axisYControlRotation: boolean;
  38328. /**
  38329. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38330. */
  38331. axisPinchControlRadius: boolean;
  38332. /**
  38333. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38334. */
  38335. axisPinchControlHeight: boolean;
  38336. /**
  38337. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38338. */
  38339. axisPinchControlRotation: boolean;
  38340. /**
  38341. * Log error messages if basic misconfiguration has occurred.
  38342. */
  38343. warningEnable: boolean;
  38344. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38345. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38346. private _warningCounter;
  38347. private _warning;
  38348. }
  38349. }
  38350. declare module BABYLON {
  38351. /**
  38352. * Default Inputs manager for the FollowCamera.
  38353. * It groups all the default supported inputs for ease of use.
  38354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38355. */
  38356. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38357. /**
  38358. * Instantiates a new FollowCameraInputsManager.
  38359. * @param camera Defines the camera the inputs belong to
  38360. */
  38361. constructor(camera: FollowCamera);
  38362. /**
  38363. * Add keyboard input support to the input manager.
  38364. * @returns the current input manager
  38365. */
  38366. addKeyboard(): FollowCameraInputsManager;
  38367. /**
  38368. * Add mouse wheel input support to the input manager.
  38369. * @returns the current input manager
  38370. */
  38371. addMouseWheel(): FollowCameraInputsManager;
  38372. /**
  38373. * Add pointers input support to the input manager.
  38374. * @returns the current input manager
  38375. */
  38376. addPointers(): FollowCameraInputsManager;
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): FollowCameraInputsManager;
  38382. }
  38383. }
  38384. declare module BABYLON {
  38385. /**
  38386. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38387. * an arc rotate version arcFollowCamera are available.
  38388. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38389. */
  38390. export class FollowCamera extends TargetCamera {
  38391. /**
  38392. * Distance the follow camera should follow an object at
  38393. */
  38394. radius: number;
  38395. /**
  38396. * Minimum allowed distance of the camera to the axis of rotation
  38397. * (The camera can not get closer).
  38398. * This can help limiting how the Camera is able to move in the scene.
  38399. */
  38400. lowerRadiusLimit: Nullable<number>;
  38401. /**
  38402. * Maximum allowed distance of the camera to the axis of rotation
  38403. * (The camera can not get further).
  38404. * This can help limiting how the Camera is able to move in the scene.
  38405. */
  38406. upperRadiusLimit: Nullable<number>;
  38407. /**
  38408. * Define a rotation offset between the camera and the object it follows
  38409. */
  38410. rotationOffset: number;
  38411. /**
  38412. * Minimum allowed angle to camera position relative to target object.
  38413. * This can help limiting how the Camera is able to move in the scene.
  38414. */
  38415. lowerRotationOffsetLimit: Nullable<number>;
  38416. /**
  38417. * Maximum allowed angle to camera position relative to target object.
  38418. * This can help limiting how the Camera is able to move in the scene.
  38419. */
  38420. upperRotationOffsetLimit: Nullable<number>;
  38421. /**
  38422. * Define a height offset between the camera and the object it follows.
  38423. * It can help following an object from the top (like a car chaing a plane)
  38424. */
  38425. heightOffset: number;
  38426. /**
  38427. * Minimum allowed height of camera position relative to target object.
  38428. * This can help limiting how the Camera is able to move in the scene.
  38429. */
  38430. lowerHeightOffsetLimit: Nullable<number>;
  38431. /**
  38432. * Maximum allowed height of camera position relative to target object.
  38433. * This can help limiting how the Camera is able to move in the scene.
  38434. */
  38435. upperHeightOffsetLimit: Nullable<number>;
  38436. /**
  38437. * Define how fast the camera can accelerate to follow it s target.
  38438. */
  38439. cameraAcceleration: number;
  38440. /**
  38441. * Define the speed limit of the camera following an object.
  38442. */
  38443. maxCameraSpeed: number;
  38444. /**
  38445. * Define the target of the camera.
  38446. */
  38447. lockedTarget: Nullable<AbstractMesh>;
  38448. /**
  38449. * Defines the input associated with the camera.
  38450. */
  38451. inputs: FollowCameraInputsManager;
  38452. /**
  38453. * Instantiates the follow camera.
  38454. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38455. * @param name Define the name of the camera in the scene
  38456. * @param position Define the position of the camera
  38457. * @param scene Define the scene the camera belong to
  38458. * @param lockedTarget Define the target of the camera
  38459. */
  38460. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38461. private _follow;
  38462. /**
  38463. * Attached controls to the current camera.
  38464. * @param element Defines the element the controls should be listened from
  38465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38466. */
  38467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38468. /**
  38469. * Detach the current controls from the camera.
  38470. * The camera will stop reacting to inputs.
  38471. * @param element Defines the element to stop listening the inputs from
  38472. */
  38473. detachControl(element: HTMLElement): void;
  38474. /** @hidden */
  38475. _checkInputs(): void;
  38476. private _checkLimits;
  38477. /**
  38478. * Gets the camera class name.
  38479. * @returns the class name
  38480. */
  38481. getClassName(): string;
  38482. }
  38483. /**
  38484. * Arc Rotate version of the follow camera.
  38485. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38486. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38487. */
  38488. export class ArcFollowCamera extends TargetCamera {
  38489. /** The longitudinal angle of the camera */
  38490. alpha: number;
  38491. /** The latitudinal angle of the camera */
  38492. beta: number;
  38493. /** The radius of the camera from its target */
  38494. radius: number;
  38495. /** Define the camera target (the messh it should follow) */
  38496. target: Nullable<AbstractMesh>;
  38497. private _cartesianCoordinates;
  38498. /**
  38499. * Instantiates a new ArcFollowCamera
  38500. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38501. * @param name Define the name of the camera
  38502. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38503. * @param beta Define the rotation angle of the camera around the elevation axis
  38504. * @param radius Define the radius of the camera from its target point
  38505. * @param target Define the target of the camera
  38506. * @param scene Define the scene the camera belongs to
  38507. */
  38508. constructor(name: string,
  38509. /** The longitudinal angle of the camera */
  38510. alpha: number,
  38511. /** The latitudinal angle of the camera */
  38512. beta: number,
  38513. /** The radius of the camera from its target */
  38514. radius: number,
  38515. /** Define the camera target (the messh it should follow) */
  38516. target: Nullable<AbstractMesh>, scene: Scene);
  38517. private _follow;
  38518. /** @hidden */
  38519. _checkInputs(): void;
  38520. /**
  38521. * Returns the class name of the object.
  38522. * It is mostly used internally for serialization purposes.
  38523. */
  38524. getClassName(): string;
  38525. }
  38526. }
  38527. declare module BABYLON {
  38528. /**
  38529. * Manage the keyboard inputs to control the movement of a follow camera.
  38530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38531. */
  38532. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38533. /**
  38534. * Defines the camera the input is attached to.
  38535. */
  38536. camera: FollowCamera;
  38537. /**
  38538. * Defines the list of key codes associated with the up action (increase heightOffset)
  38539. */
  38540. keysHeightOffsetIncr: number[];
  38541. /**
  38542. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38543. */
  38544. keysHeightOffsetDecr: number[];
  38545. /**
  38546. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38547. */
  38548. keysHeightOffsetModifierAlt: boolean;
  38549. /**
  38550. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38551. */
  38552. keysHeightOffsetModifierCtrl: boolean;
  38553. /**
  38554. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38555. */
  38556. keysHeightOffsetModifierShift: boolean;
  38557. /**
  38558. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38559. */
  38560. keysRotationOffsetIncr: number[];
  38561. /**
  38562. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38563. */
  38564. keysRotationOffsetDecr: number[];
  38565. /**
  38566. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38567. */
  38568. keysRotationOffsetModifierAlt: boolean;
  38569. /**
  38570. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38571. */
  38572. keysRotationOffsetModifierCtrl: boolean;
  38573. /**
  38574. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38575. */
  38576. keysRotationOffsetModifierShift: boolean;
  38577. /**
  38578. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38579. */
  38580. keysRadiusIncr: number[];
  38581. /**
  38582. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38583. */
  38584. keysRadiusDecr: number[];
  38585. /**
  38586. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38587. */
  38588. keysRadiusModifierAlt: boolean;
  38589. /**
  38590. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38591. */
  38592. keysRadiusModifierCtrl: boolean;
  38593. /**
  38594. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38595. */
  38596. keysRadiusModifierShift: boolean;
  38597. /**
  38598. * Defines the rate of change of heightOffset.
  38599. */
  38600. heightSensibility: number;
  38601. /**
  38602. * Defines the rate of change of rotationOffset.
  38603. */
  38604. rotationSensibility: number;
  38605. /**
  38606. * Defines the rate of change of radius.
  38607. */
  38608. radiusSensibility: number;
  38609. private _keys;
  38610. private _ctrlPressed;
  38611. private _altPressed;
  38612. private _shiftPressed;
  38613. private _onCanvasBlurObserver;
  38614. private _onKeyboardObserver;
  38615. private _engine;
  38616. private _scene;
  38617. /**
  38618. * Attach the input controls to a specific dom element to get the input from.
  38619. * @param element Defines the element the controls should be listened from
  38620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38621. */
  38622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38623. /**
  38624. * Detach the current controls from the specified dom element.
  38625. * @param element Defines the element to stop listening the inputs from
  38626. */
  38627. detachControl(element: Nullable<HTMLElement>): void;
  38628. /**
  38629. * Update the current camera state depending on the inputs that have been used this frame.
  38630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38631. */
  38632. checkInputs(): void;
  38633. /**
  38634. * Gets the class name of the current input.
  38635. * @returns the class name
  38636. */
  38637. getClassName(): string;
  38638. /**
  38639. * Get the friendly name associated with the input class.
  38640. * @returns the input friendly name
  38641. */
  38642. getSimpleName(): string;
  38643. /**
  38644. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38645. * allow modification of the heightOffset value.
  38646. */
  38647. private _modifierHeightOffset;
  38648. /**
  38649. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38650. * allow modification of the rotationOffset value.
  38651. */
  38652. private _modifierRotationOffset;
  38653. /**
  38654. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38655. * allow modification of the radius value.
  38656. */
  38657. private _modifierRadius;
  38658. }
  38659. }
  38660. declare module BABYLON {
  38661. interface FreeCameraInputsManager {
  38662. /**
  38663. * @hidden
  38664. */
  38665. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38666. /**
  38667. * Add orientation input support to the input manager.
  38668. * @returns the current input manager
  38669. */
  38670. addDeviceOrientation(): FreeCameraInputsManager;
  38671. }
  38672. /**
  38673. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38674. * Screen rotation is taken into account.
  38675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38676. */
  38677. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38678. private _camera;
  38679. private _screenOrientationAngle;
  38680. private _constantTranform;
  38681. private _screenQuaternion;
  38682. private _alpha;
  38683. private _beta;
  38684. private _gamma;
  38685. /**
  38686. * Can be used to detect if a device orientation sensor is availible on a device
  38687. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38688. * @returns a promise that will resolve on orientation change
  38689. */
  38690. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38691. /**
  38692. * @hidden
  38693. */
  38694. _onDeviceOrientationChangedObservable: Observable<void>;
  38695. /**
  38696. * Instantiates a new input
  38697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38698. */
  38699. constructor();
  38700. /**
  38701. * Define the camera controlled by the input.
  38702. */
  38703. camera: FreeCamera;
  38704. /**
  38705. * Attach the input controls to a specific dom element to get the input from.
  38706. * @param element Defines the element the controls should be listened from
  38707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38708. */
  38709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38710. private _orientationChanged;
  38711. private _deviceOrientation;
  38712. /**
  38713. * Detach the current controls from the specified dom element.
  38714. * @param element Defines the element to stop listening the inputs from
  38715. */
  38716. detachControl(element: Nullable<HTMLElement>): void;
  38717. /**
  38718. * Update the current camera state depending on the inputs that have been used this frame.
  38719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38720. */
  38721. checkInputs(): void;
  38722. /**
  38723. * Gets the class name of the current intput.
  38724. * @returns the class name
  38725. */
  38726. getClassName(): string;
  38727. /**
  38728. * Get the friendly name associated with the input class.
  38729. * @returns the input friendly name
  38730. */
  38731. getSimpleName(): string;
  38732. }
  38733. }
  38734. declare module BABYLON {
  38735. /**
  38736. * Manage the gamepad inputs to control a free camera.
  38737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38738. */
  38739. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38740. /**
  38741. * Define the camera the input is attached to.
  38742. */
  38743. camera: FreeCamera;
  38744. /**
  38745. * Define the Gamepad controlling the input
  38746. */
  38747. gamepad: Nullable<Gamepad>;
  38748. /**
  38749. * Defines the gamepad rotation sensiblity.
  38750. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38751. */
  38752. gamepadAngularSensibility: number;
  38753. /**
  38754. * Defines the gamepad move sensiblity.
  38755. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38756. */
  38757. gamepadMoveSensibility: number;
  38758. private _yAxisScale;
  38759. /**
  38760. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38761. */
  38762. invertYAxis: boolean;
  38763. private _onGamepadConnectedObserver;
  38764. private _onGamepadDisconnectedObserver;
  38765. private _cameraTransform;
  38766. private _deltaTransform;
  38767. private _vector3;
  38768. private _vector2;
  38769. /**
  38770. * Attach the input controls to a specific dom element to get the input from.
  38771. * @param element Defines the element the controls should be listened from
  38772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38773. */
  38774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38775. /**
  38776. * Detach the current controls from the specified dom element.
  38777. * @param element Defines the element to stop listening the inputs from
  38778. */
  38779. detachControl(element: Nullable<HTMLElement>): void;
  38780. /**
  38781. * Update the current camera state depending on the inputs that have been used this frame.
  38782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38783. */
  38784. checkInputs(): void;
  38785. /**
  38786. * Gets the class name of the current intput.
  38787. * @returns the class name
  38788. */
  38789. getClassName(): string;
  38790. /**
  38791. * Get the friendly name associated with the input class.
  38792. * @returns the input friendly name
  38793. */
  38794. getSimpleName(): string;
  38795. }
  38796. }
  38797. declare module BABYLON {
  38798. /**
  38799. * Defines the potential axis of a Joystick
  38800. */
  38801. export enum JoystickAxis {
  38802. /** X axis */
  38803. X = 0,
  38804. /** Y axis */
  38805. Y = 1,
  38806. /** Z axis */
  38807. Z = 2
  38808. }
  38809. /**
  38810. * Class used to define virtual joystick (used in touch mode)
  38811. */
  38812. export class VirtualJoystick {
  38813. /**
  38814. * Gets or sets a boolean indicating that left and right values must be inverted
  38815. */
  38816. reverseLeftRight: boolean;
  38817. /**
  38818. * Gets or sets a boolean indicating that up and down values must be inverted
  38819. */
  38820. reverseUpDown: boolean;
  38821. /**
  38822. * Gets the offset value for the position (ie. the change of the position value)
  38823. */
  38824. deltaPosition: Vector3;
  38825. /**
  38826. * Gets a boolean indicating if the virtual joystick was pressed
  38827. */
  38828. pressed: boolean;
  38829. /**
  38830. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38831. */
  38832. static Canvas: Nullable<HTMLCanvasElement>;
  38833. private static _globalJoystickIndex;
  38834. private static vjCanvasContext;
  38835. private static vjCanvasWidth;
  38836. private static vjCanvasHeight;
  38837. private static halfWidth;
  38838. private _action;
  38839. private _axisTargetedByLeftAndRight;
  38840. private _axisTargetedByUpAndDown;
  38841. private _joystickSensibility;
  38842. private _inversedSensibility;
  38843. private _joystickPointerID;
  38844. private _joystickColor;
  38845. private _joystickPointerPos;
  38846. private _joystickPreviousPointerPos;
  38847. private _joystickPointerStartPos;
  38848. private _deltaJoystickVector;
  38849. private _leftJoystick;
  38850. private _touches;
  38851. private _onPointerDownHandlerRef;
  38852. private _onPointerMoveHandlerRef;
  38853. private _onPointerUpHandlerRef;
  38854. private _onResize;
  38855. /**
  38856. * Creates a new virtual joystick
  38857. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38858. */
  38859. constructor(leftJoystick?: boolean);
  38860. /**
  38861. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38862. * @param newJoystickSensibility defines the new sensibility
  38863. */
  38864. setJoystickSensibility(newJoystickSensibility: number): void;
  38865. private _onPointerDown;
  38866. private _onPointerMove;
  38867. private _onPointerUp;
  38868. /**
  38869. * Change the color of the virtual joystick
  38870. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38871. */
  38872. setJoystickColor(newColor: string): void;
  38873. /**
  38874. * Defines a callback to call when the joystick is touched
  38875. * @param action defines the callback
  38876. */
  38877. setActionOnTouch(action: () => any): void;
  38878. /**
  38879. * Defines which axis you'd like to control for left & right
  38880. * @param axis defines the axis to use
  38881. */
  38882. setAxisForLeftRight(axis: JoystickAxis): void;
  38883. /**
  38884. * Defines which axis you'd like to control for up & down
  38885. * @param axis defines the axis to use
  38886. */
  38887. setAxisForUpDown(axis: JoystickAxis): void;
  38888. private _drawVirtualJoystick;
  38889. /**
  38890. * Release internal HTML canvas
  38891. */
  38892. releaseCanvas(): void;
  38893. }
  38894. }
  38895. declare module BABYLON {
  38896. interface FreeCameraInputsManager {
  38897. /**
  38898. * Add virtual joystick input support to the input manager.
  38899. * @returns the current input manager
  38900. */
  38901. addVirtualJoystick(): FreeCameraInputsManager;
  38902. }
  38903. /**
  38904. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38905. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38906. */
  38907. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38908. /**
  38909. * Defines the camera the input is attached to.
  38910. */
  38911. camera: FreeCamera;
  38912. private _leftjoystick;
  38913. private _rightjoystick;
  38914. /**
  38915. * Gets the left stick of the virtual joystick.
  38916. * @returns The virtual Joystick
  38917. */
  38918. getLeftJoystick(): VirtualJoystick;
  38919. /**
  38920. * Gets the right stick of the virtual joystick.
  38921. * @returns The virtual Joystick
  38922. */
  38923. getRightJoystick(): VirtualJoystick;
  38924. /**
  38925. * Update the current camera state depending on the inputs that have been used this frame.
  38926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38927. */
  38928. checkInputs(): void;
  38929. /**
  38930. * Attach the input controls to a specific dom element to get the input from.
  38931. * @param element Defines the element the controls should be listened from
  38932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38933. */
  38934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38935. /**
  38936. * Detach the current controls from the specified dom element.
  38937. * @param element Defines the element to stop listening the inputs from
  38938. */
  38939. detachControl(element: Nullable<HTMLElement>): void;
  38940. /**
  38941. * Gets the class name of the current intput.
  38942. * @returns the class name
  38943. */
  38944. getClassName(): string;
  38945. /**
  38946. * Get the friendly name associated with the input class.
  38947. * @returns the input friendly name
  38948. */
  38949. getSimpleName(): string;
  38950. }
  38951. }
  38952. declare module BABYLON {
  38953. /**
  38954. * This represents a FPS type of camera controlled by touch.
  38955. * This is like a universal camera minus the Gamepad controls.
  38956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38957. */
  38958. export class TouchCamera extends FreeCamera {
  38959. /**
  38960. * Defines the touch sensibility for rotation.
  38961. * The higher the faster.
  38962. */
  38963. touchAngularSensibility: number;
  38964. /**
  38965. * Defines the touch sensibility for move.
  38966. * The higher the faster.
  38967. */
  38968. touchMoveSensibility: number;
  38969. /**
  38970. * Instantiates a new touch camera.
  38971. * This represents a FPS type of camera controlled by touch.
  38972. * This is like a universal camera minus the Gamepad controls.
  38973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38974. * @param name Define the name of the camera in the scene
  38975. * @param position Define the start position of the camera in the scene
  38976. * @param scene Define the scene the camera belongs to
  38977. */
  38978. constructor(name: string, position: Vector3, scene: Scene);
  38979. /**
  38980. * Gets the current object class name.
  38981. * @return the class name
  38982. */
  38983. getClassName(): string;
  38984. /** @hidden */
  38985. _setupInputs(): void;
  38986. }
  38987. }
  38988. declare module BABYLON {
  38989. /**
  38990. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38991. * being tilted forward or back and left or right.
  38992. */
  38993. export class DeviceOrientationCamera extends FreeCamera {
  38994. private _initialQuaternion;
  38995. private _quaternionCache;
  38996. private _tmpDragQuaternion;
  38997. private _disablePointerInputWhenUsingDeviceOrientation;
  38998. /**
  38999. * Creates a new device orientation camera
  39000. * @param name The name of the camera
  39001. * @param position The start position camera
  39002. * @param scene The scene the camera belongs to
  39003. */
  39004. constructor(name: string, position: Vector3, scene: Scene);
  39005. /**
  39006. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39007. */
  39008. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39009. private _dragFactor;
  39010. /**
  39011. * Enabled turning on the y axis when the orientation sensor is active
  39012. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39013. */
  39014. enableHorizontalDragging(dragFactor?: number): void;
  39015. /**
  39016. * Gets the current instance class name ("DeviceOrientationCamera").
  39017. * This helps avoiding instanceof at run time.
  39018. * @returns the class name
  39019. */
  39020. getClassName(): string;
  39021. /**
  39022. * @hidden
  39023. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39024. */
  39025. _checkInputs(): void;
  39026. /**
  39027. * Reset the camera to its default orientation on the specified axis only.
  39028. * @param axis The axis to reset
  39029. */
  39030. resetToCurrentRotation(axis?: Axis): void;
  39031. }
  39032. }
  39033. declare module BABYLON {
  39034. /**
  39035. * Defines supported buttons for XBox360 compatible gamepads
  39036. */
  39037. export enum Xbox360Button {
  39038. /** A */
  39039. A = 0,
  39040. /** B */
  39041. B = 1,
  39042. /** X */
  39043. X = 2,
  39044. /** Y */
  39045. Y = 3,
  39046. /** Start */
  39047. Start = 4,
  39048. /** Back */
  39049. Back = 5,
  39050. /** Left button */
  39051. LB = 6,
  39052. /** Right button */
  39053. RB = 7,
  39054. /** Left stick */
  39055. LeftStick = 8,
  39056. /** Right stick */
  39057. RightStick = 9
  39058. }
  39059. /** Defines values for XBox360 DPad */
  39060. export enum Xbox360Dpad {
  39061. /** Up */
  39062. Up = 0,
  39063. /** Down */
  39064. Down = 1,
  39065. /** Left */
  39066. Left = 2,
  39067. /** Right */
  39068. Right = 3
  39069. }
  39070. /**
  39071. * Defines a XBox360 gamepad
  39072. */
  39073. export class Xbox360Pad extends Gamepad {
  39074. private _leftTrigger;
  39075. private _rightTrigger;
  39076. private _onlefttriggerchanged;
  39077. private _onrighttriggerchanged;
  39078. private _onbuttondown;
  39079. private _onbuttonup;
  39080. private _ondpaddown;
  39081. private _ondpadup;
  39082. /** Observable raised when a button is pressed */
  39083. onButtonDownObservable: Observable<Xbox360Button>;
  39084. /** Observable raised when a button is released */
  39085. onButtonUpObservable: Observable<Xbox360Button>;
  39086. /** Observable raised when a pad is pressed */
  39087. onPadDownObservable: Observable<Xbox360Dpad>;
  39088. /** Observable raised when a pad is released */
  39089. onPadUpObservable: Observable<Xbox360Dpad>;
  39090. private _buttonA;
  39091. private _buttonB;
  39092. private _buttonX;
  39093. private _buttonY;
  39094. private _buttonBack;
  39095. private _buttonStart;
  39096. private _buttonLB;
  39097. private _buttonRB;
  39098. private _buttonLeftStick;
  39099. private _buttonRightStick;
  39100. private _dPadUp;
  39101. private _dPadDown;
  39102. private _dPadLeft;
  39103. private _dPadRight;
  39104. private _isXboxOnePad;
  39105. /**
  39106. * Creates a new XBox360 gamepad object
  39107. * @param id defines the id of this gamepad
  39108. * @param index defines its index
  39109. * @param gamepad defines the internal HTML gamepad object
  39110. * @param xboxOne defines if it is a XBox One gamepad
  39111. */
  39112. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39113. /**
  39114. * Defines the callback to call when left trigger is pressed
  39115. * @param callback defines the callback to use
  39116. */
  39117. onlefttriggerchanged(callback: (value: number) => void): void;
  39118. /**
  39119. * Defines the callback to call when right trigger is pressed
  39120. * @param callback defines the callback to use
  39121. */
  39122. onrighttriggerchanged(callback: (value: number) => void): void;
  39123. /**
  39124. * Gets the left trigger value
  39125. */
  39126. /**
  39127. * Sets the left trigger value
  39128. */
  39129. leftTrigger: number;
  39130. /**
  39131. * Gets the right trigger value
  39132. */
  39133. /**
  39134. * Sets the right trigger value
  39135. */
  39136. rightTrigger: number;
  39137. /**
  39138. * Defines the callback to call when a button is pressed
  39139. * @param callback defines the callback to use
  39140. */
  39141. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39142. /**
  39143. * Defines the callback to call when a button is released
  39144. * @param callback defines the callback to use
  39145. */
  39146. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39147. /**
  39148. * Defines the callback to call when a pad is pressed
  39149. * @param callback defines the callback to use
  39150. */
  39151. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39152. /**
  39153. * Defines the callback to call when a pad is released
  39154. * @param callback defines the callback to use
  39155. */
  39156. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39157. private _setButtonValue;
  39158. private _setDPadValue;
  39159. /**
  39160. * Gets the value of the `A` button
  39161. */
  39162. /**
  39163. * Sets the value of the `A` button
  39164. */
  39165. buttonA: number;
  39166. /**
  39167. * Gets the value of the `B` button
  39168. */
  39169. /**
  39170. * Sets the value of the `B` button
  39171. */
  39172. buttonB: number;
  39173. /**
  39174. * Gets the value of the `X` button
  39175. */
  39176. /**
  39177. * Sets the value of the `X` button
  39178. */
  39179. buttonX: number;
  39180. /**
  39181. * Gets the value of the `Y` button
  39182. */
  39183. /**
  39184. * Sets the value of the `Y` button
  39185. */
  39186. buttonY: number;
  39187. /**
  39188. * Gets the value of the `Start` button
  39189. */
  39190. /**
  39191. * Sets the value of the `Start` button
  39192. */
  39193. buttonStart: number;
  39194. /**
  39195. * Gets the value of the `Back` button
  39196. */
  39197. /**
  39198. * Sets the value of the `Back` button
  39199. */
  39200. buttonBack: number;
  39201. /**
  39202. * Gets the value of the `Left` button
  39203. */
  39204. /**
  39205. * Sets the value of the `Left` button
  39206. */
  39207. buttonLB: number;
  39208. /**
  39209. * Gets the value of the `Right` button
  39210. */
  39211. /**
  39212. * Sets the value of the `Right` button
  39213. */
  39214. buttonRB: number;
  39215. /**
  39216. * Gets the value of the Left joystick
  39217. */
  39218. /**
  39219. * Sets the value of the Left joystick
  39220. */
  39221. buttonLeftStick: number;
  39222. /**
  39223. * Gets the value of the Right joystick
  39224. */
  39225. /**
  39226. * Sets the value of the Right joystick
  39227. */
  39228. buttonRightStick: number;
  39229. /**
  39230. * Gets the value of D-pad up
  39231. */
  39232. /**
  39233. * Sets the value of D-pad up
  39234. */
  39235. dPadUp: number;
  39236. /**
  39237. * Gets the value of D-pad down
  39238. */
  39239. /**
  39240. * Sets the value of D-pad down
  39241. */
  39242. dPadDown: number;
  39243. /**
  39244. * Gets the value of D-pad left
  39245. */
  39246. /**
  39247. * Sets the value of D-pad left
  39248. */
  39249. dPadLeft: number;
  39250. /**
  39251. * Gets the value of D-pad right
  39252. */
  39253. /**
  39254. * Sets the value of D-pad right
  39255. */
  39256. dPadRight: number;
  39257. /**
  39258. * Force the gamepad to synchronize with device values
  39259. */
  39260. update(): void;
  39261. /**
  39262. * Disposes the gamepad
  39263. */
  39264. dispose(): void;
  39265. }
  39266. }
  39267. declare module BABYLON {
  39268. /**
  39269. * Defines supported buttons for DualShock compatible gamepads
  39270. */
  39271. export enum DualShockButton {
  39272. /** Cross */
  39273. Cross = 0,
  39274. /** Circle */
  39275. Circle = 1,
  39276. /** Square */
  39277. Square = 2,
  39278. /** Triangle */
  39279. Triangle = 3,
  39280. /** Options */
  39281. Options = 4,
  39282. /** Share */
  39283. Share = 5,
  39284. /** L1 */
  39285. L1 = 6,
  39286. /** R1 */
  39287. R1 = 7,
  39288. /** Left stick */
  39289. LeftStick = 8,
  39290. /** Right stick */
  39291. RightStick = 9
  39292. }
  39293. /** Defines values for DualShock DPad */
  39294. export enum DualShockDpad {
  39295. /** Up */
  39296. Up = 0,
  39297. /** Down */
  39298. Down = 1,
  39299. /** Left */
  39300. Left = 2,
  39301. /** Right */
  39302. Right = 3
  39303. }
  39304. /**
  39305. * Defines a DualShock gamepad
  39306. */
  39307. export class DualShockPad extends Gamepad {
  39308. private _leftTrigger;
  39309. private _rightTrigger;
  39310. private _onlefttriggerchanged;
  39311. private _onrighttriggerchanged;
  39312. private _onbuttondown;
  39313. private _onbuttonup;
  39314. private _ondpaddown;
  39315. private _ondpadup;
  39316. /** Observable raised when a button is pressed */
  39317. onButtonDownObservable: Observable<DualShockButton>;
  39318. /** Observable raised when a button is released */
  39319. onButtonUpObservable: Observable<DualShockButton>;
  39320. /** Observable raised when a pad is pressed */
  39321. onPadDownObservable: Observable<DualShockDpad>;
  39322. /** Observable raised when a pad is released */
  39323. onPadUpObservable: Observable<DualShockDpad>;
  39324. private _buttonCross;
  39325. private _buttonCircle;
  39326. private _buttonSquare;
  39327. private _buttonTriangle;
  39328. private _buttonShare;
  39329. private _buttonOptions;
  39330. private _buttonL1;
  39331. private _buttonR1;
  39332. private _buttonLeftStick;
  39333. private _buttonRightStick;
  39334. private _dPadUp;
  39335. private _dPadDown;
  39336. private _dPadLeft;
  39337. private _dPadRight;
  39338. /**
  39339. * Creates a new DualShock gamepad object
  39340. * @param id defines the id of this gamepad
  39341. * @param index defines its index
  39342. * @param gamepad defines the internal HTML gamepad object
  39343. */
  39344. constructor(id: string, index: number, gamepad: any);
  39345. /**
  39346. * Defines the callback to call when left trigger is pressed
  39347. * @param callback defines the callback to use
  39348. */
  39349. onlefttriggerchanged(callback: (value: number) => void): void;
  39350. /**
  39351. * Defines the callback to call when right trigger is pressed
  39352. * @param callback defines the callback to use
  39353. */
  39354. onrighttriggerchanged(callback: (value: number) => void): void;
  39355. /**
  39356. * Gets the left trigger value
  39357. */
  39358. /**
  39359. * Sets the left trigger value
  39360. */
  39361. leftTrigger: number;
  39362. /**
  39363. * Gets the right trigger value
  39364. */
  39365. /**
  39366. * Sets the right trigger value
  39367. */
  39368. rightTrigger: number;
  39369. /**
  39370. * Defines the callback to call when a button is pressed
  39371. * @param callback defines the callback to use
  39372. */
  39373. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39374. /**
  39375. * Defines the callback to call when a button is released
  39376. * @param callback defines the callback to use
  39377. */
  39378. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39379. /**
  39380. * Defines the callback to call when a pad is pressed
  39381. * @param callback defines the callback to use
  39382. */
  39383. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39384. /**
  39385. * Defines the callback to call when a pad is released
  39386. * @param callback defines the callback to use
  39387. */
  39388. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39389. private _setButtonValue;
  39390. private _setDPadValue;
  39391. /**
  39392. * Gets the value of the `Cross` button
  39393. */
  39394. /**
  39395. * Sets the value of the `Cross` button
  39396. */
  39397. buttonCross: number;
  39398. /**
  39399. * Gets the value of the `Circle` button
  39400. */
  39401. /**
  39402. * Sets the value of the `Circle` button
  39403. */
  39404. buttonCircle: number;
  39405. /**
  39406. * Gets the value of the `Square` button
  39407. */
  39408. /**
  39409. * Sets the value of the `Square` button
  39410. */
  39411. buttonSquare: number;
  39412. /**
  39413. * Gets the value of the `Triangle` button
  39414. */
  39415. /**
  39416. * Sets the value of the `Triangle` button
  39417. */
  39418. buttonTriangle: number;
  39419. /**
  39420. * Gets the value of the `Options` button
  39421. */
  39422. /**
  39423. * Sets the value of the `Options` button
  39424. */
  39425. buttonOptions: number;
  39426. /**
  39427. * Gets the value of the `Share` button
  39428. */
  39429. /**
  39430. * Sets the value of the `Share` button
  39431. */
  39432. buttonShare: number;
  39433. /**
  39434. * Gets the value of the `L1` button
  39435. */
  39436. /**
  39437. * Sets the value of the `L1` button
  39438. */
  39439. buttonL1: number;
  39440. /**
  39441. * Gets the value of the `R1` button
  39442. */
  39443. /**
  39444. * Sets the value of the `R1` button
  39445. */
  39446. buttonR1: number;
  39447. /**
  39448. * Gets the value of the Left joystick
  39449. */
  39450. /**
  39451. * Sets the value of the Left joystick
  39452. */
  39453. buttonLeftStick: number;
  39454. /**
  39455. * Gets the value of the Right joystick
  39456. */
  39457. /**
  39458. * Sets the value of the Right joystick
  39459. */
  39460. buttonRightStick: number;
  39461. /**
  39462. * Gets the value of D-pad up
  39463. */
  39464. /**
  39465. * Sets the value of D-pad up
  39466. */
  39467. dPadUp: number;
  39468. /**
  39469. * Gets the value of D-pad down
  39470. */
  39471. /**
  39472. * Sets the value of D-pad down
  39473. */
  39474. dPadDown: number;
  39475. /**
  39476. * Gets the value of D-pad left
  39477. */
  39478. /**
  39479. * Sets the value of D-pad left
  39480. */
  39481. dPadLeft: number;
  39482. /**
  39483. * Gets the value of D-pad right
  39484. */
  39485. /**
  39486. * Sets the value of D-pad right
  39487. */
  39488. dPadRight: number;
  39489. /**
  39490. * Force the gamepad to synchronize with device values
  39491. */
  39492. update(): void;
  39493. /**
  39494. * Disposes the gamepad
  39495. */
  39496. dispose(): void;
  39497. }
  39498. }
  39499. declare module BABYLON {
  39500. /**
  39501. * Manager for handling gamepads
  39502. */
  39503. export class GamepadManager {
  39504. private _scene?;
  39505. private _babylonGamepads;
  39506. private _oneGamepadConnected;
  39507. /** @hidden */
  39508. _isMonitoring: boolean;
  39509. private _gamepadEventSupported;
  39510. private _gamepadSupport;
  39511. /**
  39512. * observable to be triggered when the gamepad controller has been connected
  39513. */
  39514. onGamepadConnectedObservable: Observable<Gamepad>;
  39515. /**
  39516. * observable to be triggered when the gamepad controller has been disconnected
  39517. */
  39518. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39519. private _onGamepadConnectedEvent;
  39520. private _onGamepadDisconnectedEvent;
  39521. /**
  39522. * Initializes the gamepad manager
  39523. * @param _scene BabylonJS scene
  39524. */
  39525. constructor(_scene?: Scene | undefined);
  39526. /**
  39527. * The gamepads in the game pad manager
  39528. */
  39529. readonly gamepads: Gamepad[];
  39530. /**
  39531. * Get the gamepad controllers based on type
  39532. * @param type The type of gamepad controller
  39533. * @returns Nullable gamepad
  39534. */
  39535. getGamepadByType(type?: number): Nullable<Gamepad>;
  39536. /**
  39537. * Disposes the gamepad manager
  39538. */
  39539. dispose(): void;
  39540. private _addNewGamepad;
  39541. private _startMonitoringGamepads;
  39542. private _stopMonitoringGamepads;
  39543. /** @hidden */
  39544. _checkGamepadsStatus(): void;
  39545. private _updateGamepadObjects;
  39546. }
  39547. }
  39548. declare module BABYLON {
  39549. interface Scene {
  39550. /** @hidden */
  39551. _gamepadManager: Nullable<GamepadManager>;
  39552. /**
  39553. * Gets the gamepad manager associated with the scene
  39554. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39555. */
  39556. gamepadManager: GamepadManager;
  39557. }
  39558. /**
  39559. * Interface representing a free camera inputs manager
  39560. */
  39561. interface FreeCameraInputsManager {
  39562. /**
  39563. * Adds gamepad input support to the FreeCameraInputsManager.
  39564. * @returns the FreeCameraInputsManager
  39565. */
  39566. addGamepad(): FreeCameraInputsManager;
  39567. }
  39568. /**
  39569. * Interface representing an arc rotate camera inputs manager
  39570. */
  39571. interface ArcRotateCameraInputsManager {
  39572. /**
  39573. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39574. * @returns the camera inputs manager
  39575. */
  39576. addGamepad(): ArcRotateCameraInputsManager;
  39577. }
  39578. /**
  39579. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39580. */
  39581. export class GamepadSystemSceneComponent implements ISceneComponent {
  39582. /**
  39583. * The component name helpfull to identify the component in the list of scene components.
  39584. */
  39585. readonly name: string;
  39586. /**
  39587. * The scene the component belongs to.
  39588. */
  39589. scene: Scene;
  39590. /**
  39591. * Creates a new instance of the component for the given scene
  39592. * @param scene Defines the scene to register the component in
  39593. */
  39594. constructor(scene: Scene);
  39595. /**
  39596. * Registers the component in a given scene
  39597. */
  39598. register(): void;
  39599. /**
  39600. * Rebuilds the elements related to this component in case of
  39601. * context lost for instance.
  39602. */
  39603. rebuild(): void;
  39604. /**
  39605. * Disposes the component and the associated ressources
  39606. */
  39607. dispose(): void;
  39608. private _beforeCameraUpdate;
  39609. }
  39610. }
  39611. declare module BABYLON {
  39612. /**
  39613. * 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,
  39614. * which still works and will still be found in many Playgrounds.
  39615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39616. */
  39617. export class UniversalCamera extends TouchCamera {
  39618. /**
  39619. * Defines the gamepad rotation sensiblity.
  39620. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39621. */
  39622. gamepadAngularSensibility: number;
  39623. /**
  39624. * Defines the gamepad move sensiblity.
  39625. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39626. */
  39627. gamepadMoveSensibility: number;
  39628. /**
  39629. * 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,
  39630. * which still works and will still be found in many Playgrounds.
  39631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39632. * @param name Define the name of the camera in the scene
  39633. * @param position Define the start position of the camera in the scene
  39634. * @param scene Define the scene the camera belongs to
  39635. */
  39636. constructor(name: string, position: Vector3, scene: Scene);
  39637. /**
  39638. * Gets the current object class name.
  39639. * @return the class name
  39640. */
  39641. getClassName(): string;
  39642. }
  39643. }
  39644. declare module BABYLON {
  39645. /**
  39646. * This represents a FPS type of camera. This is only here for back compat purpose.
  39647. * Please use the UniversalCamera instead as both are identical.
  39648. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39649. */
  39650. export class GamepadCamera extends UniversalCamera {
  39651. /**
  39652. * Instantiates a new Gamepad Camera
  39653. * This represents a FPS type of camera. This is only here for back compat purpose.
  39654. * Please use the UniversalCamera instead as both are identical.
  39655. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39656. * @param name Define the name of the camera in the scene
  39657. * @param position Define the start position of the camera in the scene
  39658. * @param scene Define the scene the camera belongs to
  39659. */
  39660. constructor(name: string, position: Vector3, scene: Scene);
  39661. /**
  39662. * Gets the current object class name.
  39663. * @return the class name
  39664. */
  39665. getClassName(): string;
  39666. }
  39667. }
  39668. declare module BABYLON {
  39669. /** @hidden */
  39670. export var passPixelShader: {
  39671. name: string;
  39672. shader: string;
  39673. };
  39674. }
  39675. declare module BABYLON {
  39676. /** @hidden */
  39677. export var passCubePixelShader: {
  39678. name: string;
  39679. shader: string;
  39680. };
  39681. }
  39682. declare module BABYLON {
  39683. /**
  39684. * PassPostProcess which produces an output the same as it's input
  39685. */
  39686. export class PassPostProcess extends PostProcess {
  39687. /**
  39688. * Creates the PassPostProcess
  39689. * @param name The name of the effect.
  39690. * @param options The required width/height ratio to downsize to before computing the render pass.
  39691. * @param camera The camera to apply the render pass to.
  39692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39693. * @param engine The engine which the post process will be applied. (default: current engine)
  39694. * @param reusable If the post process can be reused on the same frame. (default: false)
  39695. * @param textureType The type of texture to be used when performing the post processing.
  39696. * @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)
  39697. */
  39698. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39699. }
  39700. /**
  39701. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39702. */
  39703. export class PassCubePostProcess extends PostProcess {
  39704. private _face;
  39705. /**
  39706. * Gets or sets the cube face to display.
  39707. * * 0 is +X
  39708. * * 1 is -X
  39709. * * 2 is +Y
  39710. * * 3 is -Y
  39711. * * 4 is +Z
  39712. * * 5 is -Z
  39713. */
  39714. face: number;
  39715. /**
  39716. * Creates the PassCubePostProcess
  39717. * @param name The name of the effect.
  39718. * @param options The required width/height ratio to downsize to before computing the render pass.
  39719. * @param camera The camera to apply the render pass to.
  39720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39721. * @param engine The engine which the post process will be applied. (default: current engine)
  39722. * @param reusable If the post process can be reused on the same frame. (default: false)
  39723. * @param textureType The type of texture to be used when performing the post processing.
  39724. * @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)
  39725. */
  39726. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. /** @hidden */
  39731. export var anaglyphPixelShader: {
  39732. name: string;
  39733. shader: string;
  39734. };
  39735. }
  39736. declare module BABYLON {
  39737. /**
  39738. * Postprocess used to generate anaglyphic rendering
  39739. */
  39740. export class AnaglyphPostProcess extends PostProcess {
  39741. private _passedProcess;
  39742. /**
  39743. * Creates a new AnaglyphPostProcess
  39744. * @param name defines postprocess name
  39745. * @param options defines creation options or target ratio scale
  39746. * @param rigCameras defines cameras using this postprocess
  39747. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39748. * @param engine defines hosting engine
  39749. * @param reusable defines if the postprocess will be reused multiple times per frame
  39750. */
  39751. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39752. }
  39753. }
  39754. declare module BABYLON {
  39755. /**
  39756. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39757. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39758. */
  39759. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39760. /**
  39761. * Creates a new AnaglyphArcRotateCamera
  39762. * @param name defines camera name
  39763. * @param alpha defines alpha angle (in radians)
  39764. * @param beta defines beta angle (in radians)
  39765. * @param radius defines radius
  39766. * @param target defines camera target
  39767. * @param interaxialDistance defines distance between each color axis
  39768. * @param scene defines the hosting scene
  39769. */
  39770. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39771. /**
  39772. * Gets camera class name
  39773. * @returns AnaglyphArcRotateCamera
  39774. */
  39775. getClassName(): string;
  39776. }
  39777. }
  39778. declare module BABYLON {
  39779. /**
  39780. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39782. */
  39783. export class AnaglyphFreeCamera extends FreeCamera {
  39784. /**
  39785. * Creates a new AnaglyphFreeCamera
  39786. * @param name defines camera name
  39787. * @param position defines initial position
  39788. * @param interaxialDistance defines distance between each color axis
  39789. * @param scene defines the hosting scene
  39790. */
  39791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39792. /**
  39793. * Gets camera class name
  39794. * @returns AnaglyphFreeCamera
  39795. */
  39796. getClassName(): string;
  39797. }
  39798. }
  39799. declare module BABYLON {
  39800. /**
  39801. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39803. */
  39804. export class AnaglyphGamepadCamera extends GamepadCamera {
  39805. /**
  39806. * Creates a new AnaglyphGamepadCamera
  39807. * @param name defines camera name
  39808. * @param position defines initial position
  39809. * @param interaxialDistance defines distance between each color axis
  39810. * @param scene defines the hosting scene
  39811. */
  39812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39813. /**
  39814. * Gets camera class name
  39815. * @returns AnaglyphGamepadCamera
  39816. */
  39817. getClassName(): string;
  39818. }
  39819. }
  39820. declare module BABYLON {
  39821. /**
  39822. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39824. */
  39825. export class AnaglyphUniversalCamera extends UniversalCamera {
  39826. /**
  39827. * Creates a new AnaglyphUniversalCamera
  39828. * @param name defines camera name
  39829. * @param position defines initial position
  39830. * @param interaxialDistance defines distance between each color axis
  39831. * @param scene defines the hosting scene
  39832. */
  39833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39834. /**
  39835. * Gets camera class name
  39836. * @returns AnaglyphUniversalCamera
  39837. */
  39838. getClassName(): string;
  39839. }
  39840. }
  39841. declare module BABYLON {
  39842. /** @hidden */
  39843. export var stereoscopicInterlacePixelShader: {
  39844. name: string;
  39845. shader: string;
  39846. };
  39847. }
  39848. declare module BABYLON {
  39849. /**
  39850. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39851. */
  39852. export class StereoscopicInterlacePostProcess extends PostProcess {
  39853. private _stepSize;
  39854. private _passedProcess;
  39855. /**
  39856. * Initializes a StereoscopicInterlacePostProcess
  39857. * @param name The name of the effect.
  39858. * @param rigCameras The rig cameras to be appled to the post process
  39859. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39861. * @param engine The engine which the post process will be applied. (default: current engine)
  39862. * @param reusable If the post process can be reused on the same frame. (default: false)
  39863. */
  39864. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39865. }
  39866. }
  39867. declare module BABYLON {
  39868. /**
  39869. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39870. * @see http://doc.babylonjs.com/features/cameras
  39871. */
  39872. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39873. /**
  39874. * Creates a new StereoscopicArcRotateCamera
  39875. * @param name defines camera name
  39876. * @param alpha defines alpha angle (in radians)
  39877. * @param beta defines beta angle (in radians)
  39878. * @param radius defines radius
  39879. * @param target defines camera target
  39880. * @param interaxialDistance defines distance between each color axis
  39881. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39882. * @param scene defines the hosting scene
  39883. */
  39884. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39885. /**
  39886. * Gets camera class name
  39887. * @returns StereoscopicArcRotateCamera
  39888. */
  39889. getClassName(): string;
  39890. }
  39891. }
  39892. declare module BABYLON {
  39893. /**
  39894. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39895. * @see http://doc.babylonjs.com/features/cameras
  39896. */
  39897. export class StereoscopicFreeCamera extends FreeCamera {
  39898. /**
  39899. * Creates a new StereoscopicFreeCamera
  39900. * @param name defines camera name
  39901. * @param position defines initial position
  39902. * @param interaxialDistance defines distance between each color axis
  39903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39904. * @param scene defines the hosting scene
  39905. */
  39906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39907. /**
  39908. * Gets camera class name
  39909. * @returns StereoscopicFreeCamera
  39910. */
  39911. getClassName(): string;
  39912. }
  39913. }
  39914. declare module BABYLON {
  39915. /**
  39916. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39917. * @see http://doc.babylonjs.com/features/cameras
  39918. */
  39919. export class StereoscopicGamepadCamera extends GamepadCamera {
  39920. /**
  39921. * Creates a new StereoscopicGamepadCamera
  39922. * @param name defines camera name
  39923. * @param position defines initial position
  39924. * @param interaxialDistance defines distance between each color axis
  39925. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39926. * @param scene defines the hosting scene
  39927. */
  39928. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39929. /**
  39930. * Gets camera class name
  39931. * @returns StereoscopicGamepadCamera
  39932. */
  39933. getClassName(): string;
  39934. }
  39935. }
  39936. declare module BABYLON {
  39937. /**
  39938. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39939. * @see http://doc.babylonjs.com/features/cameras
  39940. */
  39941. export class StereoscopicUniversalCamera extends UniversalCamera {
  39942. /**
  39943. * Creates a new StereoscopicUniversalCamera
  39944. * @param name defines camera name
  39945. * @param position defines initial position
  39946. * @param interaxialDistance defines distance between each color axis
  39947. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39948. * @param scene defines the hosting scene
  39949. */
  39950. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39951. /**
  39952. * Gets camera class name
  39953. * @returns StereoscopicUniversalCamera
  39954. */
  39955. getClassName(): string;
  39956. }
  39957. }
  39958. declare module BABYLON {
  39959. /**
  39960. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39961. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39962. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39963. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39964. */
  39965. export class VirtualJoysticksCamera extends FreeCamera {
  39966. /**
  39967. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39968. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39969. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39970. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39971. * @param name Define the name of the camera in the scene
  39972. * @param position Define the start position of the camera in the scene
  39973. * @param scene Define the scene the camera belongs to
  39974. */
  39975. constructor(name: string, position: Vector3, scene: Scene);
  39976. /**
  39977. * Gets the current object class name.
  39978. * @return the class name
  39979. */
  39980. getClassName(): string;
  39981. }
  39982. }
  39983. declare module BABYLON {
  39984. /**
  39985. * This represents all the required metrics to create a VR camera.
  39986. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39987. */
  39988. export class VRCameraMetrics {
  39989. /**
  39990. * Define the horizontal resolution off the screen.
  39991. */
  39992. hResolution: number;
  39993. /**
  39994. * Define the vertical resolution off the screen.
  39995. */
  39996. vResolution: number;
  39997. /**
  39998. * Define the horizontal screen size.
  39999. */
  40000. hScreenSize: number;
  40001. /**
  40002. * Define the vertical screen size.
  40003. */
  40004. vScreenSize: number;
  40005. /**
  40006. * Define the vertical screen center position.
  40007. */
  40008. vScreenCenter: number;
  40009. /**
  40010. * Define the distance of the eyes to the screen.
  40011. */
  40012. eyeToScreenDistance: number;
  40013. /**
  40014. * Define the distance between both lenses
  40015. */
  40016. lensSeparationDistance: number;
  40017. /**
  40018. * Define the distance between both viewer's eyes.
  40019. */
  40020. interpupillaryDistance: number;
  40021. /**
  40022. * Define the distortion factor of the VR postprocess.
  40023. * Please, touch with care.
  40024. */
  40025. distortionK: number[];
  40026. /**
  40027. * Define the chromatic aberration correction factors for the VR post process.
  40028. */
  40029. chromaAbCorrection: number[];
  40030. /**
  40031. * Define the scale factor of the post process.
  40032. * The smaller the better but the slower.
  40033. */
  40034. postProcessScaleFactor: number;
  40035. /**
  40036. * Define an offset for the lens center.
  40037. */
  40038. lensCenterOffset: number;
  40039. /**
  40040. * Define if the current vr camera should compensate the distortion of the lense or not.
  40041. */
  40042. compensateDistortion: boolean;
  40043. /**
  40044. * Defines if multiview should be enabled when rendering (Default: false)
  40045. */
  40046. multiviewEnabled: boolean;
  40047. /**
  40048. * Gets the rendering aspect ratio based on the provided resolutions.
  40049. */
  40050. readonly aspectRatio: number;
  40051. /**
  40052. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40053. */
  40054. readonly aspectRatioFov: number;
  40055. /**
  40056. * @hidden
  40057. */
  40058. readonly leftHMatrix: Matrix;
  40059. /**
  40060. * @hidden
  40061. */
  40062. readonly rightHMatrix: Matrix;
  40063. /**
  40064. * @hidden
  40065. */
  40066. readonly leftPreViewMatrix: Matrix;
  40067. /**
  40068. * @hidden
  40069. */
  40070. readonly rightPreViewMatrix: Matrix;
  40071. /**
  40072. * Get the default VRMetrics based on the most generic setup.
  40073. * @returns the default vr metrics
  40074. */
  40075. static GetDefault(): VRCameraMetrics;
  40076. }
  40077. }
  40078. declare module BABYLON {
  40079. /** @hidden */
  40080. export var vrDistortionCorrectionPixelShader: {
  40081. name: string;
  40082. shader: string;
  40083. };
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * VRDistortionCorrectionPostProcess used for mobile VR
  40088. */
  40089. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40090. private _isRightEye;
  40091. private _distortionFactors;
  40092. private _postProcessScaleFactor;
  40093. private _lensCenterOffset;
  40094. private _scaleIn;
  40095. private _scaleFactor;
  40096. private _lensCenter;
  40097. /**
  40098. * Initializes the VRDistortionCorrectionPostProcess
  40099. * @param name The name of the effect.
  40100. * @param camera The camera to apply the render pass to.
  40101. * @param isRightEye If this is for the right eye distortion
  40102. * @param vrMetrics All the required metrics for the VR camera
  40103. */
  40104. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40105. }
  40106. }
  40107. declare module BABYLON {
  40108. /**
  40109. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40110. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40111. */
  40112. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40113. /**
  40114. * Creates a new VRDeviceOrientationArcRotateCamera
  40115. * @param name defines camera name
  40116. * @param alpha defines the camera rotation along the logitudinal axis
  40117. * @param beta defines the camera rotation along the latitudinal axis
  40118. * @param radius defines the camera distance from its target
  40119. * @param target defines the camera target
  40120. * @param scene defines the scene the camera belongs to
  40121. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40122. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40123. */
  40124. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40125. /**
  40126. * Gets camera class name
  40127. * @returns VRDeviceOrientationArcRotateCamera
  40128. */
  40129. getClassName(): string;
  40130. }
  40131. }
  40132. declare module BABYLON {
  40133. /**
  40134. * Camera used to simulate VR rendering (based on FreeCamera)
  40135. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40136. */
  40137. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40138. /**
  40139. * Creates a new VRDeviceOrientationFreeCamera
  40140. * @param name defines camera name
  40141. * @param position defines the start position of the camera
  40142. * @param scene defines the scene the camera belongs to
  40143. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40144. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40145. */
  40146. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40147. /**
  40148. * Gets camera class name
  40149. * @returns VRDeviceOrientationFreeCamera
  40150. */
  40151. getClassName(): string;
  40152. }
  40153. }
  40154. declare module BABYLON {
  40155. /**
  40156. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40157. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40158. */
  40159. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40160. /**
  40161. * Creates a new VRDeviceOrientationGamepadCamera
  40162. * @param name defines camera name
  40163. * @param position defines the start position of the camera
  40164. * @param scene defines the scene the camera belongs to
  40165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40167. */
  40168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40169. /**
  40170. * Gets camera class name
  40171. * @returns VRDeviceOrientationGamepadCamera
  40172. */
  40173. getClassName(): string;
  40174. }
  40175. }
  40176. declare module BABYLON {
  40177. /**
  40178. * Base class of materials working in push mode in babylon JS
  40179. * @hidden
  40180. */
  40181. export class PushMaterial extends Material {
  40182. protected _activeEffect: Effect;
  40183. protected _normalMatrix: Matrix;
  40184. /**
  40185. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40186. * This means that the material can keep using a previous shader while a new one is being compiled.
  40187. * This is mostly used when shader parallel compilation is supported (true by default)
  40188. */
  40189. allowShaderHotSwapping: boolean;
  40190. constructor(name: string, scene: Scene);
  40191. getEffect(): Effect;
  40192. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40193. /**
  40194. * Binds the given world matrix to the active effect
  40195. *
  40196. * @param world the matrix to bind
  40197. */
  40198. bindOnlyWorldMatrix(world: Matrix): void;
  40199. /**
  40200. * Binds the given normal matrix to the active effect
  40201. *
  40202. * @param normalMatrix the matrix to bind
  40203. */
  40204. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40205. bind(world: Matrix, mesh?: Mesh): void;
  40206. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40207. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40208. }
  40209. }
  40210. declare module BABYLON {
  40211. /**
  40212. * This groups all the flags used to control the materials channel.
  40213. */
  40214. export class MaterialFlags {
  40215. private static _DiffuseTextureEnabled;
  40216. /**
  40217. * Are diffuse textures enabled in the application.
  40218. */
  40219. static DiffuseTextureEnabled: boolean;
  40220. private static _AmbientTextureEnabled;
  40221. /**
  40222. * Are ambient textures enabled in the application.
  40223. */
  40224. static AmbientTextureEnabled: boolean;
  40225. private static _OpacityTextureEnabled;
  40226. /**
  40227. * Are opacity textures enabled in the application.
  40228. */
  40229. static OpacityTextureEnabled: boolean;
  40230. private static _ReflectionTextureEnabled;
  40231. /**
  40232. * Are reflection textures enabled in the application.
  40233. */
  40234. static ReflectionTextureEnabled: boolean;
  40235. private static _EmissiveTextureEnabled;
  40236. /**
  40237. * Are emissive textures enabled in the application.
  40238. */
  40239. static EmissiveTextureEnabled: boolean;
  40240. private static _SpecularTextureEnabled;
  40241. /**
  40242. * Are specular textures enabled in the application.
  40243. */
  40244. static SpecularTextureEnabled: boolean;
  40245. private static _BumpTextureEnabled;
  40246. /**
  40247. * Are bump textures enabled in the application.
  40248. */
  40249. static BumpTextureEnabled: boolean;
  40250. private static _LightmapTextureEnabled;
  40251. /**
  40252. * Are lightmap textures enabled in the application.
  40253. */
  40254. static LightmapTextureEnabled: boolean;
  40255. private static _RefractionTextureEnabled;
  40256. /**
  40257. * Are refraction textures enabled in the application.
  40258. */
  40259. static RefractionTextureEnabled: boolean;
  40260. private static _ColorGradingTextureEnabled;
  40261. /**
  40262. * Are color grading textures enabled in the application.
  40263. */
  40264. static ColorGradingTextureEnabled: boolean;
  40265. private static _FresnelEnabled;
  40266. /**
  40267. * Are fresnels enabled in the application.
  40268. */
  40269. static FresnelEnabled: boolean;
  40270. private static _ClearCoatTextureEnabled;
  40271. /**
  40272. * Are clear coat textures enabled in the application.
  40273. */
  40274. static ClearCoatTextureEnabled: boolean;
  40275. private static _ClearCoatBumpTextureEnabled;
  40276. /**
  40277. * Are clear coat bump textures enabled in the application.
  40278. */
  40279. static ClearCoatBumpTextureEnabled: boolean;
  40280. private static _ClearCoatTintTextureEnabled;
  40281. /**
  40282. * Are clear coat tint textures enabled in the application.
  40283. */
  40284. static ClearCoatTintTextureEnabled: boolean;
  40285. private static _SheenTextureEnabled;
  40286. /**
  40287. * Are sheen textures enabled in the application.
  40288. */
  40289. static SheenTextureEnabled: boolean;
  40290. private static _AnisotropicTextureEnabled;
  40291. /**
  40292. * Are anisotropic textures enabled in the application.
  40293. */
  40294. static AnisotropicTextureEnabled: boolean;
  40295. private static _ThicknessTextureEnabled;
  40296. /**
  40297. * Are thickness textures enabled in the application.
  40298. */
  40299. static ThicknessTextureEnabled: boolean;
  40300. }
  40301. }
  40302. declare module BABYLON {
  40303. /** @hidden */
  40304. export var defaultFragmentDeclaration: {
  40305. name: string;
  40306. shader: string;
  40307. };
  40308. }
  40309. declare module BABYLON {
  40310. /** @hidden */
  40311. export var defaultUboDeclaration: {
  40312. name: string;
  40313. shader: string;
  40314. };
  40315. }
  40316. declare module BABYLON {
  40317. /** @hidden */
  40318. export var lightFragmentDeclaration: {
  40319. name: string;
  40320. shader: string;
  40321. };
  40322. }
  40323. declare module BABYLON {
  40324. /** @hidden */
  40325. export var lightUboDeclaration: {
  40326. name: string;
  40327. shader: string;
  40328. };
  40329. }
  40330. declare module BABYLON {
  40331. /** @hidden */
  40332. export var lightsFragmentFunctions: {
  40333. name: string;
  40334. shader: string;
  40335. };
  40336. }
  40337. declare module BABYLON {
  40338. /** @hidden */
  40339. export var shadowsFragmentFunctions: {
  40340. name: string;
  40341. shader: string;
  40342. };
  40343. }
  40344. declare module BABYLON {
  40345. /** @hidden */
  40346. export var fresnelFunction: {
  40347. name: string;
  40348. shader: string;
  40349. };
  40350. }
  40351. declare module BABYLON {
  40352. /** @hidden */
  40353. export var reflectionFunction: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module BABYLON {
  40359. /** @hidden */
  40360. export var bumpFragmentFunctions: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module BABYLON {
  40366. /** @hidden */
  40367. export var logDepthDeclaration: {
  40368. name: string;
  40369. shader: string;
  40370. };
  40371. }
  40372. declare module BABYLON {
  40373. /** @hidden */
  40374. export var bumpFragment: {
  40375. name: string;
  40376. shader: string;
  40377. };
  40378. }
  40379. declare module BABYLON {
  40380. /** @hidden */
  40381. export var depthPrePass: {
  40382. name: string;
  40383. shader: string;
  40384. };
  40385. }
  40386. declare module BABYLON {
  40387. /** @hidden */
  40388. export var lightFragment: {
  40389. name: string;
  40390. shader: string;
  40391. };
  40392. }
  40393. declare module BABYLON {
  40394. /** @hidden */
  40395. export var logDepthFragment: {
  40396. name: string;
  40397. shader: string;
  40398. };
  40399. }
  40400. declare module BABYLON {
  40401. /** @hidden */
  40402. export var defaultPixelShader: {
  40403. name: string;
  40404. shader: string;
  40405. };
  40406. }
  40407. declare module BABYLON {
  40408. /** @hidden */
  40409. export var defaultVertexDeclaration: {
  40410. name: string;
  40411. shader: string;
  40412. };
  40413. }
  40414. declare module BABYLON {
  40415. /** @hidden */
  40416. export var bumpVertexDeclaration: {
  40417. name: string;
  40418. shader: string;
  40419. };
  40420. }
  40421. declare module BABYLON {
  40422. /** @hidden */
  40423. export var bumpVertex: {
  40424. name: string;
  40425. shader: string;
  40426. };
  40427. }
  40428. declare module BABYLON {
  40429. /** @hidden */
  40430. export var fogVertex: {
  40431. name: string;
  40432. shader: string;
  40433. };
  40434. }
  40435. declare module BABYLON {
  40436. /** @hidden */
  40437. export var shadowsVertex: {
  40438. name: string;
  40439. shader: string;
  40440. };
  40441. }
  40442. declare module BABYLON {
  40443. /** @hidden */
  40444. export var pointCloudVertex: {
  40445. name: string;
  40446. shader: string;
  40447. };
  40448. }
  40449. declare module BABYLON {
  40450. /** @hidden */
  40451. export var logDepthVertex: {
  40452. name: string;
  40453. shader: string;
  40454. };
  40455. }
  40456. declare module BABYLON {
  40457. /** @hidden */
  40458. export var defaultVertexShader: {
  40459. name: string;
  40460. shader: string;
  40461. };
  40462. }
  40463. declare module BABYLON {
  40464. /** @hidden */
  40465. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40466. MAINUV1: boolean;
  40467. MAINUV2: boolean;
  40468. DIFFUSE: boolean;
  40469. DIFFUSEDIRECTUV: number;
  40470. AMBIENT: boolean;
  40471. AMBIENTDIRECTUV: number;
  40472. OPACITY: boolean;
  40473. OPACITYDIRECTUV: number;
  40474. OPACITYRGB: boolean;
  40475. REFLECTION: boolean;
  40476. EMISSIVE: boolean;
  40477. EMISSIVEDIRECTUV: number;
  40478. SPECULAR: boolean;
  40479. SPECULARDIRECTUV: number;
  40480. BUMP: boolean;
  40481. BUMPDIRECTUV: number;
  40482. PARALLAX: boolean;
  40483. PARALLAXOCCLUSION: boolean;
  40484. SPECULAROVERALPHA: boolean;
  40485. CLIPPLANE: boolean;
  40486. CLIPPLANE2: boolean;
  40487. CLIPPLANE3: boolean;
  40488. CLIPPLANE4: boolean;
  40489. ALPHATEST: boolean;
  40490. DEPTHPREPASS: boolean;
  40491. ALPHAFROMDIFFUSE: boolean;
  40492. POINTSIZE: boolean;
  40493. FOG: boolean;
  40494. SPECULARTERM: boolean;
  40495. DIFFUSEFRESNEL: boolean;
  40496. OPACITYFRESNEL: boolean;
  40497. REFLECTIONFRESNEL: boolean;
  40498. REFRACTIONFRESNEL: boolean;
  40499. EMISSIVEFRESNEL: boolean;
  40500. FRESNEL: boolean;
  40501. NORMAL: boolean;
  40502. UV1: boolean;
  40503. UV2: boolean;
  40504. VERTEXCOLOR: boolean;
  40505. VERTEXALPHA: boolean;
  40506. NUM_BONE_INFLUENCERS: number;
  40507. BonesPerMesh: number;
  40508. BONETEXTURE: boolean;
  40509. INSTANCES: boolean;
  40510. GLOSSINESS: boolean;
  40511. ROUGHNESS: boolean;
  40512. EMISSIVEASILLUMINATION: boolean;
  40513. LINKEMISSIVEWITHDIFFUSE: boolean;
  40514. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40515. LIGHTMAP: boolean;
  40516. LIGHTMAPDIRECTUV: number;
  40517. OBJECTSPACE_NORMALMAP: boolean;
  40518. USELIGHTMAPASSHADOWMAP: boolean;
  40519. REFLECTIONMAP_3D: boolean;
  40520. REFLECTIONMAP_SPHERICAL: boolean;
  40521. REFLECTIONMAP_PLANAR: boolean;
  40522. REFLECTIONMAP_CUBIC: boolean;
  40523. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40524. REFLECTIONMAP_PROJECTION: boolean;
  40525. REFLECTIONMAP_SKYBOX: boolean;
  40526. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40527. REFLECTIONMAP_EXPLICIT: boolean;
  40528. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40529. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40530. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40531. INVERTCUBICMAP: boolean;
  40532. LOGARITHMICDEPTH: boolean;
  40533. REFRACTION: boolean;
  40534. REFRACTIONMAP_3D: boolean;
  40535. REFLECTIONOVERALPHA: boolean;
  40536. TWOSIDEDLIGHTING: boolean;
  40537. SHADOWFLOAT: boolean;
  40538. MORPHTARGETS: boolean;
  40539. MORPHTARGETS_NORMAL: boolean;
  40540. MORPHTARGETS_TANGENT: boolean;
  40541. MORPHTARGETS_UV: boolean;
  40542. NUM_MORPH_INFLUENCERS: number;
  40543. NONUNIFORMSCALING: boolean;
  40544. PREMULTIPLYALPHA: boolean;
  40545. IMAGEPROCESSING: boolean;
  40546. VIGNETTE: boolean;
  40547. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40548. VIGNETTEBLENDMODEOPAQUE: boolean;
  40549. TONEMAPPING: boolean;
  40550. TONEMAPPING_ACES: boolean;
  40551. CONTRAST: boolean;
  40552. COLORCURVES: boolean;
  40553. COLORGRADING: boolean;
  40554. COLORGRADING3D: boolean;
  40555. SAMPLER3DGREENDEPTH: boolean;
  40556. SAMPLER3DBGRMAP: boolean;
  40557. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40558. MULTIVIEW: boolean;
  40559. /**
  40560. * If the reflection texture on this material is in linear color space
  40561. * @hidden
  40562. */
  40563. IS_REFLECTION_LINEAR: boolean;
  40564. /**
  40565. * If the refraction texture on this material is in linear color space
  40566. * @hidden
  40567. */
  40568. IS_REFRACTION_LINEAR: boolean;
  40569. EXPOSURE: boolean;
  40570. constructor();
  40571. setReflectionMode(modeToEnable: string): void;
  40572. }
  40573. /**
  40574. * This is the default material used in Babylon. It is the best trade off between quality
  40575. * and performances.
  40576. * @see http://doc.babylonjs.com/babylon101/materials
  40577. */
  40578. export class StandardMaterial extends PushMaterial {
  40579. private _diffuseTexture;
  40580. /**
  40581. * The basic texture of the material as viewed under a light.
  40582. */
  40583. diffuseTexture: Nullable<BaseTexture>;
  40584. private _ambientTexture;
  40585. /**
  40586. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40587. */
  40588. ambientTexture: Nullable<BaseTexture>;
  40589. private _opacityTexture;
  40590. /**
  40591. * Define the transparency of the material from a texture.
  40592. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40593. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40594. */
  40595. opacityTexture: Nullable<BaseTexture>;
  40596. private _reflectionTexture;
  40597. /**
  40598. * Define the texture used to display the reflection.
  40599. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40600. */
  40601. reflectionTexture: Nullable<BaseTexture>;
  40602. private _emissiveTexture;
  40603. /**
  40604. * Define texture of the material as if self lit.
  40605. * This will be mixed in the final result even in the absence of light.
  40606. */
  40607. emissiveTexture: Nullable<BaseTexture>;
  40608. private _specularTexture;
  40609. /**
  40610. * Define how the color and intensity of the highlight given by the light in the material.
  40611. */
  40612. specularTexture: Nullable<BaseTexture>;
  40613. private _bumpTexture;
  40614. /**
  40615. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40616. * 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.
  40617. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40618. */
  40619. bumpTexture: Nullable<BaseTexture>;
  40620. private _lightmapTexture;
  40621. /**
  40622. * Complex lighting can be computationally expensive to compute at runtime.
  40623. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40624. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40625. */
  40626. lightmapTexture: Nullable<BaseTexture>;
  40627. private _refractionTexture;
  40628. /**
  40629. * Define the texture used to display the refraction.
  40630. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40631. */
  40632. refractionTexture: Nullable<BaseTexture>;
  40633. /**
  40634. * The color of the material lit by the environmental background lighting.
  40635. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40636. */
  40637. ambientColor: Color3;
  40638. /**
  40639. * The basic color of the material as viewed under a light.
  40640. */
  40641. diffuseColor: Color3;
  40642. /**
  40643. * Define how the color and intensity of the highlight given by the light in the material.
  40644. */
  40645. specularColor: Color3;
  40646. /**
  40647. * Define the color of the material as if self lit.
  40648. * This will be mixed in the final result even in the absence of light.
  40649. */
  40650. emissiveColor: Color3;
  40651. /**
  40652. * Defines how sharp are the highlights in the material.
  40653. * The bigger the value the sharper giving a more glossy feeling to the result.
  40654. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40655. */
  40656. specularPower: number;
  40657. private _useAlphaFromDiffuseTexture;
  40658. /**
  40659. * Does the transparency come from the diffuse texture alpha channel.
  40660. */
  40661. useAlphaFromDiffuseTexture: boolean;
  40662. private _useEmissiveAsIllumination;
  40663. /**
  40664. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40665. */
  40666. useEmissiveAsIllumination: boolean;
  40667. private _linkEmissiveWithDiffuse;
  40668. /**
  40669. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40670. * the emissive level when the final color is close to one.
  40671. */
  40672. linkEmissiveWithDiffuse: boolean;
  40673. private _useSpecularOverAlpha;
  40674. /**
  40675. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40676. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40677. */
  40678. useSpecularOverAlpha: boolean;
  40679. private _useReflectionOverAlpha;
  40680. /**
  40681. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40682. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40683. */
  40684. useReflectionOverAlpha: boolean;
  40685. private _disableLighting;
  40686. /**
  40687. * Does lights from the scene impacts this material.
  40688. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40689. */
  40690. disableLighting: boolean;
  40691. private _useObjectSpaceNormalMap;
  40692. /**
  40693. * Allows using an object space normal map (instead of tangent space).
  40694. */
  40695. useObjectSpaceNormalMap: boolean;
  40696. private _useParallax;
  40697. /**
  40698. * Is parallax enabled or not.
  40699. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40700. */
  40701. useParallax: boolean;
  40702. private _useParallaxOcclusion;
  40703. /**
  40704. * Is parallax occlusion enabled or not.
  40705. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40706. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40707. */
  40708. useParallaxOcclusion: boolean;
  40709. /**
  40710. * 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.
  40711. */
  40712. parallaxScaleBias: number;
  40713. private _roughness;
  40714. /**
  40715. * Helps to define how blurry the reflections should appears in the material.
  40716. */
  40717. roughness: number;
  40718. /**
  40719. * In case of refraction, define the value of the index of refraction.
  40720. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40721. */
  40722. indexOfRefraction: number;
  40723. /**
  40724. * Invert the refraction texture alongside the y axis.
  40725. * It can be useful with procedural textures or probe for instance.
  40726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40727. */
  40728. invertRefractionY: boolean;
  40729. /**
  40730. * Defines the alpha limits in alpha test mode.
  40731. */
  40732. alphaCutOff: number;
  40733. private _useLightmapAsShadowmap;
  40734. /**
  40735. * In case of light mapping, define whether the map contains light or shadow informations.
  40736. */
  40737. useLightmapAsShadowmap: boolean;
  40738. private _diffuseFresnelParameters;
  40739. /**
  40740. * Define the diffuse fresnel parameters of the material.
  40741. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40742. */
  40743. diffuseFresnelParameters: FresnelParameters;
  40744. private _opacityFresnelParameters;
  40745. /**
  40746. * Define the opacity fresnel parameters of the material.
  40747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40748. */
  40749. opacityFresnelParameters: FresnelParameters;
  40750. private _reflectionFresnelParameters;
  40751. /**
  40752. * Define the reflection fresnel parameters of the material.
  40753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40754. */
  40755. reflectionFresnelParameters: FresnelParameters;
  40756. private _refractionFresnelParameters;
  40757. /**
  40758. * Define the refraction fresnel parameters of the material.
  40759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40760. */
  40761. refractionFresnelParameters: FresnelParameters;
  40762. private _emissiveFresnelParameters;
  40763. /**
  40764. * Define the emissive fresnel parameters of the material.
  40765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40766. */
  40767. emissiveFresnelParameters: FresnelParameters;
  40768. private _useReflectionFresnelFromSpecular;
  40769. /**
  40770. * If true automatically deducts the fresnels values from the material specularity.
  40771. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40772. */
  40773. useReflectionFresnelFromSpecular: boolean;
  40774. private _useGlossinessFromSpecularMapAlpha;
  40775. /**
  40776. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40777. */
  40778. useGlossinessFromSpecularMapAlpha: boolean;
  40779. private _maxSimultaneousLights;
  40780. /**
  40781. * Defines the maximum number of lights that can be used in the material
  40782. */
  40783. maxSimultaneousLights: number;
  40784. private _invertNormalMapX;
  40785. /**
  40786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40787. */
  40788. invertNormalMapX: boolean;
  40789. private _invertNormalMapY;
  40790. /**
  40791. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40792. */
  40793. invertNormalMapY: boolean;
  40794. private _twoSidedLighting;
  40795. /**
  40796. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40797. */
  40798. twoSidedLighting: boolean;
  40799. /**
  40800. * Default configuration related to image processing available in the standard Material.
  40801. */
  40802. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40803. /**
  40804. * Gets the image processing configuration used either in this material.
  40805. */
  40806. /**
  40807. * Sets the Default image processing configuration used either in the this material.
  40808. *
  40809. * If sets to null, the scene one is in use.
  40810. */
  40811. imageProcessingConfiguration: ImageProcessingConfiguration;
  40812. /**
  40813. * Keep track of the image processing observer to allow dispose and replace.
  40814. */
  40815. private _imageProcessingObserver;
  40816. /**
  40817. * Attaches a new image processing configuration to the Standard Material.
  40818. * @param configuration
  40819. */
  40820. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40821. /**
  40822. * Gets wether the color curves effect is enabled.
  40823. */
  40824. /**
  40825. * Sets wether the color curves effect is enabled.
  40826. */
  40827. cameraColorCurvesEnabled: boolean;
  40828. /**
  40829. * Gets wether the color grading effect is enabled.
  40830. */
  40831. /**
  40832. * Gets wether the color grading effect is enabled.
  40833. */
  40834. cameraColorGradingEnabled: boolean;
  40835. /**
  40836. * Gets wether tonemapping is enabled or not.
  40837. */
  40838. /**
  40839. * Sets wether tonemapping is enabled or not
  40840. */
  40841. cameraToneMappingEnabled: boolean;
  40842. /**
  40843. * The camera exposure used on this material.
  40844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40845. * This corresponds to a photographic exposure.
  40846. */
  40847. /**
  40848. * The camera exposure used on this material.
  40849. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40850. * This corresponds to a photographic exposure.
  40851. */
  40852. cameraExposure: number;
  40853. /**
  40854. * Gets The camera contrast used on this material.
  40855. */
  40856. /**
  40857. * Sets The camera contrast used on this material.
  40858. */
  40859. cameraContrast: number;
  40860. /**
  40861. * Gets the Color Grading 2D Lookup Texture.
  40862. */
  40863. /**
  40864. * Sets the Color Grading 2D Lookup Texture.
  40865. */
  40866. cameraColorGradingTexture: Nullable<BaseTexture>;
  40867. /**
  40868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40870. * 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;
  40871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40872. */
  40873. /**
  40874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40876. * 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;
  40877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40878. */
  40879. cameraColorCurves: Nullable<ColorCurves>;
  40880. /**
  40881. * Custom callback helping to override the default shader used in the material.
  40882. */
  40883. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40884. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40885. protected _worldViewProjectionMatrix: Matrix;
  40886. protected _globalAmbientColor: Color3;
  40887. protected _useLogarithmicDepth: boolean;
  40888. protected _rebuildInParallel: boolean;
  40889. /**
  40890. * Instantiates a new standard material.
  40891. * This is the default material used in Babylon. It is the best trade off between quality
  40892. * and performances.
  40893. * @see http://doc.babylonjs.com/babylon101/materials
  40894. * @param name Define the name of the material in the scene
  40895. * @param scene Define the scene the material belong to
  40896. */
  40897. constructor(name: string, scene: Scene);
  40898. /**
  40899. * Gets a boolean indicating that current material needs to register RTT
  40900. */
  40901. readonly hasRenderTargetTextures: boolean;
  40902. /**
  40903. * Gets the current class name of the material e.g. "StandardMaterial"
  40904. * Mainly use in serialization.
  40905. * @returns the class name
  40906. */
  40907. getClassName(): string;
  40908. /**
  40909. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40910. * You can try switching to logarithmic depth.
  40911. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40912. */
  40913. useLogarithmicDepth: boolean;
  40914. /**
  40915. * Specifies if the material will require alpha blending
  40916. * @returns a boolean specifying if alpha blending is needed
  40917. */
  40918. needAlphaBlending(): boolean;
  40919. /**
  40920. * Specifies if this material should be rendered in alpha test mode
  40921. * @returns a boolean specifying if an alpha test is needed.
  40922. */
  40923. needAlphaTesting(): boolean;
  40924. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40925. /**
  40926. * Get the texture used for alpha test purpose.
  40927. * @returns the diffuse texture in case of the standard material.
  40928. */
  40929. getAlphaTestTexture(): Nullable<BaseTexture>;
  40930. /**
  40931. * Get if the submesh is ready to be used and all its information available.
  40932. * Child classes can use it to update shaders
  40933. * @param mesh defines the mesh to check
  40934. * @param subMesh defines which submesh to check
  40935. * @param useInstances specifies that instances should be used
  40936. * @returns a boolean indicating that the submesh is ready or not
  40937. */
  40938. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40939. /**
  40940. * Builds the material UBO layouts.
  40941. * Used internally during the effect preparation.
  40942. */
  40943. buildUniformLayout(): void;
  40944. /**
  40945. * Unbinds the material from the mesh
  40946. */
  40947. unbind(): void;
  40948. /**
  40949. * Binds the submesh to this material by preparing the effect and shader to draw
  40950. * @param world defines the world transformation matrix
  40951. * @param mesh defines the mesh containing the submesh
  40952. * @param subMesh defines the submesh to bind the material to
  40953. */
  40954. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40955. /**
  40956. * Get the list of animatables in the material.
  40957. * @returns the list of animatables object used in the material
  40958. */
  40959. getAnimatables(): IAnimatable[];
  40960. /**
  40961. * Gets the active textures from the material
  40962. * @returns an array of textures
  40963. */
  40964. getActiveTextures(): BaseTexture[];
  40965. /**
  40966. * Specifies if the material uses a texture
  40967. * @param texture defines the texture to check against the material
  40968. * @returns a boolean specifying if the material uses the texture
  40969. */
  40970. hasTexture(texture: BaseTexture): boolean;
  40971. /**
  40972. * Disposes the material
  40973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40975. */
  40976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40977. /**
  40978. * Makes a duplicate of the material, and gives it a new name
  40979. * @param name defines the new name for the duplicated material
  40980. * @returns the cloned material
  40981. */
  40982. clone(name: string): StandardMaterial;
  40983. /**
  40984. * Serializes this material in a JSON representation
  40985. * @returns the serialized material object
  40986. */
  40987. serialize(): any;
  40988. /**
  40989. * Creates a standard material from parsed material data
  40990. * @param source defines the JSON representation of the material
  40991. * @param scene defines the hosting scene
  40992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40993. * @returns a new standard material
  40994. */
  40995. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40996. /**
  40997. * Are diffuse textures enabled in the application.
  40998. */
  40999. static DiffuseTextureEnabled: boolean;
  41000. /**
  41001. * Are ambient textures enabled in the application.
  41002. */
  41003. static AmbientTextureEnabled: boolean;
  41004. /**
  41005. * Are opacity textures enabled in the application.
  41006. */
  41007. static OpacityTextureEnabled: boolean;
  41008. /**
  41009. * Are reflection textures enabled in the application.
  41010. */
  41011. static ReflectionTextureEnabled: boolean;
  41012. /**
  41013. * Are emissive textures enabled in the application.
  41014. */
  41015. static EmissiveTextureEnabled: boolean;
  41016. /**
  41017. * Are specular textures enabled in the application.
  41018. */
  41019. static SpecularTextureEnabled: boolean;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. /**
  41025. * Are lightmap textures enabled in the application.
  41026. */
  41027. static LightmapTextureEnabled: boolean;
  41028. /**
  41029. * Are refraction textures enabled in the application.
  41030. */
  41031. static RefractionTextureEnabled: boolean;
  41032. /**
  41033. * Are color grading textures enabled in the application.
  41034. */
  41035. static ColorGradingTextureEnabled: boolean;
  41036. /**
  41037. * Are fresnels enabled in the application.
  41038. */
  41039. static FresnelEnabled: boolean;
  41040. }
  41041. }
  41042. declare module BABYLON {
  41043. /** @hidden */
  41044. export var imageProcessingPixelShader: {
  41045. name: string;
  41046. shader: string;
  41047. };
  41048. }
  41049. declare module BABYLON {
  41050. /**
  41051. * ImageProcessingPostProcess
  41052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41053. */
  41054. export class ImageProcessingPostProcess extends PostProcess {
  41055. /**
  41056. * Default configuration related to image processing available in the PBR Material.
  41057. */
  41058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41059. /**
  41060. * Gets the image processing configuration used either in this material.
  41061. */
  41062. /**
  41063. * Sets the Default image processing configuration used either in the this material.
  41064. *
  41065. * If sets to null, the scene one is in use.
  41066. */
  41067. imageProcessingConfiguration: ImageProcessingConfiguration;
  41068. /**
  41069. * Keep track of the image processing observer to allow dispose and replace.
  41070. */
  41071. private _imageProcessingObserver;
  41072. /**
  41073. * Attaches a new image processing configuration to the PBR Material.
  41074. * @param configuration
  41075. */
  41076. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41077. /**
  41078. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41079. */
  41080. /**
  41081. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41082. */
  41083. colorCurves: Nullable<ColorCurves>;
  41084. /**
  41085. * Gets wether the color curves effect is enabled.
  41086. */
  41087. /**
  41088. * Sets wether the color curves effect is enabled.
  41089. */
  41090. colorCurvesEnabled: boolean;
  41091. /**
  41092. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41093. */
  41094. /**
  41095. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41096. */
  41097. colorGradingTexture: Nullable<BaseTexture>;
  41098. /**
  41099. * Gets wether the color grading effect is enabled.
  41100. */
  41101. /**
  41102. * Gets wether the color grading effect is enabled.
  41103. */
  41104. colorGradingEnabled: boolean;
  41105. /**
  41106. * Gets exposure used in the effect.
  41107. */
  41108. /**
  41109. * Sets exposure used in the effect.
  41110. */
  41111. exposure: number;
  41112. /**
  41113. * Gets wether tonemapping is enabled or not.
  41114. */
  41115. /**
  41116. * Sets wether tonemapping is enabled or not
  41117. */
  41118. toneMappingEnabled: boolean;
  41119. /**
  41120. * Gets the type of tone mapping effect.
  41121. */
  41122. /**
  41123. * Sets the type of tone mapping effect.
  41124. */
  41125. toneMappingType: number;
  41126. /**
  41127. * Gets contrast used in the effect.
  41128. */
  41129. /**
  41130. * Sets contrast used in the effect.
  41131. */
  41132. contrast: number;
  41133. /**
  41134. * Gets Vignette stretch size.
  41135. */
  41136. /**
  41137. * Sets Vignette stretch size.
  41138. */
  41139. vignetteStretch: number;
  41140. /**
  41141. * Gets Vignette centre X Offset.
  41142. */
  41143. /**
  41144. * Sets Vignette centre X Offset.
  41145. */
  41146. vignetteCentreX: number;
  41147. /**
  41148. * Gets Vignette centre Y Offset.
  41149. */
  41150. /**
  41151. * Sets Vignette centre Y Offset.
  41152. */
  41153. vignetteCentreY: number;
  41154. /**
  41155. * Gets Vignette weight or intensity of the vignette effect.
  41156. */
  41157. /**
  41158. * Sets Vignette weight or intensity of the vignette effect.
  41159. */
  41160. vignetteWeight: number;
  41161. /**
  41162. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41163. * if vignetteEnabled is set to true.
  41164. */
  41165. /**
  41166. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41167. * if vignetteEnabled is set to true.
  41168. */
  41169. vignetteColor: Color4;
  41170. /**
  41171. * Gets Camera field of view used by the Vignette effect.
  41172. */
  41173. /**
  41174. * Sets Camera field of view used by the Vignette effect.
  41175. */
  41176. vignetteCameraFov: number;
  41177. /**
  41178. * Gets the vignette blend mode allowing different kind of effect.
  41179. */
  41180. /**
  41181. * Sets the vignette blend mode allowing different kind of effect.
  41182. */
  41183. vignetteBlendMode: number;
  41184. /**
  41185. * Gets wether the vignette effect is enabled.
  41186. */
  41187. /**
  41188. * Sets wether the vignette effect is enabled.
  41189. */
  41190. vignetteEnabled: boolean;
  41191. private _fromLinearSpace;
  41192. /**
  41193. * Gets wether the input of the processing is in Gamma or Linear Space.
  41194. */
  41195. /**
  41196. * Sets wether the input of the processing is in Gamma or Linear Space.
  41197. */
  41198. fromLinearSpace: boolean;
  41199. /**
  41200. * Defines cache preventing GC.
  41201. */
  41202. private _defines;
  41203. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41204. /**
  41205. * "ImageProcessingPostProcess"
  41206. * @returns "ImageProcessingPostProcess"
  41207. */
  41208. getClassName(): string;
  41209. protected _updateParameters(): void;
  41210. dispose(camera?: Camera): void;
  41211. }
  41212. }
  41213. declare module BABYLON {
  41214. /**
  41215. * Class containing static functions to help procedurally build meshes
  41216. */
  41217. export class GroundBuilder {
  41218. /**
  41219. * Creates a ground mesh
  41220. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41221. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41223. * @param name defines the name of the mesh
  41224. * @param options defines the options used to create the mesh
  41225. * @param scene defines the hosting scene
  41226. * @returns the ground mesh
  41227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41228. */
  41229. static CreateGround(name: string, options: {
  41230. width?: number;
  41231. height?: number;
  41232. subdivisions?: number;
  41233. subdivisionsX?: number;
  41234. subdivisionsY?: number;
  41235. updatable?: boolean;
  41236. }, scene: any): Mesh;
  41237. /**
  41238. * Creates a tiled ground mesh
  41239. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41240. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41241. * * 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
  41242. * * 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
  41243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41244. * @param name defines the name of the mesh
  41245. * @param options defines the options used to create the mesh
  41246. * @param scene defines the hosting scene
  41247. * @returns the tiled ground mesh
  41248. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41249. */
  41250. static CreateTiledGround(name: string, options: {
  41251. xmin: number;
  41252. zmin: number;
  41253. xmax: number;
  41254. zmax: number;
  41255. subdivisions?: {
  41256. w: number;
  41257. h: number;
  41258. };
  41259. precision?: {
  41260. w: number;
  41261. h: number;
  41262. };
  41263. updatable?: boolean;
  41264. }, scene?: Nullable<Scene>): Mesh;
  41265. /**
  41266. * Creates a ground mesh from a height map
  41267. * * The parameter `url` sets the URL of the height map image resource.
  41268. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41269. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41270. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41271. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41272. * * 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.
  41273. * * 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).
  41274. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41276. * @param name defines the name of the mesh
  41277. * @param url defines the url to the height map
  41278. * @param options defines the options used to create the mesh
  41279. * @param scene defines the hosting scene
  41280. * @returns the ground mesh
  41281. * @see https://doc.babylonjs.com/babylon101/height_map
  41282. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41283. */
  41284. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41285. width?: number;
  41286. height?: number;
  41287. subdivisions?: number;
  41288. minHeight?: number;
  41289. maxHeight?: number;
  41290. colorFilter?: Color3;
  41291. alphaFilter?: number;
  41292. updatable?: boolean;
  41293. onReady?: (mesh: GroundMesh) => void;
  41294. }, scene?: Nullable<Scene>): GroundMesh;
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Class containing static functions to help procedurally build meshes
  41300. */
  41301. export class TorusBuilder {
  41302. /**
  41303. * Creates a torus mesh
  41304. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41305. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41306. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41308. * * 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
  41309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41310. * @param name defines the name of the mesh
  41311. * @param options defines the options used to create the mesh
  41312. * @param scene defines the hosting scene
  41313. * @returns the torus mesh
  41314. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41315. */
  41316. static CreateTorus(name: string, options: {
  41317. diameter?: number;
  41318. thickness?: number;
  41319. tessellation?: number;
  41320. updatable?: boolean;
  41321. sideOrientation?: number;
  41322. frontUVs?: Vector4;
  41323. backUVs?: Vector4;
  41324. }, scene: any): Mesh;
  41325. }
  41326. }
  41327. declare module BABYLON {
  41328. /**
  41329. * Class containing static functions to help procedurally build meshes
  41330. */
  41331. export class CylinderBuilder {
  41332. /**
  41333. * Creates a cylinder or a cone mesh
  41334. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41335. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41336. * * 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.
  41337. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41338. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41339. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41340. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41341. * * 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).
  41342. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41343. * * 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).
  41344. * * 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
  41345. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41346. * * 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
  41347. * * 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.
  41348. * * If `enclose` is false, a ring surface is one element.
  41349. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41350. * * 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
  41351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41352. * * 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
  41353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41354. * @param name defines the name of the mesh
  41355. * @param options defines the options used to create the mesh
  41356. * @param scene defines the hosting scene
  41357. * @returns the cylinder mesh
  41358. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41359. */
  41360. static CreateCylinder(name: string, options: {
  41361. height?: number;
  41362. diameterTop?: number;
  41363. diameterBottom?: number;
  41364. diameter?: number;
  41365. tessellation?: number;
  41366. subdivisions?: number;
  41367. arc?: number;
  41368. faceColors?: Color4[];
  41369. faceUV?: Vector4[];
  41370. updatable?: boolean;
  41371. hasRings?: boolean;
  41372. enclose?: boolean;
  41373. cap?: number;
  41374. sideOrientation?: number;
  41375. frontUVs?: Vector4;
  41376. backUVs?: Vector4;
  41377. }, scene: any): Mesh;
  41378. }
  41379. }
  41380. declare module BABYLON {
  41381. /**
  41382. * Options to modify the vr teleportation behavior.
  41383. */
  41384. export interface VRTeleportationOptions {
  41385. /**
  41386. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41387. */
  41388. floorMeshName?: string;
  41389. /**
  41390. * A list of meshes to be used as the teleportation floor. (default: empty)
  41391. */
  41392. floorMeshes?: Mesh[];
  41393. }
  41394. /**
  41395. * Options to modify the vr experience helper's behavior.
  41396. */
  41397. export interface VRExperienceHelperOptions extends WebVROptions {
  41398. /**
  41399. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41400. */
  41401. createDeviceOrientationCamera?: boolean;
  41402. /**
  41403. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41404. */
  41405. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41406. /**
  41407. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41408. */
  41409. laserToggle?: boolean;
  41410. /**
  41411. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41412. */
  41413. floorMeshes?: Mesh[];
  41414. /**
  41415. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41416. */
  41417. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41418. }
  41419. /**
  41420. * Event containing information after VR has been entered
  41421. */
  41422. export class OnAfterEnteringVRObservableEvent {
  41423. /**
  41424. * If entering vr was successful
  41425. */
  41426. success: boolean;
  41427. }
  41428. /**
  41429. * Helps to quickly add VR support to an existing scene.
  41430. * See http://doc.babylonjs.com/how_to/webvr_helper
  41431. */
  41432. export class VRExperienceHelper {
  41433. /** Options to modify the vr experience helper's behavior. */
  41434. webVROptions: VRExperienceHelperOptions;
  41435. private _scene;
  41436. private _position;
  41437. private _btnVR;
  41438. private _btnVRDisplayed;
  41439. private _webVRsupported;
  41440. private _webVRready;
  41441. private _webVRrequesting;
  41442. private _webVRpresenting;
  41443. private _hasEnteredVR;
  41444. private _fullscreenVRpresenting;
  41445. private _inputElement;
  41446. private _webVRCamera;
  41447. private _vrDeviceOrientationCamera;
  41448. private _deviceOrientationCamera;
  41449. private _existingCamera;
  41450. private _onKeyDown;
  41451. private _onVrDisplayPresentChange;
  41452. private _onVRDisplayChanged;
  41453. private _onVRRequestPresentStart;
  41454. private _onVRRequestPresentComplete;
  41455. /**
  41456. * 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)
  41457. */
  41458. enableGazeEvenWhenNoPointerLock: boolean;
  41459. /**
  41460. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41461. */
  41462. exitVROnDoubleTap: boolean;
  41463. /**
  41464. * Observable raised right before entering VR.
  41465. */
  41466. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41467. /**
  41468. * Observable raised when entering VR has completed.
  41469. */
  41470. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41471. /**
  41472. * Observable raised when exiting VR.
  41473. */
  41474. onExitingVRObservable: Observable<VRExperienceHelper>;
  41475. /**
  41476. * Observable raised when controller mesh is loaded.
  41477. */
  41478. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41479. /** Return this.onEnteringVRObservable
  41480. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41481. */
  41482. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41483. /** Return this.onExitingVRObservable
  41484. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41485. */
  41486. readonly onExitingVR: Observable<VRExperienceHelper>;
  41487. /** Return this.onControllerMeshLoadedObservable
  41488. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41489. */
  41490. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41491. private _rayLength;
  41492. private _useCustomVRButton;
  41493. private _teleportationRequested;
  41494. private _teleportActive;
  41495. private _floorMeshName;
  41496. private _floorMeshesCollection;
  41497. private _rotationAllowed;
  41498. private _teleportBackwardsVector;
  41499. private _teleportationTarget;
  41500. private _isDefaultTeleportationTarget;
  41501. private _postProcessMove;
  41502. private _teleportationFillColor;
  41503. private _teleportationBorderColor;
  41504. private _rotationAngle;
  41505. private _haloCenter;
  41506. private _cameraGazer;
  41507. private _padSensibilityUp;
  41508. private _padSensibilityDown;
  41509. private _leftController;
  41510. private _rightController;
  41511. /**
  41512. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41513. */
  41514. onNewMeshSelected: Observable<AbstractMesh>;
  41515. /**
  41516. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41517. * This observable will provide the mesh and the controller used to select the mesh
  41518. */
  41519. onMeshSelectedWithController: Observable<{
  41520. mesh: AbstractMesh;
  41521. controller: WebVRController;
  41522. }>;
  41523. /**
  41524. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41525. */
  41526. onNewMeshPicked: Observable<PickingInfo>;
  41527. private _circleEase;
  41528. /**
  41529. * Observable raised before camera teleportation
  41530. */
  41531. onBeforeCameraTeleport: Observable<Vector3>;
  41532. /**
  41533. * Observable raised after camera teleportation
  41534. */
  41535. onAfterCameraTeleport: Observable<Vector3>;
  41536. /**
  41537. * Observable raised when current selected mesh gets unselected
  41538. */
  41539. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41540. private _raySelectionPredicate;
  41541. /**
  41542. * To be optionaly changed by user to define custom ray selection
  41543. */
  41544. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41545. /**
  41546. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41547. */
  41548. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41549. /**
  41550. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41551. */
  41552. teleportationEnabled: boolean;
  41553. private _defaultHeight;
  41554. private _teleportationInitialized;
  41555. private _interactionsEnabled;
  41556. private _interactionsRequested;
  41557. private _displayGaze;
  41558. private _displayLaserPointer;
  41559. /**
  41560. * The mesh used to display where the user is going to teleport.
  41561. */
  41562. /**
  41563. * Sets the mesh to be used to display where the user is going to teleport.
  41564. */
  41565. teleportationTarget: Mesh;
  41566. /**
  41567. * 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
  41568. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41569. * See http://doc.babylonjs.com/resources/baking_transformations
  41570. */
  41571. gazeTrackerMesh: Mesh;
  41572. /**
  41573. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41574. */
  41575. updateGazeTrackerScale: boolean;
  41576. /**
  41577. * If the gaze trackers color should be updated when selecting meshes
  41578. */
  41579. updateGazeTrackerColor: boolean;
  41580. /**
  41581. * If the controller laser color should be updated when selecting meshes
  41582. */
  41583. updateControllerLaserColor: boolean;
  41584. /**
  41585. * The gaze tracking mesh corresponding to the left controller
  41586. */
  41587. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41588. /**
  41589. * The gaze tracking mesh corresponding to the right controller
  41590. */
  41591. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41592. /**
  41593. * If the ray of the gaze should be displayed.
  41594. */
  41595. /**
  41596. * Sets if the ray of the gaze should be displayed.
  41597. */
  41598. displayGaze: boolean;
  41599. /**
  41600. * If the ray of the LaserPointer should be displayed.
  41601. */
  41602. /**
  41603. * Sets if the ray of the LaserPointer should be displayed.
  41604. */
  41605. displayLaserPointer: boolean;
  41606. /**
  41607. * The deviceOrientationCamera used as the camera when not in VR.
  41608. */
  41609. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41610. /**
  41611. * Based on the current WebVR support, returns the current VR camera used.
  41612. */
  41613. readonly currentVRCamera: Nullable<Camera>;
  41614. /**
  41615. * The webVRCamera which is used when in VR.
  41616. */
  41617. readonly webVRCamera: WebVRFreeCamera;
  41618. /**
  41619. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41620. */
  41621. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41622. /**
  41623. * The html button that is used to trigger entering into VR.
  41624. */
  41625. readonly vrButton: Nullable<HTMLButtonElement>;
  41626. private readonly _teleportationRequestInitiated;
  41627. /**
  41628. * Defines wether or not Pointer lock should be requested when switching to
  41629. * full screen.
  41630. */
  41631. requestPointerLockOnFullScreen: boolean;
  41632. /**
  41633. * Instantiates a VRExperienceHelper.
  41634. * Helps to quickly add VR support to an existing scene.
  41635. * @param scene The scene the VRExperienceHelper belongs to.
  41636. * @param webVROptions Options to modify the vr experience helper's behavior.
  41637. */
  41638. constructor(scene: Scene,
  41639. /** Options to modify the vr experience helper's behavior. */
  41640. webVROptions?: VRExperienceHelperOptions);
  41641. private _onDefaultMeshLoaded;
  41642. private _onResize;
  41643. private _onFullscreenChange;
  41644. /**
  41645. * Gets a value indicating if we are currently in VR mode.
  41646. */
  41647. readonly isInVRMode: boolean;
  41648. private onVrDisplayPresentChange;
  41649. private onVRDisplayChanged;
  41650. private moveButtonToBottomRight;
  41651. private displayVRButton;
  41652. private updateButtonVisibility;
  41653. private _cachedAngularSensibility;
  41654. /**
  41655. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41656. * Otherwise, will use the fullscreen API.
  41657. */
  41658. enterVR(): void;
  41659. /**
  41660. * Attempt to exit VR, or fullscreen.
  41661. */
  41662. exitVR(): void;
  41663. /**
  41664. * The position of the vr experience helper.
  41665. */
  41666. /**
  41667. * Sets the position of the vr experience helper.
  41668. */
  41669. position: Vector3;
  41670. /**
  41671. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41672. */
  41673. enableInteractions(): void;
  41674. private readonly _noControllerIsActive;
  41675. private beforeRender;
  41676. private _isTeleportationFloor;
  41677. /**
  41678. * Adds a floor mesh to be used for teleportation.
  41679. * @param floorMesh the mesh to be used for teleportation.
  41680. */
  41681. addFloorMesh(floorMesh: Mesh): void;
  41682. /**
  41683. * Removes a floor mesh from being used for teleportation.
  41684. * @param floorMesh the mesh to be removed.
  41685. */
  41686. removeFloorMesh(floorMesh: Mesh): void;
  41687. /**
  41688. * Enables interactions and teleportation using the VR controllers and gaze.
  41689. * @param vrTeleportationOptions options to modify teleportation behavior.
  41690. */
  41691. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41692. private _onNewGamepadConnected;
  41693. private _tryEnableInteractionOnController;
  41694. private _onNewGamepadDisconnected;
  41695. private _enableInteractionOnController;
  41696. private _checkTeleportWithRay;
  41697. private _checkRotate;
  41698. private _checkTeleportBackwards;
  41699. private _enableTeleportationOnController;
  41700. private _createTeleportationCircles;
  41701. private _displayTeleportationTarget;
  41702. private _hideTeleportationTarget;
  41703. private _rotateCamera;
  41704. private _moveTeleportationSelectorTo;
  41705. private _workingVector;
  41706. private _workingQuaternion;
  41707. private _workingMatrix;
  41708. /**
  41709. * Teleports the users feet to the desired location
  41710. * @param location The location where the user's feet should be placed
  41711. */
  41712. teleportCamera(location: Vector3): void;
  41713. private _convertNormalToDirectionOfRay;
  41714. private _castRayAndSelectObject;
  41715. private _notifySelectedMeshUnselected;
  41716. /**
  41717. * Sets the color of the laser ray from the vr controllers.
  41718. * @param color new color for the ray.
  41719. */
  41720. changeLaserColor(color: Color3): void;
  41721. /**
  41722. * Sets the color of the ray from the vr headsets gaze.
  41723. * @param color new color for the ray.
  41724. */
  41725. changeGazeColor(color: Color3): void;
  41726. /**
  41727. * Exits VR and disposes of the vr experience helper
  41728. */
  41729. dispose(): void;
  41730. /**
  41731. * Gets the name of the VRExperienceHelper class
  41732. * @returns "VRExperienceHelper"
  41733. */
  41734. getClassName(): string;
  41735. }
  41736. }
  41737. declare module BABYLON {
  41738. /**
  41739. * States of the webXR experience
  41740. */
  41741. export enum WebXRState {
  41742. /**
  41743. * Transitioning to being in XR mode
  41744. */
  41745. ENTERING_XR = 0,
  41746. /**
  41747. * Transitioning to non XR mode
  41748. */
  41749. EXITING_XR = 1,
  41750. /**
  41751. * In XR mode and presenting
  41752. */
  41753. IN_XR = 2,
  41754. /**
  41755. * Not entered XR mode
  41756. */
  41757. NOT_IN_XR = 3
  41758. }
  41759. /**
  41760. * Abstraction of the XR render target
  41761. */
  41762. export interface WebXRRenderTarget extends IDisposable {
  41763. /**
  41764. * xrpresent context of the canvas which can be used to display/mirror xr content
  41765. */
  41766. canvasContext: WebGLRenderingContext;
  41767. /**
  41768. * xr layer for the canvas
  41769. */
  41770. xrLayer: Nullable<XRWebGLLayer>;
  41771. /**
  41772. * Initializes the xr layer for the session
  41773. * @param xrSession xr session
  41774. * @returns a promise that will resolve once the XR Layer has been created
  41775. */
  41776. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  41777. }
  41778. }
  41779. declare module BABYLON {
  41780. /**
  41781. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41782. */
  41783. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  41784. private _engine;
  41785. private _canvas;
  41786. /**
  41787. * xrpresent context of the canvas which can be used to display/mirror xr content
  41788. */
  41789. canvasContext: WebGLRenderingContext;
  41790. /**
  41791. * xr layer for the canvas
  41792. */
  41793. xrLayer: Nullable<XRWebGLLayer>;
  41794. /**
  41795. * Initializes the xr layer for the session
  41796. * @param xrSession xr session
  41797. * @returns a promise that will resolve once the XR Layer has been created
  41798. */
  41799. initializeXRLayerAsync(xrSession: any): any;
  41800. /**
  41801. * Initializes the canvas to be added/removed upon entering/exiting xr
  41802. * @param engine the Babylon engine
  41803. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41804. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  41805. */
  41806. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>);
  41807. /**
  41808. * Disposes of the object
  41809. */
  41810. dispose(): void;
  41811. private _setManagedOutputCanvas;
  41812. private _addCanvas;
  41813. private _removeCanvas;
  41814. }
  41815. }
  41816. declare module BABYLON {
  41817. /**
  41818. * Manages an XRSession to work with Babylon's engine
  41819. * @see https://doc.babylonjs.com/how_to/webxr
  41820. */
  41821. export class WebXRSessionManager implements IDisposable {
  41822. private scene;
  41823. /**
  41824. * Fires every time a new xrFrame arrives which can be used to update the camera
  41825. */
  41826. onXRFrameObservable: Observable<any>;
  41827. /**
  41828. * Fires when the xr session is ended either by the device or manually done
  41829. */
  41830. onXRSessionEnded: Observable<any>;
  41831. /**
  41832. * Underlying xr session
  41833. */
  41834. session: XRSession;
  41835. /**
  41836. * Type of reference space used when creating the session
  41837. */
  41838. referenceSpace: XRReferenceSpace;
  41839. /**
  41840. * Current XR frame
  41841. */
  41842. currentFrame: Nullable<XRFrame>;
  41843. private _xrNavigator;
  41844. private baseLayer;
  41845. private _rttProvider;
  41846. private _sessionEnded;
  41847. /**
  41848. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41849. * @param scene The scene which the session should be created for
  41850. */
  41851. constructor(scene: Scene);
  41852. /**
  41853. * Initializes the manager
  41854. * After initialization enterXR can be called to start an XR session
  41855. * @returns Promise which resolves after it is initialized
  41856. */
  41857. initializeAsync(): Promise<void>;
  41858. /**
  41859. * Initializes an xr session
  41860. * @param xrSessionMode mode to initialize
  41861. * @param optionalFeatures defines optional values to pass to the session builder
  41862. * @returns a promise which will resolve once the session has been initialized
  41863. */
  41864. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): any;
  41865. /**
  41866. * Sets the reference space on the xr session
  41867. * @param referenceSpace space to set
  41868. * @returns a promise that will resolve once the reference space has been set
  41869. */
  41870. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41871. /**
  41872. * Updates the render state of the session
  41873. * @param state state to set
  41874. * @returns a promise that resolves once the render state has been updated
  41875. */
  41876. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41877. /**
  41878. * Starts rendering to the xr layer
  41879. * @returns a promise that will resolve once rendering has started
  41880. */
  41881. startRenderingToXRAsync(): Promise<void>;
  41882. /**
  41883. * Gets the correct render target texture to be rendered this frame for this eye
  41884. * @param eye the eye for which to get the render target
  41885. * @returns the render target for the specified eye
  41886. */
  41887. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  41888. /**
  41889. * Stops the xrSession and restores the renderloop
  41890. * @returns Promise which resolves after it exits XR
  41891. */
  41892. exitXRAsync(): Promise<void>;
  41893. /**
  41894. * Checks if a session would be supported for the creation options specified
  41895. * @param sessionMode session mode to check if supported eg. immersive-vr
  41896. * @returns true if supported
  41897. */
  41898. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41899. /**
  41900. * Creates a WebXRRenderTarget object for the XR session
  41901. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  41902. * @returns a WebXR render target to which the session can render
  41903. */
  41904. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  41905. /**
  41906. * @hidden
  41907. * Converts the render layer of xrSession to a render target
  41908. * @param session session to create render target for
  41909. * @param scene scene the new render target should be created for
  41910. */
  41911. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41912. /**
  41913. * Disposes of the session manager
  41914. */
  41915. dispose(): void;
  41916. }
  41917. }
  41918. declare module BABYLON {
  41919. /**
  41920. * WebXR Camera which holds the views for the xrSession
  41921. * @see https://doc.babylonjs.com/how_to/webxr
  41922. */
  41923. export class WebXRCamera extends FreeCamera {
  41924. private static _TmpMatrix;
  41925. /**
  41926. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41927. * @param name the name of the camera
  41928. * @param scene the scene to add the camera to
  41929. */
  41930. constructor(name: string, scene: Scene);
  41931. private _updateNumberOfRigCameras;
  41932. /** @hidden */
  41933. _updateForDualEyeDebugging(): void;
  41934. /**
  41935. * Updates the cameras position from the current pose information of the XR session
  41936. * @param xrSessionManager the session containing pose information
  41937. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41938. */
  41939. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41940. }
  41941. }
  41942. declare module BABYLON {
  41943. /**
  41944. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41945. * @see https://doc.babylonjs.com/how_to/webxr
  41946. */
  41947. export class WebXRExperienceHelper implements IDisposable {
  41948. private scene;
  41949. /**
  41950. * 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
  41951. */
  41952. container: AbstractMesh;
  41953. /**
  41954. * Camera used to render xr content
  41955. */
  41956. camera: WebXRCamera;
  41957. /**
  41958. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41959. */
  41960. state: WebXRState;
  41961. private _setState;
  41962. private static _TmpVector;
  41963. /**
  41964. * Fires when the state of the experience helper has changed
  41965. */
  41966. onStateChangedObservable: Observable<WebXRState>;
  41967. /** Session manager used to keep track of xr session */
  41968. sessionManager: WebXRSessionManager;
  41969. private _nonVRCamera;
  41970. private _originalSceneAutoClear;
  41971. private _supported;
  41972. /**
  41973. * Creates the experience helper
  41974. * @param scene the scene to attach the experience helper to
  41975. * @returns a promise for the experience helper
  41976. */
  41977. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41978. /**
  41979. * Creates a WebXRExperienceHelper
  41980. * @param scene The scene the helper should be created in
  41981. */
  41982. private constructor();
  41983. /**
  41984. * Exits XR mode and returns the scene to its original state
  41985. * @returns promise that resolves after xr mode has exited
  41986. */
  41987. exitXRAsync(): Promise<void>;
  41988. /**
  41989. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41990. * @param sessionMode options for the XR session
  41991. * @param referenceSpaceType frame of reference of the XR session
  41992. * @param renderTarget the output canvas that will be used to enter XR mode
  41993. * @returns promise that resolves after xr mode has entered
  41994. */
  41995. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  41996. /**
  41997. * Updates the global position of the camera by moving the camera's container
  41998. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41999. * @param position The desired global position of the camera
  42000. */
  42001. setPositionOfCameraUsingContainer(position: Vector3): void;
  42002. /**
  42003. * Rotates the xr camera by rotating the camera's container around the camera's position
  42004. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42005. * @param rotation the desired quaternion rotation to apply to the camera
  42006. */
  42007. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42008. /**
  42009. * Disposes of the experience helper
  42010. */
  42011. dispose(): void;
  42012. }
  42013. }
  42014. declare module BABYLON {
  42015. /**
  42016. * Button which can be used to enter a different mode of XR
  42017. */
  42018. export class WebXREnterExitUIButton {
  42019. /** button element */
  42020. element: HTMLElement;
  42021. /** XR initialization options for the button */
  42022. sessionMode: XRSessionMode;
  42023. /** Reference space type */
  42024. referenceSpaceType: XRReferenceSpaceType;
  42025. /**
  42026. * Creates a WebXREnterExitUIButton
  42027. * @param element button element
  42028. * @param sessionMode XR initialization session mode
  42029. * @param referenceSpaceType the type of reference space to be used
  42030. */
  42031. constructor(
  42032. /** button element */
  42033. element: HTMLElement,
  42034. /** XR initialization options for the button */
  42035. sessionMode: XRSessionMode,
  42036. /** Reference space type */
  42037. referenceSpaceType: XRReferenceSpaceType);
  42038. /**
  42039. * Overwritable function which can be used to update the button's visuals when the state changes
  42040. * @param activeButton the current active button in the UI
  42041. */
  42042. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42043. }
  42044. /**
  42045. * Options to create the webXR UI
  42046. */
  42047. export class WebXREnterExitUIOptions {
  42048. /**
  42049. * Context to enter xr with
  42050. */
  42051. renderTarget?: Nullable<WebXRRenderTarget>;
  42052. /**
  42053. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42054. */
  42055. customButtons?: Array<WebXREnterExitUIButton>;
  42056. }
  42057. /**
  42058. * UI to allow the user to enter/exit XR mode
  42059. */
  42060. export class WebXREnterExitUI implements IDisposable {
  42061. private scene;
  42062. private _overlay;
  42063. private _buttons;
  42064. private _activeButton;
  42065. /**
  42066. * Fired every time the active button is changed.
  42067. *
  42068. * When xr is entered via a button that launches xr that button will be the callback parameter
  42069. *
  42070. * When exiting xr the callback parameter will be null)
  42071. */
  42072. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42073. /**
  42074. * Creates UI to allow the user to enter/exit XR mode
  42075. * @param scene the scene to add the ui to
  42076. * @param helper the xr experience helper to enter/exit xr with
  42077. * @param options options to configure the UI
  42078. * @returns the created ui
  42079. */
  42080. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42081. private constructor();
  42082. private _updateButtons;
  42083. /**
  42084. * Disposes of the object
  42085. */
  42086. dispose(): void;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Represents an XR input
  42092. */
  42093. export class WebXRController {
  42094. private scene;
  42095. /** The underlying input source for the controller */
  42096. inputSource: XRInputSource;
  42097. private parentContainer;
  42098. /**
  42099. * 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
  42100. */
  42101. grip?: AbstractMesh;
  42102. /**
  42103. * Pointer which can be used to select objects or attach a visible laser to
  42104. */
  42105. pointer: AbstractMesh;
  42106. private _gamepadMode;
  42107. /**
  42108. * If available, this is the gamepad object related to this controller.
  42109. * Using this object it is possible to get click events and trackpad changes of the
  42110. * webxr controller that is currently being used.
  42111. */
  42112. gamepadController?: WebVRController;
  42113. /**
  42114. * Event that fires when the controller is removed/disposed
  42115. */
  42116. onDisposeObservable: Observable<{}>;
  42117. private _tmpMatrix;
  42118. private _tmpQuaternion;
  42119. private _tmpVector;
  42120. /**
  42121. * Creates the controller
  42122. * @see https://doc.babylonjs.com/how_to/webxr
  42123. * @param scene the scene which the controller should be associated to
  42124. * @param inputSource the underlying input source for the controller
  42125. * @param parentContainer parent that the controller meshes should be children of
  42126. */
  42127. constructor(scene: Scene,
  42128. /** The underlying input source for the controller */
  42129. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42130. /**
  42131. * Updates the controller pose based on the given XRFrame
  42132. * @param xrFrame xr frame to update the pose with
  42133. * @param referenceSpace reference space to use
  42134. */
  42135. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42136. /**
  42137. * Gets a world space ray coming from the controller
  42138. * @param result the resulting ray
  42139. */
  42140. getWorldPointerRayToRef(result: Ray): void;
  42141. /**
  42142. * Get the scene associated with this controller
  42143. * @returns the scene object
  42144. */
  42145. getScene(): Scene;
  42146. /**
  42147. * Disposes of the object
  42148. */
  42149. dispose(): void;
  42150. }
  42151. }
  42152. declare module BABYLON {
  42153. /**
  42154. * XR input used to track XR inputs such as controllers/rays
  42155. */
  42156. export class WebXRInput implements IDisposable {
  42157. /**
  42158. * Base experience the input listens to
  42159. */
  42160. baseExperience: WebXRExperienceHelper;
  42161. /**
  42162. * XR controllers being tracked
  42163. */
  42164. controllers: Array<WebXRController>;
  42165. private _frameObserver;
  42166. private _stateObserver;
  42167. /**
  42168. * Event when a controller has been connected/added
  42169. */
  42170. onControllerAddedObservable: Observable<WebXRController>;
  42171. /**
  42172. * Event when a controller has been removed/disconnected
  42173. */
  42174. onControllerRemovedObservable: Observable<WebXRController>;
  42175. /**
  42176. * Initializes the WebXRInput
  42177. * @param baseExperience experience helper which the input should be created for
  42178. */
  42179. constructor(
  42180. /**
  42181. * Base experience the input listens to
  42182. */
  42183. baseExperience: WebXRExperienceHelper);
  42184. private _onInputSourcesChange;
  42185. private _addAndRemoveControllers;
  42186. /**
  42187. * Disposes of the object
  42188. */
  42189. dispose(): void;
  42190. }
  42191. }
  42192. declare module BABYLON {
  42193. /**
  42194. * Enables teleportation
  42195. */
  42196. export class WebXRControllerTeleportation {
  42197. private _teleportationFillColor;
  42198. private _teleportationBorderColor;
  42199. private _tmpRay;
  42200. private _tmpVector;
  42201. /**
  42202. * Creates a WebXRControllerTeleportation
  42203. * @param input input manager to add teleportation to
  42204. * @param floorMeshes floormeshes which can be teleported to
  42205. */
  42206. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42207. }
  42208. }
  42209. declare module BABYLON {
  42210. /**
  42211. * Handles pointer input automatically for the pointer of XR controllers
  42212. */
  42213. export class WebXRControllerPointerSelection {
  42214. private static _idCounter;
  42215. private _tmpRay;
  42216. /**
  42217. * Creates a WebXRControllerPointerSelection
  42218. * @param input input manager to setup pointer selection
  42219. */
  42220. constructor(input: WebXRInput);
  42221. private _convertNormalToDirectionOfRay;
  42222. private _updatePointerDistance;
  42223. }
  42224. }
  42225. declare module BABYLON {
  42226. /**
  42227. * Class used to represent data loading progression
  42228. */
  42229. export class SceneLoaderProgressEvent {
  42230. /** defines if data length to load can be evaluated */
  42231. readonly lengthComputable: boolean;
  42232. /** defines the loaded data length */
  42233. readonly loaded: number;
  42234. /** defines the data length to load */
  42235. readonly total: number;
  42236. /**
  42237. * Create a new progress event
  42238. * @param lengthComputable defines if data length to load can be evaluated
  42239. * @param loaded defines the loaded data length
  42240. * @param total defines the data length to load
  42241. */
  42242. constructor(
  42243. /** defines if data length to load can be evaluated */
  42244. lengthComputable: boolean,
  42245. /** defines the loaded data length */
  42246. loaded: number,
  42247. /** defines the data length to load */
  42248. total: number);
  42249. /**
  42250. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42251. * @param event defines the source event
  42252. * @returns a new SceneLoaderProgressEvent
  42253. */
  42254. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42255. }
  42256. /**
  42257. * Interface used by SceneLoader plugins to define supported file extensions
  42258. */
  42259. export interface ISceneLoaderPluginExtensions {
  42260. /**
  42261. * Defines the list of supported extensions
  42262. */
  42263. [extension: string]: {
  42264. isBinary: boolean;
  42265. };
  42266. }
  42267. /**
  42268. * Interface used by SceneLoader plugin factory
  42269. */
  42270. export interface ISceneLoaderPluginFactory {
  42271. /**
  42272. * Defines the name of the factory
  42273. */
  42274. name: string;
  42275. /**
  42276. * Function called to create a new plugin
  42277. * @return the new plugin
  42278. */
  42279. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42280. /**
  42281. * The callback that returns true if the data can be directly loaded.
  42282. * @param data string containing the file data
  42283. * @returns if the data can be loaded directly
  42284. */
  42285. canDirectLoad?(data: string): boolean;
  42286. }
  42287. /**
  42288. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42289. */
  42290. export interface ISceneLoaderPluginBase {
  42291. /**
  42292. * The friendly name of this plugin.
  42293. */
  42294. name: string;
  42295. /**
  42296. * The file extensions supported by this plugin.
  42297. */
  42298. extensions: string | ISceneLoaderPluginExtensions;
  42299. /**
  42300. * The callback called when loading from a url.
  42301. * @param scene scene loading this url
  42302. * @param url url to load
  42303. * @param onSuccess callback called when the file successfully loads
  42304. * @param onProgress callback called while file is loading (if the server supports this mode)
  42305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42306. * @param onError callback called when the file fails to load
  42307. * @returns a file request object
  42308. */
  42309. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42310. /**
  42311. * The callback called when loading from a file object.
  42312. * @param scene scene loading this file
  42313. * @param file defines the file to load
  42314. * @param onSuccess defines the callback to call when data is loaded
  42315. * @param onProgress defines the callback to call during loading process
  42316. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42317. * @param onError defines the callback to call when an error occurs
  42318. * @returns a file request object
  42319. */
  42320. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42321. /**
  42322. * The callback that returns true if the data can be directly loaded.
  42323. * @param data string containing the file data
  42324. * @returns if the data can be loaded directly
  42325. */
  42326. canDirectLoad?(data: string): boolean;
  42327. /**
  42328. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42329. * @param scene scene loading this data
  42330. * @param data string containing the data
  42331. * @returns data to pass to the plugin
  42332. */
  42333. directLoad?(scene: Scene, data: string): any;
  42334. /**
  42335. * The callback that allows custom handling of the root url based on the response url.
  42336. * @param rootUrl the original root url
  42337. * @param responseURL the response url if available
  42338. * @returns the new root url
  42339. */
  42340. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42341. }
  42342. /**
  42343. * Interface used to define a SceneLoader plugin
  42344. */
  42345. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42346. /**
  42347. * Import meshes into a scene.
  42348. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42349. * @param scene The scene to import into
  42350. * @param data The data to import
  42351. * @param rootUrl The root url for scene and resources
  42352. * @param meshes The meshes array to import into
  42353. * @param particleSystems The particle systems array to import into
  42354. * @param skeletons The skeletons array to import into
  42355. * @param onError The callback when import fails
  42356. * @returns True if successful or false otherwise
  42357. */
  42358. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42359. /**
  42360. * Load into a scene.
  42361. * @param scene The scene to load into
  42362. * @param data The data to import
  42363. * @param rootUrl The root url for scene and resources
  42364. * @param onError The callback when import fails
  42365. * @returns True if successful or false otherwise
  42366. */
  42367. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42368. /**
  42369. * Load into an asset container.
  42370. * @param scene The scene to load into
  42371. * @param data The data to import
  42372. * @param rootUrl The root url for scene and resources
  42373. * @param onError The callback when import fails
  42374. * @returns The loaded asset container
  42375. */
  42376. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42377. }
  42378. /**
  42379. * Interface used to define an async SceneLoader plugin
  42380. */
  42381. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42382. /**
  42383. * Import meshes into a scene.
  42384. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42385. * @param scene The scene to import into
  42386. * @param data The data to import
  42387. * @param rootUrl The root url for scene and resources
  42388. * @param onProgress The callback when the load progresses
  42389. * @param fileName Defines the name of the file to load
  42390. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42391. */
  42392. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42393. meshes: AbstractMesh[];
  42394. particleSystems: IParticleSystem[];
  42395. skeletons: Skeleton[];
  42396. animationGroups: AnimationGroup[];
  42397. }>;
  42398. /**
  42399. * Load into a scene.
  42400. * @param scene The scene to load into
  42401. * @param data The data to import
  42402. * @param rootUrl The root url for scene and resources
  42403. * @param onProgress The callback when the load progresses
  42404. * @param fileName Defines the name of the file to load
  42405. * @returns Nothing
  42406. */
  42407. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42408. /**
  42409. * Load into an asset container.
  42410. * @param scene The scene to load into
  42411. * @param data The data to import
  42412. * @param rootUrl The root url for scene and resources
  42413. * @param onProgress The callback when the load progresses
  42414. * @param fileName Defines the name of the file to load
  42415. * @returns The loaded asset container
  42416. */
  42417. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42418. }
  42419. /**
  42420. * Class used to load scene from various file formats using registered plugins
  42421. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42422. */
  42423. export class SceneLoader {
  42424. /**
  42425. * No logging while loading
  42426. */
  42427. static readonly NO_LOGGING: number;
  42428. /**
  42429. * Minimal logging while loading
  42430. */
  42431. static readonly MINIMAL_LOGGING: number;
  42432. /**
  42433. * Summary logging while loading
  42434. */
  42435. static readonly SUMMARY_LOGGING: number;
  42436. /**
  42437. * Detailled logging while loading
  42438. */
  42439. static readonly DETAILED_LOGGING: number;
  42440. /**
  42441. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42442. */
  42443. static ForceFullSceneLoadingForIncremental: boolean;
  42444. /**
  42445. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42446. */
  42447. static ShowLoadingScreen: boolean;
  42448. /**
  42449. * Defines the current logging level (while loading the scene)
  42450. * @ignorenaming
  42451. */
  42452. static loggingLevel: number;
  42453. /**
  42454. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42455. */
  42456. static CleanBoneMatrixWeights: boolean;
  42457. /**
  42458. * Event raised when a plugin is used to load a scene
  42459. */
  42460. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42461. private static _registeredPlugins;
  42462. private static _getDefaultPlugin;
  42463. private static _getPluginForExtension;
  42464. private static _getPluginForDirectLoad;
  42465. private static _getPluginForFilename;
  42466. private static _getDirectLoad;
  42467. private static _loadData;
  42468. private static _getFileInfo;
  42469. /**
  42470. * Gets a plugin that can load the given extension
  42471. * @param extension defines the extension to load
  42472. * @returns a plugin or null if none works
  42473. */
  42474. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42475. /**
  42476. * Gets a boolean indicating that the given extension can be loaded
  42477. * @param extension defines the extension to load
  42478. * @returns true if the extension is supported
  42479. */
  42480. static IsPluginForExtensionAvailable(extension: string): boolean;
  42481. /**
  42482. * Adds a new plugin to the list of registered plugins
  42483. * @param plugin defines the plugin to add
  42484. */
  42485. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42486. /**
  42487. * Import meshes into a scene
  42488. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42489. * @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)
  42490. * @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)
  42491. * @param scene the instance of BABYLON.Scene to append to
  42492. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42493. * @param onProgress a callback with a progress event for each file being loaded
  42494. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42495. * @param pluginExtension the extension used to determine the plugin
  42496. * @returns The loaded plugin
  42497. */
  42498. 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>;
  42499. /**
  42500. * Import meshes into a scene
  42501. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42502. * @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)
  42503. * @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)
  42504. * @param scene the instance of BABYLON.Scene to append to
  42505. * @param onProgress a callback with a progress event for each file being loaded
  42506. * @param pluginExtension the extension used to determine the plugin
  42507. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42508. */
  42509. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42510. meshes: AbstractMesh[];
  42511. particleSystems: IParticleSystem[];
  42512. skeletons: Skeleton[];
  42513. animationGroups: AnimationGroup[];
  42514. }>;
  42515. /**
  42516. * Load a scene
  42517. * @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)
  42518. * @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)
  42519. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42520. * @param onSuccess a callback with the scene when import succeeds
  42521. * @param onProgress a callback with a progress event for each file being loaded
  42522. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42523. * @param pluginExtension the extension used to determine the plugin
  42524. * @returns The loaded plugin
  42525. */
  42526. 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>;
  42527. /**
  42528. * Load a scene
  42529. * @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)
  42530. * @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)
  42531. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42532. * @param onProgress a callback with a progress event for each file being loaded
  42533. * @param pluginExtension the extension used to determine the plugin
  42534. * @returns The loaded scene
  42535. */
  42536. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42537. /**
  42538. * Append a scene
  42539. * @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)
  42540. * @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)
  42541. * @param scene is the instance of BABYLON.Scene to append to
  42542. * @param onSuccess a callback with the scene when import succeeds
  42543. * @param onProgress a callback with a progress event for each file being loaded
  42544. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42545. * @param pluginExtension the extension used to determine the plugin
  42546. * @returns The loaded plugin
  42547. */
  42548. 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>;
  42549. /**
  42550. * Append a scene
  42551. * @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)
  42552. * @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)
  42553. * @param scene is the instance of BABYLON.Scene to append to
  42554. * @param onProgress a callback with a progress event for each file being loaded
  42555. * @param pluginExtension the extension used to determine the plugin
  42556. * @returns The given scene
  42557. */
  42558. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42559. /**
  42560. * Load a scene into an asset container
  42561. * @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)
  42562. * @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)
  42563. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42564. * @param onSuccess a callback with the scene when import succeeds
  42565. * @param onProgress a callback with a progress event for each file being loaded
  42566. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42567. * @param pluginExtension the extension used to determine the plugin
  42568. * @returns The loaded plugin
  42569. */
  42570. 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>;
  42571. /**
  42572. * Load a scene into an asset container
  42573. * @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)
  42574. * @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)
  42575. * @param scene is the instance of Scene to append to
  42576. * @param onProgress a callback with a progress event for each file being loaded
  42577. * @param pluginExtension the extension used to determine the plugin
  42578. * @returns The loaded asset container
  42579. */
  42580. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42581. }
  42582. }
  42583. declare module BABYLON {
  42584. /**
  42585. * Generic Controller
  42586. */
  42587. export class GenericController extends WebVRController {
  42588. /**
  42589. * Base Url for the controller model.
  42590. */
  42591. static readonly MODEL_BASE_URL: string;
  42592. /**
  42593. * File name for the controller model.
  42594. */
  42595. static readonly MODEL_FILENAME: string;
  42596. /**
  42597. * Creates a new GenericController from a gamepad
  42598. * @param vrGamepad the gamepad that the controller should be created from
  42599. */
  42600. constructor(vrGamepad: any);
  42601. /**
  42602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42603. * @param scene scene in which to add meshes
  42604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42605. */
  42606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42607. /**
  42608. * Called once for each button that changed state since the last frame
  42609. * @param buttonIdx Which button index changed
  42610. * @param state New state of the button
  42611. * @param changes Which properties on the state changed since last frame
  42612. */
  42613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42614. }
  42615. }
  42616. declare module BABYLON {
  42617. /**
  42618. * Defines the WindowsMotionController object that the state of the windows motion controller
  42619. */
  42620. export class WindowsMotionController extends WebVRController {
  42621. /**
  42622. * The base url used to load the left and right controller models
  42623. */
  42624. static MODEL_BASE_URL: string;
  42625. /**
  42626. * The name of the left controller model file
  42627. */
  42628. static MODEL_LEFT_FILENAME: string;
  42629. /**
  42630. * The name of the right controller model file
  42631. */
  42632. static MODEL_RIGHT_FILENAME: string;
  42633. /**
  42634. * The controller name prefix for this controller type
  42635. */
  42636. static readonly GAMEPAD_ID_PREFIX: string;
  42637. /**
  42638. * The controller id pattern for this controller type
  42639. */
  42640. private static readonly GAMEPAD_ID_PATTERN;
  42641. private _loadedMeshInfo;
  42642. private readonly _mapping;
  42643. /**
  42644. * Fired when the trackpad on this controller is clicked
  42645. */
  42646. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42647. /**
  42648. * Fired when the trackpad on this controller is modified
  42649. */
  42650. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42651. /**
  42652. * The current x and y values of this controller's trackpad
  42653. */
  42654. trackpad: StickValues;
  42655. /**
  42656. * Creates a new WindowsMotionController from a gamepad
  42657. * @param vrGamepad the gamepad that the controller should be created from
  42658. */
  42659. constructor(vrGamepad: any);
  42660. /**
  42661. * Fired when the trigger on this controller is modified
  42662. */
  42663. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42664. /**
  42665. * Fired when the menu button on this controller is modified
  42666. */
  42667. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42668. /**
  42669. * Fired when the grip button on this controller is modified
  42670. */
  42671. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42672. /**
  42673. * Fired when the thumbstick button on this controller is modified
  42674. */
  42675. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42676. /**
  42677. * Fired when the touchpad button on this controller is modified
  42678. */
  42679. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42680. /**
  42681. * Fired when the touchpad values on this controller are modified
  42682. */
  42683. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42684. private _updateTrackpad;
  42685. /**
  42686. * Called once per frame by the engine.
  42687. */
  42688. update(): void;
  42689. /**
  42690. * Called once for each button that changed state since the last frame
  42691. * @param buttonIdx Which button index changed
  42692. * @param state New state of the button
  42693. * @param changes Which properties on the state changed since last frame
  42694. */
  42695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42696. /**
  42697. * Moves the buttons on the controller mesh based on their current state
  42698. * @param buttonName the name of the button to move
  42699. * @param buttonValue the value of the button which determines the buttons new position
  42700. */
  42701. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42702. /**
  42703. * Moves the axis on the controller mesh based on its current state
  42704. * @param axis the index of the axis
  42705. * @param axisValue the value of the axis which determines the meshes new position
  42706. * @hidden
  42707. */
  42708. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42709. /**
  42710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42711. * @param scene scene in which to add meshes
  42712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42713. */
  42714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42715. /**
  42716. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42717. * can be transformed by button presses and axes values, based on this._mapping.
  42718. *
  42719. * @param scene scene in which the meshes exist
  42720. * @param meshes list of meshes that make up the controller model to process
  42721. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42722. */
  42723. private processModel;
  42724. private createMeshInfo;
  42725. /**
  42726. * Gets the ray of the controller in the direction the controller is pointing
  42727. * @param length the length the resulting ray should be
  42728. * @returns a ray in the direction the controller is pointing
  42729. */
  42730. getForwardRay(length?: number): Ray;
  42731. /**
  42732. * Disposes of the controller
  42733. */
  42734. dispose(): void;
  42735. }
  42736. }
  42737. declare module BABYLON {
  42738. /**
  42739. * Oculus Touch Controller
  42740. */
  42741. export class OculusTouchController extends WebVRController {
  42742. /**
  42743. * Base Url for the controller model.
  42744. */
  42745. static MODEL_BASE_URL: string;
  42746. /**
  42747. * File name for the left controller model.
  42748. */
  42749. static MODEL_LEFT_FILENAME: string;
  42750. /**
  42751. * File name for the right controller model.
  42752. */
  42753. static MODEL_RIGHT_FILENAME: string;
  42754. /**
  42755. * Base Url for the Quest controller model.
  42756. */
  42757. static QUEST_MODEL_BASE_URL: string;
  42758. /**
  42759. * @hidden
  42760. * If the controllers are running on a device that needs the updated Quest controller models
  42761. */
  42762. static _IsQuest: boolean;
  42763. /**
  42764. * Fired when the secondary trigger on this controller is modified
  42765. */
  42766. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42767. /**
  42768. * Fired when the thumb rest on this controller is modified
  42769. */
  42770. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42771. /**
  42772. * Creates a new OculusTouchController from a gamepad
  42773. * @param vrGamepad the gamepad that the controller should be created from
  42774. */
  42775. constructor(vrGamepad: any);
  42776. /**
  42777. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42778. * @param scene scene in which to add meshes
  42779. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42780. */
  42781. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42782. /**
  42783. * Fired when the A button on this controller is modified
  42784. */
  42785. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42786. /**
  42787. * Fired when the B button on this controller is modified
  42788. */
  42789. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42790. /**
  42791. * Fired when the X button on this controller is modified
  42792. */
  42793. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42794. /**
  42795. * Fired when the Y button on this controller is modified
  42796. */
  42797. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42798. /**
  42799. * Called once for each button that changed state since the last frame
  42800. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42801. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42802. * 2) secondary trigger (same)
  42803. * 3) A (right) X (left), touch, pressed = value
  42804. * 4) B / Y
  42805. * 5) thumb rest
  42806. * @param buttonIdx Which button index changed
  42807. * @param state New state of the button
  42808. * @param changes Which properties on the state changed since last frame
  42809. */
  42810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42811. }
  42812. }
  42813. declare module BABYLON {
  42814. /**
  42815. * Vive Controller
  42816. */
  42817. export class ViveController extends WebVRController {
  42818. /**
  42819. * Base Url for the controller model.
  42820. */
  42821. static MODEL_BASE_URL: string;
  42822. /**
  42823. * File name for the controller model.
  42824. */
  42825. static MODEL_FILENAME: string;
  42826. /**
  42827. * Creates a new ViveController from a gamepad
  42828. * @param vrGamepad the gamepad that the controller should be created from
  42829. */
  42830. constructor(vrGamepad: any);
  42831. /**
  42832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42833. * @param scene scene in which to add meshes
  42834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42835. */
  42836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42837. /**
  42838. * Fired when the left button on this controller is modified
  42839. */
  42840. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42841. /**
  42842. * Fired when the right button on this controller is modified
  42843. */
  42844. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42845. /**
  42846. * Fired when the menu button on this controller is modified
  42847. */
  42848. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42849. /**
  42850. * Called once for each button that changed state since the last frame
  42851. * Vive mapping:
  42852. * 0: touchpad
  42853. * 1: trigger
  42854. * 2: left AND right buttons
  42855. * 3: menu button
  42856. * @param buttonIdx Which button index changed
  42857. * @param state New state of the button
  42858. * @param changes Which properties on the state changed since last frame
  42859. */
  42860. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42861. }
  42862. }
  42863. declare module BABYLON {
  42864. /**
  42865. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42866. */
  42867. export class WebXRControllerModelLoader {
  42868. /**
  42869. * Creates the WebXRControllerModelLoader
  42870. * @param input xr input that creates the controllers
  42871. */
  42872. constructor(input: WebXRInput);
  42873. }
  42874. }
  42875. declare module BABYLON {
  42876. /**
  42877. * Contains an array of blocks representing the octree
  42878. */
  42879. export interface IOctreeContainer<T> {
  42880. /**
  42881. * Blocks within the octree
  42882. */
  42883. blocks: Array<OctreeBlock<T>>;
  42884. }
  42885. /**
  42886. * Class used to store a cell in an octree
  42887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42888. */
  42889. export class OctreeBlock<T> {
  42890. /**
  42891. * Gets the content of the current block
  42892. */
  42893. entries: T[];
  42894. /**
  42895. * Gets the list of block children
  42896. */
  42897. blocks: Array<OctreeBlock<T>>;
  42898. private _depth;
  42899. private _maxDepth;
  42900. private _capacity;
  42901. private _minPoint;
  42902. private _maxPoint;
  42903. private _boundingVectors;
  42904. private _creationFunc;
  42905. /**
  42906. * Creates a new block
  42907. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42908. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42909. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42910. * @param depth defines the current depth of this block in the octree
  42911. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42912. * @param creationFunc defines a callback to call when an element is added to the block
  42913. */
  42914. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42915. /**
  42916. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42917. */
  42918. readonly capacity: number;
  42919. /**
  42920. * Gets the minimum vector (in world space) of the block's bounding box
  42921. */
  42922. readonly minPoint: Vector3;
  42923. /**
  42924. * Gets the maximum vector (in world space) of the block's bounding box
  42925. */
  42926. readonly maxPoint: Vector3;
  42927. /**
  42928. * Add a new element to this block
  42929. * @param entry defines the element to add
  42930. */
  42931. addEntry(entry: T): void;
  42932. /**
  42933. * Remove an element from this block
  42934. * @param entry defines the element to remove
  42935. */
  42936. removeEntry(entry: T): void;
  42937. /**
  42938. * Add an array of elements to this block
  42939. * @param entries defines the array of elements to add
  42940. */
  42941. addEntries(entries: T[]): void;
  42942. /**
  42943. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42944. * @param frustumPlanes defines the frustum planes to test
  42945. * @param selection defines the array to store current content if selection is positive
  42946. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42947. */
  42948. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42949. /**
  42950. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42951. * @param sphereCenter defines the bounding sphere center
  42952. * @param sphereRadius defines the bounding sphere radius
  42953. * @param selection defines the array to store current content if selection is positive
  42954. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42955. */
  42956. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42957. /**
  42958. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42959. * @param ray defines the ray to test with
  42960. * @param selection defines the array to store current content if selection is positive
  42961. */
  42962. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42963. /**
  42964. * Subdivide the content into child blocks (this block will then be empty)
  42965. */
  42966. createInnerBlocks(): void;
  42967. /**
  42968. * @hidden
  42969. */
  42970. 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;
  42971. }
  42972. }
  42973. declare module BABYLON {
  42974. /**
  42975. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42976. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42977. */
  42978. export class Octree<T> {
  42979. /** 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.) */
  42980. maxDepth: number;
  42981. /**
  42982. * Blocks within the octree containing objects
  42983. */
  42984. blocks: Array<OctreeBlock<T>>;
  42985. /**
  42986. * Content stored in the octree
  42987. */
  42988. dynamicContent: T[];
  42989. private _maxBlockCapacity;
  42990. private _selectionContent;
  42991. private _creationFunc;
  42992. /**
  42993. * Creates a octree
  42994. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42995. * @param creationFunc function to be used to instatiate the octree
  42996. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42997. * @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.)
  42998. */
  42999. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43000. /** 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.) */
  43001. maxDepth?: number);
  43002. /**
  43003. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43004. * @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);
  43005. * @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);
  43006. * @param entries meshes to be added to the octree blocks
  43007. */
  43008. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43009. /**
  43010. * Adds a mesh to the octree
  43011. * @param entry Mesh to add to the octree
  43012. */
  43013. addMesh(entry: T): void;
  43014. /**
  43015. * Remove an element from the octree
  43016. * @param entry defines the element to remove
  43017. */
  43018. removeMesh(entry: T): void;
  43019. /**
  43020. * Selects an array of meshes within the frustum
  43021. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43022. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43023. * @returns array of meshes within the frustum
  43024. */
  43025. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43026. /**
  43027. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43028. * @param sphereCenter defines the bounding sphere center
  43029. * @param sphereRadius defines the bounding sphere radius
  43030. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43031. * @returns an array of objects that intersect the sphere
  43032. */
  43033. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43034. /**
  43035. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43036. * @param ray defines the ray to test with
  43037. * @returns array of intersected objects
  43038. */
  43039. intersectsRay(ray: Ray): SmartArray<T>;
  43040. /**
  43041. * Adds a mesh into the octree block if it intersects the block
  43042. */
  43043. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43044. /**
  43045. * Adds a submesh into the octree block if it intersects the block
  43046. */
  43047. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43048. }
  43049. }
  43050. declare module BABYLON {
  43051. interface Scene {
  43052. /**
  43053. * @hidden
  43054. * Backing Filed
  43055. */
  43056. _selectionOctree: Octree<AbstractMesh>;
  43057. /**
  43058. * Gets the octree used to boost mesh selection (picking)
  43059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43060. */
  43061. selectionOctree: Octree<AbstractMesh>;
  43062. /**
  43063. * Creates or updates the octree used to boost selection (picking)
  43064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43065. * @param maxCapacity defines the maximum capacity per leaf
  43066. * @param maxDepth defines the maximum depth of the octree
  43067. * @returns an octree of AbstractMesh
  43068. */
  43069. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43070. }
  43071. interface AbstractMesh {
  43072. /**
  43073. * @hidden
  43074. * Backing Field
  43075. */
  43076. _submeshesOctree: Octree<SubMesh>;
  43077. /**
  43078. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43079. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43080. * @param maxCapacity defines the maximum size of each block (64 by default)
  43081. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43082. * @returns the new octree
  43083. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43085. */
  43086. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43087. }
  43088. /**
  43089. * Defines the octree scene component responsible to manage any octrees
  43090. * in a given scene.
  43091. */
  43092. export class OctreeSceneComponent {
  43093. /**
  43094. * The component name help to identify the component in the list of scene components.
  43095. */
  43096. readonly name: string;
  43097. /**
  43098. * The scene the component belongs to.
  43099. */
  43100. scene: Scene;
  43101. /**
  43102. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43103. */
  43104. readonly checksIsEnabled: boolean;
  43105. /**
  43106. * Creates a new instance of the component for the given scene
  43107. * @param scene Defines the scene to register the component in
  43108. */
  43109. constructor(scene: Scene);
  43110. /**
  43111. * Registers the component in a given scene
  43112. */
  43113. register(): void;
  43114. /**
  43115. * Return the list of active meshes
  43116. * @returns the list of active meshes
  43117. */
  43118. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43119. /**
  43120. * Return the list of active sub meshes
  43121. * @param mesh The mesh to get the candidates sub meshes from
  43122. * @returns the list of active sub meshes
  43123. */
  43124. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43125. private _tempRay;
  43126. /**
  43127. * Return the list of sub meshes intersecting with a given local ray
  43128. * @param mesh defines the mesh to find the submesh for
  43129. * @param localRay defines the ray in local space
  43130. * @returns the list of intersecting sub meshes
  43131. */
  43132. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43133. /**
  43134. * Return the list of sub meshes colliding with a collider
  43135. * @param mesh defines the mesh to find the submesh for
  43136. * @param collider defines the collider to evaluate the collision against
  43137. * @returns the list of colliding sub meshes
  43138. */
  43139. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43140. /**
  43141. * Rebuilds the elements related to this component in case of
  43142. * context lost for instance.
  43143. */
  43144. rebuild(): void;
  43145. /**
  43146. * Disposes the component and the associated ressources.
  43147. */
  43148. dispose(): void;
  43149. }
  43150. }
  43151. declare module BABYLON {
  43152. /**
  43153. * Renders a layer on top of an existing scene
  43154. */
  43155. export class UtilityLayerRenderer implements IDisposable {
  43156. /** the original scene that will be rendered on top of */
  43157. originalScene: Scene;
  43158. private _pointerCaptures;
  43159. private _lastPointerEvents;
  43160. private static _DefaultUtilityLayer;
  43161. private static _DefaultKeepDepthUtilityLayer;
  43162. private _sharedGizmoLight;
  43163. private _renderCamera;
  43164. /**
  43165. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43166. * @returns the camera that is used when rendering the utility layer
  43167. */
  43168. getRenderCamera(): Nullable<Camera>;
  43169. /**
  43170. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43171. * @param cam the camera that should be used when rendering the utility layer
  43172. */
  43173. setRenderCamera(cam: Nullable<Camera>): void;
  43174. /**
  43175. * @hidden
  43176. * Light which used by gizmos to get light shading
  43177. */
  43178. _getSharedGizmoLight(): HemisphericLight;
  43179. /**
  43180. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43181. */
  43182. pickUtilitySceneFirst: boolean;
  43183. /**
  43184. * 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)
  43185. */
  43186. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43187. /**
  43188. * 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)
  43189. */
  43190. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43191. /**
  43192. * The scene that is rendered on top of the original scene
  43193. */
  43194. utilityLayerScene: Scene;
  43195. /**
  43196. * If the utility layer should automatically be rendered on top of existing scene
  43197. */
  43198. shouldRender: boolean;
  43199. /**
  43200. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43201. */
  43202. onlyCheckPointerDownEvents: boolean;
  43203. /**
  43204. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43205. */
  43206. processAllEvents: boolean;
  43207. /**
  43208. * Observable raised when the pointer move from the utility layer scene to the main scene
  43209. */
  43210. onPointerOutObservable: Observable<number>;
  43211. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43212. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43213. private _afterRenderObserver;
  43214. private _sceneDisposeObserver;
  43215. private _originalPointerObserver;
  43216. /**
  43217. * Instantiates a UtilityLayerRenderer
  43218. * @param originalScene the original scene that will be rendered on top of
  43219. * @param handleEvents boolean indicating if the utility layer should handle events
  43220. */
  43221. constructor(
  43222. /** the original scene that will be rendered on top of */
  43223. originalScene: Scene, handleEvents?: boolean);
  43224. private _notifyObservers;
  43225. /**
  43226. * Renders the utility layers scene on top of the original scene
  43227. */
  43228. render(): void;
  43229. /**
  43230. * Disposes of the renderer
  43231. */
  43232. dispose(): void;
  43233. private _updateCamera;
  43234. }
  43235. }
  43236. declare module BABYLON {
  43237. /**
  43238. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43239. */
  43240. export class Gizmo implements IDisposable {
  43241. /** The utility layer the gizmo will be added to */
  43242. gizmoLayer: UtilityLayerRenderer;
  43243. /**
  43244. * The root mesh of the gizmo
  43245. */
  43246. _rootMesh: Mesh;
  43247. private _attachedMesh;
  43248. /**
  43249. * Ratio for the scale of the gizmo (Default: 1)
  43250. */
  43251. scaleRatio: number;
  43252. /**
  43253. * If a custom mesh has been set (Default: false)
  43254. */
  43255. protected _customMeshSet: boolean;
  43256. /**
  43257. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43258. * * When set, interactions will be enabled
  43259. */
  43260. attachedMesh: Nullable<AbstractMesh>;
  43261. /**
  43262. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43263. * @param mesh The mesh to replace the default mesh of the gizmo
  43264. */
  43265. setCustomMesh(mesh: Mesh): void;
  43266. /**
  43267. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43268. */
  43269. updateGizmoRotationToMatchAttachedMesh: boolean;
  43270. /**
  43271. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43272. */
  43273. updateGizmoPositionToMatchAttachedMesh: boolean;
  43274. /**
  43275. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43276. */
  43277. updateScale: boolean;
  43278. protected _interactionsEnabled: boolean;
  43279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43280. private _beforeRenderObserver;
  43281. private _tempVector;
  43282. /**
  43283. * Creates a gizmo
  43284. * @param gizmoLayer The utility layer the gizmo will be added to
  43285. */
  43286. constructor(
  43287. /** The utility layer the gizmo will be added to */
  43288. gizmoLayer?: UtilityLayerRenderer);
  43289. /**
  43290. * Updates the gizmo to match the attached mesh's position/rotation
  43291. */
  43292. protected _update(): void;
  43293. /**
  43294. * Disposes of the gizmo
  43295. */
  43296. dispose(): void;
  43297. }
  43298. }
  43299. declare module BABYLON {
  43300. /**
  43301. * Single plane drag gizmo
  43302. */
  43303. export class PlaneDragGizmo extends Gizmo {
  43304. /**
  43305. * Drag behavior responsible for the gizmos dragging interactions
  43306. */
  43307. dragBehavior: PointerDragBehavior;
  43308. private _pointerObserver;
  43309. /**
  43310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43311. */
  43312. snapDistance: number;
  43313. /**
  43314. * Event that fires each time the gizmo snaps to a new location.
  43315. * * snapDistance is the the change in distance
  43316. */
  43317. onSnapObservable: Observable<{
  43318. snapDistance: number;
  43319. }>;
  43320. private _plane;
  43321. private _coloredMaterial;
  43322. private _hoverMaterial;
  43323. private _isEnabled;
  43324. private _parent;
  43325. /** @hidden */
  43326. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43327. /** @hidden */
  43328. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43329. /**
  43330. * Creates a PlaneDragGizmo
  43331. * @param gizmoLayer The utility layer the gizmo will be added to
  43332. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43333. * @param color The color of the gizmo
  43334. */
  43335. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43336. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43337. /**
  43338. * If the gizmo is enabled
  43339. */
  43340. isEnabled: boolean;
  43341. /**
  43342. * Disposes of the gizmo
  43343. */
  43344. dispose(): void;
  43345. }
  43346. }
  43347. declare module BABYLON {
  43348. /**
  43349. * Gizmo that enables dragging a mesh along 3 axis
  43350. */
  43351. export class PositionGizmo extends Gizmo {
  43352. /**
  43353. * Internal gizmo used for interactions on the x axis
  43354. */
  43355. xGizmo: AxisDragGizmo;
  43356. /**
  43357. * Internal gizmo used for interactions on the y axis
  43358. */
  43359. yGizmo: AxisDragGizmo;
  43360. /**
  43361. * Internal gizmo used for interactions on the z axis
  43362. */
  43363. zGizmo: AxisDragGizmo;
  43364. /**
  43365. * Internal gizmo used for interactions on the yz plane
  43366. */
  43367. xPlaneGizmo: PlaneDragGizmo;
  43368. /**
  43369. * Internal gizmo used for interactions on the xz plane
  43370. */
  43371. yPlaneGizmo: PlaneDragGizmo;
  43372. /**
  43373. * Internal gizmo used for interactions on the xy plane
  43374. */
  43375. zPlaneGizmo: PlaneDragGizmo;
  43376. /**
  43377. * private variables
  43378. */
  43379. private _meshAttached;
  43380. private _updateGizmoRotationToMatchAttachedMesh;
  43381. private _snapDistance;
  43382. private _scaleRatio;
  43383. /** Fires an event when any of it's sub gizmos are dragged */
  43384. onDragStartObservable: Observable<unknown>;
  43385. /** Fires an event when any of it's sub gizmos are released from dragging */
  43386. onDragEndObservable: Observable<unknown>;
  43387. /**
  43388. * If set to true, planar drag is enabled
  43389. */
  43390. private _planarGizmoEnabled;
  43391. attachedMesh: Nullable<AbstractMesh>;
  43392. /**
  43393. * Creates a PositionGizmo
  43394. * @param gizmoLayer The utility layer the gizmo will be added to
  43395. */
  43396. constructor(gizmoLayer?: UtilityLayerRenderer);
  43397. /**
  43398. * If the planar drag gizmo is enabled
  43399. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43400. */
  43401. planarGizmoEnabled: boolean;
  43402. updateGizmoRotationToMatchAttachedMesh: boolean;
  43403. /**
  43404. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43405. */
  43406. snapDistance: number;
  43407. /**
  43408. * Ratio for the scale of the gizmo (Default: 1)
  43409. */
  43410. scaleRatio: number;
  43411. /**
  43412. * Disposes of the gizmo
  43413. */
  43414. dispose(): void;
  43415. /**
  43416. * CustomMeshes are not supported by this gizmo
  43417. * @param mesh The mesh to replace the default mesh of the gizmo
  43418. */
  43419. setCustomMesh(mesh: Mesh): void;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * Single axis drag gizmo
  43425. */
  43426. export class AxisDragGizmo extends Gizmo {
  43427. /**
  43428. * Drag behavior responsible for the gizmos dragging interactions
  43429. */
  43430. dragBehavior: PointerDragBehavior;
  43431. private _pointerObserver;
  43432. /**
  43433. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43434. */
  43435. snapDistance: number;
  43436. /**
  43437. * Event that fires each time the gizmo snaps to a new location.
  43438. * * snapDistance is the the change in distance
  43439. */
  43440. onSnapObservable: Observable<{
  43441. snapDistance: number;
  43442. }>;
  43443. private _isEnabled;
  43444. private _parent;
  43445. private _arrow;
  43446. private _coloredMaterial;
  43447. private _hoverMaterial;
  43448. /** @hidden */
  43449. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43450. /** @hidden */
  43451. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43452. /**
  43453. * Creates an AxisDragGizmo
  43454. * @param gizmoLayer The utility layer the gizmo will be added to
  43455. * @param dragAxis The axis which the gizmo will be able to drag on
  43456. * @param color The color of the gizmo
  43457. */
  43458. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43459. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43460. /**
  43461. * If the gizmo is enabled
  43462. */
  43463. isEnabled: boolean;
  43464. /**
  43465. * Disposes of the gizmo
  43466. */
  43467. dispose(): void;
  43468. }
  43469. }
  43470. declare module BABYLON.Debug {
  43471. /**
  43472. * The Axes viewer will show 3 axes in a specific point in space
  43473. */
  43474. export class AxesViewer {
  43475. private _xAxis;
  43476. private _yAxis;
  43477. private _zAxis;
  43478. private _scaleLinesFactor;
  43479. private _instanced;
  43480. /**
  43481. * Gets the hosting scene
  43482. */
  43483. scene: Scene;
  43484. /**
  43485. * Gets or sets a number used to scale line length
  43486. */
  43487. scaleLines: number;
  43488. /** Gets the node hierarchy used to render x-axis */
  43489. readonly xAxis: TransformNode;
  43490. /** Gets the node hierarchy used to render y-axis */
  43491. readonly yAxis: TransformNode;
  43492. /** Gets the node hierarchy used to render z-axis */
  43493. readonly zAxis: TransformNode;
  43494. /**
  43495. * Creates a new AxesViewer
  43496. * @param scene defines the hosting scene
  43497. * @param scaleLines defines a number used to scale line length (1 by default)
  43498. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43499. * @param xAxis defines the node hierarchy used to render the x-axis
  43500. * @param yAxis defines the node hierarchy used to render the y-axis
  43501. * @param zAxis defines the node hierarchy used to render the z-axis
  43502. */
  43503. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43504. /**
  43505. * Force the viewer to update
  43506. * @param position defines the position of the viewer
  43507. * @param xaxis defines the x axis of the viewer
  43508. * @param yaxis defines the y axis of the viewer
  43509. * @param zaxis defines the z axis of the viewer
  43510. */
  43511. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43512. /**
  43513. * Creates an instance of this axes viewer.
  43514. * @returns a new axes viewer with instanced meshes
  43515. */
  43516. createInstance(): AxesViewer;
  43517. /** Releases resources */
  43518. dispose(): void;
  43519. private static _SetRenderingGroupId;
  43520. }
  43521. }
  43522. declare module BABYLON.Debug {
  43523. /**
  43524. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43525. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43526. */
  43527. export class BoneAxesViewer extends AxesViewer {
  43528. /**
  43529. * Gets or sets the target mesh where to display the axes viewer
  43530. */
  43531. mesh: Nullable<Mesh>;
  43532. /**
  43533. * Gets or sets the target bone where to display the axes viewer
  43534. */
  43535. bone: Nullable<Bone>;
  43536. /** Gets current position */
  43537. pos: Vector3;
  43538. /** Gets direction of X axis */
  43539. xaxis: Vector3;
  43540. /** Gets direction of Y axis */
  43541. yaxis: Vector3;
  43542. /** Gets direction of Z axis */
  43543. zaxis: Vector3;
  43544. /**
  43545. * Creates a new BoneAxesViewer
  43546. * @param scene defines the hosting scene
  43547. * @param bone defines the target bone
  43548. * @param mesh defines the target mesh
  43549. * @param scaleLines defines a scaling factor for line length (1 by default)
  43550. */
  43551. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43552. /**
  43553. * Force the viewer to update
  43554. */
  43555. update(): void;
  43556. /** Releases resources */
  43557. dispose(): void;
  43558. }
  43559. }
  43560. declare module BABYLON {
  43561. /**
  43562. * Interface used to define scene explorer extensibility option
  43563. */
  43564. export interface IExplorerExtensibilityOption {
  43565. /**
  43566. * Define the option label
  43567. */
  43568. label: string;
  43569. /**
  43570. * Defines the action to execute on click
  43571. */
  43572. action: (entity: any) => void;
  43573. }
  43574. /**
  43575. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43576. */
  43577. export interface IExplorerExtensibilityGroup {
  43578. /**
  43579. * Defines a predicate to test if a given type mut be extended
  43580. */
  43581. predicate: (entity: any) => boolean;
  43582. /**
  43583. * Gets the list of options added to a type
  43584. */
  43585. entries: IExplorerExtensibilityOption[];
  43586. }
  43587. /**
  43588. * Interface used to define the options to use to create the Inspector
  43589. */
  43590. export interface IInspectorOptions {
  43591. /**
  43592. * Display in overlay mode (default: false)
  43593. */
  43594. overlay?: boolean;
  43595. /**
  43596. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43597. */
  43598. globalRoot?: HTMLElement;
  43599. /**
  43600. * Display the Scene explorer
  43601. */
  43602. showExplorer?: boolean;
  43603. /**
  43604. * Display the property inspector
  43605. */
  43606. showInspector?: boolean;
  43607. /**
  43608. * Display in embed mode (both panes on the right)
  43609. */
  43610. embedMode?: boolean;
  43611. /**
  43612. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43613. */
  43614. handleResize?: boolean;
  43615. /**
  43616. * Allow the panes to popup (default: true)
  43617. */
  43618. enablePopup?: boolean;
  43619. /**
  43620. * Allow the panes to be closed by users (default: true)
  43621. */
  43622. enableClose?: boolean;
  43623. /**
  43624. * Optional list of extensibility entries
  43625. */
  43626. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43627. /**
  43628. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43629. */
  43630. inspectorURL?: string;
  43631. }
  43632. interface Scene {
  43633. /**
  43634. * @hidden
  43635. * Backing field
  43636. */
  43637. _debugLayer: DebugLayer;
  43638. /**
  43639. * Gets the debug layer (aka Inspector) associated with the scene
  43640. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43641. */
  43642. debugLayer: DebugLayer;
  43643. }
  43644. /**
  43645. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43646. * what is happening in your scene
  43647. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43648. */
  43649. export class DebugLayer {
  43650. /**
  43651. * Define the url to get the inspector script from.
  43652. * By default it uses the babylonjs CDN.
  43653. * @ignoreNaming
  43654. */
  43655. static InspectorURL: string;
  43656. private _scene;
  43657. private BJSINSPECTOR;
  43658. private _onPropertyChangedObservable?;
  43659. /**
  43660. * Observable triggered when a property is changed through the inspector.
  43661. */
  43662. readonly onPropertyChangedObservable: any;
  43663. /**
  43664. * Instantiates a new debug layer.
  43665. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43666. * what is happening in your scene
  43667. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43668. * @param scene Defines the scene to inspect
  43669. */
  43670. constructor(scene: Scene);
  43671. /** Creates the inspector window. */
  43672. private _createInspector;
  43673. /**
  43674. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43675. * @param entity defines the entity to select
  43676. * @param lineContainerTitle defines the specific block to highlight
  43677. */
  43678. select(entity: any, lineContainerTitle?: string): void;
  43679. /** Get the inspector from bundle or global */
  43680. private _getGlobalInspector;
  43681. /**
  43682. * Get if the inspector is visible or not.
  43683. * @returns true if visible otherwise, false
  43684. */
  43685. isVisible(): boolean;
  43686. /**
  43687. * Hide the inspector and close its window.
  43688. */
  43689. hide(): void;
  43690. /**
  43691. * Launch the debugLayer.
  43692. * @param config Define the configuration of the inspector
  43693. * @return a promise fulfilled when the debug layer is visible
  43694. */
  43695. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43696. }
  43697. }
  43698. declare module BABYLON {
  43699. /**
  43700. * Class containing static functions to help procedurally build meshes
  43701. */
  43702. export class BoxBuilder {
  43703. /**
  43704. * Creates a box mesh
  43705. * * The parameter `size` sets the size (float) of each box side (default 1)
  43706. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43707. * * 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)
  43708. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43710. * * 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
  43711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43712. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43713. * @param name defines the name of the mesh
  43714. * @param options defines the options used to create the mesh
  43715. * @param scene defines the hosting scene
  43716. * @returns the box mesh
  43717. */
  43718. static CreateBox(name: string, options: {
  43719. size?: number;
  43720. width?: number;
  43721. height?: number;
  43722. depth?: number;
  43723. faceUV?: Vector4[];
  43724. faceColors?: Color4[];
  43725. sideOrientation?: number;
  43726. frontUVs?: Vector4;
  43727. backUVs?: Vector4;
  43728. wrap?: boolean;
  43729. topBaseAt?: number;
  43730. bottomBaseAt?: number;
  43731. updatable?: boolean;
  43732. }, scene?: Nullable<Scene>): Mesh;
  43733. }
  43734. }
  43735. declare module BABYLON {
  43736. /**
  43737. * Class containing static functions to help procedurally build meshes
  43738. */
  43739. export class SphereBuilder {
  43740. /**
  43741. * Creates a sphere mesh
  43742. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43743. * * 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`)
  43744. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43745. * * 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
  43746. * * 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)
  43747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43748. * * 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
  43749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43750. * @param name defines the name of the mesh
  43751. * @param options defines the options used to create the mesh
  43752. * @param scene defines the hosting scene
  43753. * @returns the sphere mesh
  43754. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43755. */
  43756. static CreateSphere(name: string, options: {
  43757. segments?: number;
  43758. diameter?: number;
  43759. diameterX?: number;
  43760. diameterY?: number;
  43761. diameterZ?: number;
  43762. arc?: number;
  43763. slice?: number;
  43764. sideOrientation?: number;
  43765. frontUVs?: Vector4;
  43766. backUVs?: Vector4;
  43767. updatable?: boolean;
  43768. }, scene?: Nullable<Scene>): Mesh;
  43769. }
  43770. }
  43771. declare module BABYLON.Debug {
  43772. /**
  43773. * Used to show the physics impostor around the specific mesh
  43774. */
  43775. export class PhysicsViewer {
  43776. /** @hidden */
  43777. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43778. /** @hidden */
  43779. protected _meshes: Array<Nullable<AbstractMesh>>;
  43780. /** @hidden */
  43781. protected _scene: Nullable<Scene>;
  43782. /** @hidden */
  43783. protected _numMeshes: number;
  43784. /** @hidden */
  43785. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43786. private _renderFunction;
  43787. private _utilityLayer;
  43788. private _debugBoxMesh;
  43789. private _debugSphereMesh;
  43790. private _debugCylinderMesh;
  43791. private _debugMaterial;
  43792. private _debugMeshMeshes;
  43793. /**
  43794. * Creates a new PhysicsViewer
  43795. * @param scene defines the hosting scene
  43796. */
  43797. constructor(scene: Scene);
  43798. /** @hidden */
  43799. protected _updateDebugMeshes(): void;
  43800. /**
  43801. * Renders a specified physic impostor
  43802. * @param impostor defines the impostor to render
  43803. * @param targetMesh defines the mesh represented by the impostor
  43804. * @returns the new debug mesh used to render the impostor
  43805. */
  43806. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43807. /**
  43808. * Hides a specified physic impostor
  43809. * @param impostor defines the impostor to hide
  43810. */
  43811. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43812. private _getDebugMaterial;
  43813. private _getDebugBoxMesh;
  43814. private _getDebugSphereMesh;
  43815. private _getDebugCylinderMesh;
  43816. private _getDebugMeshMesh;
  43817. private _getDebugMesh;
  43818. /** Releases all resources */
  43819. dispose(): void;
  43820. }
  43821. }
  43822. declare module BABYLON {
  43823. /**
  43824. * Class containing static functions to help procedurally build meshes
  43825. */
  43826. export class LinesBuilder {
  43827. /**
  43828. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43829. * * 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
  43830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43831. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43832. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43833. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43834. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43835. * * 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
  43836. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43839. * @param name defines the name of the new line system
  43840. * @param options defines the options used to create the line system
  43841. * @param scene defines the hosting scene
  43842. * @returns a new line system mesh
  43843. */
  43844. static CreateLineSystem(name: string, options: {
  43845. lines: Vector3[][];
  43846. updatable?: boolean;
  43847. instance?: Nullable<LinesMesh>;
  43848. colors?: Nullable<Color4[][]>;
  43849. useVertexAlpha?: boolean;
  43850. }, scene: Nullable<Scene>): LinesMesh;
  43851. /**
  43852. * Creates a line mesh
  43853. * 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
  43854. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43855. * * The parameter `points` is an array successive Vector3
  43856. * * 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
  43857. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43858. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43859. * * When updating an instance, remember that only point positions can change, not the number of points
  43860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43862. * @param name defines the name of the new line system
  43863. * @param options defines the options used to create the line system
  43864. * @param scene defines the hosting scene
  43865. * @returns a new line mesh
  43866. */
  43867. static CreateLines(name: string, options: {
  43868. points: Vector3[];
  43869. updatable?: boolean;
  43870. instance?: Nullable<LinesMesh>;
  43871. colors?: Color4[];
  43872. useVertexAlpha?: boolean;
  43873. }, scene?: Nullable<Scene>): LinesMesh;
  43874. /**
  43875. * Creates a dashed line mesh
  43876. * * 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
  43877. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43878. * * The parameter `points` is an array successive Vector3
  43879. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43880. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43881. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43882. * * 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
  43883. * * When updating an instance, remember that only point positions can change, not the number of points
  43884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43885. * @param name defines the name of the mesh
  43886. * @param options defines the options used to create the mesh
  43887. * @param scene defines the hosting scene
  43888. * @returns the dashed line mesh
  43889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43890. */
  43891. static CreateDashedLines(name: string, options: {
  43892. points: Vector3[];
  43893. dashSize?: number;
  43894. gapSize?: number;
  43895. dashNb?: number;
  43896. updatable?: boolean;
  43897. instance?: LinesMesh;
  43898. }, scene?: Nullable<Scene>): LinesMesh;
  43899. }
  43900. }
  43901. declare module BABYLON {
  43902. /**
  43903. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43904. * in order to better appreciate the issue one might have.
  43905. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43906. */
  43907. export class RayHelper {
  43908. /**
  43909. * Defines the ray we are currently tryin to visualize.
  43910. */
  43911. ray: Nullable<Ray>;
  43912. private _renderPoints;
  43913. private _renderLine;
  43914. private _renderFunction;
  43915. private _scene;
  43916. private _updateToMeshFunction;
  43917. private _attachedToMesh;
  43918. private _meshSpaceDirection;
  43919. private _meshSpaceOrigin;
  43920. /**
  43921. * Helper function to create a colored helper in a scene in one line.
  43922. * @param ray Defines the ray we are currently tryin to visualize
  43923. * @param scene Defines the scene the ray is used in
  43924. * @param color Defines the color we want to see the ray in
  43925. * @returns The newly created ray helper.
  43926. */
  43927. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43928. /**
  43929. * Instantiate a new ray helper.
  43930. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43931. * in order to better appreciate the issue one might have.
  43932. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43933. * @param ray Defines the ray we are currently tryin to visualize
  43934. */
  43935. constructor(ray: Ray);
  43936. /**
  43937. * Shows the ray we are willing to debug.
  43938. * @param scene Defines the scene the ray needs to be rendered in
  43939. * @param color Defines the color the ray needs to be rendered in
  43940. */
  43941. show(scene: Scene, color?: Color3): void;
  43942. /**
  43943. * Hides the ray we are debugging.
  43944. */
  43945. hide(): void;
  43946. private _render;
  43947. /**
  43948. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43949. * @param mesh Defines the mesh we want the helper attached to
  43950. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43951. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43952. * @param length Defines the length of the ray
  43953. */
  43954. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43955. /**
  43956. * Detach the ray helper from the mesh it has previously been attached to.
  43957. */
  43958. detachFromMesh(): void;
  43959. private _updateToMesh;
  43960. /**
  43961. * Dispose the helper and release its associated resources.
  43962. */
  43963. dispose(): void;
  43964. }
  43965. }
  43966. declare module BABYLON.Debug {
  43967. /**
  43968. * Class used to render a debug view of a given skeleton
  43969. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43970. */
  43971. export class SkeletonViewer {
  43972. /** defines the skeleton to render */
  43973. skeleton: Skeleton;
  43974. /** defines the mesh attached to the skeleton */
  43975. mesh: AbstractMesh;
  43976. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43977. autoUpdateBonesMatrices: boolean;
  43978. /** defines the rendering group id to use with the viewer */
  43979. renderingGroupId: number;
  43980. /** Gets or sets the color used to render the skeleton */
  43981. color: Color3;
  43982. private _scene;
  43983. private _debugLines;
  43984. private _debugMesh;
  43985. private _isEnabled;
  43986. private _renderFunction;
  43987. private _utilityLayer;
  43988. /**
  43989. * Returns the mesh used to render the bones
  43990. */
  43991. readonly debugMesh: Nullable<LinesMesh>;
  43992. /**
  43993. * Creates a new SkeletonViewer
  43994. * @param skeleton defines the skeleton to render
  43995. * @param mesh defines the mesh attached to the skeleton
  43996. * @param scene defines the hosting scene
  43997. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43998. * @param renderingGroupId defines the rendering group id to use with the viewer
  43999. */
  44000. constructor(
  44001. /** defines the skeleton to render */
  44002. skeleton: Skeleton,
  44003. /** defines the mesh attached to the skeleton */
  44004. mesh: AbstractMesh, scene: Scene,
  44005. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44006. autoUpdateBonesMatrices?: boolean,
  44007. /** defines the rendering group id to use with the viewer */
  44008. renderingGroupId?: number);
  44009. /** Gets or sets a boolean indicating if the viewer is enabled */
  44010. isEnabled: boolean;
  44011. private _getBonePosition;
  44012. private _getLinesForBonesWithLength;
  44013. private _getLinesForBonesNoLength;
  44014. /** Update the viewer to sync with current skeleton state */
  44015. update(): void;
  44016. /** Release associated resources */
  44017. dispose(): void;
  44018. }
  44019. }
  44020. declare module BABYLON {
  44021. /**
  44022. * Options to create the null engine
  44023. */
  44024. export class NullEngineOptions {
  44025. /**
  44026. * Render width (Default: 512)
  44027. */
  44028. renderWidth: number;
  44029. /**
  44030. * Render height (Default: 256)
  44031. */
  44032. renderHeight: number;
  44033. /**
  44034. * Texture size (Default: 512)
  44035. */
  44036. textureSize: number;
  44037. /**
  44038. * If delta time between frames should be constant
  44039. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44040. */
  44041. deterministicLockstep: boolean;
  44042. /**
  44043. * Maximum about of steps between frames (Default: 4)
  44044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44045. */
  44046. lockstepMaxSteps: number;
  44047. }
  44048. /**
  44049. * The null engine class provides support for headless version of babylon.js.
  44050. * This can be used in server side scenario or for testing purposes
  44051. */
  44052. export class NullEngine extends Engine {
  44053. private _options;
  44054. /**
  44055. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  44056. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44057. * @returns true if engine is in deterministic lock step mode
  44058. */
  44059. isDeterministicLockStep(): boolean;
  44060. /**
  44061. * Gets the max steps when engine is running in deterministic lock step
  44062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44063. * @returns the max steps
  44064. */
  44065. getLockstepMaxSteps(): number;
  44066. /**
  44067. * Gets the current hardware scaling level.
  44068. * By default the hardware scaling level is computed from the window device ratio.
  44069. * 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.
  44070. * @returns a number indicating the current hardware scaling level
  44071. */
  44072. getHardwareScalingLevel(): number;
  44073. constructor(options?: NullEngineOptions);
  44074. /**
  44075. * Creates a vertex buffer
  44076. * @param vertices the data for the vertex buffer
  44077. * @returns the new WebGL static buffer
  44078. */
  44079. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44080. /**
  44081. * Creates a new index buffer
  44082. * @param indices defines the content of the index buffer
  44083. * @param updatable defines if the index buffer must be updatable
  44084. * @returns a new webGL buffer
  44085. */
  44086. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44087. /**
  44088. * Clear the current render buffer or the current render target (if any is set up)
  44089. * @param color defines the color to use
  44090. * @param backBuffer defines if the back buffer must be cleared
  44091. * @param depth defines if the depth buffer must be cleared
  44092. * @param stencil defines if the stencil buffer must be cleared
  44093. */
  44094. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44095. /**
  44096. * Gets the current render width
  44097. * @param useScreen defines if screen size must be used (or the current render target if any)
  44098. * @returns a number defining the current render width
  44099. */
  44100. getRenderWidth(useScreen?: boolean): number;
  44101. /**
  44102. * Gets the current render height
  44103. * @param useScreen defines if screen size must be used (or the current render target if any)
  44104. * @returns a number defining the current render height
  44105. */
  44106. getRenderHeight(useScreen?: boolean): number;
  44107. /**
  44108. * Set the WebGL's viewport
  44109. * @param viewport defines the viewport element to be used
  44110. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  44111. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  44112. */
  44113. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44114. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44115. /**
  44116. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  44117. * @param pipelineContext defines the pipeline context to use
  44118. * @param uniformsNames defines the list of uniform names
  44119. * @returns an array of webGL uniform locations
  44120. */
  44121. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44122. /**
  44123. * Gets the lsit of active attributes for a given webGL program
  44124. * @param pipelineContext defines the pipeline context to use
  44125. * @param attributesNames defines the list of attribute names to get
  44126. * @returns an array of indices indicating the offset of each attribute
  44127. */
  44128. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44129. /**
  44130. * Binds an effect to the webGL context
  44131. * @param effect defines the effect to bind
  44132. */
  44133. bindSamplers(effect: Effect): void;
  44134. /**
  44135. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  44136. * @param effect defines the effect to activate
  44137. */
  44138. enableEffect(effect: Effect): void;
  44139. /**
  44140. * Set various states to the webGL context
  44141. * @param culling defines backface culling state
  44142. * @param zOffset defines the value to apply to zOffset (0 by default)
  44143. * @param force defines if states must be applied even if cache is up to date
  44144. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44145. */
  44146. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44147. /**
  44148. * Set the value of an uniform to an array of int32
  44149. * @param uniform defines the webGL uniform location where to store the value
  44150. * @param array defines the array of int32 to store
  44151. */
  44152. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44153. /**
  44154. * Set the value of an uniform to an array of int32 (stored as vec2)
  44155. * @param uniform defines the webGL uniform location where to store the value
  44156. * @param array defines the array of int32 to store
  44157. */
  44158. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44159. /**
  44160. * Set the value of an uniform to an array of int32 (stored as vec3)
  44161. * @param uniform defines the webGL uniform location where to store the value
  44162. * @param array defines the array of int32 to store
  44163. */
  44164. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44165. /**
  44166. * Set the value of an uniform to an array of int32 (stored as vec4)
  44167. * @param uniform defines the webGL uniform location where to store the value
  44168. * @param array defines the array of int32 to store
  44169. */
  44170. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44171. /**
  44172. * Set the value of an uniform to an array of float32
  44173. * @param uniform defines the webGL uniform location where to store the value
  44174. * @param array defines the array of float32 to store
  44175. */
  44176. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44177. /**
  44178. * Set the value of an uniform to an array of float32 (stored as vec2)
  44179. * @param uniform defines the webGL uniform location where to store the value
  44180. * @param array defines the array of float32 to store
  44181. */
  44182. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44183. /**
  44184. * Set the value of an uniform to an array of float32 (stored as vec3)
  44185. * @param uniform defines the webGL uniform location where to store the value
  44186. * @param array defines the array of float32 to store
  44187. */
  44188. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44189. /**
  44190. * Set the value of an uniform to an array of float32 (stored as vec4)
  44191. * @param uniform defines the webGL uniform location where to store the value
  44192. * @param array defines the array of float32 to store
  44193. */
  44194. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44195. /**
  44196. * Set the value of an uniform to an array of number
  44197. * @param uniform defines the webGL uniform location where to store the value
  44198. * @param array defines the array of number to store
  44199. */
  44200. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44201. /**
  44202. * Set the value of an uniform to an array of number (stored as vec2)
  44203. * @param uniform defines the webGL uniform location where to store the value
  44204. * @param array defines the array of number to store
  44205. */
  44206. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44207. /**
  44208. * Set the value of an uniform to an array of number (stored as vec3)
  44209. * @param uniform defines the webGL uniform location where to store the value
  44210. * @param array defines the array of number to store
  44211. */
  44212. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44213. /**
  44214. * Set the value of an uniform to an array of number (stored as vec4)
  44215. * @param uniform defines the webGL uniform location where to store the value
  44216. * @param array defines the array of number to store
  44217. */
  44218. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44219. /**
  44220. * Set the value of an uniform to an array of float32 (stored as matrices)
  44221. * @param uniform defines the webGL uniform location where to store the value
  44222. * @param matrices defines the array of float32 to store
  44223. */
  44224. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44225. /**
  44226. * Set the value of an uniform to a matrix (3x3)
  44227. * @param uniform defines the webGL uniform location where to store the value
  44228. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  44229. */
  44230. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44231. /**
  44232. * Set the value of an uniform to a matrix (2x2)
  44233. * @param uniform defines the webGL uniform location where to store the value
  44234. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  44235. */
  44236. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44237. /**
  44238. * Set the value of an uniform to a number (float)
  44239. * @param uniform defines the webGL uniform location where to store the value
  44240. * @param value defines the float number to store
  44241. */
  44242. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44243. /**
  44244. * Set the value of an uniform to a vec2
  44245. * @param uniform defines the webGL uniform location where to store the value
  44246. * @param x defines the 1st component of the value
  44247. * @param y defines the 2nd component of the value
  44248. */
  44249. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44250. /**
  44251. * Set the value of an uniform to a vec3
  44252. * @param uniform defines the webGL uniform location where to store the value
  44253. * @param x defines the 1st component of the value
  44254. * @param y defines the 2nd component of the value
  44255. * @param z defines the 3rd component of the value
  44256. */
  44257. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44258. /**
  44259. * Set the value of an uniform to a boolean
  44260. * @param uniform defines the webGL uniform location where to store the value
  44261. * @param bool defines the boolean to store
  44262. */
  44263. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44264. /**
  44265. * Set the value of an uniform to a vec4
  44266. * @param uniform defines the webGL uniform location where to store the value
  44267. * @param x defines the 1st component of the value
  44268. * @param y defines the 2nd component of the value
  44269. * @param z defines the 3rd component of the value
  44270. * @param w defines the 4th component of the value
  44271. */
  44272. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44273. /**
  44274. * Sets the current alpha mode
  44275. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44276. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44278. */
  44279. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44280. /**
  44281. * Bind webGl buffers directly to the webGL context
  44282. * @param vertexBuffers defines the vertex buffer to bind
  44283. * @param indexBuffer defines the index buffer to bind
  44284. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  44285. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  44286. * @param effect defines the effect associated with the vertex buffer
  44287. */
  44288. bindBuffers(vertexBuffers: {
  44289. [key: string]: VertexBuffer;
  44290. }, indexBuffer: DataBuffer, effect: Effect): void;
  44291. /**
  44292. * Force the entire cache to be cleared
  44293. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44294. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44295. */
  44296. wipeCaches(bruteForce?: boolean): void;
  44297. /**
  44298. * Send a draw order
  44299. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44300. * @param indexStart defines the starting index
  44301. * @param indexCount defines the number of index to draw
  44302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44303. */
  44304. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44305. /**
  44306. * Draw a list of indexed primitives
  44307. * @param fillMode defines the primitive to use
  44308. * @param indexStart defines the starting index
  44309. * @param indexCount defines the number of index to draw
  44310. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44311. */
  44312. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44313. /**
  44314. * Draw a list of unindexed primitives
  44315. * @param fillMode defines the primitive to use
  44316. * @param verticesStart defines the index of first vertex to draw
  44317. * @param verticesCount defines the count of vertices to draw
  44318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44319. */
  44320. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44321. /** @hidden */
  44322. _createTexture(): WebGLTexture;
  44323. /** @hidden */
  44324. _releaseTexture(texture: InternalTexture): void;
  44325. /**
  44326. * Usually called from Texture.ts.
  44327. * Passed information to create a WebGLTexture
  44328. * @param urlArg defines a value which contains one of the following:
  44329. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44330. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44331. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44332. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44333. * @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)
  44334. * @param scene needed for loading to the correct scene
  44335. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44336. * @param onLoad optional callback to be called upon successful completion
  44337. * @param onError optional callback to be called upon failure
  44338. * @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
  44339. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44340. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44341. * @param forcedExtension defines the extension to use to pick the right loader
  44342. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44343. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44344. */
  44345. 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;
  44346. /**
  44347. * Creates a new render target texture
  44348. * @param size defines the size of the texture
  44349. * @param options defines the options used to create the texture
  44350. * @returns a new render target texture stored in an InternalTexture
  44351. */
  44352. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44353. /**
  44354. * Update the sampling mode of a given texture
  44355. * @param samplingMode defines the required sampling mode
  44356. * @param texture defines the texture to update
  44357. */
  44358. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44359. /**
  44360. * Binds the frame buffer to the specified texture.
  44361. * @param texture The texture to render to or null for the default canvas
  44362. * @param faceIndex The face of the texture to render to in case of cube texture
  44363. * @param requiredWidth The width of the target to render to
  44364. * @param requiredHeight The height of the target to render to
  44365. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44366. * @param depthStencilTexture The depth stencil texture to use to render
  44367. * @param lodLevel defines le lod level to bind to the frame buffer
  44368. */
  44369. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44370. /**
  44371. * Unbind the current render target texture from the webGL context
  44372. * @param texture defines the render target texture to unbind
  44373. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44374. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44375. */
  44376. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44377. /**
  44378. * Creates a dynamic vertex buffer
  44379. * @param vertices the data for the dynamic vertex buffer
  44380. * @returns the new WebGL dynamic buffer
  44381. */
  44382. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44383. /**
  44384. * Update the content of a dynamic texture
  44385. * @param texture defines the texture to update
  44386. * @param canvas defines the canvas containing the source
  44387. * @param invertY defines if data must be stored with Y axis inverted
  44388. * @param premulAlpha defines if alpha is stored as premultiplied
  44389. * @param format defines the format of the data
  44390. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44391. */
  44392. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44393. /**
  44394. * Gets a boolean indicating if all created effects are ready
  44395. * @returns true if all effects are ready
  44396. */
  44397. areAllEffectsReady(): boolean;
  44398. /**
  44399. * @hidden
  44400. * Get the current error code of the webGL context
  44401. * @returns the error code
  44402. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44403. */
  44404. getError(): number;
  44405. /** @hidden */
  44406. _getUnpackAlignement(): number;
  44407. /** @hidden */
  44408. _unpackFlipY(value: boolean): void;
  44409. /**
  44410. * Update a dynamic index buffer
  44411. * @param indexBuffer defines the target index buffer
  44412. * @param indices defines the data to update
  44413. * @param offset defines the offset in the target index buffer where update should start
  44414. */
  44415. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44416. /**
  44417. * Updates a dynamic vertex buffer.
  44418. * @param vertexBuffer the vertex buffer to update
  44419. * @param vertices the data used to update the vertex buffer
  44420. * @param byteOffset the byte offset of the data (optional)
  44421. * @param byteLength the byte length of the data (optional)
  44422. */
  44423. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44424. /** @hidden */
  44425. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44426. /** @hidden */
  44427. _bindTexture(channel: number, texture: InternalTexture): void;
  44428. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44429. /**
  44430. * 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
  44431. */
  44432. releaseEffects(): void;
  44433. displayLoadingUI(): void;
  44434. hideLoadingUI(): void;
  44435. /** @hidden */
  44436. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44437. /** @hidden */
  44438. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44439. /** @hidden */
  44440. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44441. /** @hidden */
  44442. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44443. }
  44444. }
  44445. declare module BABYLON {
  44446. /** @hidden */
  44447. export class _OcclusionDataStorage {
  44448. /** @hidden */
  44449. occlusionInternalRetryCounter: number;
  44450. /** @hidden */
  44451. isOcclusionQueryInProgress: boolean;
  44452. /** @hidden */
  44453. isOccluded: boolean;
  44454. /** @hidden */
  44455. occlusionRetryCount: number;
  44456. /** @hidden */
  44457. occlusionType: number;
  44458. /** @hidden */
  44459. occlusionQueryAlgorithmType: number;
  44460. }
  44461. interface Engine {
  44462. /**
  44463. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44464. * @return the new query
  44465. */
  44466. createQuery(): WebGLQuery;
  44467. /**
  44468. * Delete and release a webGL query
  44469. * @param query defines the query to delete
  44470. * @return the current engine
  44471. */
  44472. deleteQuery(query: WebGLQuery): Engine;
  44473. /**
  44474. * Check if a given query has resolved and got its value
  44475. * @param query defines the query to check
  44476. * @returns true if the query got its value
  44477. */
  44478. isQueryResultAvailable(query: WebGLQuery): boolean;
  44479. /**
  44480. * Gets the value of a given query
  44481. * @param query defines the query to check
  44482. * @returns the value of the query
  44483. */
  44484. getQueryResult(query: WebGLQuery): number;
  44485. /**
  44486. * Initiates an occlusion query
  44487. * @param algorithmType defines the algorithm to use
  44488. * @param query defines the query to use
  44489. * @returns the current engine
  44490. * @see http://doc.babylonjs.com/features/occlusionquery
  44491. */
  44492. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44493. /**
  44494. * Ends an occlusion query
  44495. * @see http://doc.babylonjs.com/features/occlusionquery
  44496. * @param algorithmType defines the algorithm to use
  44497. * @returns the current engine
  44498. */
  44499. endOcclusionQuery(algorithmType: number): Engine;
  44500. /**
  44501. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44502. * Please note that only one query can be issued at a time
  44503. * @returns a time token used to track the time span
  44504. */
  44505. startTimeQuery(): Nullable<_TimeToken>;
  44506. /**
  44507. * Ends a time query
  44508. * @param token defines the token used to measure the time span
  44509. * @returns the time spent (in ns)
  44510. */
  44511. endTimeQuery(token: _TimeToken): int;
  44512. /** @hidden */
  44513. _currentNonTimestampToken: Nullable<_TimeToken>;
  44514. /** @hidden */
  44515. _createTimeQuery(): WebGLQuery;
  44516. /** @hidden */
  44517. _deleteTimeQuery(query: WebGLQuery): void;
  44518. /** @hidden */
  44519. _getGlAlgorithmType(algorithmType: number): number;
  44520. /** @hidden */
  44521. _getTimeQueryResult(query: WebGLQuery): any;
  44522. /** @hidden */
  44523. _getTimeQueryAvailability(query: WebGLQuery): any;
  44524. }
  44525. interface AbstractMesh {
  44526. /**
  44527. * Backing filed
  44528. * @hidden
  44529. */
  44530. __occlusionDataStorage: _OcclusionDataStorage;
  44531. /**
  44532. * Access property
  44533. * @hidden
  44534. */
  44535. _occlusionDataStorage: _OcclusionDataStorage;
  44536. /**
  44537. * 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.
  44538. * The default value is -1 which means don't break the query and wait till the result
  44539. * @see http://doc.babylonjs.com/features/occlusionquery
  44540. */
  44541. occlusionRetryCount: number;
  44542. /**
  44543. * 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:
  44544. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44545. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44546. * * 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.
  44547. * @see http://doc.babylonjs.com/features/occlusionquery
  44548. */
  44549. occlusionType: number;
  44550. /**
  44551. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44552. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44553. * * 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.
  44554. * @see http://doc.babylonjs.com/features/occlusionquery
  44555. */
  44556. occlusionQueryAlgorithmType: number;
  44557. /**
  44558. * 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
  44559. * @see http://doc.babylonjs.com/features/occlusionquery
  44560. */
  44561. isOccluded: boolean;
  44562. /**
  44563. * Flag to check the progress status of the query
  44564. * @see http://doc.babylonjs.com/features/occlusionquery
  44565. */
  44566. isOcclusionQueryInProgress: boolean;
  44567. }
  44568. }
  44569. declare module BABYLON {
  44570. /** @hidden */
  44571. export var _forceTransformFeedbackToBundle: boolean;
  44572. interface Engine {
  44573. /**
  44574. * Creates a webGL transform feedback object
  44575. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44576. * @returns the webGL transform feedback object
  44577. */
  44578. createTransformFeedback(): WebGLTransformFeedback;
  44579. /**
  44580. * Delete a webGL transform feedback object
  44581. * @param value defines the webGL transform feedback object to delete
  44582. */
  44583. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44584. /**
  44585. * Bind a webGL transform feedback object to the webgl context
  44586. * @param value defines the webGL transform feedback object to bind
  44587. */
  44588. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44589. /**
  44590. * Begins a transform feedback operation
  44591. * @param usePoints defines if points or triangles must be used
  44592. */
  44593. beginTransformFeedback(usePoints: boolean): void;
  44594. /**
  44595. * Ends a transform feedback operation
  44596. */
  44597. endTransformFeedback(): void;
  44598. /**
  44599. * Specify the varyings to use with transform feedback
  44600. * @param program defines the associated webGL program
  44601. * @param value defines the list of strings representing the varying names
  44602. */
  44603. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44604. /**
  44605. * Bind a webGL buffer for a transform feedback operation
  44606. * @param value defines the webGL buffer to bind
  44607. */
  44608. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44609. }
  44610. }
  44611. declare module BABYLON {
  44612. /**
  44613. * Creation options of the multi render target texture.
  44614. */
  44615. export interface IMultiRenderTargetOptions {
  44616. /**
  44617. * Define if the texture needs to create mip maps after render.
  44618. */
  44619. generateMipMaps?: boolean;
  44620. /**
  44621. * Define the types of all the draw buffers we want to create
  44622. */
  44623. types?: number[];
  44624. /**
  44625. * Define the sampling modes of all the draw buffers we want to create
  44626. */
  44627. samplingModes?: number[];
  44628. /**
  44629. * Define if a depth buffer is required
  44630. */
  44631. generateDepthBuffer?: boolean;
  44632. /**
  44633. * Define if a stencil buffer is required
  44634. */
  44635. generateStencilBuffer?: boolean;
  44636. /**
  44637. * Define if a depth texture is required instead of a depth buffer
  44638. */
  44639. generateDepthTexture?: boolean;
  44640. /**
  44641. * Define the number of desired draw buffers
  44642. */
  44643. textureCount?: number;
  44644. /**
  44645. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44646. */
  44647. doNotChangeAspectRatio?: boolean;
  44648. /**
  44649. * Define the default type of the buffers we are creating
  44650. */
  44651. defaultType?: number;
  44652. }
  44653. /**
  44654. * A multi render target, like a render target provides the ability to render to a texture.
  44655. * Unlike the render target, it can render to several draw buffers in one draw.
  44656. * This is specially interesting in deferred rendering or for any effects requiring more than
  44657. * just one color from a single pass.
  44658. */
  44659. export class MultiRenderTarget extends RenderTargetTexture {
  44660. private _internalTextures;
  44661. private _textures;
  44662. private _multiRenderTargetOptions;
  44663. /**
  44664. * Get if draw buffers are currently supported by the used hardware and browser.
  44665. */
  44666. readonly isSupported: boolean;
  44667. /**
  44668. * Get the list of textures generated by the multi render target.
  44669. */
  44670. readonly textures: Texture[];
  44671. /**
  44672. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44673. */
  44674. readonly depthTexture: Texture;
  44675. /**
  44676. * Set the wrapping mode on U of all the textures we are rendering to.
  44677. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44678. */
  44679. wrapU: number;
  44680. /**
  44681. * Set the wrapping mode on V of all the textures we are rendering to.
  44682. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44683. */
  44684. wrapV: number;
  44685. /**
  44686. * Instantiate a new multi render target texture.
  44687. * A multi render target, like a render target provides the ability to render to a texture.
  44688. * Unlike the render target, it can render to several draw buffers in one draw.
  44689. * This is specially interesting in deferred rendering or for any effects requiring more than
  44690. * just one color from a single pass.
  44691. * @param name Define the name of the texture
  44692. * @param size Define the size of the buffers to render to
  44693. * @param count Define the number of target we are rendering into
  44694. * @param scene Define the scene the texture belongs to
  44695. * @param options Define the options used to create the multi render target
  44696. */
  44697. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44698. /** @hidden */
  44699. _rebuild(): void;
  44700. private _createInternalTextures;
  44701. private _createTextures;
  44702. /**
  44703. * Define the number of samples used if MSAA is enabled.
  44704. */
  44705. samples: number;
  44706. /**
  44707. * Resize all the textures in the multi render target.
  44708. * Be carrefull as it will recreate all the data in the new texture.
  44709. * @param size Define the new size
  44710. */
  44711. resize(size: any): void;
  44712. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44713. /**
  44714. * Dispose the render targets and their associated resources
  44715. */
  44716. dispose(): void;
  44717. /**
  44718. * Release all the underlying texture used as draw buffers.
  44719. */
  44720. releaseInternalTextures(): void;
  44721. }
  44722. }
  44723. declare module BABYLON {
  44724. interface ThinEngine {
  44725. /**
  44726. * Unbind a list of render target textures from the webGL context
  44727. * This is used only when drawBuffer extension or webGL2 are active
  44728. * @param textures defines the render target textures to unbind
  44729. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44730. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44731. */
  44732. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44733. /**
  44734. * Create a multi render target texture
  44735. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44736. * @param size defines the size of the texture
  44737. * @param options defines the creation options
  44738. * @returns the cube texture as an InternalTexture
  44739. */
  44740. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44741. /**
  44742. * Update the sample count for a given multiple render target texture
  44743. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44744. * @param textures defines the textures to update
  44745. * @param samples defines the sample count to set
  44746. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44747. */
  44748. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44749. }
  44750. }
  44751. declare module BABYLON {
  44752. /**
  44753. * Class used to define an additional view for the engine
  44754. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44755. */
  44756. export class EngineView {
  44757. /** Defines the canvas where to render the view */
  44758. target: HTMLCanvasElement;
  44759. /** Defines an optional camera used to render the view (will use active camera else) */
  44760. camera?: Camera;
  44761. }
  44762. interface Engine {
  44763. /**
  44764. * Gets or sets the HTML element to use for attaching events
  44765. */
  44766. inputElement: Nullable<HTMLElement>;
  44767. /**
  44768. * Gets the current engine view
  44769. * @see https://doc.babylonjs.com/how_to/multi_canvases
  44770. */
  44771. activeView: Nullable<EngineView>;
  44772. /** Gets or sets the list of views */
  44773. views: EngineView[];
  44774. /**
  44775. * Register a new child canvas
  44776. * @param canvas defines the canvas to register
  44777. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  44778. * @returns the associated view
  44779. */
  44780. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  44781. /**
  44782. * Remove a registered child canvas
  44783. * @param canvas defines the canvas to remove
  44784. * @returns the current engine
  44785. */
  44786. unRegisterView(canvas: HTMLCanvasElement): Engine;
  44787. }
  44788. }
  44789. declare module BABYLON {
  44790. /**
  44791. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44792. */
  44793. export interface CubeMapInfo {
  44794. /**
  44795. * The pixel array for the front face.
  44796. * This is stored in format, left to right, up to down format.
  44797. */
  44798. front: Nullable<ArrayBufferView>;
  44799. /**
  44800. * The pixel array for the back face.
  44801. * This is stored in format, left to right, up to down format.
  44802. */
  44803. back: Nullable<ArrayBufferView>;
  44804. /**
  44805. * The pixel array for the left face.
  44806. * This is stored in format, left to right, up to down format.
  44807. */
  44808. left: Nullable<ArrayBufferView>;
  44809. /**
  44810. * The pixel array for the right face.
  44811. * This is stored in format, left to right, up to down format.
  44812. */
  44813. right: Nullable<ArrayBufferView>;
  44814. /**
  44815. * The pixel array for the up face.
  44816. * This is stored in format, left to right, up to down format.
  44817. */
  44818. up: Nullable<ArrayBufferView>;
  44819. /**
  44820. * The pixel array for the down face.
  44821. * This is stored in format, left to right, up to down format.
  44822. */
  44823. down: Nullable<ArrayBufferView>;
  44824. /**
  44825. * The size of the cubemap stored.
  44826. *
  44827. * Each faces will be size * size pixels.
  44828. */
  44829. size: number;
  44830. /**
  44831. * The format of the texture.
  44832. *
  44833. * RGBA, RGB.
  44834. */
  44835. format: number;
  44836. /**
  44837. * The type of the texture data.
  44838. *
  44839. * UNSIGNED_INT, FLOAT.
  44840. */
  44841. type: number;
  44842. /**
  44843. * Specifies whether the texture is in gamma space.
  44844. */
  44845. gammaSpace: boolean;
  44846. }
  44847. /**
  44848. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44849. */
  44850. export class PanoramaToCubeMapTools {
  44851. private static FACE_FRONT;
  44852. private static FACE_BACK;
  44853. private static FACE_RIGHT;
  44854. private static FACE_LEFT;
  44855. private static FACE_DOWN;
  44856. private static FACE_UP;
  44857. /**
  44858. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44859. *
  44860. * @param float32Array The source data.
  44861. * @param inputWidth The width of the input panorama.
  44862. * @param inputHeight The height of the input panorama.
  44863. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44864. * @return The cubemap data
  44865. */
  44866. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44867. private static CreateCubemapTexture;
  44868. private static CalcProjectionSpherical;
  44869. }
  44870. }
  44871. declare module BABYLON {
  44872. /**
  44873. * Helper class dealing with the extraction of spherical polynomial dataArray
  44874. * from a cube map.
  44875. */
  44876. export class CubeMapToSphericalPolynomialTools {
  44877. private static FileFaces;
  44878. /**
  44879. * Converts a texture to the according Spherical Polynomial data.
  44880. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44881. *
  44882. * @param texture The texture to extract the information from.
  44883. * @return The Spherical Polynomial data.
  44884. */
  44885. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44886. /**
  44887. * Converts a cubemap to the according Spherical Polynomial data.
  44888. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44889. *
  44890. * @param cubeInfo The Cube map to extract the information from.
  44891. * @return The Spherical Polynomial data.
  44892. */
  44893. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44894. }
  44895. }
  44896. declare module BABYLON {
  44897. interface BaseTexture {
  44898. /**
  44899. * Get the polynomial representation of the texture data.
  44900. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44901. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44902. */
  44903. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export var rgbdEncodePixelShader: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module BABYLON {
  44914. /** @hidden */
  44915. export var rgbdDecodePixelShader: {
  44916. name: string;
  44917. shader: string;
  44918. };
  44919. }
  44920. declare module BABYLON {
  44921. /**
  44922. * Raw texture data and descriptor sufficient for WebGL texture upload
  44923. */
  44924. export interface EnvironmentTextureInfo {
  44925. /**
  44926. * Version of the environment map
  44927. */
  44928. version: number;
  44929. /**
  44930. * Width of image
  44931. */
  44932. width: number;
  44933. /**
  44934. * Irradiance information stored in the file.
  44935. */
  44936. irradiance: any;
  44937. /**
  44938. * Specular information stored in the file.
  44939. */
  44940. specular: any;
  44941. }
  44942. /**
  44943. * Defines One Image in the file. It requires only the position in the file
  44944. * as well as the length.
  44945. */
  44946. interface BufferImageData {
  44947. /**
  44948. * Length of the image data.
  44949. */
  44950. length: number;
  44951. /**
  44952. * Position of the data from the null terminator delimiting the end of the JSON.
  44953. */
  44954. position: number;
  44955. }
  44956. /**
  44957. * Defines the specular data enclosed in the file.
  44958. * This corresponds to the version 1 of the data.
  44959. */
  44960. export interface EnvironmentTextureSpecularInfoV1 {
  44961. /**
  44962. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44963. */
  44964. specularDataPosition?: number;
  44965. /**
  44966. * This contains all the images data needed to reconstruct the cubemap.
  44967. */
  44968. mipmaps: Array<BufferImageData>;
  44969. /**
  44970. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44971. */
  44972. lodGenerationScale: number;
  44973. }
  44974. /**
  44975. * Sets of helpers addressing the serialization and deserialization of environment texture
  44976. * stored in a BabylonJS env file.
  44977. * Those files are usually stored as .env files.
  44978. */
  44979. export class EnvironmentTextureTools {
  44980. /**
  44981. * Magic number identifying the env file.
  44982. */
  44983. private static _MagicBytes;
  44984. /**
  44985. * Gets the environment info from an env file.
  44986. * @param data The array buffer containing the .env bytes.
  44987. * @returns the environment file info (the json header) if successfully parsed.
  44988. */
  44989. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44990. /**
  44991. * Creates an environment texture from a loaded cube texture.
  44992. * @param texture defines the cube texture to convert in env file
  44993. * @return a promise containing the environment data if succesfull.
  44994. */
  44995. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44996. /**
  44997. * Creates a JSON representation of the spherical data.
  44998. * @param texture defines the texture containing the polynomials
  44999. * @return the JSON representation of the spherical info
  45000. */
  45001. private static _CreateEnvTextureIrradiance;
  45002. /**
  45003. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45004. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45005. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45006. * @return the views described by info providing access to the underlying buffer
  45007. */
  45008. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45009. /**
  45010. * Uploads the texture info contained in the env file to the GPU.
  45011. * @param texture defines the internal texture to upload to
  45012. * @param arrayBuffer defines the buffer cotaining the data to load
  45013. * @param info defines the texture info retrieved through the GetEnvInfo method
  45014. * @returns a promise
  45015. */
  45016. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45017. private static _OnImageReadyAsync;
  45018. /**
  45019. * Uploads the levels of image data to the GPU.
  45020. * @param texture defines the internal texture to upload to
  45021. * @param imageData defines the array buffer views of image data [mipmap][face]
  45022. * @returns a promise
  45023. */
  45024. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45025. /**
  45026. * Uploads spherical polynomials information to the texture.
  45027. * @param texture defines the texture we are trying to upload the information to
  45028. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45029. */
  45030. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45031. /** @hidden */
  45032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45033. }
  45034. }
  45035. declare module BABYLON {
  45036. /**
  45037. * Contains position and normal vectors for a vertex
  45038. */
  45039. export class PositionNormalVertex {
  45040. /** the position of the vertex (defaut: 0,0,0) */
  45041. position: Vector3;
  45042. /** the normal of the vertex (defaut: 0,1,0) */
  45043. normal: Vector3;
  45044. /**
  45045. * Creates a PositionNormalVertex
  45046. * @param position the position of the vertex (defaut: 0,0,0)
  45047. * @param normal the normal of the vertex (defaut: 0,1,0)
  45048. */
  45049. constructor(
  45050. /** the position of the vertex (defaut: 0,0,0) */
  45051. position?: Vector3,
  45052. /** the normal of the vertex (defaut: 0,1,0) */
  45053. normal?: Vector3);
  45054. /**
  45055. * Clones the PositionNormalVertex
  45056. * @returns the cloned PositionNormalVertex
  45057. */
  45058. clone(): PositionNormalVertex;
  45059. }
  45060. /**
  45061. * Contains position, normal and uv vectors for a vertex
  45062. */
  45063. export class PositionNormalTextureVertex {
  45064. /** the position of the vertex (defaut: 0,0,0) */
  45065. position: Vector3;
  45066. /** the normal of the vertex (defaut: 0,1,0) */
  45067. normal: Vector3;
  45068. /** the uv of the vertex (default: 0,0) */
  45069. uv: Vector2;
  45070. /**
  45071. * Creates a PositionNormalTextureVertex
  45072. * @param position the position of the vertex (defaut: 0,0,0)
  45073. * @param normal the normal of the vertex (defaut: 0,1,0)
  45074. * @param uv the uv of the vertex (default: 0,0)
  45075. */
  45076. constructor(
  45077. /** the position of the vertex (defaut: 0,0,0) */
  45078. position?: Vector3,
  45079. /** the normal of the vertex (defaut: 0,1,0) */
  45080. normal?: Vector3,
  45081. /** the uv of the vertex (default: 0,0) */
  45082. uv?: Vector2);
  45083. /**
  45084. * Clones the PositionNormalTextureVertex
  45085. * @returns the cloned PositionNormalTextureVertex
  45086. */
  45087. clone(): PositionNormalTextureVertex;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /** @hidden */
  45092. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45093. private _genericAttributeLocation;
  45094. private _varyingLocationCount;
  45095. private _varyingLocationMap;
  45096. private _replacements;
  45097. private _textureCount;
  45098. private _uniforms;
  45099. lineProcessor(line: string): string;
  45100. attributeProcessor(attribute: string): string;
  45101. varyingProcessor(varying: string, isFragment: boolean): string;
  45102. uniformProcessor(uniform: string): string;
  45103. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45104. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45105. }
  45106. }
  45107. declare module BABYLON {
  45108. /**
  45109. * Container for accessors for natively-stored mesh data buffers.
  45110. */
  45111. class NativeDataBuffer extends DataBuffer {
  45112. /**
  45113. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45114. */
  45115. nativeIndexBuffer?: any;
  45116. /**
  45117. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45118. */
  45119. nativeVertexBuffer?: any;
  45120. }
  45121. /** @hidden */
  45122. class NativeTexture extends InternalTexture {
  45123. getInternalTexture(): InternalTexture;
  45124. getViewCount(): number;
  45125. }
  45126. /** @hidden */
  45127. export class NativeEngine extends Engine {
  45128. private readonly _native;
  45129. getHardwareScalingLevel(): number;
  45130. constructor();
  45131. /**
  45132. * Can be used to override the current requestAnimationFrame requester.
  45133. * @hidden
  45134. */
  45135. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  45136. /**
  45137. * Override default engine behavior.
  45138. * @param color
  45139. * @param backBuffer
  45140. * @param depth
  45141. * @param stencil
  45142. */
  45143. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  45144. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45145. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45146. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45147. recordVertexArrayObject(vertexBuffers: {
  45148. [key: string]: VertexBuffer;
  45149. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45150. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45151. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45153. /**
  45154. * Draw a list of indexed primitives
  45155. * @param fillMode defines the primitive to use
  45156. * @param indexStart defines the starting index
  45157. * @param indexCount defines the number of index to draw
  45158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45159. */
  45160. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45161. /**
  45162. * Draw a list of unindexed primitives
  45163. * @param fillMode defines the primitive to use
  45164. * @param verticesStart defines the index of first vertex to draw
  45165. * @param verticesCount defines the count of vertices to draw
  45166. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45167. */
  45168. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45169. createPipelineContext(): IPipelineContext;
  45170. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45171. /** @hidden */
  45172. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45173. /** @hidden */
  45174. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45175. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45177. protected _setProgram(program: WebGLProgram): void;
  45178. _releaseEffect(effect: Effect): void;
  45179. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45180. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45182. bindSamplers(effect: Effect): void;
  45183. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45184. getRenderWidth(useScreen?: boolean): number;
  45185. getRenderHeight(useScreen?: boolean): number;
  45186. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45188. /**
  45189. * Set the z offset to apply to current rendering
  45190. * @param value defines the offset to apply
  45191. */
  45192. setZOffset(value: number): void;
  45193. /**
  45194. * Gets the current value of the zOffset
  45195. * @returns the current zOffset state
  45196. */
  45197. getZOffset(): number;
  45198. /**
  45199. * Enable or disable depth buffering
  45200. * @param enable defines the state to set
  45201. */
  45202. setDepthBuffer(enable: boolean): void;
  45203. /**
  45204. * Gets a boolean indicating if depth writing is enabled
  45205. * @returns the current depth writing state
  45206. */
  45207. getDepthWrite(): boolean;
  45208. /**
  45209. * Enable or disable depth writing
  45210. * @param enable defines the state to set
  45211. */
  45212. setDepthWrite(enable: boolean): void;
  45213. /**
  45214. * Enable or disable color writing
  45215. * @param enable defines the state to set
  45216. */
  45217. setColorWrite(enable: boolean): void;
  45218. /**
  45219. * Gets a boolean indicating if color writing is enabled
  45220. * @returns the current color writing state
  45221. */
  45222. getColorWrite(): boolean;
  45223. /**
  45224. * Sets alpha constants used by some alpha blending modes
  45225. * @param r defines the red component
  45226. * @param g defines the green component
  45227. * @param b defines the blue component
  45228. * @param a defines the alpha component
  45229. */
  45230. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45231. /**
  45232. * Sets the current alpha mode
  45233. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45234. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45236. */
  45237. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45238. /**
  45239. * Gets the current alpha mode
  45240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45241. * @returns the current alpha mode
  45242. */
  45243. getAlphaMode(): number;
  45244. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45245. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45246. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45247. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45248. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45249. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45251. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45252. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45253. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45254. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45255. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45256. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45257. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45258. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45259. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45260. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45261. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45262. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45263. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45264. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45265. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45266. wipeCaches(bruteForce?: boolean): void;
  45267. _createTexture(): WebGLTexture;
  45268. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45269. /**
  45270. * Usually called from BABYLON.Texture.ts.
  45271. * Passed information to create a WebGLTexture
  45272. * @param urlArg defines a value which contains one of the following:
  45273. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45274. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45275. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45276. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45277. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45278. * @param scene needed for loading to the correct scene
  45279. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45280. * @param onLoad optional callback to be called upon successful completion
  45281. * @param onError optional callback to be called upon failure
  45282. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45283. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45284. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45285. * @param forcedExtension defines the extension to use to pick the right loader
  45286. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45287. */
  45288. 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;
  45289. /**
  45290. * Creates a cube texture
  45291. * @param rootUrl defines the url where the files to load is located
  45292. * @param scene defines the current scene
  45293. * @param files defines the list of files to load (1 per face)
  45294. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45295. * @param onLoad defines an optional callback raised when the texture is loaded
  45296. * @param onError defines an optional callback raised if there is an issue to load the texture
  45297. * @param format defines the format of the data
  45298. * @param forcedExtension defines the extension to use to pick the right loader
  45299. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45300. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45301. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45302. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45303. * @returns the cube texture as an InternalTexture
  45304. */
  45305. 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;
  45306. private _getSamplingFilter;
  45307. private static _GetNativeTextureFormat;
  45308. createRenderTargetTexture(size: number | {
  45309. width: number;
  45310. height: number;
  45311. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  45312. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45313. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45314. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45315. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45316. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45317. /**
  45318. * Updates a dynamic vertex buffer.
  45319. * @param vertexBuffer the vertex buffer to update
  45320. * @param data the data used to update the vertex buffer
  45321. * @param byteOffset the byte offset of the data (optional)
  45322. * @param byteLength the byte length of the data (optional)
  45323. */
  45324. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45325. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45326. private _updateAnisotropicLevel;
  45327. private _getAddressMode;
  45328. /** @hidden */
  45329. _bindTexture(channel: number, texture: InternalTexture): void;
  45330. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45331. releaseEffects(): void;
  45332. /** @hidden */
  45333. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45334. /** @hidden */
  45335. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45336. /** @hidden */
  45337. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45338. /** @hidden */
  45339. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45340. }
  45341. }
  45342. declare module BABYLON {
  45343. /**
  45344. * Gather the list of clipboard event types as constants.
  45345. */
  45346. export class ClipboardEventTypes {
  45347. /**
  45348. * The clipboard event is fired when a copy command is active (pressed).
  45349. */
  45350. static readonly COPY: number;
  45351. /**
  45352. * The clipboard event is fired when a cut command is active (pressed).
  45353. */
  45354. static readonly CUT: number;
  45355. /**
  45356. * The clipboard event is fired when a paste command is active (pressed).
  45357. */
  45358. static readonly PASTE: number;
  45359. }
  45360. /**
  45361. * This class is used to store clipboard related info for the onClipboardObservable event.
  45362. */
  45363. export class ClipboardInfo {
  45364. /**
  45365. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45366. */
  45367. type: number;
  45368. /**
  45369. * Defines the related dom event
  45370. */
  45371. event: ClipboardEvent;
  45372. /**
  45373. *Creates an instance of ClipboardInfo.
  45374. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45375. * @param event Defines the related dom event
  45376. */
  45377. constructor(
  45378. /**
  45379. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45380. */
  45381. type: number,
  45382. /**
  45383. * Defines the related dom event
  45384. */
  45385. event: ClipboardEvent);
  45386. /**
  45387. * Get the clipboard event's type from the keycode.
  45388. * @param keyCode Defines the keyCode for the current keyboard event.
  45389. * @return {number}
  45390. */
  45391. static GetTypeFromCharacter(keyCode: number): number;
  45392. }
  45393. }
  45394. declare module BABYLON {
  45395. /**
  45396. * Google Daydream controller
  45397. */
  45398. export class DaydreamController extends WebVRController {
  45399. /**
  45400. * Base Url for the controller model.
  45401. */
  45402. static MODEL_BASE_URL: string;
  45403. /**
  45404. * File name for the controller model.
  45405. */
  45406. static MODEL_FILENAME: string;
  45407. /**
  45408. * Gamepad Id prefix used to identify Daydream Controller.
  45409. */
  45410. static readonly GAMEPAD_ID_PREFIX: string;
  45411. /**
  45412. * Creates a new DaydreamController from a gamepad
  45413. * @param vrGamepad the gamepad that the controller should be created from
  45414. */
  45415. constructor(vrGamepad: any);
  45416. /**
  45417. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45418. * @param scene scene in which to add meshes
  45419. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45420. */
  45421. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45422. /**
  45423. * Called once for each button that changed state since the last frame
  45424. * @param buttonIdx Which button index changed
  45425. * @param state New state of the button
  45426. * @param changes Which properties on the state changed since last frame
  45427. */
  45428. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45429. }
  45430. }
  45431. declare module BABYLON {
  45432. /**
  45433. * Gear VR Controller
  45434. */
  45435. export class GearVRController extends WebVRController {
  45436. /**
  45437. * Base Url for the controller model.
  45438. */
  45439. static MODEL_BASE_URL: string;
  45440. /**
  45441. * File name for the controller model.
  45442. */
  45443. static MODEL_FILENAME: string;
  45444. /**
  45445. * Gamepad Id prefix used to identify this controller.
  45446. */
  45447. static readonly GAMEPAD_ID_PREFIX: string;
  45448. private readonly _buttonIndexToObservableNameMap;
  45449. /**
  45450. * Creates a new GearVRController from a gamepad
  45451. * @param vrGamepad the gamepad that the controller should be created from
  45452. */
  45453. constructor(vrGamepad: any);
  45454. /**
  45455. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45456. * @param scene scene in which to add meshes
  45457. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45458. */
  45459. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45460. /**
  45461. * Called once for each button that changed state since the last frame
  45462. * @param buttonIdx Which button index changed
  45463. * @param state New state of the button
  45464. * @param changes Which properties on the state changed since last frame
  45465. */
  45466. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45467. }
  45468. }
  45469. declare module BABYLON {
  45470. /**
  45471. * Class containing static functions to help procedurally build meshes
  45472. */
  45473. export class PolyhedronBuilder {
  45474. /**
  45475. * Creates a polyhedron mesh
  45476. * * 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
  45477. * * The parameter `size` (positive float, default 1) sets the polygon size
  45478. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45479. * * 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`
  45480. * * 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
  45481. * * 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)`)
  45482. * * 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
  45483. * * 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
  45484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45485. * * 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
  45486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45487. * @param name defines the name of the mesh
  45488. * @param options defines the options used to create the mesh
  45489. * @param scene defines the hosting scene
  45490. * @returns the polyhedron mesh
  45491. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45492. */
  45493. static CreatePolyhedron(name: string, options: {
  45494. type?: number;
  45495. size?: number;
  45496. sizeX?: number;
  45497. sizeY?: number;
  45498. sizeZ?: number;
  45499. custom?: any;
  45500. faceUV?: Vector4[];
  45501. faceColors?: Color4[];
  45502. flat?: boolean;
  45503. updatable?: boolean;
  45504. sideOrientation?: number;
  45505. frontUVs?: Vector4;
  45506. backUVs?: Vector4;
  45507. }, scene?: Nullable<Scene>): Mesh;
  45508. }
  45509. }
  45510. declare module BABYLON {
  45511. /**
  45512. * Gizmo that enables scaling a mesh along 3 axis
  45513. */
  45514. export class ScaleGizmo extends Gizmo {
  45515. /**
  45516. * Internal gizmo used for interactions on the x axis
  45517. */
  45518. xGizmo: AxisScaleGizmo;
  45519. /**
  45520. * Internal gizmo used for interactions on the y axis
  45521. */
  45522. yGizmo: AxisScaleGizmo;
  45523. /**
  45524. * Internal gizmo used for interactions on the z axis
  45525. */
  45526. zGizmo: AxisScaleGizmo;
  45527. /**
  45528. * Internal gizmo used to scale all axis equally
  45529. */
  45530. uniformScaleGizmo: AxisScaleGizmo;
  45531. private _meshAttached;
  45532. private _updateGizmoRotationToMatchAttachedMesh;
  45533. private _snapDistance;
  45534. private _scaleRatio;
  45535. private _uniformScalingMesh;
  45536. private _octahedron;
  45537. /** Fires an event when any of it's sub gizmos are dragged */
  45538. onDragStartObservable: Observable<unknown>;
  45539. /** Fires an event when any of it's sub gizmos are released from dragging */
  45540. onDragEndObservable: Observable<unknown>;
  45541. attachedMesh: Nullable<AbstractMesh>;
  45542. /**
  45543. * Creates a ScaleGizmo
  45544. * @param gizmoLayer The utility layer the gizmo will be added to
  45545. */
  45546. constructor(gizmoLayer?: UtilityLayerRenderer);
  45547. updateGizmoRotationToMatchAttachedMesh: boolean;
  45548. /**
  45549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45550. */
  45551. snapDistance: number;
  45552. /**
  45553. * Ratio for the scale of the gizmo (Default: 1)
  45554. */
  45555. scaleRatio: number;
  45556. /**
  45557. * Disposes of the gizmo
  45558. */
  45559. dispose(): void;
  45560. }
  45561. }
  45562. declare module BABYLON {
  45563. /**
  45564. * Single axis scale gizmo
  45565. */
  45566. export class AxisScaleGizmo extends Gizmo {
  45567. /**
  45568. * Drag behavior responsible for the gizmos dragging interactions
  45569. */
  45570. dragBehavior: PointerDragBehavior;
  45571. private _pointerObserver;
  45572. /**
  45573. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45574. */
  45575. snapDistance: number;
  45576. /**
  45577. * Event that fires each time the gizmo snaps to a new location.
  45578. * * snapDistance is the the change in distance
  45579. */
  45580. onSnapObservable: Observable<{
  45581. snapDistance: number;
  45582. }>;
  45583. /**
  45584. * If the scaling operation should be done on all axis (default: false)
  45585. */
  45586. uniformScaling: boolean;
  45587. private _isEnabled;
  45588. private _parent;
  45589. private _arrow;
  45590. private _coloredMaterial;
  45591. private _hoverMaterial;
  45592. /**
  45593. * Creates an AxisScaleGizmo
  45594. * @param gizmoLayer The utility layer the gizmo will be added to
  45595. * @param dragAxis The axis which the gizmo will be able to scale on
  45596. * @param color The color of the gizmo
  45597. */
  45598. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45600. /**
  45601. * If the gizmo is enabled
  45602. */
  45603. isEnabled: boolean;
  45604. /**
  45605. * Disposes of the gizmo
  45606. */
  45607. dispose(): void;
  45608. /**
  45609. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45610. * @param mesh The mesh to replace the default mesh of the gizmo
  45611. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45612. */
  45613. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45614. }
  45615. }
  45616. declare module BABYLON {
  45617. /**
  45618. * Bounding box gizmo
  45619. */
  45620. export class BoundingBoxGizmo extends Gizmo {
  45621. private _lineBoundingBox;
  45622. private _rotateSpheresParent;
  45623. private _scaleBoxesParent;
  45624. private _boundingDimensions;
  45625. private _renderObserver;
  45626. private _pointerObserver;
  45627. private _scaleDragSpeed;
  45628. private _tmpQuaternion;
  45629. private _tmpVector;
  45630. private _tmpRotationMatrix;
  45631. /**
  45632. * 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)
  45633. */
  45634. ignoreChildren: boolean;
  45635. /**
  45636. * 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)
  45637. */
  45638. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45639. /**
  45640. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45641. */
  45642. rotationSphereSize: number;
  45643. /**
  45644. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45645. */
  45646. scaleBoxSize: number;
  45647. /**
  45648. * 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)
  45649. */
  45650. fixedDragMeshScreenSize: boolean;
  45651. /**
  45652. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45653. */
  45654. fixedDragMeshScreenSizeDistanceFactor: number;
  45655. /**
  45656. * Fired when a rotation sphere or scale box is dragged
  45657. */
  45658. onDragStartObservable: Observable<{}>;
  45659. /**
  45660. * Fired when a scale box is dragged
  45661. */
  45662. onScaleBoxDragObservable: Observable<{}>;
  45663. /**
  45664. * Fired when a scale box drag is ended
  45665. */
  45666. onScaleBoxDragEndObservable: Observable<{}>;
  45667. /**
  45668. * Fired when a rotation sphere is dragged
  45669. */
  45670. onRotationSphereDragObservable: Observable<{}>;
  45671. /**
  45672. * Fired when a rotation sphere drag is ended
  45673. */
  45674. onRotationSphereDragEndObservable: Observable<{}>;
  45675. /**
  45676. * 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)
  45677. */
  45678. scalePivot: Nullable<Vector3>;
  45679. /**
  45680. * Mesh used as a pivot to rotate the attached mesh
  45681. */
  45682. private _anchorMesh;
  45683. private _existingMeshScale;
  45684. private _dragMesh;
  45685. private pointerDragBehavior;
  45686. private coloredMaterial;
  45687. private hoverColoredMaterial;
  45688. /**
  45689. * Sets the color of the bounding box gizmo
  45690. * @param color the color to set
  45691. */
  45692. setColor(color: Color3): void;
  45693. /**
  45694. * Creates an BoundingBoxGizmo
  45695. * @param gizmoLayer The utility layer the gizmo will be added to
  45696. * @param color The color of the gizmo
  45697. */
  45698. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45699. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45700. private _selectNode;
  45701. /**
  45702. * Updates the bounding box information for the Gizmo
  45703. */
  45704. updateBoundingBox(): void;
  45705. private _updateRotationSpheres;
  45706. private _updateScaleBoxes;
  45707. /**
  45708. * Enables rotation on the specified axis and disables rotation on the others
  45709. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45710. */
  45711. setEnabledRotationAxis(axis: string): void;
  45712. /**
  45713. * Enables/disables scaling
  45714. * @param enable if scaling should be enabled
  45715. */
  45716. setEnabledScaling(enable: boolean): void;
  45717. private _updateDummy;
  45718. /**
  45719. * Enables a pointer drag behavior on the bounding box of the gizmo
  45720. */
  45721. enableDragBehavior(): void;
  45722. /**
  45723. * Disposes of the gizmo
  45724. */
  45725. dispose(): void;
  45726. /**
  45727. * 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)
  45728. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45729. * @returns the bounding box mesh with the passed in mesh as a child
  45730. */
  45731. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45732. /**
  45733. * CustomMeshes are not supported by this gizmo
  45734. * @param mesh The mesh to replace the default mesh of the gizmo
  45735. */
  45736. setCustomMesh(mesh: Mesh): void;
  45737. }
  45738. }
  45739. declare module BABYLON {
  45740. /**
  45741. * Single plane rotation gizmo
  45742. */
  45743. export class PlaneRotationGizmo extends Gizmo {
  45744. /**
  45745. * Drag behavior responsible for the gizmos dragging interactions
  45746. */
  45747. dragBehavior: PointerDragBehavior;
  45748. private _pointerObserver;
  45749. /**
  45750. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45751. */
  45752. snapDistance: number;
  45753. /**
  45754. * Event that fires each time the gizmo snaps to a new location.
  45755. * * snapDistance is the the change in distance
  45756. */
  45757. onSnapObservable: Observable<{
  45758. snapDistance: number;
  45759. }>;
  45760. private _isEnabled;
  45761. private _parent;
  45762. /**
  45763. * Creates a PlaneRotationGizmo
  45764. * @param gizmoLayer The utility layer the gizmo will be added to
  45765. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45766. * @param color The color of the gizmo
  45767. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45768. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45769. */
  45770. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45771. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45772. /**
  45773. * If the gizmo is enabled
  45774. */
  45775. isEnabled: boolean;
  45776. /**
  45777. * Disposes of the gizmo
  45778. */
  45779. dispose(): void;
  45780. }
  45781. }
  45782. declare module BABYLON {
  45783. /**
  45784. * Gizmo that enables rotating a mesh along 3 axis
  45785. */
  45786. export class RotationGizmo extends Gizmo {
  45787. /**
  45788. * Internal gizmo used for interactions on the x axis
  45789. */
  45790. xGizmo: PlaneRotationGizmo;
  45791. /**
  45792. * Internal gizmo used for interactions on the y axis
  45793. */
  45794. yGizmo: PlaneRotationGizmo;
  45795. /**
  45796. * Internal gizmo used for interactions on the z axis
  45797. */
  45798. zGizmo: PlaneRotationGizmo;
  45799. /** Fires an event when any of it's sub gizmos are dragged */
  45800. onDragStartObservable: Observable<unknown>;
  45801. /** Fires an event when any of it's sub gizmos are released from dragging */
  45802. onDragEndObservable: Observable<unknown>;
  45803. private _meshAttached;
  45804. attachedMesh: Nullable<AbstractMesh>;
  45805. /**
  45806. * Creates a RotationGizmo
  45807. * @param gizmoLayer The utility layer the gizmo will be added to
  45808. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45809. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45810. */
  45811. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45812. updateGizmoRotationToMatchAttachedMesh: boolean;
  45813. /**
  45814. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45815. */
  45816. snapDistance: number;
  45817. /**
  45818. * Ratio for the scale of the gizmo (Default: 1)
  45819. */
  45820. scaleRatio: number;
  45821. /**
  45822. * Disposes of the gizmo
  45823. */
  45824. dispose(): void;
  45825. /**
  45826. * CustomMeshes are not supported by this gizmo
  45827. * @param mesh The mesh to replace the default mesh of the gizmo
  45828. */
  45829. setCustomMesh(mesh: Mesh): void;
  45830. }
  45831. }
  45832. declare module BABYLON {
  45833. /**
  45834. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45835. */
  45836. export class GizmoManager implements IDisposable {
  45837. private scene;
  45838. /**
  45839. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45840. */
  45841. gizmos: {
  45842. positionGizmo: Nullable<PositionGizmo>;
  45843. rotationGizmo: Nullable<RotationGizmo>;
  45844. scaleGizmo: Nullable<ScaleGizmo>;
  45845. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45846. };
  45847. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45848. clearGizmoOnEmptyPointerEvent: boolean;
  45849. /** Fires an event when the manager is attached to a mesh */
  45850. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45851. private _gizmosEnabled;
  45852. private _pointerObserver;
  45853. private _attachedMesh;
  45854. private _boundingBoxColor;
  45855. private _defaultUtilityLayer;
  45856. private _defaultKeepDepthUtilityLayer;
  45857. /**
  45858. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45859. */
  45860. boundingBoxDragBehavior: SixDofDragBehavior;
  45861. /**
  45862. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45863. */
  45864. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45865. /**
  45866. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45867. */
  45868. usePointerToAttachGizmos: boolean;
  45869. /**
  45870. * Utility layer that the bounding box gizmo belongs to
  45871. */
  45872. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45873. /**
  45874. * Utility layer that all gizmos besides bounding box belong to
  45875. */
  45876. readonly utilityLayer: UtilityLayerRenderer;
  45877. /**
  45878. * Instatiates a gizmo manager
  45879. * @param scene the scene to overlay the gizmos on top of
  45880. */
  45881. constructor(scene: Scene);
  45882. /**
  45883. * Attaches a set of gizmos to the specified mesh
  45884. * @param mesh The mesh the gizmo's should be attached to
  45885. */
  45886. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45887. /**
  45888. * If the position gizmo is enabled
  45889. */
  45890. positionGizmoEnabled: boolean;
  45891. /**
  45892. * If the rotation gizmo is enabled
  45893. */
  45894. rotationGizmoEnabled: boolean;
  45895. /**
  45896. * If the scale gizmo is enabled
  45897. */
  45898. scaleGizmoEnabled: boolean;
  45899. /**
  45900. * If the boundingBox gizmo is enabled
  45901. */
  45902. boundingBoxGizmoEnabled: boolean;
  45903. /**
  45904. * Disposes of the gizmo manager
  45905. */
  45906. dispose(): void;
  45907. }
  45908. }
  45909. declare module BABYLON {
  45910. /**
  45911. * A directional light is defined by a direction (what a surprise!).
  45912. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45913. * 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.
  45914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45915. */
  45916. export class DirectionalLight extends ShadowLight {
  45917. private _shadowFrustumSize;
  45918. /**
  45919. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45920. */
  45921. /**
  45922. * Specifies a fix frustum size for the shadow generation.
  45923. */
  45924. shadowFrustumSize: number;
  45925. private _shadowOrthoScale;
  45926. /**
  45927. * Gets the shadow projection scale against the optimal computed one.
  45928. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45929. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45930. */
  45931. /**
  45932. * Sets the shadow projection scale against the optimal computed one.
  45933. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45934. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45935. */
  45936. shadowOrthoScale: number;
  45937. /**
  45938. * Automatically compute the projection matrix to best fit (including all the casters)
  45939. * on each frame.
  45940. */
  45941. autoUpdateExtends: boolean;
  45942. private _orthoLeft;
  45943. private _orthoRight;
  45944. private _orthoTop;
  45945. private _orthoBottom;
  45946. /**
  45947. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45948. * The directional light is emitted from everywhere in the given direction.
  45949. * It can cast shadows.
  45950. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45951. * @param name The friendly name of the light
  45952. * @param direction The direction of the light
  45953. * @param scene The scene the light belongs to
  45954. */
  45955. constructor(name: string, direction: Vector3, scene: Scene);
  45956. /**
  45957. * Returns the string "DirectionalLight".
  45958. * @return The class name
  45959. */
  45960. getClassName(): string;
  45961. /**
  45962. * Returns the integer 1.
  45963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45964. */
  45965. getTypeID(): number;
  45966. /**
  45967. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45968. * Returns the DirectionalLight Shadow projection matrix.
  45969. */
  45970. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45971. /**
  45972. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45973. * Returns the DirectionalLight Shadow projection matrix.
  45974. */
  45975. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45976. /**
  45977. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45978. * Returns the DirectionalLight Shadow projection matrix.
  45979. */
  45980. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45981. protected _buildUniformLayout(): void;
  45982. /**
  45983. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45984. * @param effect The effect to update
  45985. * @param lightIndex The index of the light in the effect to update
  45986. * @returns The directional light
  45987. */
  45988. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45989. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45990. /**
  45991. * Gets the minZ used for shadow according to both the scene and the light.
  45992. *
  45993. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45994. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45995. * @param activeCamera The camera we are returning the min for
  45996. * @returns the depth min z
  45997. */
  45998. getDepthMinZ(activeCamera: Camera): number;
  45999. /**
  46000. * Gets the maxZ used for shadow according to both the scene and the light.
  46001. *
  46002. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46003. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46004. * @param activeCamera The camera we are returning the max for
  46005. * @returns the depth max z
  46006. */
  46007. getDepthMaxZ(activeCamera: Camera): number;
  46008. /**
  46009. * Prepares the list of defines specific to the light type.
  46010. * @param defines the list of defines
  46011. * @param lightIndex defines the index of the light for the effect
  46012. */
  46013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46014. }
  46015. }
  46016. declare module BABYLON {
  46017. /**
  46018. * Class containing static functions to help procedurally build meshes
  46019. */
  46020. export class HemisphereBuilder {
  46021. /**
  46022. * Creates a hemisphere mesh
  46023. * @param name defines the name of the mesh
  46024. * @param options defines the options used to create the mesh
  46025. * @param scene defines the hosting scene
  46026. * @returns the hemisphere mesh
  46027. */
  46028. static CreateHemisphere(name: string, options: {
  46029. segments?: number;
  46030. diameter?: number;
  46031. sideOrientation?: number;
  46032. }, scene: any): Mesh;
  46033. }
  46034. }
  46035. declare module BABYLON {
  46036. /**
  46037. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46038. * These values define a cone of light starting from the position, emitting toward the direction.
  46039. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46040. * and the exponent defines the speed of the decay of the light with distance (reach).
  46041. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46042. */
  46043. export class SpotLight extends ShadowLight {
  46044. private _angle;
  46045. private _innerAngle;
  46046. private _cosHalfAngle;
  46047. private _lightAngleScale;
  46048. private _lightAngleOffset;
  46049. /**
  46050. * Gets the cone angle of the spot light in Radians.
  46051. */
  46052. /**
  46053. * Sets the cone angle of the spot light in Radians.
  46054. */
  46055. angle: number;
  46056. /**
  46057. * Only used in gltf falloff mode, this defines the angle where
  46058. * the directional falloff will start before cutting at angle which could be seen
  46059. * as outer angle.
  46060. */
  46061. /**
  46062. * Only used in gltf falloff mode, this defines the angle where
  46063. * the directional falloff will start before cutting at angle which could be seen
  46064. * as outer angle.
  46065. */
  46066. innerAngle: number;
  46067. private _shadowAngleScale;
  46068. /**
  46069. * Allows scaling the angle of the light for shadow generation only.
  46070. */
  46071. /**
  46072. * Allows scaling the angle of the light for shadow generation only.
  46073. */
  46074. shadowAngleScale: number;
  46075. /**
  46076. * The light decay speed with the distance from the emission spot.
  46077. */
  46078. exponent: number;
  46079. private _projectionTextureMatrix;
  46080. /**
  46081. * Allows reading the projecton texture
  46082. */
  46083. readonly projectionTextureMatrix: Matrix;
  46084. protected _projectionTextureLightNear: number;
  46085. /**
  46086. * Gets the near clip of the Spotlight for texture projection.
  46087. */
  46088. /**
  46089. * Sets the near clip of the Spotlight for texture projection.
  46090. */
  46091. projectionTextureLightNear: number;
  46092. protected _projectionTextureLightFar: number;
  46093. /**
  46094. * Gets the far clip of the Spotlight for texture projection.
  46095. */
  46096. /**
  46097. * Sets the far clip of the Spotlight for texture projection.
  46098. */
  46099. projectionTextureLightFar: number;
  46100. protected _projectionTextureUpDirection: Vector3;
  46101. /**
  46102. * Gets the Up vector of the Spotlight for texture projection.
  46103. */
  46104. /**
  46105. * Sets the Up vector of the Spotlight for texture projection.
  46106. */
  46107. projectionTextureUpDirection: Vector3;
  46108. private _projectionTexture;
  46109. /**
  46110. * Gets the projection texture of the light.
  46111. */
  46112. /**
  46113. * Sets the projection texture of the light.
  46114. */
  46115. projectionTexture: Nullable<BaseTexture>;
  46116. private _projectionTextureViewLightDirty;
  46117. private _projectionTextureProjectionLightDirty;
  46118. private _projectionTextureDirty;
  46119. private _projectionTextureViewTargetVector;
  46120. private _projectionTextureViewLightMatrix;
  46121. private _projectionTextureProjectionLightMatrix;
  46122. private _projectionTextureScalingMatrix;
  46123. /**
  46124. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46125. * It can cast shadows.
  46126. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46127. * @param name The light friendly name
  46128. * @param position The position of the spot light in the scene
  46129. * @param direction The direction of the light in the scene
  46130. * @param angle The cone angle of the light in Radians
  46131. * @param exponent The light decay speed with the distance from the emission spot
  46132. * @param scene The scene the lights belongs to
  46133. */
  46134. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46135. /**
  46136. * Returns the string "SpotLight".
  46137. * @returns the class name
  46138. */
  46139. getClassName(): string;
  46140. /**
  46141. * Returns the integer 2.
  46142. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46143. */
  46144. getTypeID(): number;
  46145. /**
  46146. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46147. */
  46148. protected _setDirection(value: Vector3): void;
  46149. /**
  46150. * Overrides the position setter to recompute the projection texture view light Matrix.
  46151. */
  46152. protected _setPosition(value: Vector3): void;
  46153. /**
  46154. * 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.
  46155. * Returns the SpotLight.
  46156. */
  46157. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46158. protected _computeProjectionTextureViewLightMatrix(): void;
  46159. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46160. /**
  46161. * Main function for light texture projection matrix computing.
  46162. */
  46163. protected _computeProjectionTextureMatrix(): void;
  46164. protected _buildUniformLayout(): void;
  46165. private _computeAngleValues;
  46166. /**
  46167. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46168. * @param effect The effect to update
  46169. * @param lightIndex The index of the light in the effect to update
  46170. * @returns The spot light
  46171. */
  46172. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46173. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46174. /**
  46175. * Disposes the light and the associated resources.
  46176. */
  46177. dispose(): void;
  46178. /**
  46179. * Prepares the list of defines specific to the light type.
  46180. * @param defines the list of defines
  46181. * @param lightIndex defines the index of the light for the effect
  46182. */
  46183. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46184. }
  46185. }
  46186. declare module BABYLON {
  46187. /**
  46188. * Gizmo that enables viewing a light
  46189. */
  46190. export class LightGizmo extends Gizmo {
  46191. private _lightMesh;
  46192. private _material;
  46193. private cachedPosition;
  46194. private cachedForward;
  46195. /**
  46196. * Creates a LightGizmo
  46197. * @param gizmoLayer The utility layer the gizmo will be added to
  46198. */
  46199. constructor(gizmoLayer?: UtilityLayerRenderer);
  46200. private _light;
  46201. /**
  46202. * The light that the gizmo is attached to
  46203. */
  46204. light: Nullable<Light>;
  46205. /**
  46206. * Gets the material used to render the light gizmo
  46207. */
  46208. readonly material: StandardMaterial;
  46209. /**
  46210. * @hidden
  46211. * Updates the gizmo to match the attached mesh's position/rotation
  46212. */
  46213. protected _update(): void;
  46214. private static _Scale;
  46215. /**
  46216. * Creates the lines for a light mesh
  46217. */
  46218. private static _createLightLines;
  46219. /**
  46220. * Disposes of the light gizmo
  46221. */
  46222. dispose(): void;
  46223. private static _CreateHemisphericLightMesh;
  46224. private static _CreatePointLightMesh;
  46225. private static _CreateSpotLightMesh;
  46226. private static _CreateDirectionalLightMesh;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /** @hidden */
  46231. export var backgroundFragmentDeclaration: {
  46232. name: string;
  46233. shader: string;
  46234. };
  46235. }
  46236. declare module BABYLON {
  46237. /** @hidden */
  46238. export var backgroundUboDeclaration: {
  46239. name: string;
  46240. shader: string;
  46241. };
  46242. }
  46243. declare module BABYLON {
  46244. /** @hidden */
  46245. export var backgroundPixelShader: {
  46246. name: string;
  46247. shader: string;
  46248. };
  46249. }
  46250. declare module BABYLON {
  46251. /** @hidden */
  46252. export var backgroundVertexDeclaration: {
  46253. name: string;
  46254. shader: string;
  46255. };
  46256. }
  46257. declare module BABYLON {
  46258. /** @hidden */
  46259. export var backgroundVertexShader: {
  46260. name: string;
  46261. shader: string;
  46262. };
  46263. }
  46264. declare module BABYLON {
  46265. /**
  46266. * Background material used to create an efficient environement around your scene.
  46267. */
  46268. export class BackgroundMaterial extends PushMaterial {
  46269. /**
  46270. * Standard reflectance value at parallel view angle.
  46271. */
  46272. static StandardReflectance0: number;
  46273. /**
  46274. * Standard reflectance value at grazing angle.
  46275. */
  46276. static StandardReflectance90: number;
  46277. protected _primaryColor: Color3;
  46278. /**
  46279. * Key light Color (multiply against the environement texture)
  46280. */
  46281. primaryColor: Color3;
  46282. protected __perceptualColor: Nullable<Color3>;
  46283. /**
  46284. * Experimental Internal Use Only.
  46285. *
  46286. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46287. * This acts as a helper to set the primary color to a more "human friendly" value.
  46288. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46289. * output color as close as possible from the chosen value.
  46290. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46291. * part of lighting setup.)
  46292. */
  46293. _perceptualColor: Nullable<Color3>;
  46294. protected _primaryColorShadowLevel: float;
  46295. /**
  46296. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46297. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46298. */
  46299. primaryColorShadowLevel: float;
  46300. protected _primaryColorHighlightLevel: float;
  46301. /**
  46302. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46303. * The primary color is used at the level chosen to define what the white area would look.
  46304. */
  46305. primaryColorHighlightLevel: float;
  46306. protected _reflectionTexture: Nullable<BaseTexture>;
  46307. /**
  46308. * Reflection Texture used in the material.
  46309. * Should be author in a specific way for the best result (refer to the documentation).
  46310. */
  46311. reflectionTexture: Nullable<BaseTexture>;
  46312. protected _reflectionBlur: float;
  46313. /**
  46314. * Reflection Texture level of blur.
  46315. *
  46316. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46317. * texture twice.
  46318. */
  46319. reflectionBlur: float;
  46320. protected _diffuseTexture: Nullable<BaseTexture>;
  46321. /**
  46322. * Diffuse Texture used in the material.
  46323. * Should be author in a specific way for the best result (refer to the documentation).
  46324. */
  46325. diffuseTexture: Nullable<BaseTexture>;
  46326. protected _shadowLights: Nullable<IShadowLight[]>;
  46327. /**
  46328. * Specify the list of lights casting shadow on the material.
  46329. * All scene shadow lights will be included if null.
  46330. */
  46331. shadowLights: Nullable<IShadowLight[]>;
  46332. protected _shadowLevel: float;
  46333. /**
  46334. * Helps adjusting the shadow to a softer level if required.
  46335. * 0 means black shadows and 1 means no shadows.
  46336. */
  46337. shadowLevel: float;
  46338. protected _sceneCenter: Vector3;
  46339. /**
  46340. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46341. * It is usually zero but might be interesting to modify according to your setup.
  46342. */
  46343. sceneCenter: Vector3;
  46344. protected _opacityFresnel: boolean;
  46345. /**
  46346. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46347. * This helps ensuring a nice transition when the camera goes under the ground.
  46348. */
  46349. opacityFresnel: boolean;
  46350. protected _reflectionFresnel: boolean;
  46351. /**
  46352. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46353. * This helps adding a mirror texture on the ground.
  46354. */
  46355. reflectionFresnel: boolean;
  46356. protected _reflectionFalloffDistance: number;
  46357. /**
  46358. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46359. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46360. */
  46361. reflectionFalloffDistance: number;
  46362. protected _reflectionAmount: number;
  46363. /**
  46364. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46365. */
  46366. reflectionAmount: number;
  46367. protected _reflectionReflectance0: number;
  46368. /**
  46369. * This specifies the weight of the reflection at grazing angle.
  46370. */
  46371. reflectionReflectance0: number;
  46372. protected _reflectionReflectance90: number;
  46373. /**
  46374. * This specifies the weight of the reflection at a perpendicular point of view.
  46375. */
  46376. reflectionReflectance90: number;
  46377. /**
  46378. * Sets the reflection reflectance fresnel values according to the default standard
  46379. * empirically know to work well :-)
  46380. */
  46381. reflectionStandardFresnelWeight: number;
  46382. protected _useRGBColor: boolean;
  46383. /**
  46384. * Helps to directly use the maps channels instead of their level.
  46385. */
  46386. useRGBColor: boolean;
  46387. protected _enableNoise: boolean;
  46388. /**
  46389. * This helps reducing the banding effect that could occur on the background.
  46390. */
  46391. enableNoise: boolean;
  46392. /**
  46393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46394. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46395. * Recommended to be keep at 1.0 except for special cases.
  46396. */
  46397. fovMultiplier: number;
  46398. private _fovMultiplier;
  46399. /**
  46400. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46401. */
  46402. useEquirectangularFOV: boolean;
  46403. private _maxSimultaneousLights;
  46404. /**
  46405. * Number of Simultaneous lights allowed on the material.
  46406. */
  46407. maxSimultaneousLights: int;
  46408. /**
  46409. * Default configuration related to image processing available in the Background Material.
  46410. */
  46411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46412. /**
  46413. * Keep track of the image processing observer to allow dispose and replace.
  46414. */
  46415. private _imageProcessingObserver;
  46416. /**
  46417. * Attaches a new image processing configuration to the PBR Material.
  46418. * @param configuration (if null the scene configuration will be use)
  46419. */
  46420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46421. /**
  46422. * Gets the image processing configuration used either in this material.
  46423. */
  46424. /**
  46425. * Sets the Default image processing configuration used either in the this material.
  46426. *
  46427. * If sets to null, the scene one is in use.
  46428. */
  46429. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46430. /**
  46431. * Gets wether the color curves effect is enabled.
  46432. */
  46433. /**
  46434. * Sets wether the color curves effect is enabled.
  46435. */
  46436. cameraColorCurvesEnabled: boolean;
  46437. /**
  46438. * Gets wether the color grading effect is enabled.
  46439. */
  46440. /**
  46441. * Gets wether the color grading effect is enabled.
  46442. */
  46443. cameraColorGradingEnabled: boolean;
  46444. /**
  46445. * Gets wether tonemapping is enabled or not.
  46446. */
  46447. /**
  46448. * Sets wether tonemapping is enabled or not
  46449. */
  46450. cameraToneMappingEnabled: boolean;
  46451. /**
  46452. * The camera exposure used on this material.
  46453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46454. * This corresponds to a photographic exposure.
  46455. */
  46456. /**
  46457. * The camera exposure used on this material.
  46458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46459. * This corresponds to a photographic exposure.
  46460. */
  46461. cameraExposure: float;
  46462. /**
  46463. * Gets The camera contrast used on this material.
  46464. */
  46465. /**
  46466. * Sets The camera contrast used on this material.
  46467. */
  46468. cameraContrast: float;
  46469. /**
  46470. * Gets the Color Grading 2D Lookup Texture.
  46471. */
  46472. /**
  46473. * Sets the Color Grading 2D Lookup Texture.
  46474. */
  46475. cameraColorGradingTexture: Nullable<BaseTexture>;
  46476. /**
  46477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46479. * 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;
  46480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46481. */
  46482. /**
  46483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46485. * 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;
  46486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46487. */
  46488. cameraColorCurves: Nullable<ColorCurves>;
  46489. /**
  46490. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46491. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46492. */
  46493. switchToBGR: boolean;
  46494. private _renderTargets;
  46495. private _reflectionControls;
  46496. private _white;
  46497. private _primaryShadowColor;
  46498. private _primaryHighlightColor;
  46499. /**
  46500. * Instantiates a Background Material in the given scene
  46501. * @param name The friendly name of the material
  46502. * @param scene The scene to add the material to
  46503. */
  46504. constructor(name: string, scene: Scene);
  46505. /**
  46506. * Gets a boolean indicating that current material needs to register RTT
  46507. */
  46508. readonly hasRenderTargetTextures: boolean;
  46509. /**
  46510. * The entire material has been created in order to prevent overdraw.
  46511. * @returns false
  46512. */
  46513. needAlphaTesting(): boolean;
  46514. /**
  46515. * The entire material has been created in order to prevent overdraw.
  46516. * @returns true if blending is enable
  46517. */
  46518. needAlphaBlending(): boolean;
  46519. /**
  46520. * Checks wether the material is ready to be rendered for a given mesh.
  46521. * @param mesh The mesh to render
  46522. * @param subMesh The submesh to check against
  46523. * @param useInstances Specify wether or not the material is used with instances
  46524. * @returns true if all the dependencies are ready (Textures, Effects...)
  46525. */
  46526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46527. /**
  46528. * Compute the primary color according to the chosen perceptual color.
  46529. */
  46530. private _computePrimaryColorFromPerceptualColor;
  46531. /**
  46532. * Compute the highlights and shadow colors according to their chosen levels.
  46533. */
  46534. private _computePrimaryColors;
  46535. /**
  46536. * Build the uniform buffer used in the material.
  46537. */
  46538. buildUniformLayout(): void;
  46539. /**
  46540. * Unbind the material.
  46541. */
  46542. unbind(): void;
  46543. /**
  46544. * Bind only the world matrix to the material.
  46545. * @param world The world matrix to bind.
  46546. */
  46547. bindOnlyWorldMatrix(world: Matrix): void;
  46548. /**
  46549. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46550. * @param world The world matrix to bind.
  46551. * @param subMesh The submesh to bind for.
  46552. */
  46553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46554. /**
  46555. * Checks to see if a texture is used in the material.
  46556. * @param texture - Base texture to use.
  46557. * @returns - Boolean specifying if a texture is used in the material.
  46558. */
  46559. hasTexture(texture: BaseTexture): boolean;
  46560. /**
  46561. * Dispose the material.
  46562. * @param forceDisposeEffect Force disposal of the associated effect.
  46563. * @param forceDisposeTextures Force disposal of the associated textures.
  46564. */
  46565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46566. /**
  46567. * Clones the material.
  46568. * @param name The cloned name.
  46569. * @returns The cloned material.
  46570. */
  46571. clone(name: string): BackgroundMaterial;
  46572. /**
  46573. * Serializes the current material to its JSON representation.
  46574. * @returns The JSON representation.
  46575. */
  46576. serialize(): any;
  46577. /**
  46578. * Gets the class name of the material
  46579. * @returns "BackgroundMaterial"
  46580. */
  46581. getClassName(): string;
  46582. /**
  46583. * Parse a JSON input to create back a background material.
  46584. * @param source The JSON data to parse
  46585. * @param scene The scene to create the parsed material in
  46586. * @param rootUrl The root url of the assets the material depends upon
  46587. * @returns the instantiated BackgroundMaterial.
  46588. */
  46589. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46590. }
  46591. }
  46592. declare module BABYLON {
  46593. /**
  46594. * Represents the different options available during the creation of
  46595. * a Environment helper.
  46596. *
  46597. * This can control the default ground, skybox and image processing setup of your scene.
  46598. */
  46599. export interface IEnvironmentHelperOptions {
  46600. /**
  46601. * Specifies wether or not to create a ground.
  46602. * True by default.
  46603. */
  46604. createGround: boolean;
  46605. /**
  46606. * Specifies the ground size.
  46607. * 15 by default.
  46608. */
  46609. groundSize: number;
  46610. /**
  46611. * The texture used on the ground for the main color.
  46612. * Comes from the BabylonJS CDN by default.
  46613. *
  46614. * Remarks: Can be either a texture or a url.
  46615. */
  46616. groundTexture: string | BaseTexture;
  46617. /**
  46618. * The color mixed in the ground texture by default.
  46619. * BabylonJS clearColor by default.
  46620. */
  46621. groundColor: Color3;
  46622. /**
  46623. * Specifies the ground opacity.
  46624. * 1 by default.
  46625. */
  46626. groundOpacity: number;
  46627. /**
  46628. * Enables the ground to receive shadows.
  46629. * True by default.
  46630. */
  46631. enableGroundShadow: boolean;
  46632. /**
  46633. * Helps preventing the shadow to be fully black on the ground.
  46634. * 0.5 by default.
  46635. */
  46636. groundShadowLevel: number;
  46637. /**
  46638. * Creates a mirror texture attach to the ground.
  46639. * false by default.
  46640. */
  46641. enableGroundMirror: boolean;
  46642. /**
  46643. * Specifies the ground mirror size ratio.
  46644. * 0.3 by default as the default kernel is 64.
  46645. */
  46646. groundMirrorSizeRatio: number;
  46647. /**
  46648. * Specifies the ground mirror blur kernel size.
  46649. * 64 by default.
  46650. */
  46651. groundMirrorBlurKernel: number;
  46652. /**
  46653. * Specifies the ground mirror visibility amount.
  46654. * 1 by default
  46655. */
  46656. groundMirrorAmount: number;
  46657. /**
  46658. * Specifies the ground mirror reflectance weight.
  46659. * This uses the standard weight of the background material to setup the fresnel effect
  46660. * of the mirror.
  46661. * 1 by default.
  46662. */
  46663. groundMirrorFresnelWeight: number;
  46664. /**
  46665. * Specifies the ground mirror Falloff distance.
  46666. * This can helps reducing the size of the reflection.
  46667. * 0 by Default.
  46668. */
  46669. groundMirrorFallOffDistance: number;
  46670. /**
  46671. * Specifies the ground mirror texture type.
  46672. * Unsigned Int by Default.
  46673. */
  46674. groundMirrorTextureType: number;
  46675. /**
  46676. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46677. * the shown objects.
  46678. */
  46679. groundYBias: number;
  46680. /**
  46681. * Specifies wether or not to create a skybox.
  46682. * True by default.
  46683. */
  46684. createSkybox: boolean;
  46685. /**
  46686. * Specifies the skybox size.
  46687. * 20 by default.
  46688. */
  46689. skyboxSize: number;
  46690. /**
  46691. * The texture used on the skybox for the main color.
  46692. * Comes from the BabylonJS CDN by default.
  46693. *
  46694. * Remarks: Can be either a texture or a url.
  46695. */
  46696. skyboxTexture: string | BaseTexture;
  46697. /**
  46698. * The color mixed in the skybox texture by default.
  46699. * BabylonJS clearColor by default.
  46700. */
  46701. skyboxColor: Color3;
  46702. /**
  46703. * The background rotation around the Y axis of the scene.
  46704. * This helps aligning the key lights of your scene with the background.
  46705. * 0 by default.
  46706. */
  46707. backgroundYRotation: number;
  46708. /**
  46709. * Compute automatically the size of the elements to best fit with the scene.
  46710. */
  46711. sizeAuto: boolean;
  46712. /**
  46713. * Default position of the rootMesh if autoSize is not true.
  46714. */
  46715. rootPosition: Vector3;
  46716. /**
  46717. * Sets up the image processing in the scene.
  46718. * true by default.
  46719. */
  46720. setupImageProcessing: boolean;
  46721. /**
  46722. * The texture used as your environment texture in the scene.
  46723. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46724. *
  46725. * Remarks: Can be either a texture or a url.
  46726. */
  46727. environmentTexture: string | BaseTexture;
  46728. /**
  46729. * The value of the exposure to apply to the scene.
  46730. * 0.6 by default if setupImageProcessing is true.
  46731. */
  46732. cameraExposure: number;
  46733. /**
  46734. * The value of the contrast to apply to the scene.
  46735. * 1.6 by default if setupImageProcessing is true.
  46736. */
  46737. cameraContrast: number;
  46738. /**
  46739. * Specifies wether or not tonemapping should be enabled in the scene.
  46740. * true by default if setupImageProcessing is true.
  46741. */
  46742. toneMappingEnabled: boolean;
  46743. }
  46744. /**
  46745. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46746. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46747. * It also helps with the default setup of your imageProcessing configuration.
  46748. */
  46749. export class EnvironmentHelper {
  46750. /**
  46751. * Default ground texture URL.
  46752. */
  46753. private static _groundTextureCDNUrl;
  46754. /**
  46755. * Default skybox texture URL.
  46756. */
  46757. private static _skyboxTextureCDNUrl;
  46758. /**
  46759. * Default environment texture URL.
  46760. */
  46761. private static _environmentTextureCDNUrl;
  46762. /**
  46763. * Creates the default options for the helper.
  46764. */
  46765. private static _getDefaultOptions;
  46766. private _rootMesh;
  46767. /**
  46768. * Gets the root mesh created by the helper.
  46769. */
  46770. readonly rootMesh: Mesh;
  46771. private _skybox;
  46772. /**
  46773. * Gets the skybox created by the helper.
  46774. */
  46775. readonly skybox: Nullable<Mesh>;
  46776. private _skyboxTexture;
  46777. /**
  46778. * Gets the skybox texture created by the helper.
  46779. */
  46780. readonly skyboxTexture: Nullable<BaseTexture>;
  46781. private _skyboxMaterial;
  46782. /**
  46783. * Gets the skybox material created by the helper.
  46784. */
  46785. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46786. private _ground;
  46787. /**
  46788. * Gets the ground mesh created by the helper.
  46789. */
  46790. readonly ground: Nullable<Mesh>;
  46791. private _groundTexture;
  46792. /**
  46793. * Gets the ground texture created by the helper.
  46794. */
  46795. readonly groundTexture: Nullable<BaseTexture>;
  46796. private _groundMirror;
  46797. /**
  46798. * Gets the ground mirror created by the helper.
  46799. */
  46800. readonly groundMirror: Nullable<MirrorTexture>;
  46801. /**
  46802. * Gets the ground mirror render list to helps pushing the meshes
  46803. * you wish in the ground reflection.
  46804. */
  46805. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46806. private _groundMaterial;
  46807. /**
  46808. * Gets the ground material created by the helper.
  46809. */
  46810. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46811. /**
  46812. * Stores the creation options.
  46813. */
  46814. private readonly _scene;
  46815. private _options;
  46816. /**
  46817. * This observable will be notified with any error during the creation of the environment,
  46818. * mainly texture creation errors.
  46819. */
  46820. onErrorObservable: Observable<{
  46821. message?: string;
  46822. exception?: any;
  46823. }>;
  46824. /**
  46825. * constructor
  46826. * @param options Defines the options we want to customize the helper
  46827. * @param scene The scene to add the material to
  46828. */
  46829. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46830. /**
  46831. * Updates the background according to the new options
  46832. * @param options
  46833. */
  46834. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46835. /**
  46836. * Sets the primary color of all the available elements.
  46837. * @param color the main color to affect to the ground and the background
  46838. */
  46839. setMainColor(color: Color3): void;
  46840. /**
  46841. * Setup the image processing according to the specified options.
  46842. */
  46843. private _setupImageProcessing;
  46844. /**
  46845. * Setup the environment texture according to the specified options.
  46846. */
  46847. private _setupEnvironmentTexture;
  46848. /**
  46849. * Setup the background according to the specified options.
  46850. */
  46851. private _setupBackground;
  46852. /**
  46853. * Get the scene sizes according to the setup.
  46854. */
  46855. private _getSceneSize;
  46856. /**
  46857. * Setup the ground according to the specified options.
  46858. */
  46859. private _setupGround;
  46860. /**
  46861. * Setup the ground material according to the specified options.
  46862. */
  46863. private _setupGroundMaterial;
  46864. /**
  46865. * Setup the ground diffuse texture according to the specified options.
  46866. */
  46867. private _setupGroundDiffuseTexture;
  46868. /**
  46869. * Setup the ground mirror texture according to the specified options.
  46870. */
  46871. private _setupGroundMirrorTexture;
  46872. /**
  46873. * Setup the ground to receive the mirror texture.
  46874. */
  46875. private _setupMirrorInGroundMaterial;
  46876. /**
  46877. * Setup the skybox according to the specified options.
  46878. */
  46879. private _setupSkybox;
  46880. /**
  46881. * Setup the skybox material according to the specified options.
  46882. */
  46883. private _setupSkyboxMaterial;
  46884. /**
  46885. * Setup the skybox reflection texture according to the specified options.
  46886. */
  46887. private _setupSkyboxReflectionTexture;
  46888. private _errorHandler;
  46889. /**
  46890. * Dispose all the elements created by the Helper.
  46891. */
  46892. dispose(): void;
  46893. }
  46894. }
  46895. declare module BABYLON {
  46896. /**
  46897. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46898. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46899. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46900. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46901. */
  46902. export class PhotoDome extends TransformNode {
  46903. /**
  46904. * Define the image as a Monoscopic panoramic 360 image.
  46905. */
  46906. static readonly MODE_MONOSCOPIC: number;
  46907. /**
  46908. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46909. */
  46910. static readonly MODE_TOPBOTTOM: number;
  46911. /**
  46912. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46913. */
  46914. static readonly MODE_SIDEBYSIDE: number;
  46915. private _useDirectMapping;
  46916. /**
  46917. * The texture being displayed on the sphere
  46918. */
  46919. protected _photoTexture: Texture;
  46920. /**
  46921. * Gets or sets the texture being displayed on the sphere
  46922. */
  46923. photoTexture: Texture;
  46924. /**
  46925. * Observable raised when an error occured while loading the 360 image
  46926. */
  46927. onLoadErrorObservable: Observable<string>;
  46928. /**
  46929. * The skybox material
  46930. */
  46931. protected _material: BackgroundMaterial;
  46932. /**
  46933. * The surface used for the skybox
  46934. */
  46935. protected _mesh: Mesh;
  46936. /**
  46937. * Gets the mesh used for the skybox.
  46938. */
  46939. readonly mesh: Mesh;
  46940. /**
  46941. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46942. * Also see the options.resolution property.
  46943. */
  46944. fovMultiplier: number;
  46945. private _imageMode;
  46946. /**
  46947. * Gets or set the current video mode for the video. It can be:
  46948. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46949. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46950. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46951. */
  46952. imageMode: number;
  46953. /**
  46954. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46955. * @param name Element's name, child elements will append suffixes for their own names.
  46956. * @param urlsOfPhoto defines the url of the photo to display
  46957. * @param options defines an object containing optional or exposed sub element properties
  46958. * @param onError defines a callback called when an error occured while loading the texture
  46959. */
  46960. constructor(name: string, urlOfPhoto: string, options: {
  46961. resolution?: number;
  46962. size?: number;
  46963. useDirectMapping?: boolean;
  46964. faceForward?: boolean;
  46965. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46966. private _onBeforeCameraRenderObserver;
  46967. private _changeImageMode;
  46968. /**
  46969. * Releases resources associated with this node.
  46970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46972. */
  46973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46974. }
  46975. }
  46976. declare module BABYLON {
  46977. /**
  46978. * Class used to host RGBD texture specific utilities
  46979. */
  46980. export class RGBDTextureTools {
  46981. /**
  46982. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46983. * @param texture the texture to expand.
  46984. */
  46985. static ExpandRGBDTexture(texture: Texture): void;
  46986. }
  46987. }
  46988. declare module BABYLON {
  46989. /**
  46990. * Class used to host texture specific utilities
  46991. */
  46992. export class BRDFTextureTools {
  46993. /**
  46994. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46995. * @param scene defines the hosting scene
  46996. * @returns the environment BRDF texture
  46997. */
  46998. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46999. private static _environmentBRDFBase64Texture;
  47000. }
  47001. }
  47002. declare module BABYLON {
  47003. /**
  47004. * @hidden
  47005. */
  47006. export interface IMaterialClearCoatDefines {
  47007. CLEARCOAT: boolean;
  47008. CLEARCOAT_DEFAULTIOR: boolean;
  47009. CLEARCOAT_TEXTURE: boolean;
  47010. CLEARCOAT_TEXTUREDIRECTUV: number;
  47011. CLEARCOAT_BUMP: boolean;
  47012. CLEARCOAT_BUMPDIRECTUV: number;
  47013. CLEARCOAT_TINT: boolean;
  47014. CLEARCOAT_TINT_TEXTURE: boolean;
  47015. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47016. /** @hidden */
  47017. _areTexturesDirty: boolean;
  47018. }
  47019. /**
  47020. * Define the code related to the clear coat parameters of the pbr material.
  47021. */
  47022. export class PBRClearCoatConfiguration {
  47023. /**
  47024. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47025. * The default fits with a polyurethane material.
  47026. */
  47027. private static readonly _DefaultIndexOfRefraction;
  47028. private _isEnabled;
  47029. /**
  47030. * Defines if the clear coat is enabled in the material.
  47031. */
  47032. isEnabled: boolean;
  47033. /**
  47034. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47035. */
  47036. intensity: number;
  47037. /**
  47038. * Defines the clear coat layer roughness.
  47039. */
  47040. roughness: number;
  47041. private _indexOfRefraction;
  47042. /**
  47043. * Defines the index of refraction of the clear coat.
  47044. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47045. * The default fits with a polyurethane material.
  47046. * Changing the default value is more performance intensive.
  47047. */
  47048. indexOfRefraction: number;
  47049. private _texture;
  47050. /**
  47051. * Stores the clear coat values in a texture.
  47052. */
  47053. texture: Nullable<BaseTexture>;
  47054. private _bumpTexture;
  47055. /**
  47056. * Define the clear coat specific bump texture.
  47057. */
  47058. bumpTexture: Nullable<BaseTexture>;
  47059. private _isTintEnabled;
  47060. /**
  47061. * Defines if the clear coat tint is enabled in the material.
  47062. */
  47063. isTintEnabled: boolean;
  47064. /**
  47065. * Defines the clear coat tint of the material.
  47066. * This is only use if tint is enabled
  47067. */
  47068. tintColor: Color3;
  47069. /**
  47070. * Defines the distance at which the tint color should be found in the
  47071. * clear coat media.
  47072. * This is only use if tint is enabled
  47073. */
  47074. tintColorAtDistance: number;
  47075. /**
  47076. * Defines the clear coat layer thickness.
  47077. * This is only use if tint is enabled
  47078. */
  47079. tintThickness: number;
  47080. private _tintTexture;
  47081. /**
  47082. * Stores the clear tint values in a texture.
  47083. * rgb is tint
  47084. * a is a thickness factor
  47085. */
  47086. tintTexture: Nullable<BaseTexture>;
  47087. /** @hidden */
  47088. private _internalMarkAllSubMeshesAsTexturesDirty;
  47089. /** @hidden */
  47090. _markAllSubMeshesAsTexturesDirty(): void;
  47091. /**
  47092. * Instantiate a new istance of clear coat configuration.
  47093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47094. */
  47095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47096. /**
  47097. * Gets wehter the submesh is ready to be used or not.
  47098. * @param defines the list of "defines" to update.
  47099. * @param scene defines the scene the material belongs to.
  47100. * @param engine defines the engine the material belongs to.
  47101. * @param disableBumpMap defines wether the material disables bump or not.
  47102. * @returns - boolean indicating that the submesh is ready or not.
  47103. */
  47104. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47105. /**
  47106. * Checks to see if a texture is used in the material.
  47107. * @param defines the list of "defines" to update.
  47108. * @param scene defines the scene to the material belongs to.
  47109. */
  47110. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47111. /**
  47112. * Binds the material data.
  47113. * @param uniformBuffer defines the Uniform buffer to fill in.
  47114. * @param scene defines the scene the material belongs to.
  47115. * @param engine defines the engine the material belongs to.
  47116. * @param disableBumpMap defines wether the material disables bump or not.
  47117. * @param isFrozen defines wether the material is frozen or not.
  47118. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47119. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47120. */
  47121. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47122. /**
  47123. * Checks to see if a texture is used in the material.
  47124. * @param texture - Base texture to use.
  47125. * @returns - Boolean specifying if a texture is used in the material.
  47126. */
  47127. hasTexture(texture: BaseTexture): boolean;
  47128. /**
  47129. * Returns an array of the actively used textures.
  47130. * @param activeTextures Array of BaseTextures
  47131. */
  47132. getActiveTextures(activeTextures: BaseTexture[]): void;
  47133. /**
  47134. * Returns the animatable textures.
  47135. * @param animatables Array of animatable textures.
  47136. */
  47137. getAnimatables(animatables: IAnimatable[]): void;
  47138. /**
  47139. * Disposes the resources of the material.
  47140. * @param forceDisposeTextures - Forces the disposal of all textures.
  47141. */
  47142. dispose(forceDisposeTextures?: boolean): void;
  47143. /**
  47144. * Get the current class name of the texture useful for serialization or dynamic coding.
  47145. * @returns "PBRClearCoatConfiguration"
  47146. */
  47147. getClassName(): string;
  47148. /**
  47149. * Add fallbacks to the effect fallbacks list.
  47150. * @param defines defines the Base texture to use.
  47151. * @param fallbacks defines the current fallback list.
  47152. * @param currentRank defines the current fallback rank.
  47153. * @returns the new fallback rank.
  47154. */
  47155. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47156. /**
  47157. * Add the required uniforms to the current list.
  47158. * @param uniforms defines the current uniform list.
  47159. */
  47160. static AddUniforms(uniforms: string[]): void;
  47161. /**
  47162. * Add the required samplers to the current list.
  47163. * @param samplers defines the current sampler list.
  47164. */
  47165. static AddSamplers(samplers: string[]): void;
  47166. /**
  47167. * Add the required uniforms to the current buffer.
  47168. * @param uniformBuffer defines the current uniform buffer.
  47169. */
  47170. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47171. /**
  47172. * Makes a duplicate of the current configuration into another one.
  47173. * @param clearCoatConfiguration define the config where to copy the info
  47174. */
  47175. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47176. /**
  47177. * Serializes this clear coat configuration.
  47178. * @returns - An object with the serialized config.
  47179. */
  47180. serialize(): any;
  47181. /**
  47182. * Parses a anisotropy Configuration from a serialized object.
  47183. * @param source - Serialized object.
  47184. * @param scene Defines the scene we are parsing for
  47185. * @param rootUrl Defines the rootUrl to load from
  47186. */
  47187. parse(source: any, scene: Scene, rootUrl: string): void;
  47188. }
  47189. }
  47190. declare module BABYLON {
  47191. /**
  47192. * @hidden
  47193. */
  47194. export interface IMaterialAnisotropicDefines {
  47195. ANISOTROPIC: boolean;
  47196. ANISOTROPIC_TEXTURE: boolean;
  47197. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47198. MAINUV1: boolean;
  47199. _areTexturesDirty: boolean;
  47200. _needUVs: boolean;
  47201. }
  47202. /**
  47203. * Define the code related to the anisotropic parameters of the pbr material.
  47204. */
  47205. export class PBRAnisotropicConfiguration {
  47206. private _isEnabled;
  47207. /**
  47208. * Defines if the anisotropy is enabled in the material.
  47209. */
  47210. isEnabled: boolean;
  47211. /**
  47212. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47213. */
  47214. intensity: number;
  47215. /**
  47216. * Defines if the effect is along the tangents, bitangents or in between.
  47217. * By default, the effect is "strectching" the highlights along the tangents.
  47218. */
  47219. direction: Vector2;
  47220. private _texture;
  47221. /**
  47222. * Stores the anisotropy values in a texture.
  47223. * rg is direction (like normal from -1 to 1)
  47224. * b is a intensity
  47225. */
  47226. texture: Nullable<BaseTexture>;
  47227. /** @hidden */
  47228. private _internalMarkAllSubMeshesAsTexturesDirty;
  47229. /** @hidden */
  47230. _markAllSubMeshesAsTexturesDirty(): void;
  47231. /**
  47232. * Instantiate a new istance of anisotropy configuration.
  47233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47234. */
  47235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47236. /**
  47237. * Specifies that the submesh is ready to be used.
  47238. * @param defines the list of "defines" to update.
  47239. * @param scene defines the scene the material belongs to.
  47240. * @returns - boolean indicating that the submesh is ready or not.
  47241. */
  47242. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47243. /**
  47244. * Checks to see if a texture is used in the material.
  47245. * @param defines the list of "defines" to update.
  47246. * @param mesh the mesh we are preparing the defines for.
  47247. * @param scene defines the scene the material belongs to.
  47248. */
  47249. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47250. /**
  47251. * Binds the material data.
  47252. * @param uniformBuffer defines the Uniform buffer to fill in.
  47253. * @param scene defines the scene the material belongs to.
  47254. * @param isFrozen defines wether the material is frozen or not.
  47255. */
  47256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47257. /**
  47258. * Checks to see if a texture is used in the material.
  47259. * @param texture - Base texture to use.
  47260. * @returns - Boolean specifying if a texture is used in the material.
  47261. */
  47262. hasTexture(texture: BaseTexture): boolean;
  47263. /**
  47264. * Returns an array of the actively used textures.
  47265. * @param activeTextures Array of BaseTextures
  47266. */
  47267. getActiveTextures(activeTextures: BaseTexture[]): void;
  47268. /**
  47269. * Returns the animatable textures.
  47270. * @param animatables Array of animatable textures.
  47271. */
  47272. getAnimatables(animatables: IAnimatable[]): void;
  47273. /**
  47274. * Disposes the resources of the material.
  47275. * @param forceDisposeTextures - Forces the disposal of all textures.
  47276. */
  47277. dispose(forceDisposeTextures?: boolean): void;
  47278. /**
  47279. * Get the current class name of the texture useful for serialization or dynamic coding.
  47280. * @returns "PBRAnisotropicConfiguration"
  47281. */
  47282. getClassName(): string;
  47283. /**
  47284. * Add fallbacks to the effect fallbacks list.
  47285. * @param defines defines the Base texture to use.
  47286. * @param fallbacks defines the current fallback list.
  47287. * @param currentRank defines the current fallback rank.
  47288. * @returns the new fallback rank.
  47289. */
  47290. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47291. /**
  47292. * Add the required uniforms to the current list.
  47293. * @param uniforms defines the current uniform list.
  47294. */
  47295. static AddUniforms(uniforms: string[]): void;
  47296. /**
  47297. * Add the required uniforms to the current buffer.
  47298. * @param uniformBuffer defines the current uniform buffer.
  47299. */
  47300. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47301. /**
  47302. * Add the required samplers to the current list.
  47303. * @param samplers defines the current sampler list.
  47304. */
  47305. static AddSamplers(samplers: string[]): void;
  47306. /**
  47307. * Makes a duplicate of the current configuration into another one.
  47308. * @param anisotropicConfiguration define the config where to copy the info
  47309. */
  47310. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47311. /**
  47312. * Serializes this anisotropy configuration.
  47313. * @returns - An object with the serialized config.
  47314. */
  47315. serialize(): any;
  47316. /**
  47317. * Parses a anisotropy Configuration from a serialized object.
  47318. * @param source - Serialized object.
  47319. * @param scene Defines the scene we are parsing for
  47320. * @param rootUrl Defines the rootUrl to load from
  47321. */
  47322. parse(source: any, scene: Scene, rootUrl: string): void;
  47323. }
  47324. }
  47325. declare module BABYLON {
  47326. /**
  47327. * @hidden
  47328. */
  47329. export interface IMaterialBRDFDefines {
  47330. BRDF_V_HEIGHT_CORRELATED: boolean;
  47331. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47332. SPHERICAL_HARMONICS: boolean;
  47333. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47334. /** @hidden */
  47335. _areMiscDirty: boolean;
  47336. }
  47337. /**
  47338. * Define the code related to the BRDF parameters of the pbr material.
  47339. */
  47340. export class PBRBRDFConfiguration {
  47341. /**
  47342. * Default value used for the energy conservation.
  47343. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47344. */
  47345. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47346. /**
  47347. * Default value used for the Smith Visibility Height Correlated mode.
  47348. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47349. */
  47350. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47351. /**
  47352. * Default value used for the IBL diffuse part.
  47353. * This can help switching back to the polynomials mode globally which is a tiny bit
  47354. * less GPU intensive at the drawback of a lower quality.
  47355. */
  47356. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47357. /**
  47358. * Default value used for activating energy conservation for the specular workflow.
  47359. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47360. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47361. */
  47362. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47363. private _useEnergyConservation;
  47364. /**
  47365. * Defines if the material uses energy conservation.
  47366. */
  47367. useEnergyConservation: boolean;
  47368. private _useSmithVisibilityHeightCorrelated;
  47369. /**
  47370. * LEGACY Mode set to false
  47371. * Defines if the material uses height smith correlated visibility term.
  47372. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47373. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47374. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47375. * Not relying on height correlated will also disable energy conservation.
  47376. */
  47377. useSmithVisibilityHeightCorrelated: boolean;
  47378. private _useSphericalHarmonics;
  47379. /**
  47380. * LEGACY Mode set to false
  47381. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47382. * diffuse part of the IBL.
  47383. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47384. * to the ground truth.
  47385. */
  47386. useSphericalHarmonics: boolean;
  47387. private _useSpecularGlossinessInputEnergyConservation;
  47388. /**
  47389. * Defines if the material uses energy conservation, when the specular workflow is active.
  47390. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47391. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47392. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47393. */
  47394. useSpecularGlossinessInputEnergyConservation: boolean;
  47395. /** @hidden */
  47396. private _internalMarkAllSubMeshesAsMiscDirty;
  47397. /** @hidden */
  47398. _markAllSubMeshesAsMiscDirty(): void;
  47399. /**
  47400. * Instantiate a new istance of clear coat configuration.
  47401. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47402. */
  47403. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47404. /**
  47405. * Checks to see if a texture is used in the material.
  47406. * @param defines the list of "defines" to update.
  47407. */
  47408. prepareDefines(defines: IMaterialBRDFDefines): void;
  47409. /**
  47410. * Get the current class name of the texture useful for serialization or dynamic coding.
  47411. * @returns "PBRClearCoatConfiguration"
  47412. */
  47413. getClassName(): string;
  47414. /**
  47415. * Makes a duplicate of the current configuration into another one.
  47416. * @param brdfConfiguration define the config where to copy the info
  47417. */
  47418. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47419. /**
  47420. * Serializes this BRDF configuration.
  47421. * @returns - An object with the serialized config.
  47422. */
  47423. serialize(): any;
  47424. /**
  47425. * Parses a anisotropy Configuration from a serialized object.
  47426. * @param source - Serialized object.
  47427. * @param scene Defines the scene we are parsing for
  47428. * @param rootUrl Defines the rootUrl to load from
  47429. */
  47430. parse(source: any, scene: Scene, rootUrl: string): void;
  47431. }
  47432. }
  47433. declare module BABYLON {
  47434. /**
  47435. * @hidden
  47436. */
  47437. export interface IMaterialSheenDefines {
  47438. SHEEN: boolean;
  47439. SHEEN_TEXTURE: boolean;
  47440. SHEEN_TEXTUREDIRECTUV: number;
  47441. SHEEN_LINKWITHALBEDO: boolean;
  47442. /** @hidden */
  47443. _areTexturesDirty: boolean;
  47444. }
  47445. /**
  47446. * Define the code related to the Sheen parameters of the pbr material.
  47447. */
  47448. export class PBRSheenConfiguration {
  47449. private _isEnabled;
  47450. /**
  47451. * Defines if the material uses sheen.
  47452. */
  47453. isEnabled: boolean;
  47454. private _linkSheenWithAlbedo;
  47455. /**
  47456. * Defines if the sheen is linked to the sheen color.
  47457. */
  47458. linkSheenWithAlbedo: boolean;
  47459. /**
  47460. * Defines the sheen intensity.
  47461. */
  47462. intensity: number;
  47463. /**
  47464. * Defines the sheen color.
  47465. */
  47466. color: Color3;
  47467. private _texture;
  47468. /**
  47469. * Stores the sheen tint values in a texture.
  47470. * rgb is tint
  47471. * a is a intensity
  47472. */
  47473. texture: Nullable<BaseTexture>;
  47474. /** @hidden */
  47475. private _internalMarkAllSubMeshesAsTexturesDirty;
  47476. /** @hidden */
  47477. _markAllSubMeshesAsTexturesDirty(): void;
  47478. /**
  47479. * Instantiate a new istance of clear coat configuration.
  47480. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47481. */
  47482. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47483. /**
  47484. * Specifies that the submesh is ready to be used.
  47485. * @param defines the list of "defines" to update.
  47486. * @param scene defines the scene the material belongs to.
  47487. * @returns - boolean indicating that the submesh is ready or not.
  47488. */
  47489. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47490. /**
  47491. * Checks to see if a texture is used in the material.
  47492. * @param defines the list of "defines" to update.
  47493. * @param scene defines the scene the material belongs to.
  47494. */
  47495. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47496. /**
  47497. * Binds the material data.
  47498. * @param uniformBuffer defines the Uniform buffer to fill in.
  47499. * @param scene defines the scene the material belongs to.
  47500. * @param isFrozen defines wether the material is frozen or not.
  47501. */
  47502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47503. /**
  47504. * Checks to see if a texture is used in the material.
  47505. * @param texture - Base texture to use.
  47506. * @returns - Boolean specifying if a texture is used in the material.
  47507. */
  47508. hasTexture(texture: BaseTexture): boolean;
  47509. /**
  47510. * Returns an array of the actively used textures.
  47511. * @param activeTextures Array of BaseTextures
  47512. */
  47513. getActiveTextures(activeTextures: BaseTexture[]): void;
  47514. /**
  47515. * Returns the animatable textures.
  47516. * @param animatables Array of animatable textures.
  47517. */
  47518. getAnimatables(animatables: IAnimatable[]): void;
  47519. /**
  47520. * Disposes the resources of the material.
  47521. * @param forceDisposeTextures - Forces the disposal of all textures.
  47522. */
  47523. dispose(forceDisposeTextures?: boolean): void;
  47524. /**
  47525. * Get the current class name of the texture useful for serialization or dynamic coding.
  47526. * @returns "PBRSheenConfiguration"
  47527. */
  47528. getClassName(): string;
  47529. /**
  47530. * Add fallbacks to the effect fallbacks list.
  47531. * @param defines defines the Base texture to use.
  47532. * @param fallbacks defines the current fallback list.
  47533. * @param currentRank defines the current fallback rank.
  47534. * @returns the new fallback rank.
  47535. */
  47536. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47537. /**
  47538. * Add the required uniforms to the current list.
  47539. * @param uniforms defines the current uniform list.
  47540. */
  47541. static AddUniforms(uniforms: string[]): void;
  47542. /**
  47543. * Add the required uniforms to the current buffer.
  47544. * @param uniformBuffer defines the current uniform buffer.
  47545. */
  47546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47547. /**
  47548. * Add the required samplers to the current list.
  47549. * @param samplers defines the current sampler list.
  47550. */
  47551. static AddSamplers(samplers: string[]): void;
  47552. /**
  47553. * Makes a duplicate of the current configuration into another one.
  47554. * @param sheenConfiguration define the config where to copy the info
  47555. */
  47556. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47557. /**
  47558. * Serializes this BRDF configuration.
  47559. * @returns - An object with the serialized config.
  47560. */
  47561. serialize(): any;
  47562. /**
  47563. * Parses a anisotropy Configuration from a serialized object.
  47564. * @param source - Serialized object.
  47565. * @param scene Defines the scene we are parsing for
  47566. * @param rootUrl Defines the rootUrl to load from
  47567. */
  47568. parse(source: any, scene: Scene, rootUrl: string): void;
  47569. }
  47570. }
  47571. declare module BABYLON {
  47572. /**
  47573. * @hidden
  47574. */
  47575. export interface IMaterialSubSurfaceDefines {
  47576. SUBSURFACE: boolean;
  47577. SS_REFRACTION: boolean;
  47578. SS_TRANSLUCENCY: boolean;
  47579. SS_SCATERRING: boolean;
  47580. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47581. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47582. SS_REFRACTIONMAP_3D: boolean;
  47583. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47584. SS_LODINREFRACTIONALPHA: boolean;
  47585. SS_GAMMAREFRACTION: boolean;
  47586. SS_RGBDREFRACTION: boolean;
  47587. SS_LINEARSPECULARREFRACTION: boolean;
  47588. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47589. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47590. /** @hidden */
  47591. _areTexturesDirty: boolean;
  47592. }
  47593. /**
  47594. * Define the code related to the sub surface parameters of the pbr material.
  47595. */
  47596. export class PBRSubSurfaceConfiguration {
  47597. private _isRefractionEnabled;
  47598. /**
  47599. * Defines if the refraction is enabled in the material.
  47600. */
  47601. isRefractionEnabled: boolean;
  47602. private _isTranslucencyEnabled;
  47603. /**
  47604. * Defines if the translucency is enabled in the material.
  47605. */
  47606. isTranslucencyEnabled: boolean;
  47607. private _isScatteringEnabled;
  47608. /**
  47609. * Defines the refraction intensity of the material.
  47610. * The refraction when enabled replaces the Diffuse part of the material.
  47611. * The intensity helps transitionning between diffuse and refraction.
  47612. */
  47613. refractionIntensity: number;
  47614. /**
  47615. * Defines the translucency intensity of the material.
  47616. * When translucency has been enabled, this defines how much of the "translucency"
  47617. * is addded to the diffuse part of the material.
  47618. */
  47619. translucencyIntensity: number;
  47620. /**
  47621. * Defines the scattering intensity of the material.
  47622. * When scattering has been enabled, this defines how much of the "scattered light"
  47623. * is addded to the diffuse part of the material.
  47624. */
  47625. scatteringIntensity: number;
  47626. private _thicknessTexture;
  47627. /**
  47628. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47629. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47630. * 0 would mean minimumThickness
  47631. * 1 would mean maximumThickness
  47632. * The other channels might be use as a mask to vary the different effects intensity.
  47633. */
  47634. thicknessTexture: Nullable<BaseTexture>;
  47635. private _refractionTexture;
  47636. /**
  47637. * Defines the texture to use for refraction.
  47638. */
  47639. refractionTexture: Nullable<BaseTexture>;
  47640. private _indexOfRefraction;
  47641. /**
  47642. * Defines the index of refraction used in the material.
  47643. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47644. */
  47645. indexOfRefraction: number;
  47646. private _invertRefractionY;
  47647. /**
  47648. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47649. */
  47650. invertRefractionY: boolean;
  47651. private _linkRefractionWithTransparency;
  47652. /**
  47653. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47654. * Materials half opaque for instance using refraction could benefit from this control.
  47655. */
  47656. linkRefractionWithTransparency: boolean;
  47657. /**
  47658. * Defines the minimum thickness stored in the thickness map.
  47659. * If no thickness map is defined, this value will be used to simulate thickness.
  47660. */
  47661. minimumThickness: number;
  47662. /**
  47663. * Defines the maximum thickness stored in the thickness map.
  47664. */
  47665. maximumThickness: number;
  47666. /**
  47667. * Defines the volume tint of the material.
  47668. * This is used for both translucency and scattering.
  47669. */
  47670. tintColor: Color3;
  47671. /**
  47672. * Defines the distance at which the tint color should be found in the media.
  47673. * This is used for refraction only.
  47674. */
  47675. tintColorAtDistance: number;
  47676. /**
  47677. * Defines how far each channel transmit through the media.
  47678. * It is defined as a color to simplify it selection.
  47679. */
  47680. diffusionDistance: Color3;
  47681. private _useMaskFromThicknessTexture;
  47682. /**
  47683. * Stores the intensity of the different subsurface effects in the thickness texture.
  47684. * * the green channel is the translucency intensity.
  47685. * * the blue channel is the scattering intensity.
  47686. * * the alpha channel is the refraction intensity.
  47687. */
  47688. useMaskFromThicknessTexture: boolean;
  47689. /** @hidden */
  47690. private _internalMarkAllSubMeshesAsTexturesDirty;
  47691. /** @hidden */
  47692. _markAllSubMeshesAsTexturesDirty(): void;
  47693. /**
  47694. * Instantiate a new istance of sub surface configuration.
  47695. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47696. */
  47697. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47698. /**
  47699. * Gets wehter the submesh is ready to be used or not.
  47700. * @param defines the list of "defines" to update.
  47701. * @param scene defines the scene the material belongs to.
  47702. * @returns - boolean indicating that the submesh is ready or not.
  47703. */
  47704. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47705. /**
  47706. * Checks to see if a texture is used in the material.
  47707. * @param defines the list of "defines" to update.
  47708. * @param scene defines the scene to the material belongs to.
  47709. */
  47710. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47711. /**
  47712. * Binds the material data.
  47713. * @param uniformBuffer defines the Uniform buffer to fill in.
  47714. * @param scene defines the scene the material belongs to.
  47715. * @param engine defines the engine the material belongs to.
  47716. * @param isFrozen defines wether the material is frozen or not.
  47717. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47718. */
  47719. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47720. /**
  47721. * Unbinds the material from the mesh.
  47722. * @param activeEffect defines the effect that should be unbound from.
  47723. * @returns true if unbound, otherwise false
  47724. */
  47725. unbind(activeEffect: Effect): boolean;
  47726. /**
  47727. * Returns the texture used for refraction or null if none is used.
  47728. * @param scene defines the scene the material belongs to.
  47729. * @returns - Refraction texture if present. If no refraction texture and refraction
  47730. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47731. */
  47732. private _getRefractionTexture;
  47733. /**
  47734. * Returns true if alpha blending should be disabled.
  47735. */
  47736. readonly disableAlphaBlending: boolean;
  47737. /**
  47738. * Fills the list of render target textures.
  47739. * @param renderTargets the list of render targets to update
  47740. */
  47741. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47742. /**
  47743. * Checks to see if a texture is used in the material.
  47744. * @param texture - Base texture to use.
  47745. * @returns - Boolean specifying if a texture is used in the material.
  47746. */
  47747. hasTexture(texture: BaseTexture): boolean;
  47748. /**
  47749. * Gets a boolean indicating that current material needs to register RTT
  47750. * @returns true if this uses a render target otherwise false.
  47751. */
  47752. hasRenderTargetTextures(): boolean;
  47753. /**
  47754. * Returns an array of the actively used textures.
  47755. * @param activeTextures Array of BaseTextures
  47756. */
  47757. getActiveTextures(activeTextures: BaseTexture[]): void;
  47758. /**
  47759. * Returns the animatable textures.
  47760. * @param animatables Array of animatable textures.
  47761. */
  47762. getAnimatables(animatables: IAnimatable[]): void;
  47763. /**
  47764. * Disposes the resources of the material.
  47765. * @param forceDisposeTextures - Forces the disposal of all textures.
  47766. */
  47767. dispose(forceDisposeTextures?: boolean): void;
  47768. /**
  47769. * Get the current class name of the texture useful for serialization or dynamic coding.
  47770. * @returns "PBRSubSurfaceConfiguration"
  47771. */
  47772. getClassName(): string;
  47773. /**
  47774. * Add fallbacks to the effect fallbacks list.
  47775. * @param defines defines the Base texture to use.
  47776. * @param fallbacks defines the current fallback list.
  47777. * @param currentRank defines the current fallback rank.
  47778. * @returns the new fallback rank.
  47779. */
  47780. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47781. /**
  47782. * Add the required uniforms to the current list.
  47783. * @param uniforms defines the current uniform list.
  47784. */
  47785. static AddUniforms(uniforms: string[]): void;
  47786. /**
  47787. * Add the required samplers to the current list.
  47788. * @param samplers defines the current sampler list.
  47789. */
  47790. static AddSamplers(samplers: string[]): void;
  47791. /**
  47792. * Add the required uniforms to the current buffer.
  47793. * @param uniformBuffer defines the current uniform buffer.
  47794. */
  47795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47796. /**
  47797. * Makes a duplicate of the current configuration into another one.
  47798. * @param configuration define the config where to copy the info
  47799. */
  47800. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47801. /**
  47802. * Serializes this Sub Surface configuration.
  47803. * @returns - An object with the serialized config.
  47804. */
  47805. serialize(): any;
  47806. /**
  47807. * Parses a anisotropy Configuration from a serialized object.
  47808. * @param source - Serialized object.
  47809. * @param scene Defines the scene we are parsing for
  47810. * @param rootUrl Defines the rootUrl to load from
  47811. */
  47812. parse(source: any, scene: Scene, rootUrl: string): void;
  47813. }
  47814. }
  47815. declare module BABYLON {
  47816. /** @hidden */
  47817. export var pbrFragmentDeclaration: {
  47818. name: string;
  47819. shader: string;
  47820. };
  47821. }
  47822. declare module BABYLON {
  47823. /** @hidden */
  47824. export var pbrUboDeclaration: {
  47825. name: string;
  47826. shader: string;
  47827. };
  47828. }
  47829. declare module BABYLON {
  47830. /** @hidden */
  47831. export var pbrFragmentExtraDeclaration: {
  47832. name: string;
  47833. shader: string;
  47834. };
  47835. }
  47836. declare module BABYLON {
  47837. /** @hidden */
  47838. export var pbrFragmentSamplersDeclaration: {
  47839. name: string;
  47840. shader: string;
  47841. };
  47842. }
  47843. declare module BABYLON {
  47844. /** @hidden */
  47845. export var pbrHelperFunctions: {
  47846. name: string;
  47847. shader: string;
  47848. };
  47849. }
  47850. declare module BABYLON {
  47851. /** @hidden */
  47852. export var harmonicsFunctions: {
  47853. name: string;
  47854. shader: string;
  47855. };
  47856. }
  47857. declare module BABYLON {
  47858. /** @hidden */
  47859. export var pbrDirectLightingSetupFunctions: {
  47860. name: string;
  47861. shader: string;
  47862. };
  47863. }
  47864. declare module BABYLON {
  47865. /** @hidden */
  47866. export var pbrDirectLightingFalloffFunctions: {
  47867. name: string;
  47868. shader: string;
  47869. };
  47870. }
  47871. declare module BABYLON {
  47872. /** @hidden */
  47873. export var pbrBRDFFunctions: {
  47874. name: string;
  47875. shader: string;
  47876. };
  47877. }
  47878. declare module BABYLON {
  47879. /** @hidden */
  47880. export var pbrDirectLightingFunctions: {
  47881. name: string;
  47882. shader: string;
  47883. };
  47884. }
  47885. declare module BABYLON {
  47886. /** @hidden */
  47887. export var pbrIBLFunctions: {
  47888. name: string;
  47889. shader: string;
  47890. };
  47891. }
  47892. declare module BABYLON {
  47893. /** @hidden */
  47894. export var pbrDebug: {
  47895. name: string;
  47896. shader: string;
  47897. };
  47898. }
  47899. declare module BABYLON {
  47900. /** @hidden */
  47901. export var pbrPixelShader: {
  47902. name: string;
  47903. shader: string;
  47904. };
  47905. }
  47906. declare module BABYLON {
  47907. /** @hidden */
  47908. export var pbrVertexDeclaration: {
  47909. name: string;
  47910. shader: string;
  47911. };
  47912. }
  47913. declare module BABYLON {
  47914. /** @hidden */
  47915. export var pbrVertexShader: {
  47916. name: string;
  47917. shader: string;
  47918. };
  47919. }
  47920. declare module BABYLON {
  47921. /**
  47922. * Manages the defines for the PBR Material.
  47923. * @hidden
  47924. */
  47925. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47926. PBR: boolean;
  47927. MAINUV1: boolean;
  47928. MAINUV2: boolean;
  47929. UV1: boolean;
  47930. UV2: boolean;
  47931. ALBEDO: boolean;
  47932. ALBEDODIRECTUV: number;
  47933. VERTEXCOLOR: boolean;
  47934. AMBIENT: boolean;
  47935. AMBIENTDIRECTUV: number;
  47936. AMBIENTINGRAYSCALE: boolean;
  47937. OPACITY: boolean;
  47938. VERTEXALPHA: boolean;
  47939. OPACITYDIRECTUV: number;
  47940. OPACITYRGB: boolean;
  47941. ALPHATEST: boolean;
  47942. DEPTHPREPASS: boolean;
  47943. ALPHABLEND: boolean;
  47944. ALPHAFROMALBEDO: boolean;
  47945. ALPHATESTVALUE: string;
  47946. SPECULAROVERALPHA: boolean;
  47947. RADIANCEOVERALPHA: boolean;
  47948. ALPHAFRESNEL: boolean;
  47949. LINEARALPHAFRESNEL: boolean;
  47950. PREMULTIPLYALPHA: boolean;
  47951. EMISSIVE: boolean;
  47952. EMISSIVEDIRECTUV: number;
  47953. REFLECTIVITY: boolean;
  47954. REFLECTIVITYDIRECTUV: number;
  47955. SPECULARTERM: boolean;
  47956. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47957. MICROSURFACEAUTOMATIC: boolean;
  47958. LODBASEDMICROSFURACE: boolean;
  47959. MICROSURFACEMAP: boolean;
  47960. MICROSURFACEMAPDIRECTUV: number;
  47961. METALLICWORKFLOW: boolean;
  47962. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47963. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47964. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47965. AOSTOREINMETALMAPRED: boolean;
  47966. METALLICF0FACTORFROMMETALLICMAP: boolean;
  47967. ENVIRONMENTBRDF: boolean;
  47968. ENVIRONMENTBRDF_RGBD: boolean;
  47969. NORMAL: boolean;
  47970. TANGENT: boolean;
  47971. BUMP: boolean;
  47972. BUMPDIRECTUV: number;
  47973. OBJECTSPACE_NORMALMAP: boolean;
  47974. PARALLAX: boolean;
  47975. PARALLAXOCCLUSION: boolean;
  47976. NORMALXYSCALE: boolean;
  47977. LIGHTMAP: boolean;
  47978. LIGHTMAPDIRECTUV: number;
  47979. USELIGHTMAPASSHADOWMAP: boolean;
  47980. GAMMALIGHTMAP: boolean;
  47981. RGBDLIGHTMAP: boolean;
  47982. REFLECTION: boolean;
  47983. REFLECTIONMAP_3D: boolean;
  47984. REFLECTIONMAP_SPHERICAL: boolean;
  47985. REFLECTIONMAP_PLANAR: boolean;
  47986. REFLECTIONMAP_CUBIC: boolean;
  47987. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47988. REFLECTIONMAP_PROJECTION: boolean;
  47989. REFLECTIONMAP_SKYBOX: boolean;
  47990. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47991. REFLECTIONMAP_EXPLICIT: boolean;
  47992. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47993. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47994. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47995. INVERTCUBICMAP: boolean;
  47996. USESPHERICALFROMREFLECTIONMAP: boolean;
  47997. USEIRRADIANCEMAP: boolean;
  47998. SPHERICAL_HARMONICS: boolean;
  47999. USESPHERICALINVERTEX: boolean;
  48000. REFLECTIONMAP_OPPOSITEZ: boolean;
  48001. LODINREFLECTIONALPHA: boolean;
  48002. GAMMAREFLECTION: boolean;
  48003. RGBDREFLECTION: boolean;
  48004. LINEARSPECULARREFLECTION: boolean;
  48005. RADIANCEOCCLUSION: boolean;
  48006. HORIZONOCCLUSION: boolean;
  48007. INSTANCES: boolean;
  48008. NUM_BONE_INFLUENCERS: number;
  48009. BonesPerMesh: number;
  48010. BONETEXTURE: boolean;
  48011. NONUNIFORMSCALING: boolean;
  48012. MORPHTARGETS: boolean;
  48013. MORPHTARGETS_NORMAL: boolean;
  48014. MORPHTARGETS_TANGENT: boolean;
  48015. MORPHTARGETS_UV: boolean;
  48016. NUM_MORPH_INFLUENCERS: number;
  48017. IMAGEPROCESSING: boolean;
  48018. VIGNETTE: boolean;
  48019. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48020. VIGNETTEBLENDMODEOPAQUE: boolean;
  48021. TONEMAPPING: boolean;
  48022. TONEMAPPING_ACES: boolean;
  48023. CONTRAST: boolean;
  48024. COLORCURVES: boolean;
  48025. COLORGRADING: boolean;
  48026. COLORGRADING3D: boolean;
  48027. SAMPLER3DGREENDEPTH: boolean;
  48028. SAMPLER3DBGRMAP: boolean;
  48029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48030. EXPOSURE: boolean;
  48031. MULTIVIEW: boolean;
  48032. USEPHYSICALLIGHTFALLOFF: boolean;
  48033. USEGLTFLIGHTFALLOFF: boolean;
  48034. TWOSIDEDLIGHTING: boolean;
  48035. SHADOWFLOAT: boolean;
  48036. CLIPPLANE: boolean;
  48037. CLIPPLANE2: boolean;
  48038. CLIPPLANE3: boolean;
  48039. CLIPPLANE4: boolean;
  48040. POINTSIZE: boolean;
  48041. FOG: boolean;
  48042. LOGARITHMICDEPTH: boolean;
  48043. FORCENORMALFORWARD: boolean;
  48044. SPECULARAA: boolean;
  48045. CLEARCOAT: boolean;
  48046. CLEARCOAT_DEFAULTIOR: boolean;
  48047. CLEARCOAT_TEXTURE: boolean;
  48048. CLEARCOAT_TEXTUREDIRECTUV: number;
  48049. CLEARCOAT_BUMP: boolean;
  48050. CLEARCOAT_BUMPDIRECTUV: number;
  48051. CLEARCOAT_TINT: boolean;
  48052. CLEARCOAT_TINT_TEXTURE: boolean;
  48053. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48054. ANISOTROPIC: boolean;
  48055. ANISOTROPIC_TEXTURE: boolean;
  48056. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48057. BRDF_V_HEIGHT_CORRELATED: boolean;
  48058. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48059. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48060. SHEEN: boolean;
  48061. SHEEN_TEXTURE: boolean;
  48062. SHEEN_TEXTUREDIRECTUV: number;
  48063. SHEEN_LINKWITHALBEDO: boolean;
  48064. SUBSURFACE: boolean;
  48065. SS_REFRACTION: boolean;
  48066. SS_TRANSLUCENCY: boolean;
  48067. SS_SCATERRING: boolean;
  48068. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48069. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48070. SS_REFRACTIONMAP_3D: boolean;
  48071. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48072. SS_LODINREFRACTIONALPHA: boolean;
  48073. SS_GAMMAREFRACTION: boolean;
  48074. SS_RGBDREFRACTION: boolean;
  48075. SS_LINEARSPECULARREFRACTION: boolean;
  48076. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48077. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48078. UNLIT: boolean;
  48079. DEBUGMODE: number;
  48080. /**
  48081. * Initializes the PBR Material defines.
  48082. */
  48083. constructor();
  48084. /**
  48085. * Resets the PBR Material defines.
  48086. */
  48087. reset(): void;
  48088. }
  48089. /**
  48090. * The Physically based material base class of BJS.
  48091. *
  48092. * This offers the main features of a standard PBR material.
  48093. * For more information, please refer to the documentation :
  48094. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48095. */
  48096. export abstract class PBRBaseMaterial extends PushMaterial {
  48097. /**
  48098. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48099. */
  48100. static readonly PBRMATERIAL_OPAQUE: number;
  48101. /**
  48102. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48103. */
  48104. static readonly PBRMATERIAL_ALPHATEST: number;
  48105. /**
  48106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48107. */
  48108. static readonly PBRMATERIAL_ALPHABLEND: number;
  48109. /**
  48110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48111. * They are also discarded below the alpha cutoff threshold to improve performances.
  48112. */
  48113. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48114. /**
  48115. * Defines the default value of how much AO map is occluding the analytical lights
  48116. * (point spot...).
  48117. */
  48118. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48119. /**
  48120. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48121. */
  48122. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48123. /**
  48124. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48125. * to enhance interoperability with other engines.
  48126. */
  48127. static readonly LIGHTFALLOFF_GLTF: number;
  48128. /**
  48129. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48130. * to enhance interoperability with other materials.
  48131. */
  48132. static readonly LIGHTFALLOFF_STANDARD: number;
  48133. /**
  48134. * Intensity of the direct lights e.g. the four lights available in your scene.
  48135. * This impacts both the direct diffuse and specular highlights.
  48136. */
  48137. protected _directIntensity: number;
  48138. /**
  48139. * Intensity of the emissive part of the material.
  48140. * This helps controlling the emissive effect without modifying the emissive color.
  48141. */
  48142. protected _emissiveIntensity: number;
  48143. /**
  48144. * Intensity of the environment e.g. how much the environment will light the object
  48145. * either through harmonics for rough material or through the refelction for shiny ones.
  48146. */
  48147. protected _environmentIntensity: number;
  48148. /**
  48149. * This is a special control allowing the reduction of the specular highlights coming from the
  48150. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48151. */
  48152. protected _specularIntensity: number;
  48153. /**
  48154. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48155. */
  48156. private _lightingInfos;
  48157. /**
  48158. * Debug Control allowing disabling the bump map on this material.
  48159. */
  48160. protected _disableBumpMap: boolean;
  48161. /**
  48162. * AKA Diffuse Texture in standard nomenclature.
  48163. */
  48164. protected _albedoTexture: Nullable<BaseTexture>;
  48165. /**
  48166. * AKA Occlusion Texture in other nomenclature.
  48167. */
  48168. protected _ambientTexture: Nullable<BaseTexture>;
  48169. /**
  48170. * AKA Occlusion Texture Intensity in other nomenclature.
  48171. */
  48172. protected _ambientTextureStrength: number;
  48173. /**
  48174. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48175. * 1 means it completely occludes it
  48176. * 0 mean it has no impact
  48177. */
  48178. protected _ambientTextureImpactOnAnalyticalLights: number;
  48179. /**
  48180. * Stores the alpha values in a texture.
  48181. */
  48182. protected _opacityTexture: Nullable<BaseTexture>;
  48183. /**
  48184. * Stores the reflection values in a texture.
  48185. */
  48186. protected _reflectionTexture: Nullable<BaseTexture>;
  48187. /**
  48188. * Stores the emissive values in a texture.
  48189. */
  48190. protected _emissiveTexture: Nullable<BaseTexture>;
  48191. /**
  48192. * AKA Specular texture in other nomenclature.
  48193. */
  48194. protected _reflectivityTexture: Nullable<BaseTexture>;
  48195. /**
  48196. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48197. */
  48198. protected _metallicTexture: Nullable<BaseTexture>;
  48199. /**
  48200. * Specifies the metallic scalar of the metallic/roughness workflow.
  48201. * Can also be used to scale the metalness values of the metallic texture.
  48202. */
  48203. protected _metallic: Nullable<number>;
  48204. /**
  48205. * Specifies the roughness scalar of the metallic/roughness workflow.
  48206. * Can also be used to scale the roughness values of the metallic texture.
  48207. */
  48208. protected _roughness: Nullable<number>;
  48209. /**
  48210. * Specifies the an F0 factor to help configuring the material F0.
  48211. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48212. * to 0.5 the previously hard coded value stays the same.
  48213. * Can also be used to scale the F0 values of the metallic texture.
  48214. */
  48215. protected _metallicF0Factor: number;
  48216. /**
  48217. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48218. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48219. * your expectation as it multiplies with the texture data.
  48220. */
  48221. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  48222. /**
  48223. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48224. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48225. */
  48226. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48227. /**
  48228. * Stores surface normal data used to displace a mesh in a texture.
  48229. */
  48230. protected _bumpTexture: Nullable<BaseTexture>;
  48231. /**
  48232. * Stores the pre-calculated light information of a mesh in a texture.
  48233. */
  48234. protected _lightmapTexture: Nullable<BaseTexture>;
  48235. /**
  48236. * The color of a material in ambient lighting.
  48237. */
  48238. protected _ambientColor: Color3;
  48239. /**
  48240. * AKA Diffuse Color in other nomenclature.
  48241. */
  48242. protected _albedoColor: Color3;
  48243. /**
  48244. * AKA Specular Color in other nomenclature.
  48245. */
  48246. protected _reflectivityColor: Color3;
  48247. /**
  48248. * The color applied when light is reflected from a material.
  48249. */
  48250. protected _reflectionColor: Color3;
  48251. /**
  48252. * The color applied when light is emitted from a material.
  48253. */
  48254. protected _emissiveColor: Color3;
  48255. /**
  48256. * AKA Glossiness in other nomenclature.
  48257. */
  48258. protected _microSurface: number;
  48259. /**
  48260. * Specifies that the material will use the light map as a show map.
  48261. */
  48262. protected _useLightmapAsShadowmap: boolean;
  48263. /**
  48264. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48265. * makes the reflect vector face the model (under horizon).
  48266. */
  48267. protected _useHorizonOcclusion: boolean;
  48268. /**
  48269. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48270. * too much the area relying on ambient texture to define their ambient occlusion.
  48271. */
  48272. protected _useRadianceOcclusion: boolean;
  48273. /**
  48274. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48275. */
  48276. protected _useAlphaFromAlbedoTexture: boolean;
  48277. /**
  48278. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48280. */
  48281. protected _useSpecularOverAlpha: boolean;
  48282. /**
  48283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48284. */
  48285. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48286. /**
  48287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48288. */
  48289. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48290. /**
  48291. * Specifies if the metallic texture contains the roughness information in its green channel.
  48292. */
  48293. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48294. /**
  48295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48296. */
  48297. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48298. /**
  48299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48300. */
  48301. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48302. /**
  48303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48304. */
  48305. protected _useAmbientInGrayScale: boolean;
  48306. /**
  48307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48308. * The material will try to infer what glossiness each pixel should be.
  48309. */
  48310. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48311. /**
  48312. * Defines the falloff type used in this material.
  48313. * It by default is Physical.
  48314. */
  48315. protected _lightFalloff: number;
  48316. /**
  48317. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48318. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48319. */
  48320. protected _useRadianceOverAlpha: boolean;
  48321. /**
  48322. * Allows using an object space normal map (instead of tangent space).
  48323. */
  48324. protected _useObjectSpaceNormalMap: boolean;
  48325. /**
  48326. * Allows using the bump map in parallax mode.
  48327. */
  48328. protected _useParallax: boolean;
  48329. /**
  48330. * Allows using the bump map in parallax occlusion mode.
  48331. */
  48332. protected _useParallaxOcclusion: boolean;
  48333. /**
  48334. * Controls the scale bias of the parallax mode.
  48335. */
  48336. protected _parallaxScaleBias: number;
  48337. /**
  48338. * If sets to true, disables all the lights affecting the material.
  48339. */
  48340. protected _disableLighting: boolean;
  48341. /**
  48342. * Number of Simultaneous lights allowed on the material.
  48343. */
  48344. protected _maxSimultaneousLights: number;
  48345. /**
  48346. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48347. */
  48348. protected _invertNormalMapX: boolean;
  48349. /**
  48350. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48351. */
  48352. protected _invertNormalMapY: boolean;
  48353. /**
  48354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48355. */
  48356. protected _twoSidedLighting: boolean;
  48357. /**
  48358. * Defines the alpha limits in alpha test mode.
  48359. */
  48360. protected _alphaCutOff: number;
  48361. /**
  48362. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48363. */
  48364. protected _forceAlphaTest: boolean;
  48365. /**
  48366. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48367. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48368. */
  48369. protected _useAlphaFresnel: boolean;
  48370. /**
  48371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48372. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48373. */
  48374. protected _useLinearAlphaFresnel: boolean;
  48375. /**
  48376. * The transparency mode of the material.
  48377. */
  48378. protected _transparencyMode: Nullable<number>;
  48379. /**
  48380. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48381. * from cos thetav and roughness:
  48382. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48383. */
  48384. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48385. /**
  48386. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48387. */
  48388. protected _forceIrradianceInFragment: boolean;
  48389. /**
  48390. * Force normal to face away from face.
  48391. */
  48392. protected _forceNormalForward: boolean;
  48393. /**
  48394. * Enables specular anti aliasing in the PBR shader.
  48395. * It will both interacts on the Geometry for analytical and IBL lighting.
  48396. * It also prefilter the roughness map based on the bump values.
  48397. */
  48398. protected _enableSpecularAntiAliasing: boolean;
  48399. /**
  48400. * Default configuration related to image processing available in the PBR Material.
  48401. */
  48402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48403. /**
  48404. * Keep track of the image processing observer to allow dispose and replace.
  48405. */
  48406. private _imageProcessingObserver;
  48407. /**
  48408. * Attaches a new image processing configuration to the PBR Material.
  48409. * @param configuration
  48410. */
  48411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48412. /**
  48413. * Stores the available render targets.
  48414. */
  48415. private _renderTargets;
  48416. /**
  48417. * Sets the global ambient color for the material used in lighting calculations.
  48418. */
  48419. private _globalAmbientColor;
  48420. /**
  48421. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48422. */
  48423. private _useLogarithmicDepth;
  48424. /**
  48425. * If set to true, no lighting calculations will be applied.
  48426. */
  48427. private _unlit;
  48428. private _debugMode;
  48429. /**
  48430. * @hidden
  48431. * This is reserved for the inspector.
  48432. * Defines the material debug mode.
  48433. * It helps seeing only some components of the material while troubleshooting.
  48434. */
  48435. debugMode: number;
  48436. /**
  48437. * @hidden
  48438. * This is reserved for the inspector.
  48439. * Specify from where on screen the debug mode should start.
  48440. * The value goes from -1 (full screen) to 1 (not visible)
  48441. * It helps with side by side comparison against the final render
  48442. * This defaults to -1
  48443. */
  48444. private debugLimit;
  48445. /**
  48446. * @hidden
  48447. * This is reserved for the inspector.
  48448. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48449. * You can use the factor to better multiply the final value.
  48450. */
  48451. private debugFactor;
  48452. /**
  48453. * Defines the clear coat layer parameters for the material.
  48454. */
  48455. readonly clearCoat: PBRClearCoatConfiguration;
  48456. /**
  48457. * Defines the anisotropic parameters for the material.
  48458. */
  48459. readonly anisotropy: PBRAnisotropicConfiguration;
  48460. /**
  48461. * Defines the BRDF parameters for the material.
  48462. */
  48463. readonly brdf: PBRBRDFConfiguration;
  48464. /**
  48465. * Defines the Sheen parameters for the material.
  48466. */
  48467. readonly sheen: PBRSheenConfiguration;
  48468. /**
  48469. * Defines the SubSurface parameters for the material.
  48470. */
  48471. readonly subSurface: PBRSubSurfaceConfiguration;
  48472. /**
  48473. * Custom callback helping to override the default shader used in the material.
  48474. */
  48475. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48476. protected _rebuildInParallel: boolean;
  48477. /**
  48478. * Instantiates a new PBRMaterial instance.
  48479. *
  48480. * @param name The material name
  48481. * @param scene The scene the material will be use in.
  48482. */
  48483. constructor(name: string, scene: Scene);
  48484. /**
  48485. * Gets a boolean indicating that current material needs to register RTT
  48486. */
  48487. readonly hasRenderTargetTextures: boolean;
  48488. /**
  48489. * Gets the name of the material class.
  48490. */
  48491. getClassName(): string;
  48492. /**
  48493. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48494. */
  48495. /**
  48496. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48497. */
  48498. useLogarithmicDepth: boolean;
  48499. /**
  48500. * Gets the current transparency mode.
  48501. */
  48502. /**
  48503. * Sets the transparency mode of the material.
  48504. *
  48505. * | Value | Type | Description |
  48506. * | ----- | ----------------------------------- | ----------- |
  48507. * | 0 | OPAQUE | |
  48508. * | 1 | ALPHATEST | |
  48509. * | 2 | ALPHABLEND | |
  48510. * | 3 | ALPHATESTANDBLEND | |
  48511. *
  48512. */
  48513. transparencyMode: Nullable<number>;
  48514. /**
  48515. * Returns true if alpha blending should be disabled.
  48516. */
  48517. private readonly _disableAlphaBlending;
  48518. /**
  48519. * Specifies whether or not this material should be rendered in alpha blend mode.
  48520. */
  48521. needAlphaBlending(): boolean;
  48522. /**
  48523. * Specifies if the mesh will require alpha blending.
  48524. * @param mesh - BJS mesh.
  48525. */
  48526. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48527. /**
  48528. * Specifies whether or not this material should be rendered in alpha test mode.
  48529. */
  48530. needAlphaTesting(): boolean;
  48531. /**
  48532. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48533. */
  48534. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48535. /**
  48536. * Gets the texture used for the alpha test.
  48537. */
  48538. getAlphaTestTexture(): Nullable<BaseTexture>;
  48539. /**
  48540. * Specifies that the submesh is ready to be used.
  48541. * @param mesh - BJS mesh.
  48542. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48543. * @param useInstances - Specifies that instances should be used.
  48544. * @returns - boolean indicating that the submesh is ready or not.
  48545. */
  48546. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48547. /**
  48548. * Specifies if the material uses metallic roughness workflow.
  48549. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48550. */
  48551. isMetallicWorkflow(): boolean;
  48552. private _prepareEffect;
  48553. private _prepareDefines;
  48554. /**
  48555. * Force shader compilation
  48556. */
  48557. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  48558. /**
  48559. * Initializes the uniform buffer layout for the shader.
  48560. */
  48561. buildUniformLayout(): void;
  48562. /**
  48563. * Unbinds the material from the mesh
  48564. */
  48565. unbind(): void;
  48566. /**
  48567. * Binds the submesh data.
  48568. * @param world - The world matrix.
  48569. * @param mesh - The BJS mesh.
  48570. * @param subMesh - A submesh of the BJS mesh.
  48571. */
  48572. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48573. /**
  48574. * Returns the animatable textures.
  48575. * @returns - Array of animatable textures.
  48576. */
  48577. getAnimatables(): IAnimatable[];
  48578. /**
  48579. * Returns the texture used for reflections.
  48580. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48581. */
  48582. private _getReflectionTexture;
  48583. /**
  48584. * Returns an array of the actively used textures.
  48585. * @returns - Array of BaseTextures
  48586. */
  48587. getActiveTextures(): BaseTexture[];
  48588. /**
  48589. * Checks to see if a texture is used in the material.
  48590. * @param texture - Base texture to use.
  48591. * @returns - Boolean specifying if a texture is used in the material.
  48592. */
  48593. hasTexture(texture: BaseTexture): boolean;
  48594. /**
  48595. * Disposes the resources of the material.
  48596. * @param forceDisposeEffect - Forces the disposal of effects.
  48597. * @param forceDisposeTextures - Forces the disposal of all textures.
  48598. */
  48599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48600. }
  48601. }
  48602. declare module BABYLON {
  48603. /**
  48604. * The Physically based material of BJS.
  48605. *
  48606. * This offers the main features of a standard PBR material.
  48607. * For more information, please refer to the documentation :
  48608. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48609. */
  48610. export class PBRMaterial extends PBRBaseMaterial {
  48611. /**
  48612. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48613. */
  48614. static readonly PBRMATERIAL_OPAQUE: number;
  48615. /**
  48616. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48617. */
  48618. static readonly PBRMATERIAL_ALPHATEST: number;
  48619. /**
  48620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48621. */
  48622. static readonly PBRMATERIAL_ALPHABLEND: number;
  48623. /**
  48624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48625. * They are also discarded below the alpha cutoff threshold to improve performances.
  48626. */
  48627. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48628. /**
  48629. * Defines the default value of how much AO map is occluding the analytical lights
  48630. * (point spot...).
  48631. */
  48632. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48633. /**
  48634. * Intensity of the direct lights e.g. the four lights available in your scene.
  48635. * This impacts both the direct diffuse and specular highlights.
  48636. */
  48637. directIntensity: number;
  48638. /**
  48639. * Intensity of the emissive part of the material.
  48640. * This helps controlling the emissive effect without modifying the emissive color.
  48641. */
  48642. emissiveIntensity: number;
  48643. /**
  48644. * Intensity of the environment e.g. how much the environment will light the object
  48645. * either through harmonics for rough material or through the refelction for shiny ones.
  48646. */
  48647. environmentIntensity: number;
  48648. /**
  48649. * This is a special control allowing the reduction of the specular highlights coming from the
  48650. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48651. */
  48652. specularIntensity: number;
  48653. /**
  48654. * Debug Control allowing disabling the bump map on this material.
  48655. */
  48656. disableBumpMap: boolean;
  48657. /**
  48658. * AKA Diffuse Texture in standard nomenclature.
  48659. */
  48660. albedoTexture: BaseTexture;
  48661. /**
  48662. * AKA Occlusion Texture in other nomenclature.
  48663. */
  48664. ambientTexture: BaseTexture;
  48665. /**
  48666. * AKA Occlusion Texture Intensity in other nomenclature.
  48667. */
  48668. ambientTextureStrength: number;
  48669. /**
  48670. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48671. * 1 means it completely occludes it
  48672. * 0 mean it has no impact
  48673. */
  48674. ambientTextureImpactOnAnalyticalLights: number;
  48675. /**
  48676. * Stores the alpha values in a texture.
  48677. */
  48678. opacityTexture: BaseTexture;
  48679. /**
  48680. * Stores the reflection values in a texture.
  48681. */
  48682. reflectionTexture: Nullable<BaseTexture>;
  48683. /**
  48684. * Stores the emissive values in a texture.
  48685. */
  48686. emissiveTexture: BaseTexture;
  48687. /**
  48688. * AKA Specular texture in other nomenclature.
  48689. */
  48690. reflectivityTexture: BaseTexture;
  48691. /**
  48692. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48693. */
  48694. metallicTexture: BaseTexture;
  48695. /**
  48696. * Specifies the metallic scalar of the metallic/roughness workflow.
  48697. * Can also be used to scale the metalness values of the metallic texture.
  48698. */
  48699. metallic: Nullable<number>;
  48700. /**
  48701. * Specifies the roughness scalar of the metallic/roughness workflow.
  48702. * Can also be used to scale the roughness values of the metallic texture.
  48703. */
  48704. roughness: Nullable<number>;
  48705. /**
  48706. * Specifies the an F0 factor to help configuring the material F0.
  48707. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  48708. * to 0.5 the previously hard coded value stays the same.
  48709. * Can also be used to scale the F0 values of the metallic texture.
  48710. */
  48711. metallicF0Factor: number;
  48712. /**
  48713. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  48714. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  48715. * your expectation as it multiplies with the texture data.
  48716. */
  48717. useMetallicF0FactorFromMetallicTexture: boolean;
  48718. /**
  48719. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48720. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48721. */
  48722. microSurfaceTexture: BaseTexture;
  48723. /**
  48724. * Stores surface normal data used to displace a mesh in a texture.
  48725. */
  48726. bumpTexture: BaseTexture;
  48727. /**
  48728. * Stores the pre-calculated light information of a mesh in a texture.
  48729. */
  48730. lightmapTexture: BaseTexture;
  48731. /**
  48732. * Stores the refracted light information in a texture.
  48733. */
  48734. refractionTexture: Nullable<BaseTexture>;
  48735. /**
  48736. * The color of a material in ambient lighting.
  48737. */
  48738. ambientColor: Color3;
  48739. /**
  48740. * AKA Diffuse Color in other nomenclature.
  48741. */
  48742. albedoColor: Color3;
  48743. /**
  48744. * AKA Specular Color in other nomenclature.
  48745. */
  48746. reflectivityColor: Color3;
  48747. /**
  48748. * The color reflected from the material.
  48749. */
  48750. reflectionColor: Color3;
  48751. /**
  48752. * The color emitted from the material.
  48753. */
  48754. emissiveColor: Color3;
  48755. /**
  48756. * AKA Glossiness in other nomenclature.
  48757. */
  48758. microSurface: number;
  48759. /**
  48760. * source material index of refraction (IOR)' / 'destination material IOR.
  48761. */
  48762. indexOfRefraction: number;
  48763. /**
  48764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48765. */
  48766. invertRefractionY: boolean;
  48767. /**
  48768. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48769. * Materials half opaque for instance using refraction could benefit from this control.
  48770. */
  48771. linkRefractionWithTransparency: boolean;
  48772. /**
  48773. * If true, the light map contains occlusion information instead of lighting info.
  48774. */
  48775. useLightmapAsShadowmap: boolean;
  48776. /**
  48777. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48778. */
  48779. useAlphaFromAlbedoTexture: boolean;
  48780. /**
  48781. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48782. */
  48783. forceAlphaTest: boolean;
  48784. /**
  48785. * Defines the alpha limits in alpha test mode.
  48786. */
  48787. alphaCutOff: number;
  48788. /**
  48789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48791. */
  48792. useSpecularOverAlpha: boolean;
  48793. /**
  48794. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48795. */
  48796. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48797. /**
  48798. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48799. */
  48800. useRoughnessFromMetallicTextureAlpha: boolean;
  48801. /**
  48802. * Specifies if the metallic texture contains the roughness information in its green channel.
  48803. */
  48804. useRoughnessFromMetallicTextureGreen: boolean;
  48805. /**
  48806. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48807. */
  48808. useMetallnessFromMetallicTextureBlue: boolean;
  48809. /**
  48810. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48811. */
  48812. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48813. /**
  48814. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48815. */
  48816. useAmbientInGrayScale: boolean;
  48817. /**
  48818. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48819. * The material will try to infer what glossiness each pixel should be.
  48820. */
  48821. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48822. /**
  48823. * BJS is using an harcoded light falloff based on a manually sets up range.
  48824. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48825. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48826. */
  48827. /**
  48828. * BJS is using an harcoded light falloff based on a manually sets up range.
  48829. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48830. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48831. */
  48832. usePhysicalLightFalloff: boolean;
  48833. /**
  48834. * In order to support the falloff compatibility with gltf, a special mode has been added
  48835. * to reproduce the gltf light falloff.
  48836. */
  48837. /**
  48838. * In order to support the falloff compatibility with gltf, a special mode has been added
  48839. * to reproduce the gltf light falloff.
  48840. */
  48841. useGLTFLightFalloff: boolean;
  48842. /**
  48843. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48844. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48845. */
  48846. useRadianceOverAlpha: boolean;
  48847. /**
  48848. * Allows using an object space normal map (instead of tangent space).
  48849. */
  48850. useObjectSpaceNormalMap: boolean;
  48851. /**
  48852. * Allows using the bump map in parallax mode.
  48853. */
  48854. useParallax: boolean;
  48855. /**
  48856. * Allows using the bump map in parallax occlusion mode.
  48857. */
  48858. useParallaxOcclusion: boolean;
  48859. /**
  48860. * Controls the scale bias of the parallax mode.
  48861. */
  48862. parallaxScaleBias: number;
  48863. /**
  48864. * If sets to true, disables all the lights affecting the material.
  48865. */
  48866. disableLighting: boolean;
  48867. /**
  48868. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48869. */
  48870. forceIrradianceInFragment: boolean;
  48871. /**
  48872. * Number of Simultaneous lights allowed on the material.
  48873. */
  48874. maxSimultaneousLights: number;
  48875. /**
  48876. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48877. */
  48878. invertNormalMapX: boolean;
  48879. /**
  48880. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48881. */
  48882. invertNormalMapY: boolean;
  48883. /**
  48884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48885. */
  48886. twoSidedLighting: boolean;
  48887. /**
  48888. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48889. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48890. */
  48891. useAlphaFresnel: boolean;
  48892. /**
  48893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48894. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48895. */
  48896. useLinearAlphaFresnel: boolean;
  48897. /**
  48898. * Let user defines the brdf lookup texture used for IBL.
  48899. * A default 8bit version is embedded but you could point at :
  48900. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48901. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48902. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48903. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48904. */
  48905. environmentBRDFTexture: Nullable<BaseTexture>;
  48906. /**
  48907. * Force normal to face away from face.
  48908. */
  48909. forceNormalForward: boolean;
  48910. /**
  48911. * Enables specular anti aliasing in the PBR shader.
  48912. * It will both interacts on the Geometry for analytical and IBL lighting.
  48913. * It also prefilter the roughness map based on the bump values.
  48914. */
  48915. enableSpecularAntiAliasing: boolean;
  48916. /**
  48917. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48918. * makes the reflect vector face the model (under horizon).
  48919. */
  48920. useHorizonOcclusion: boolean;
  48921. /**
  48922. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48923. * too much the area relying on ambient texture to define their ambient occlusion.
  48924. */
  48925. useRadianceOcclusion: boolean;
  48926. /**
  48927. * If set to true, no lighting calculations will be applied.
  48928. */
  48929. unlit: boolean;
  48930. /**
  48931. * Gets the image processing configuration used either in this material.
  48932. */
  48933. /**
  48934. * Sets the Default image processing configuration used either in the this material.
  48935. *
  48936. * If sets to null, the scene one is in use.
  48937. */
  48938. imageProcessingConfiguration: ImageProcessingConfiguration;
  48939. /**
  48940. * Gets wether the color curves effect is enabled.
  48941. */
  48942. /**
  48943. * Sets wether the color curves effect is enabled.
  48944. */
  48945. cameraColorCurvesEnabled: boolean;
  48946. /**
  48947. * Gets wether the color grading effect is enabled.
  48948. */
  48949. /**
  48950. * Gets wether the color grading effect is enabled.
  48951. */
  48952. cameraColorGradingEnabled: boolean;
  48953. /**
  48954. * Gets wether tonemapping is enabled or not.
  48955. */
  48956. /**
  48957. * Sets wether tonemapping is enabled or not
  48958. */
  48959. cameraToneMappingEnabled: boolean;
  48960. /**
  48961. * The camera exposure used on this material.
  48962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48963. * This corresponds to a photographic exposure.
  48964. */
  48965. /**
  48966. * The camera exposure used on this material.
  48967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48968. * This corresponds to a photographic exposure.
  48969. */
  48970. cameraExposure: number;
  48971. /**
  48972. * Gets The camera contrast used on this material.
  48973. */
  48974. /**
  48975. * Sets The camera contrast used on this material.
  48976. */
  48977. cameraContrast: number;
  48978. /**
  48979. * Gets the Color Grading 2D Lookup Texture.
  48980. */
  48981. /**
  48982. * Sets the Color Grading 2D Lookup Texture.
  48983. */
  48984. cameraColorGradingTexture: Nullable<BaseTexture>;
  48985. /**
  48986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48988. * 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;
  48989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48990. */
  48991. /**
  48992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48994. * 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;
  48995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48996. */
  48997. cameraColorCurves: Nullable<ColorCurves>;
  48998. /**
  48999. * Instantiates a new PBRMaterial instance.
  49000. *
  49001. * @param name The material name
  49002. * @param scene The scene the material will be use in.
  49003. */
  49004. constructor(name: string, scene: Scene);
  49005. /**
  49006. * Returns the name of this material class.
  49007. */
  49008. getClassName(): string;
  49009. /**
  49010. * Makes a duplicate of the current material.
  49011. * @param name - name to use for the new material.
  49012. */
  49013. clone(name: string): PBRMaterial;
  49014. /**
  49015. * Serializes this PBR Material.
  49016. * @returns - An object with the serialized material.
  49017. */
  49018. serialize(): any;
  49019. /**
  49020. * Parses a PBR Material from a serialized object.
  49021. * @param source - Serialized object.
  49022. * @param scene - BJS scene instance.
  49023. * @param rootUrl - url for the scene object
  49024. * @returns - PBRMaterial
  49025. */
  49026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49027. }
  49028. }
  49029. declare module BABYLON {
  49030. /**
  49031. * Direct draw surface info
  49032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49033. */
  49034. export interface DDSInfo {
  49035. /**
  49036. * Width of the texture
  49037. */
  49038. width: number;
  49039. /**
  49040. * Width of the texture
  49041. */
  49042. height: number;
  49043. /**
  49044. * Number of Mipmaps for the texture
  49045. * @see https://en.wikipedia.org/wiki/Mipmap
  49046. */
  49047. mipmapCount: number;
  49048. /**
  49049. * If the textures format is a known fourCC format
  49050. * @see https://www.fourcc.org/
  49051. */
  49052. isFourCC: boolean;
  49053. /**
  49054. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49055. */
  49056. isRGB: boolean;
  49057. /**
  49058. * If the texture is a lumincance format
  49059. */
  49060. isLuminance: boolean;
  49061. /**
  49062. * If this is a cube texture
  49063. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49064. */
  49065. isCube: boolean;
  49066. /**
  49067. * If the texture is a compressed format eg. FOURCC_DXT1
  49068. */
  49069. isCompressed: boolean;
  49070. /**
  49071. * The dxgiFormat of the texture
  49072. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49073. */
  49074. dxgiFormat: number;
  49075. /**
  49076. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49077. */
  49078. textureType: number;
  49079. /**
  49080. * Sphericle polynomial created for the dds texture
  49081. */
  49082. sphericalPolynomial?: SphericalPolynomial;
  49083. }
  49084. /**
  49085. * Class used to provide DDS decompression tools
  49086. */
  49087. export class DDSTools {
  49088. /**
  49089. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49090. */
  49091. static StoreLODInAlphaChannel: boolean;
  49092. /**
  49093. * Gets DDS information from an array buffer
  49094. * @param arrayBuffer defines the array buffer to read data from
  49095. * @returns the DDS information
  49096. */
  49097. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49098. private static _FloatView;
  49099. private static _Int32View;
  49100. private static _ToHalfFloat;
  49101. private static _FromHalfFloat;
  49102. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49103. private static _GetHalfFloatRGBAArrayBuffer;
  49104. private static _GetFloatRGBAArrayBuffer;
  49105. private static _GetFloatAsUIntRGBAArrayBuffer;
  49106. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49107. private static _GetRGBAArrayBuffer;
  49108. private static _ExtractLongWordOrder;
  49109. private static _GetRGBArrayBuffer;
  49110. private static _GetLuminanceArrayBuffer;
  49111. /**
  49112. * Uploads DDS Levels to a Babylon Texture
  49113. * @hidden
  49114. */
  49115. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49116. }
  49117. interface ThinEngine {
  49118. /**
  49119. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49120. * @param rootUrl defines the url where the file to load is located
  49121. * @param scene defines the current scene
  49122. * @param lodScale defines scale to apply to the mip map selection
  49123. * @param lodOffset defines offset to apply to the mip map selection
  49124. * @param onLoad defines an optional callback raised when the texture is loaded
  49125. * @param onError defines an optional callback raised if there is an issue to load the texture
  49126. * @param format defines the format of the data
  49127. * @param forcedExtension defines the extension to use to pick the right loader
  49128. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49129. * @returns the cube texture as an InternalTexture
  49130. */
  49131. 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;
  49132. }
  49133. }
  49134. declare module BABYLON {
  49135. /**
  49136. * Implementation of the DDS Texture Loader.
  49137. * @hidden
  49138. */
  49139. export class _DDSTextureLoader implements IInternalTextureLoader {
  49140. /**
  49141. * Defines wether the loader supports cascade loading the different faces.
  49142. */
  49143. readonly supportCascades: boolean;
  49144. /**
  49145. * This returns if the loader support the current file information.
  49146. * @param extension defines the file extension of the file being loaded
  49147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49148. * @param fallback defines the fallback internal texture if any
  49149. * @param isBase64 defines whether the texture is encoded as a base64
  49150. * @param isBuffer defines whether the texture data are stored as a buffer
  49151. * @returns true if the loader can load the specified file
  49152. */
  49153. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49154. /**
  49155. * Transform the url before loading if required.
  49156. * @param rootUrl the url of the texture
  49157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49158. * @returns the transformed texture
  49159. */
  49160. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49161. /**
  49162. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49163. * @param rootUrl the url of the texture
  49164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49165. * @returns the fallback texture
  49166. */
  49167. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49168. /**
  49169. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49170. * @param data contains the texture data
  49171. * @param texture defines the BabylonJS internal texture
  49172. * @param createPolynomials will be true if polynomials have been requested
  49173. * @param onLoad defines the callback to trigger once the texture is ready
  49174. * @param onError defines the callback to trigger in case of error
  49175. */
  49176. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49177. /**
  49178. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49179. * @param data contains the texture data
  49180. * @param texture defines the BabylonJS internal texture
  49181. * @param callback defines the method to call once ready to upload
  49182. */
  49183. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49184. }
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Implementation of the ENV Texture Loader.
  49189. * @hidden
  49190. */
  49191. export class _ENVTextureLoader implements IInternalTextureLoader {
  49192. /**
  49193. * Defines wether the loader supports cascade loading the different faces.
  49194. */
  49195. readonly supportCascades: boolean;
  49196. /**
  49197. * This returns if the loader support the current file information.
  49198. * @param extension defines the file extension of the file being loaded
  49199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49200. * @param fallback defines the fallback internal texture if any
  49201. * @param isBase64 defines whether the texture is encoded as a base64
  49202. * @param isBuffer defines whether the texture data are stored as a buffer
  49203. * @returns true if the loader can load the specified file
  49204. */
  49205. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49206. /**
  49207. * Transform the url before loading if required.
  49208. * @param rootUrl the url of the texture
  49209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49210. * @returns the transformed texture
  49211. */
  49212. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49213. /**
  49214. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49215. * @param rootUrl the url of the texture
  49216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49217. * @returns the fallback texture
  49218. */
  49219. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49220. /**
  49221. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49222. * @param data contains the texture data
  49223. * @param texture defines the BabylonJS internal texture
  49224. * @param createPolynomials will be true if polynomials have been requested
  49225. * @param onLoad defines the callback to trigger once the texture is ready
  49226. * @param onError defines the callback to trigger in case of error
  49227. */
  49228. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49229. /**
  49230. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49231. * @param data contains the texture data
  49232. * @param texture defines the BabylonJS internal texture
  49233. * @param callback defines the method to call once ready to upload
  49234. */
  49235. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49236. }
  49237. }
  49238. declare module BABYLON {
  49239. /**
  49240. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49241. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49242. */
  49243. export class KhronosTextureContainer {
  49244. /** contents of the KTX container file */
  49245. arrayBuffer: any;
  49246. private static HEADER_LEN;
  49247. private static COMPRESSED_2D;
  49248. private static COMPRESSED_3D;
  49249. private static TEX_2D;
  49250. private static TEX_3D;
  49251. /**
  49252. * Gets the openGL type
  49253. */
  49254. glType: number;
  49255. /**
  49256. * Gets the openGL type size
  49257. */
  49258. glTypeSize: number;
  49259. /**
  49260. * Gets the openGL format
  49261. */
  49262. glFormat: number;
  49263. /**
  49264. * Gets the openGL internal format
  49265. */
  49266. glInternalFormat: number;
  49267. /**
  49268. * Gets the base internal format
  49269. */
  49270. glBaseInternalFormat: number;
  49271. /**
  49272. * Gets image width in pixel
  49273. */
  49274. pixelWidth: number;
  49275. /**
  49276. * Gets image height in pixel
  49277. */
  49278. pixelHeight: number;
  49279. /**
  49280. * Gets image depth in pixels
  49281. */
  49282. pixelDepth: number;
  49283. /**
  49284. * Gets the number of array elements
  49285. */
  49286. numberOfArrayElements: number;
  49287. /**
  49288. * Gets the number of faces
  49289. */
  49290. numberOfFaces: number;
  49291. /**
  49292. * Gets the number of mipmap levels
  49293. */
  49294. numberOfMipmapLevels: number;
  49295. /**
  49296. * Gets the bytes of key value data
  49297. */
  49298. bytesOfKeyValueData: number;
  49299. /**
  49300. * Gets the load type
  49301. */
  49302. loadType: number;
  49303. /**
  49304. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49305. */
  49306. isInvalid: boolean;
  49307. /**
  49308. * Creates a new KhronosTextureContainer
  49309. * @param arrayBuffer contents of the KTX container file
  49310. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49311. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49312. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49313. */
  49314. constructor(
  49315. /** contents of the KTX container file */
  49316. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49317. /**
  49318. * Uploads KTX content to a Babylon Texture.
  49319. * It is assumed that the texture has already been created & is currently bound
  49320. * @hidden
  49321. */
  49322. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49323. private _upload2DCompressedLevels;
  49324. }
  49325. }
  49326. declare module BABYLON {
  49327. /**
  49328. * Implementation of the KTX Texture Loader.
  49329. * @hidden
  49330. */
  49331. export class _KTXTextureLoader implements IInternalTextureLoader {
  49332. /**
  49333. * Defines wether the loader supports cascade loading the different faces.
  49334. */
  49335. readonly supportCascades: boolean;
  49336. /**
  49337. * This returns if the loader support the current file information.
  49338. * @param extension defines the file extension of the file being loaded
  49339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49340. * @param fallback defines the fallback internal texture if any
  49341. * @param isBase64 defines whether the texture is encoded as a base64
  49342. * @param isBuffer defines whether the texture data are stored as a buffer
  49343. * @returns true if the loader can load the specified file
  49344. */
  49345. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49346. /**
  49347. * Transform the url before loading if required.
  49348. * @param rootUrl the url of the texture
  49349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49350. * @returns the transformed texture
  49351. */
  49352. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49353. /**
  49354. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49355. * @param rootUrl the url of the texture
  49356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49357. * @returns the fallback texture
  49358. */
  49359. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49360. /**
  49361. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49362. * @param data contains the texture data
  49363. * @param texture defines the BabylonJS internal texture
  49364. * @param createPolynomials will be true if polynomials have been requested
  49365. * @param onLoad defines the callback to trigger once the texture is ready
  49366. * @param onError defines the callback to trigger in case of error
  49367. */
  49368. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49369. /**
  49370. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49371. * @param data contains the texture data
  49372. * @param texture defines the BabylonJS internal texture
  49373. * @param callback defines the method to call once ready to upload
  49374. */
  49375. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49376. }
  49377. }
  49378. declare module BABYLON {
  49379. /**
  49380. * Options for the default xr helper
  49381. */
  49382. export class WebXRDefaultExperienceOptions {
  49383. /**
  49384. * Floor meshes that should be used for teleporting
  49385. */
  49386. floorMeshes: Array<AbstractMesh>;
  49387. /**
  49388. * Enable or disable default UI to enter XR
  49389. */
  49390. disableDefaultUI: boolean;
  49391. }
  49392. /**
  49393. * Default experience which provides a similar setup to the previous webVRExperience
  49394. */
  49395. export class WebXRDefaultExperience {
  49396. /**
  49397. * Base experience
  49398. */
  49399. baseExperience: WebXRExperienceHelper;
  49400. /**
  49401. * Input experience extension
  49402. */
  49403. input: WebXRInput;
  49404. /**
  49405. * Loads the controller models
  49406. */
  49407. controllerModelLoader: WebXRControllerModelLoader;
  49408. /**
  49409. * Enables laser pointer and selection
  49410. */
  49411. pointerSelection: WebXRControllerPointerSelection;
  49412. /**
  49413. * Enables teleportation
  49414. */
  49415. teleportation: WebXRControllerTeleportation;
  49416. /**
  49417. * Enables ui for enetering/exiting xr
  49418. */
  49419. enterExitUI: WebXREnterExitUI;
  49420. /**
  49421. * Default target xr should render to
  49422. */
  49423. renderTarget: WebXRRenderTarget;
  49424. /**
  49425. * Creates the default xr experience
  49426. * @param scene scene
  49427. * @param options options for basic configuration
  49428. * @returns resulting WebXRDefaultExperience
  49429. */
  49430. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49431. private constructor();
  49432. /**
  49433. * DIsposes of the experience helper
  49434. */
  49435. dispose(): void;
  49436. }
  49437. }
  49438. declare module BABYLON {
  49439. /** @hidden */
  49440. export var _forceSceneHelpersToBundle: boolean;
  49441. interface Scene {
  49442. /**
  49443. * Creates a default light for the scene.
  49444. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49445. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49446. */
  49447. createDefaultLight(replace?: boolean): void;
  49448. /**
  49449. * Creates a default camera for the scene.
  49450. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49451. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49452. * @param replace has default false, when true replaces the active camera in the scene
  49453. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49454. */
  49455. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49456. /**
  49457. * Creates a default camera and a default light.
  49458. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49459. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49460. * @param replace has the default false, when true replaces the active camera/light in the scene
  49461. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49462. */
  49463. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49464. /**
  49465. * Creates a new sky box
  49466. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49467. * @param environmentTexture defines the texture to use as environment texture
  49468. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49469. * @param scale defines the overall scale of the skybox
  49470. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49471. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49472. * @returns a new mesh holding the sky box
  49473. */
  49474. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49475. /**
  49476. * Creates a new environment
  49477. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49478. * @param options defines the options you can use to configure the environment
  49479. * @returns the new EnvironmentHelper
  49480. */
  49481. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49482. /**
  49483. * Creates a new VREXperienceHelper
  49484. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49485. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49486. * @returns a new VREXperienceHelper
  49487. */
  49488. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49489. /**
  49490. * Creates a new WebXRDefaultExperience
  49491. * @see http://doc.babylonjs.com/how_to/webxr
  49492. * @param options experience options
  49493. * @returns a promise for a new WebXRDefaultExperience
  49494. */
  49495. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49496. }
  49497. }
  49498. declare module BABYLON {
  49499. /**
  49500. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49501. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49502. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49503. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49504. */
  49505. export class VideoDome extends TransformNode {
  49506. /**
  49507. * Define the video source as a Monoscopic panoramic 360 video.
  49508. */
  49509. static readonly MODE_MONOSCOPIC: number;
  49510. /**
  49511. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49512. */
  49513. static readonly MODE_TOPBOTTOM: number;
  49514. /**
  49515. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49516. */
  49517. static readonly MODE_SIDEBYSIDE: number;
  49518. private _halfDome;
  49519. private _useDirectMapping;
  49520. /**
  49521. * The video texture being displayed on the sphere
  49522. */
  49523. protected _videoTexture: VideoTexture;
  49524. /**
  49525. * Gets the video texture being displayed on the sphere
  49526. */
  49527. readonly videoTexture: VideoTexture;
  49528. /**
  49529. * The skybox material
  49530. */
  49531. protected _material: BackgroundMaterial;
  49532. /**
  49533. * The surface used for the skybox
  49534. */
  49535. protected _mesh: Mesh;
  49536. /**
  49537. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49538. */
  49539. private _halfDomeMask;
  49540. /**
  49541. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49542. * Also see the options.resolution property.
  49543. */
  49544. fovMultiplier: number;
  49545. private _videoMode;
  49546. /**
  49547. * Gets or set the current video mode for the video. It can be:
  49548. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49549. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49550. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49551. */
  49552. videoMode: number;
  49553. /**
  49554. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49555. *
  49556. */
  49557. /**
  49558. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49559. */
  49560. halfDome: boolean;
  49561. /**
  49562. * Oberserver used in Stereoscopic VR Mode.
  49563. */
  49564. private _onBeforeCameraRenderObserver;
  49565. /**
  49566. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49567. * @param name Element's name, child elements will append suffixes for their own names.
  49568. * @param urlsOrVideo defines the url(s) or the video element to use
  49569. * @param options An object containing optional or exposed sub element properties
  49570. */
  49571. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49572. resolution?: number;
  49573. clickToPlay?: boolean;
  49574. autoPlay?: boolean;
  49575. loop?: boolean;
  49576. size?: number;
  49577. poster?: string;
  49578. faceForward?: boolean;
  49579. useDirectMapping?: boolean;
  49580. halfDomeMode?: boolean;
  49581. }, scene: Scene);
  49582. private _changeVideoMode;
  49583. /**
  49584. * Releases resources associated with this node.
  49585. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49586. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49587. */
  49588. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * This class can be used to get instrumentation data from a Babylon engine
  49594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49595. */
  49596. export class EngineInstrumentation implements IDisposable {
  49597. /**
  49598. * Define the instrumented engine.
  49599. */
  49600. engine: Engine;
  49601. private _captureGPUFrameTime;
  49602. private _gpuFrameTimeToken;
  49603. private _gpuFrameTime;
  49604. private _captureShaderCompilationTime;
  49605. private _shaderCompilationTime;
  49606. private _onBeginFrameObserver;
  49607. private _onEndFrameObserver;
  49608. private _onBeforeShaderCompilationObserver;
  49609. private _onAfterShaderCompilationObserver;
  49610. /**
  49611. * Gets the perf counter used for GPU frame time
  49612. */
  49613. readonly gpuFrameTimeCounter: PerfCounter;
  49614. /**
  49615. * Gets the GPU frame time capture status
  49616. */
  49617. /**
  49618. * Enable or disable the GPU frame time capture
  49619. */
  49620. captureGPUFrameTime: boolean;
  49621. /**
  49622. * Gets the perf counter used for shader compilation time
  49623. */
  49624. readonly shaderCompilationTimeCounter: PerfCounter;
  49625. /**
  49626. * Gets the shader compilation time capture status
  49627. */
  49628. /**
  49629. * Enable or disable the shader compilation time capture
  49630. */
  49631. captureShaderCompilationTime: boolean;
  49632. /**
  49633. * Instantiates a new engine instrumentation.
  49634. * This class can be used to get instrumentation data from a Babylon engine
  49635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49636. * @param engine Defines the engine to instrument
  49637. */
  49638. constructor(
  49639. /**
  49640. * Define the instrumented engine.
  49641. */
  49642. engine: Engine);
  49643. /**
  49644. * Dispose and release associated resources.
  49645. */
  49646. dispose(): void;
  49647. }
  49648. }
  49649. declare module BABYLON {
  49650. /**
  49651. * This class can be used to get instrumentation data from a Babylon engine
  49652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49653. */
  49654. export class SceneInstrumentation implements IDisposable {
  49655. /**
  49656. * Defines the scene to instrument
  49657. */
  49658. scene: Scene;
  49659. private _captureActiveMeshesEvaluationTime;
  49660. private _activeMeshesEvaluationTime;
  49661. private _captureRenderTargetsRenderTime;
  49662. private _renderTargetsRenderTime;
  49663. private _captureFrameTime;
  49664. private _frameTime;
  49665. private _captureRenderTime;
  49666. private _renderTime;
  49667. private _captureInterFrameTime;
  49668. private _interFrameTime;
  49669. private _captureParticlesRenderTime;
  49670. private _particlesRenderTime;
  49671. private _captureSpritesRenderTime;
  49672. private _spritesRenderTime;
  49673. private _capturePhysicsTime;
  49674. private _physicsTime;
  49675. private _captureAnimationsTime;
  49676. private _animationsTime;
  49677. private _captureCameraRenderTime;
  49678. private _cameraRenderTime;
  49679. private _onBeforeActiveMeshesEvaluationObserver;
  49680. private _onAfterActiveMeshesEvaluationObserver;
  49681. private _onBeforeRenderTargetsRenderObserver;
  49682. private _onAfterRenderTargetsRenderObserver;
  49683. private _onAfterRenderObserver;
  49684. private _onBeforeDrawPhaseObserver;
  49685. private _onAfterDrawPhaseObserver;
  49686. private _onBeforeAnimationsObserver;
  49687. private _onBeforeParticlesRenderingObserver;
  49688. private _onAfterParticlesRenderingObserver;
  49689. private _onBeforeSpritesRenderingObserver;
  49690. private _onAfterSpritesRenderingObserver;
  49691. private _onBeforePhysicsObserver;
  49692. private _onAfterPhysicsObserver;
  49693. private _onAfterAnimationsObserver;
  49694. private _onBeforeCameraRenderObserver;
  49695. private _onAfterCameraRenderObserver;
  49696. /**
  49697. * Gets the perf counter used for active meshes evaluation time
  49698. */
  49699. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49700. /**
  49701. * Gets the active meshes evaluation time capture status
  49702. */
  49703. /**
  49704. * Enable or disable the active meshes evaluation time capture
  49705. */
  49706. captureActiveMeshesEvaluationTime: boolean;
  49707. /**
  49708. * Gets the perf counter used for render targets render time
  49709. */
  49710. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49711. /**
  49712. * Gets the render targets render time capture status
  49713. */
  49714. /**
  49715. * Enable or disable the render targets render time capture
  49716. */
  49717. captureRenderTargetsRenderTime: boolean;
  49718. /**
  49719. * Gets the perf counter used for particles render time
  49720. */
  49721. readonly particlesRenderTimeCounter: PerfCounter;
  49722. /**
  49723. * Gets the particles render time capture status
  49724. */
  49725. /**
  49726. * Enable or disable the particles render time capture
  49727. */
  49728. captureParticlesRenderTime: boolean;
  49729. /**
  49730. * Gets the perf counter used for sprites render time
  49731. */
  49732. readonly spritesRenderTimeCounter: PerfCounter;
  49733. /**
  49734. * Gets the sprites render time capture status
  49735. */
  49736. /**
  49737. * Enable or disable the sprites render time capture
  49738. */
  49739. captureSpritesRenderTime: boolean;
  49740. /**
  49741. * Gets the perf counter used for physics time
  49742. */
  49743. readonly physicsTimeCounter: PerfCounter;
  49744. /**
  49745. * Gets the physics time capture status
  49746. */
  49747. /**
  49748. * Enable or disable the physics time capture
  49749. */
  49750. capturePhysicsTime: boolean;
  49751. /**
  49752. * Gets the perf counter used for animations time
  49753. */
  49754. readonly animationsTimeCounter: PerfCounter;
  49755. /**
  49756. * Gets the animations time capture status
  49757. */
  49758. /**
  49759. * Enable or disable the animations time capture
  49760. */
  49761. captureAnimationsTime: boolean;
  49762. /**
  49763. * Gets the perf counter used for frame time capture
  49764. */
  49765. readonly frameTimeCounter: PerfCounter;
  49766. /**
  49767. * Gets the frame time capture status
  49768. */
  49769. /**
  49770. * Enable or disable the frame time capture
  49771. */
  49772. captureFrameTime: boolean;
  49773. /**
  49774. * Gets the perf counter used for inter-frames time capture
  49775. */
  49776. readonly interFrameTimeCounter: PerfCounter;
  49777. /**
  49778. * Gets the inter-frames time capture status
  49779. */
  49780. /**
  49781. * Enable or disable the inter-frames time capture
  49782. */
  49783. captureInterFrameTime: boolean;
  49784. /**
  49785. * Gets the perf counter used for render time capture
  49786. */
  49787. readonly renderTimeCounter: PerfCounter;
  49788. /**
  49789. * Gets the render time capture status
  49790. */
  49791. /**
  49792. * Enable or disable the render time capture
  49793. */
  49794. captureRenderTime: boolean;
  49795. /**
  49796. * Gets the perf counter used for camera render time capture
  49797. */
  49798. readonly cameraRenderTimeCounter: PerfCounter;
  49799. /**
  49800. * Gets the camera render time capture status
  49801. */
  49802. /**
  49803. * Enable or disable the camera render time capture
  49804. */
  49805. captureCameraRenderTime: boolean;
  49806. /**
  49807. * Gets the perf counter used for draw calls
  49808. */
  49809. readonly drawCallsCounter: PerfCounter;
  49810. /**
  49811. * Instantiates a new scene instrumentation.
  49812. * This class can be used to get instrumentation data from a Babylon engine
  49813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49814. * @param scene Defines the scene to instrument
  49815. */
  49816. constructor(
  49817. /**
  49818. * Defines the scene to instrument
  49819. */
  49820. scene: Scene);
  49821. /**
  49822. * Dispose and release associated resources.
  49823. */
  49824. dispose(): void;
  49825. }
  49826. }
  49827. declare module BABYLON {
  49828. /** @hidden */
  49829. export var glowMapGenerationPixelShader: {
  49830. name: string;
  49831. shader: string;
  49832. };
  49833. }
  49834. declare module BABYLON {
  49835. /** @hidden */
  49836. export var glowMapGenerationVertexShader: {
  49837. name: string;
  49838. shader: string;
  49839. };
  49840. }
  49841. declare module BABYLON {
  49842. /**
  49843. * Effect layer options. This helps customizing the behaviour
  49844. * of the effect layer.
  49845. */
  49846. export interface IEffectLayerOptions {
  49847. /**
  49848. * Multiplication factor apply to the canvas size to compute the render target size
  49849. * used to generated the objects (the smaller the faster).
  49850. */
  49851. mainTextureRatio: number;
  49852. /**
  49853. * Enforces a fixed size texture to ensure effect stability across devices.
  49854. */
  49855. mainTextureFixedSize?: number;
  49856. /**
  49857. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49858. */
  49859. alphaBlendingMode: number;
  49860. /**
  49861. * The camera attached to the layer.
  49862. */
  49863. camera: Nullable<Camera>;
  49864. /**
  49865. * The rendering group to draw the layer in.
  49866. */
  49867. renderingGroupId: number;
  49868. }
  49869. /**
  49870. * The effect layer Helps adding post process effect blended with the main pass.
  49871. *
  49872. * This can be for instance use to generate glow or higlight effects on the scene.
  49873. *
  49874. * The effect layer class can not be used directly and is intented to inherited from to be
  49875. * customized per effects.
  49876. */
  49877. export abstract class EffectLayer {
  49878. private _vertexBuffers;
  49879. private _indexBuffer;
  49880. private _cachedDefines;
  49881. private _effectLayerMapGenerationEffect;
  49882. private _effectLayerOptions;
  49883. private _mergeEffect;
  49884. protected _scene: Scene;
  49885. protected _engine: Engine;
  49886. protected _maxSize: number;
  49887. protected _mainTextureDesiredSize: ISize;
  49888. protected _mainTexture: RenderTargetTexture;
  49889. protected _shouldRender: boolean;
  49890. protected _postProcesses: PostProcess[];
  49891. protected _textures: BaseTexture[];
  49892. protected _emissiveTextureAndColor: {
  49893. texture: Nullable<BaseTexture>;
  49894. color: Color4;
  49895. };
  49896. /**
  49897. * The name of the layer
  49898. */
  49899. name: string;
  49900. /**
  49901. * The clear color of the texture used to generate the glow map.
  49902. */
  49903. neutralColor: Color4;
  49904. /**
  49905. * Specifies wether the highlight layer is enabled or not.
  49906. */
  49907. isEnabled: boolean;
  49908. /**
  49909. * Gets the camera attached to the layer.
  49910. */
  49911. readonly camera: Nullable<Camera>;
  49912. /**
  49913. * Gets the rendering group id the layer should render in.
  49914. */
  49915. renderingGroupId: number;
  49916. /**
  49917. * An event triggered when the effect layer has been disposed.
  49918. */
  49919. onDisposeObservable: Observable<EffectLayer>;
  49920. /**
  49921. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49922. */
  49923. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49924. /**
  49925. * An event triggered when the generated texture is being merged in the scene.
  49926. */
  49927. onBeforeComposeObservable: Observable<EffectLayer>;
  49928. /**
  49929. * An event triggered when the mesh is rendered into the effect render target.
  49930. */
  49931. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  49932. /**
  49933. * An event triggered after the mesh has been rendered into the effect render target.
  49934. */
  49935. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  49936. /**
  49937. * An event triggered when the generated texture has been merged in the scene.
  49938. */
  49939. onAfterComposeObservable: Observable<EffectLayer>;
  49940. /**
  49941. * An event triggered when the efffect layer changes its size.
  49942. */
  49943. onSizeChangedObservable: Observable<EffectLayer>;
  49944. /** @hidden */
  49945. static _SceneComponentInitialization: (scene: Scene) => void;
  49946. /**
  49947. * Instantiates a new effect Layer and references it in the scene.
  49948. * @param name The name of the layer
  49949. * @param scene The scene to use the layer in
  49950. */
  49951. constructor(
  49952. /** The Friendly of the effect in the scene */
  49953. name: string, scene: Scene);
  49954. /**
  49955. * Get the effect name of the layer.
  49956. * @return The effect name
  49957. */
  49958. abstract getEffectName(): string;
  49959. /**
  49960. * Checks for the readiness of the element composing the layer.
  49961. * @param subMesh the mesh to check for
  49962. * @param useInstances specify wether or not to use instances to render the mesh
  49963. * @return true if ready otherwise, false
  49964. */
  49965. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49966. /**
  49967. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49968. * @returns true if the effect requires stencil during the main canvas render pass.
  49969. */
  49970. abstract needStencil(): boolean;
  49971. /**
  49972. * Create the merge effect. This is the shader use to blit the information back
  49973. * to the main canvas at the end of the scene rendering.
  49974. * @returns The effect containing the shader used to merge the effect on the main canvas
  49975. */
  49976. protected abstract _createMergeEffect(): Effect;
  49977. /**
  49978. * Creates the render target textures and post processes used in the effect layer.
  49979. */
  49980. protected abstract _createTextureAndPostProcesses(): void;
  49981. /**
  49982. * Implementation specific of rendering the generating effect on the main canvas.
  49983. * @param effect The effect used to render through
  49984. */
  49985. protected abstract _internalRender(effect: Effect): void;
  49986. /**
  49987. * Sets the required values for both the emissive texture and and the main color.
  49988. */
  49989. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49990. /**
  49991. * Free any resources and references associated to a mesh.
  49992. * Internal use
  49993. * @param mesh The mesh to free.
  49994. */
  49995. abstract _disposeMesh(mesh: Mesh): void;
  49996. /**
  49997. * Serializes this layer (Glow or Highlight for example)
  49998. * @returns a serialized layer object
  49999. */
  50000. abstract serialize?(): any;
  50001. /**
  50002. * Initializes the effect layer with the required options.
  50003. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50004. */
  50005. protected _init(options: Partial<IEffectLayerOptions>): void;
  50006. /**
  50007. * Generates the index buffer of the full screen quad blending to the main canvas.
  50008. */
  50009. private _generateIndexBuffer;
  50010. /**
  50011. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50012. */
  50013. private _generateVertexBuffer;
  50014. /**
  50015. * Sets the main texture desired size which is the closest power of two
  50016. * of the engine canvas size.
  50017. */
  50018. private _setMainTextureSize;
  50019. /**
  50020. * Creates the main texture for the effect layer.
  50021. */
  50022. protected _createMainTexture(): void;
  50023. /**
  50024. * Adds specific effects defines.
  50025. * @param defines The defines to add specifics to.
  50026. */
  50027. protected _addCustomEffectDefines(defines: string[]): void;
  50028. /**
  50029. * Checks for the readiness of the element composing the layer.
  50030. * @param subMesh the mesh to check for
  50031. * @param useInstances specify wether or not to use instances to render the mesh
  50032. * @param emissiveTexture the associated emissive texture used to generate the glow
  50033. * @return true if ready otherwise, false
  50034. */
  50035. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50036. /**
  50037. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50038. */
  50039. render(): void;
  50040. /**
  50041. * Determine if a given mesh will be used in the current effect.
  50042. * @param mesh mesh to test
  50043. * @returns true if the mesh will be used
  50044. */
  50045. hasMesh(mesh: AbstractMesh): boolean;
  50046. /**
  50047. * Returns true if the layer contains information to display, otherwise false.
  50048. * @returns true if the glow layer should be rendered
  50049. */
  50050. shouldRender(): boolean;
  50051. /**
  50052. * Returns true if the mesh should render, otherwise false.
  50053. * @param mesh The mesh to render
  50054. * @returns true if it should render otherwise false
  50055. */
  50056. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50057. /**
  50058. * Returns true if the mesh can be rendered, otherwise false.
  50059. * @param mesh The mesh to render
  50060. * @param material The material used on the mesh
  50061. * @returns true if it can be rendered otherwise false
  50062. */
  50063. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50064. /**
  50065. * Returns true if the mesh should render, otherwise false.
  50066. * @param mesh The mesh to render
  50067. * @returns true if it should render otherwise false
  50068. */
  50069. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50070. /**
  50071. * Renders the submesh passed in parameter to the generation map.
  50072. */
  50073. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50074. /**
  50075. * Defines wether the current material of the mesh should be use to render the effect.
  50076. * @param mesh defines the current mesh to render
  50077. */
  50078. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50079. /**
  50080. * Rebuild the required buffers.
  50081. * @hidden Internal use only.
  50082. */
  50083. _rebuild(): void;
  50084. /**
  50085. * Dispose only the render target textures and post process.
  50086. */
  50087. private _disposeTextureAndPostProcesses;
  50088. /**
  50089. * Dispose the highlight layer and free resources.
  50090. */
  50091. dispose(): void;
  50092. /**
  50093. * Gets the class name of the effect layer
  50094. * @returns the string with the class name of the effect layer
  50095. */
  50096. getClassName(): string;
  50097. /**
  50098. * Creates an effect layer from parsed effect layer data
  50099. * @param parsedEffectLayer defines effect layer data
  50100. * @param scene defines the current scene
  50101. * @param rootUrl defines the root URL containing the effect layer information
  50102. * @returns a parsed effect Layer
  50103. */
  50104. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50105. }
  50106. }
  50107. declare module BABYLON {
  50108. interface AbstractScene {
  50109. /**
  50110. * The list of effect layers (highlights/glow) added to the scene
  50111. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50112. * @see http://doc.babylonjs.com/how_to/glow_layer
  50113. */
  50114. effectLayers: Array<EffectLayer>;
  50115. /**
  50116. * Removes the given effect layer from this scene.
  50117. * @param toRemove defines the effect layer to remove
  50118. * @returns the index of the removed effect layer
  50119. */
  50120. removeEffectLayer(toRemove: EffectLayer): number;
  50121. /**
  50122. * Adds the given effect layer to this scene
  50123. * @param newEffectLayer defines the effect layer to add
  50124. */
  50125. addEffectLayer(newEffectLayer: EffectLayer): void;
  50126. }
  50127. /**
  50128. * Defines the layer scene component responsible to manage any effect layers
  50129. * in a given scene.
  50130. */
  50131. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50132. /**
  50133. * The component name helpfull to identify the component in the list of scene components.
  50134. */
  50135. readonly name: string;
  50136. /**
  50137. * The scene the component belongs to.
  50138. */
  50139. scene: Scene;
  50140. private _engine;
  50141. private _renderEffects;
  50142. private _needStencil;
  50143. private _previousStencilState;
  50144. /**
  50145. * Creates a new instance of the component for the given scene
  50146. * @param scene Defines the scene to register the component in
  50147. */
  50148. constructor(scene: Scene);
  50149. /**
  50150. * Registers the component in a given scene
  50151. */
  50152. register(): void;
  50153. /**
  50154. * Rebuilds the elements related to this component in case of
  50155. * context lost for instance.
  50156. */
  50157. rebuild(): void;
  50158. /**
  50159. * Serializes the component data to the specified json object
  50160. * @param serializationObject The object to serialize to
  50161. */
  50162. serialize(serializationObject: any): void;
  50163. /**
  50164. * Adds all the elements from the container to the scene
  50165. * @param container the container holding the elements
  50166. */
  50167. addFromContainer(container: AbstractScene): void;
  50168. /**
  50169. * Removes all the elements in the container from the scene
  50170. * @param container contains the elements to remove
  50171. * @param dispose if the removed element should be disposed (default: false)
  50172. */
  50173. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50174. /**
  50175. * Disposes the component and the associated ressources.
  50176. */
  50177. dispose(): void;
  50178. private _isReadyForMesh;
  50179. private _renderMainTexture;
  50180. private _setStencil;
  50181. private _setStencilBack;
  50182. private _draw;
  50183. private _drawCamera;
  50184. private _drawRenderingGroup;
  50185. }
  50186. }
  50187. declare module BABYLON {
  50188. /** @hidden */
  50189. export var glowMapMergePixelShader: {
  50190. name: string;
  50191. shader: string;
  50192. };
  50193. }
  50194. declare module BABYLON {
  50195. /** @hidden */
  50196. export var glowMapMergeVertexShader: {
  50197. name: string;
  50198. shader: string;
  50199. };
  50200. }
  50201. declare module BABYLON {
  50202. interface AbstractScene {
  50203. /**
  50204. * Return a the first highlight layer of the scene with a given name.
  50205. * @param name The name of the highlight layer to look for.
  50206. * @return The highlight layer if found otherwise null.
  50207. */
  50208. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50209. }
  50210. /**
  50211. * Glow layer options. This helps customizing the behaviour
  50212. * of the glow layer.
  50213. */
  50214. export interface IGlowLayerOptions {
  50215. /**
  50216. * Multiplication factor apply to the canvas size to compute the render target size
  50217. * used to generated the glowing objects (the smaller the faster).
  50218. */
  50219. mainTextureRatio: number;
  50220. /**
  50221. * Enforces a fixed size texture to ensure resize independant blur.
  50222. */
  50223. mainTextureFixedSize?: number;
  50224. /**
  50225. * How big is the kernel of the blur texture.
  50226. */
  50227. blurKernelSize: number;
  50228. /**
  50229. * The camera attached to the layer.
  50230. */
  50231. camera: Nullable<Camera>;
  50232. /**
  50233. * Enable MSAA by chosing the number of samples.
  50234. */
  50235. mainTextureSamples?: number;
  50236. /**
  50237. * The rendering group to draw the layer in.
  50238. */
  50239. renderingGroupId: number;
  50240. }
  50241. /**
  50242. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50243. *
  50244. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  50245. *
  50246. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50247. */
  50248. export class GlowLayer extends EffectLayer {
  50249. /**
  50250. * Effect Name of the layer.
  50251. */
  50252. static readonly EffectName: string;
  50253. /**
  50254. * The default blur kernel size used for the glow.
  50255. */
  50256. static DefaultBlurKernelSize: number;
  50257. /**
  50258. * The default texture size ratio used for the glow.
  50259. */
  50260. static DefaultTextureRatio: number;
  50261. /**
  50262. * Sets the kernel size of the blur.
  50263. */
  50264. /**
  50265. * Gets the kernel size of the blur.
  50266. */
  50267. blurKernelSize: number;
  50268. /**
  50269. * Sets the glow intensity.
  50270. */
  50271. /**
  50272. * Gets the glow intensity.
  50273. */
  50274. intensity: number;
  50275. private _options;
  50276. private _intensity;
  50277. private _horizontalBlurPostprocess1;
  50278. private _verticalBlurPostprocess1;
  50279. private _horizontalBlurPostprocess2;
  50280. private _verticalBlurPostprocess2;
  50281. private _blurTexture1;
  50282. private _blurTexture2;
  50283. private _postProcesses1;
  50284. private _postProcesses2;
  50285. private _includedOnlyMeshes;
  50286. private _excludedMeshes;
  50287. private _meshesUsingTheirOwnMaterials;
  50288. /**
  50289. * Callback used to let the user override the color selection on a per mesh basis
  50290. */
  50291. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50292. /**
  50293. * Callback used to let the user override the texture selection on a per mesh basis
  50294. */
  50295. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50296. /**
  50297. * Instantiates a new glow Layer and references it to the scene.
  50298. * @param name The name of the layer
  50299. * @param scene The scene to use the layer in
  50300. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50301. */
  50302. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50303. /**
  50304. * Get the effect name of the layer.
  50305. * @return The effect name
  50306. */
  50307. getEffectName(): string;
  50308. /**
  50309. * Create the merge effect. This is the shader use to blit the information back
  50310. * to the main canvas at the end of the scene rendering.
  50311. */
  50312. protected _createMergeEffect(): Effect;
  50313. /**
  50314. * Creates the render target textures and post processes used in the glow layer.
  50315. */
  50316. protected _createTextureAndPostProcesses(): void;
  50317. /**
  50318. * Checks for the readiness of the element composing the layer.
  50319. * @param subMesh the mesh to check for
  50320. * @param useInstances specify wether or not to use instances to render the mesh
  50321. * @param emissiveTexture the associated emissive texture used to generate the glow
  50322. * @return true if ready otherwise, false
  50323. */
  50324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50325. /**
  50326. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50327. */
  50328. needStencil(): boolean;
  50329. /**
  50330. * Returns true if the mesh can be rendered, otherwise false.
  50331. * @param mesh The mesh to render
  50332. * @param material The material used on the mesh
  50333. * @returns true if it can be rendered otherwise false
  50334. */
  50335. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50336. /**
  50337. * Implementation specific of rendering the generating effect on the main canvas.
  50338. * @param effect The effect used to render through
  50339. */
  50340. protected _internalRender(effect: Effect): void;
  50341. /**
  50342. * Sets the required values for both the emissive texture and and the main color.
  50343. */
  50344. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50345. /**
  50346. * Returns true if the mesh should render, otherwise false.
  50347. * @param mesh The mesh to render
  50348. * @returns true if it should render otherwise false
  50349. */
  50350. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50351. /**
  50352. * Adds specific effects defines.
  50353. * @param defines The defines to add specifics to.
  50354. */
  50355. protected _addCustomEffectDefines(defines: string[]): void;
  50356. /**
  50357. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50358. * @param mesh The mesh to exclude from the glow layer
  50359. */
  50360. addExcludedMesh(mesh: Mesh): void;
  50361. /**
  50362. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50363. * @param mesh The mesh to remove
  50364. */
  50365. removeExcludedMesh(mesh: Mesh): void;
  50366. /**
  50367. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50368. * @param mesh The mesh to include in the glow layer
  50369. */
  50370. addIncludedOnlyMesh(mesh: Mesh): void;
  50371. /**
  50372. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50373. * @param mesh The mesh to remove
  50374. */
  50375. removeIncludedOnlyMesh(mesh: Mesh): void;
  50376. /**
  50377. * Determine if a given mesh will be used in the glow layer
  50378. * @param mesh The mesh to test
  50379. * @returns true if the mesh will be highlighted by the current glow layer
  50380. */
  50381. hasMesh(mesh: AbstractMesh): boolean;
  50382. /**
  50383. * Defines wether the current material of the mesh should be use to render the effect.
  50384. * @param mesh defines the current mesh to render
  50385. */
  50386. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  50387. /**
  50388. * Add a mesh to be rendered through its own material and not with emissive only.
  50389. * @param mesh The mesh for which we need to use its material
  50390. */
  50391. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  50392. /**
  50393. * Remove a mesh from being rendered through its own material and not with emissive only.
  50394. * @param mesh The mesh for which we need to not use its material
  50395. */
  50396. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  50397. /**
  50398. * Free any resources and references associated to a mesh.
  50399. * Internal use
  50400. * @param mesh The mesh to free.
  50401. * @hidden
  50402. */
  50403. _disposeMesh(mesh: Mesh): void;
  50404. /**
  50405. * Gets the class name of the effect layer
  50406. * @returns the string with the class name of the effect layer
  50407. */
  50408. getClassName(): string;
  50409. /**
  50410. * Serializes this glow layer
  50411. * @returns a serialized glow layer object
  50412. */
  50413. serialize(): any;
  50414. /**
  50415. * Creates a Glow Layer from parsed glow layer data
  50416. * @param parsedGlowLayer defines glow layer data
  50417. * @param scene defines the current scene
  50418. * @param rootUrl defines the root URL containing the glow layer information
  50419. * @returns a parsed Glow Layer
  50420. */
  50421. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50422. }
  50423. }
  50424. declare module BABYLON {
  50425. /** @hidden */
  50426. export var glowBlurPostProcessPixelShader: {
  50427. name: string;
  50428. shader: string;
  50429. };
  50430. }
  50431. declare module BABYLON {
  50432. interface AbstractScene {
  50433. /**
  50434. * Return a the first highlight layer of the scene with a given name.
  50435. * @param name The name of the highlight layer to look for.
  50436. * @return The highlight layer if found otherwise null.
  50437. */
  50438. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50439. }
  50440. /**
  50441. * Highlight layer options. This helps customizing the behaviour
  50442. * of the highlight layer.
  50443. */
  50444. export interface IHighlightLayerOptions {
  50445. /**
  50446. * Multiplication factor apply to the canvas size to compute the render target size
  50447. * used to generated the glowing objects (the smaller the faster).
  50448. */
  50449. mainTextureRatio: number;
  50450. /**
  50451. * Enforces a fixed size texture to ensure resize independant blur.
  50452. */
  50453. mainTextureFixedSize?: number;
  50454. /**
  50455. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50456. * of the picture to blur (the smaller the faster).
  50457. */
  50458. blurTextureSizeRatio: number;
  50459. /**
  50460. * How big in texel of the blur texture is the vertical blur.
  50461. */
  50462. blurVerticalSize: number;
  50463. /**
  50464. * How big in texel of the blur texture is the horizontal blur.
  50465. */
  50466. blurHorizontalSize: number;
  50467. /**
  50468. * Alpha blending mode used to apply the blur. Default is combine.
  50469. */
  50470. alphaBlendingMode: number;
  50471. /**
  50472. * The camera attached to the layer.
  50473. */
  50474. camera: Nullable<Camera>;
  50475. /**
  50476. * Should we display highlight as a solid stroke?
  50477. */
  50478. isStroke?: boolean;
  50479. /**
  50480. * The rendering group to draw the layer in.
  50481. */
  50482. renderingGroupId: number;
  50483. }
  50484. /**
  50485. * The highlight layer Helps adding a glow effect around a mesh.
  50486. *
  50487. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  50488. * glowy meshes to your scene.
  50489. *
  50490. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50491. */
  50492. export class HighlightLayer extends EffectLayer {
  50493. name: string;
  50494. /**
  50495. * Effect Name of the highlight layer.
  50496. */
  50497. static readonly EffectName: string;
  50498. /**
  50499. * The neutral color used during the preparation of the glow effect.
  50500. * This is black by default as the blend operation is a blend operation.
  50501. */
  50502. static NeutralColor: Color4;
  50503. /**
  50504. * Stencil value used for glowing meshes.
  50505. */
  50506. static GlowingMeshStencilReference: number;
  50507. /**
  50508. * Stencil value used for the other meshes in the scene.
  50509. */
  50510. static NormalMeshStencilReference: number;
  50511. /**
  50512. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50513. */
  50514. innerGlow: boolean;
  50515. /**
  50516. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50517. */
  50518. outerGlow: boolean;
  50519. /**
  50520. * Specifies the horizontal size of the blur.
  50521. */
  50522. /**
  50523. * Gets the horizontal size of the blur.
  50524. */
  50525. blurHorizontalSize: number;
  50526. /**
  50527. * Specifies the vertical size of the blur.
  50528. */
  50529. /**
  50530. * Gets the vertical size of the blur.
  50531. */
  50532. blurVerticalSize: number;
  50533. /**
  50534. * An event triggered when the highlight layer is being blurred.
  50535. */
  50536. onBeforeBlurObservable: Observable<HighlightLayer>;
  50537. /**
  50538. * An event triggered when the highlight layer has been blurred.
  50539. */
  50540. onAfterBlurObservable: Observable<HighlightLayer>;
  50541. private _instanceGlowingMeshStencilReference;
  50542. private _options;
  50543. private _downSamplePostprocess;
  50544. private _horizontalBlurPostprocess;
  50545. private _verticalBlurPostprocess;
  50546. private _blurTexture;
  50547. private _meshes;
  50548. private _excludedMeshes;
  50549. /**
  50550. * Instantiates a new highlight Layer and references it to the scene..
  50551. * @param name The name of the layer
  50552. * @param scene The scene to use the layer in
  50553. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50554. */
  50555. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50556. /**
  50557. * Get the effect name of the layer.
  50558. * @return The effect name
  50559. */
  50560. getEffectName(): string;
  50561. /**
  50562. * Create the merge effect. This is the shader use to blit the information back
  50563. * to the main canvas at the end of the scene rendering.
  50564. */
  50565. protected _createMergeEffect(): Effect;
  50566. /**
  50567. * Creates the render target textures and post processes used in the highlight layer.
  50568. */
  50569. protected _createTextureAndPostProcesses(): void;
  50570. /**
  50571. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50572. */
  50573. needStencil(): boolean;
  50574. /**
  50575. * Checks for the readiness of the element composing the layer.
  50576. * @param subMesh the mesh to check for
  50577. * @param useInstances specify wether or not to use instances to render the mesh
  50578. * @param emissiveTexture the associated emissive texture used to generate the glow
  50579. * @return true if ready otherwise, false
  50580. */
  50581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50582. /**
  50583. * Implementation specific of rendering the generating effect on the main canvas.
  50584. * @param effect The effect used to render through
  50585. */
  50586. protected _internalRender(effect: Effect): void;
  50587. /**
  50588. * Returns true if the layer contains information to display, otherwise false.
  50589. */
  50590. shouldRender(): boolean;
  50591. /**
  50592. * Returns true if the mesh should render, otherwise false.
  50593. * @param mesh The mesh to render
  50594. * @returns true if it should render otherwise false
  50595. */
  50596. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50597. /**
  50598. * Sets the required values for both the emissive texture and and the main color.
  50599. */
  50600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50601. /**
  50602. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50603. * @param mesh The mesh to exclude from the highlight layer
  50604. */
  50605. addExcludedMesh(mesh: Mesh): void;
  50606. /**
  50607. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50608. * @param mesh The mesh to highlight
  50609. */
  50610. removeExcludedMesh(mesh: Mesh): void;
  50611. /**
  50612. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50613. * @param mesh mesh to test
  50614. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50615. */
  50616. hasMesh(mesh: AbstractMesh): boolean;
  50617. /**
  50618. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50619. * @param mesh The mesh to highlight
  50620. * @param color The color of the highlight
  50621. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50622. */
  50623. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50624. /**
  50625. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50626. * @param mesh The mesh to highlight
  50627. */
  50628. removeMesh(mesh: Mesh): void;
  50629. /**
  50630. * Force the stencil to the normal expected value for none glowing parts
  50631. */
  50632. private _defaultStencilReference;
  50633. /**
  50634. * Free any resources and references associated to a mesh.
  50635. * Internal use
  50636. * @param mesh The mesh to free.
  50637. * @hidden
  50638. */
  50639. _disposeMesh(mesh: Mesh): void;
  50640. /**
  50641. * Dispose the highlight layer and free resources.
  50642. */
  50643. dispose(): void;
  50644. /**
  50645. * Gets the class name of the effect layer
  50646. * @returns the string with the class name of the effect layer
  50647. */
  50648. getClassName(): string;
  50649. /**
  50650. * Serializes this Highlight layer
  50651. * @returns a serialized Highlight layer object
  50652. */
  50653. serialize(): any;
  50654. /**
  50655. * Creates a Highlight layer from parsed Highlight layer data
  50656. * @param parsedHightlightLayer defines the Highlight layer data
  50657. * @param scene defines the current scene
  50658. * @param rootUrl defines the root URL containing the Highlight layer information
  50659. * @returns a parsed Highlight layer
  50660. */
  50661. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50662. }
  50663. }
  50664. declare module BABYLON {
  50665. interface AbstractScene {
  50666. /**
  50667. * The list of layers (background and foreground) of the scene
  50668. */
  50669. layers: Array<Layer>;
  50670. }
  50671. /**
  50672. * Defines the layer scene component responsible to manage any layers
  50673. * in a given scene.
  50674. */
  50675. export class LayerSceneComponent implements ISceneComponent {
  50676. /**
  50677. * The component name helpfull to identify the component in the list of scene components.
  50678. */
  50679. readonly name: string;
  50680. /**
  50681. * The scene the component belongs to.
  50682. */
  50683. scene: Scene;
  50684. private _engine;
  50685. /**
  50686. * Creates a new instance of the component for the given scene
  50687. * @param scene Defines the scene to register the component in
  50688. */
  50689. constructor(scene: Scene);
  50690. /**
  50691. * Registers the component in a given scene
  50692. */
  50693. register(): void;
  50694. /**
  50695. * Rebuilds the elements related to this component in case of
  50696. * context lost for instance.
  50697. */
  50698. rebuild(): void;
  50699. /**
  50700. * Disposes the component and the associated ressources.
  50701. */
  50702. dispose(): void;
  50703. private _draw;
  50704. private _drawCameraPredicate;
  50705. private _drawCameraBackground;
  50706. private _drawCameraForeground;
  50707. private _drawRenderTargetPredicate;
  50708. private _drawRenderTargetBackground;
  50709. private _drawRenderTargetForeground;
  50710. /**
  50711. * Adds all the elements from the container to the scene
  50712. * @param container the container holding the elements
  50713. */
  50714. addFromContainer(container: AbstractScene): void;
  50715. /**
  50716. * Removes all the elements in the container from the scene
  50717. * @param container contains the elements to remove
  50718. * @param dispose if the removed element should be disposed (default: false)
  50719. */
  50720. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50721. }
  50722. }
  50723. declare module BABYLON {
  50724. /** @hidden */
  50725. export var layerPixelShader: {
  50726. name: string;
  50727. shader: string;
  50728. };
  50729. }
  50730. declare module BABYLON {
  50731. /** @hidden */
  50732. export var layerVertexShader: {
  50733. name: string;
  50734. shader: string;
  50735. };
  50736. }
  50737. declare module BABYLON {
  50738. /**
  50739. * This represents a full screen 2d layer.
  50740. * This can be useful to display a picture in the background of your scene for instance.
  50741. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50742. */
  50743. export class Layer {
  50744. /**
  50745. * Define the name of the layer.
  50746. */
  50747. name: string;
  50748. /**
  50749. * Define the texture the layer should display.
  50750. */
  50751. texture: Nullable<Texture>;
  50752. /**
  50753. * Is the layer in background or foreground.
  50754. */
  50755. isBackground: boolean;
  50756. /**
  50757. * Define the color of the layer (instead of texture).
  50758. */
  50759. color: Color4;
  50760. /**
  50761. * Define the scale of the layer in order to zoom in out of the texture.
  50762. */
  50763. scale: Vector2;
  50764. /**
  50765. * Define an offset for the layer in order to shift the texture.
  50766. */
  50767. offset: Vector2;
  50768. /**
  50769. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50770. */
  50771. alphaBlendingMode: number;
  50772. /**
  50773. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50774. * Alpha test will not mix with the background color in case of transparency.
  50775. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50776. */
  50777. alphaTest: boolean;
  50778. /**
  50779. * Define a mask to restrict the layer to only some of the scene cameras.
  50780. */
  50781. layerMask: number;
  50782. /**
  50783. * Define the list of render target the layer is visible into.
  50784. */
  50785. renderTargetTextures: RenderTargetTexture[];
  50786. /**
  50787. * Define if the layer is only used in renderTarget or if it also
  50788. * renders in the main frame buffer of the canvas.
  50789. */
  50790. renderOnlyInRenderTargetTextures: boolean;
  50791. private _scene;
  50792. private _vertexBuffers;
  50793. private _indexBuffer;
  50794. private _effect;
  50795. private _alphaTestEffect;
  50796. /**
  50797. * An event triggered when the layer is disposed.
  50798. */
  50799. onDisposeObservable: Observable<Layer>;
  50800. private _onDisposeObserver;
  50801. /**
  50802. * Back compatibility with callback before the onDisposeObservable existed.
  50803. * The set callback will be triggered when the layer has been disposed.
  50804. */
  50805. onDispose: () => void;
  50806. /**
  50807. * An event triggered before rendering the scene
  50808. */
  50809. onBeforeRenderObservable: Observable<Layer>;
  50810. private _onBeforeRenderObserver;
  50811. /**
  50812. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50813. * The set callback will be triggered just before rendering the layer.
  50814. */
  50815. onBeforeRender: () => void;
  50816. /**
  50817. * An event triggered after rendering the scene
  50818. */
  50819. onAfterRenderObservable: Observable<Layer>;
  50820. private _onAfterRenderObserver;
  50821. /**
  50822. * Back compatibility with callback before the onAfterRenderObservable existed.
  50823. * The set callback will be triggered just after rendering the layer.
  50824. */
  50825. onAfterRender: () => void;
  50826. /**
  50827. * Instantiates a new layer.
  50828. * This represents a full screen 2d layer.
  50829. * This can be useful to display a picture in the background of your scene for instance.
  50830. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50831. * @param name Define the name of the layer in the scene
  50832. * @param imgUrl Define the url of the texture to display in the layer
  50833. * @param scene Define the scene the layer belongs to
  50834. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50835. * @param color Defines a color for the layer
  50836. */
  50837. constructor(
  50838. /**
  50839. * Define the name of the layer.
  50840. */
  50841. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50842. private _createIndexBuffer;
  50843. /** @hidden */
  50844. _rebuild(): void;
  50845. /**
  50846. * Renders the layer in the scene.
  50847. */
  50848. render(): void;
  50849. /**
  50850. * Disposes and releases the associated ressources.
  50851. */
  50852. dispose(): void;
  50853. }
  50854. }
  50855. declare module BABYLON {
  50856. /** @hidden */
  50857. export var lensFlarePixelShader: {
  50858. name: string;
  50859. shader: string;
  50860. };
  50861. }
  50862. declare module BABYLON {
  50863. /** @hidden */
  50864. export var lensFlareVertexShader: {
  50865. name: string;
  50866. shader: string;
  50867. };
  50868. }
  50869. declare module BABYLON {
  50870. /**
  50871. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50872. * It is usually composed of several `lensFlare`.
  50873. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50874. */
  50875. export class LensFlareSystem {
  50876. /**
  50877. * Define the name of the lens flare system
  50878. */
  50879. name: string;
  50880. /**
  50881. * List of lens flares used in this system.
  50882. */
  50883. lensFlares: LensFlare[];
  50884. /**
  50885. * Define a limit from the border the lens flare can be visible.
  50886. */
  50887. borderLimit: number;
  50888. /**
  50889. * Define a viewport border we do not want to see the lens flare in.
  50890. */
  50891. viewportBorder: number;
  50892. /**
  50893. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50894. */
  50895. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50896. /**
  50897. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50898. */
  50899. layerMask: number;
  50900. /**
  50901. * Define the id of the lens flare system in the scene.
  50902. * (equal to name by default)
  50903. */
  50904. id: string;
  50905. private _scene;
  50906. private _emitter;
  50907. private _vertexBuffers;
  50908. private _indexBuffer;
  50909. private _effect;
  50910. private _positionX;
  50911. private _positionY;
  50912. private _isEnabled;
  50913. /** @hidden */
  50914. static _SceneComponentInitialization: (scene: Scene) => void;
  50915. /**
  50916. * Instantiates a lens flare system.
  50917. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50918. * It is usually composed of several `lensFlare`.
  50919. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50920. * @param name Define the name of the lens flare system in the scene
  50921. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50922. * @param scene Define the scene the lens flare system belongs to
  50923. */
  50924. constructor(
  50925. /**
  50926. * Define the name of the lens flare system
  50927. */
  50928. name: string, emitter: any, scene: Scene);
  50929. /**
  50930. * Define if the lens flare system is enabled.
  50931. */
  50932. isEnabled: boolean;
  50933. /**
  50934. * Get the scene the effects belongs to.
  50935. * @returns the scene holding the lens flare system
  50936. */
  50937. getScene(): Scene;
  50938. /**
  50939. * Get the emitter of the lens flare system.
  50940. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50941. * @returns the emitter of the lens flare system
  50942. */
  50943. getEmitter(): any;
  50944. /**
  50945. * Set the emitter of the lens flare system.
  50946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50947. * @param newEmitter Define the new emitter of the system
  50948. */
  50949. setEmitter(newEmitter: any): void;
  50950. /**
  50951. * Get the lens flare system emitter position.
  50952. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50953. * @returns the position
  50954. */
  50955. getEmitterPosition(): Vector3;
  50956. /**
  50957. * @hidden
  50958. */
  50959. computeEffectivePosition(globalViewport: Viewport): boolean;
  50960. /** @hidden */
  50961. _isVisible(): boolean;
  50962. /**
  50963. * @hidden
  50964. */
  50965. render(): boolean;
  50966. /**
  50967. * Dispose and release the lens flare with its associated resources.
  50968. */
  50969. dispose(): void;
  50970. /**
  50971. * Parse a lens flare system from a JSON repressentation
  50972. * @param parsedLensFlareSystem Define the JSON to parse
  50973. * @param scene Define the scene the parsed system should be instantiated in
  50974. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50975. * @returns the parsed system
  50976. */
  50977. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50978. /**
  50979. * Serialize the current Lens Flare System into a JSON representation.
  50980. * @returns the serialized JSON
  50981. */
  50982. serialize(): any;
  50983. }
  50984. }
  50985. declare module BABYLON {
  50986. /**
  50987. * This represents one of the lens effect in a `lensFlareSystem`.
  50988. * It controls one of the indiviual texture used in the effect.
  50989. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50990. */
  50991. export class LensFlare {
  50992. /**
  50993. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50994. */
  50995. size: number;
  50996. /**
  50997. * 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.
  50998. */
  50999. position: number;
  51000. /**
  51001. * Define the lens color.
  51002. */
  51003. color: Color3;
  51004. /**
  51005. * Define the lens texture.
  51006. */
  51007. texture: Nullable<Texture>;
  51008. /**
  51009. * Define the alpha mode to render this particular lens.
  51010. */
  51011. alphaMode: number;
  51012. private _system;
  51013. /**
  51014. * Creates a new Lens Flare.
  51015. * This represents one of the lens effect in a `lensFlareSystem`.
  51016. * It controls one of the indiviual texture used in the effect.
  51017. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51018. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51019. * @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.
  51020. * @param color Define the lens color
  51021. * @param imgUrl Define the lens texture url
  51022. * @param system Define the `lensFlareSystem` this flare is part of
  51023. * @returns The newly created Lens Flare
  51024. */
  51025. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51026. /**
  51027. * Instantiates a new Lens Flare.
  51028. * This represents one of the lens effect in a `lensFlareSystem`.
  51029. * It controls one of the indiviual texture used in the effect.
  51030. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51031. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51032. * @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.
  51033. * @param color Define the lens color
  51034. * @param imgUrl Define the lens texture url
  51035. * @param system Define the `lensFlareSystem` this flare is part of
  51036. */
  51037. constructor(
  51038. /**
  51039. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51040. */
  51041. size: number,
  51042. /**
  51043. * 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.
  51044. */
  51045. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51046. /**
  51047. * Dispose and release the lens flare with its associated resources.
  51048. */
  51049. dispose(): void;
  51050. }
  51051. }
  51052. declare module BABYLON {
  51053. interface AbstractScene {
  51054. /**
  51055. * The list of lens flare system added to the scene
  51056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51057. */
  51058. lensFlareSystems: Array<LensFlareSystem>;
  51059. /**
  51060. * Removes the given lens flare system from this scene.
  51061. * @param toRemove The lens flare system to remove
  51062. * @returns The index of the removed lens flare system
  51063. */
  51064. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51065. /**
  51066. * Adds the given lens flare system to this scene
  51067. * @param newLensFlareSystem The lens flare system to add
  51068. */
  51069. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51070. /**
  51071. * Gets a lens flare system using its name
  51072. * @param name defines the name to look for
  51073. * @returns the lens flare system or null if not found
  51074. */
  51075. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51076. /**
  51077. * Gets a lens flare system using its id
  51078. * @param id defines the id to look for
  51079. * @returns the lens flare system or null if not found
  51080. */
  51081. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51082. }
  51083. /**
  51084. * Defines the lens flare scene component responsible to manage any lens flares
  51085. * in a given scene.
  51086. */
  51087. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51088. /**
  51089. * The component name helpfull to identify the component in the list of scene components.
  51090. */
  51091. readonly name: string;
  51092. /**
  51093. * The scene the component belongs to.
  51094. */
  51095. scene: Scene;
  51096. /**
  51097. * Creates a new instance of the component for the given scene
  51098. * @param scene Defines the scene to register the component in
  51099. */
  51100. constructor(scene: Scene);
  51101. /**
  51102. * Registers the component in a given scene
  51103. */
  51104. register(): void;
  51105. /**
  51106. * Rebuilds the elements related to this component in case of
  51107. * context lost for instance.
  51108. */
  51109. rebuild(): void;
  51110. /**
  51111. * Adds all the elements from the container to the scene
  51112. * @param container the container holding the elements
  51113. */
  51114. addFromContainer(container: AbstractScene): void;
  51115. /**
  51116. * Removes all the elements in the container from the scene
  51117. * @param container contains the elements to remove
  51118. * @param dispose if the removed element should be disposed (default: false)
  51119. */
  51120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51121. /**
  51122. * Serializes the component data to the specified json object
  51123. * @param serializationObject The object to serialize to
  51124. */
  51125. serialize(serializationObject: any): void;
  51126. /**
  51127. * Disposes the component and the associated ressources.
  51128. */
  51129. dispose(): void;
  51130. private _draw;
  51131. }
  51132. }
  51133. declare module BABYLON {
  51134. /**
  51135. * Defines the shadow generator component responsible to manage any shadow generators
  51136. * in a given scene.
  51137. */
  51138. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51139. /**
  51140. * The component name helpfull to identify the component in the list of scene components.
  51141. */
  51142. readonly name: string;
  51143. /**
  51144. * The scene the component belongs to.
  51145. */
  51146. scene: Scene;
  51147. /**
  51148. * Creates a new instance of the component for the given scene
  51149. * @param scene Defines the scene to register the component in
  51150. */
  51151. constructor(scene: Scene);
  51152. /**
  51153. * Registers the component in a given scene
  51154. */
  51155. register(): void;
  51156. /**
  51157. * Rebuilds the elements related to this component in case of
  51158. * context lost for instance.
  51159. */
  51160. rebuild(): void;
  51161. /**
  51162. * Serializes the component data to the specified json object
  51163. * @param serializationObject The object to serialize to
  51164. */
  51165. serialize(serializationObject: any): void;
  51166. /**
  51167. * Adds all the elements from the container to the scene
  51168. * @param container the container holding the elements
  51169. */
  51170. addFromContainer(container: AbstractScene): void;
  51171. /**
  51172. * Removes all the elements in the container from the scene
  51173. * @param container contains the elements to remove
  51174. * @param dispose if the removed element should be disposed (default: false)
  51175. */
  51176. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51177. /**
  51178. * Rebuilds the elements related to this component in case of
  51179. * context lost for instance.
  51180. */
  51181. dispose(): void;
  51182. private _gatherRenderTargets;
  51183. }
  51184. }
  51185. declare module BABYLON {
  51186. /**
  51187. * A point light is a light defined by an unique point in world space.
  51188. * The light is emitted in every direction from this point.
  51189. * A good example of a point light is a standard light bulb.
  51190. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51191. */
  51192. export class PointLight extends ShadowLight {
  51193. private _shadowAngle;
  51194. /**
  51195. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51196. * This specifies what angle the shadow will use to be created.
  51197. *
  51198. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51199. */
  51200. /**
  51201. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51202. * This specifies what angle the shadow will use to be created.
  51203. *
  51204. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51205. */
  51206. shadowAngle: number;
  51207. /**
  51208. * Gets the direction if it has been set.
  51209. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51210. */
  51211. /**
  51212. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51213. */
  51214. direction: Vector3;
  51215. /**
  51216. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51217. * A PointLight emits the light in every direction.
  51218. * It can cast shadows.
  51219. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51220. * ```javascript
  51221. * var pointLight = new PointLight("pl", camera.position, scene);
  51222. * ```
  51223. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51224. * @param name The light friendly name
  51225. * @param position The position of the point light in the scene
  51226. * @param scene The scene the lights belongs to
  51227. */
  51228. constructor(name: string, position: Vector3, scene: Scene);
  51229. /**
  51230. * Returns the string "PointLight"
  51231. * @returns the class name
  51232. */
  51233. getClassName(): string;
  51234. /**
  51235. * Returns the integer 0.
  51236. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51237. */
  51238. getTypeID(): number;
  51239. /**
  51240. * Specifies wether or not the shadowmap should be a cube texture.
  51241. * @returns true if the shadowmap needs to be a cube texture.
  51242. */
  51243. needCube(): boolean;
  51244. /**
  51245. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51246. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51247. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51248. */
  51249. getShadowDirection(faceIndex?: number): Vector3;
  51250. /**
  51251. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51252. * - fov = PI / 2
  51253. * - aspect ratio : 1.0
  51254. * - z-near and far equal to the active camera minZ and maxZ.
  51255. * Returns the PointLight.
  51256. */
  51257. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51258. protected _buildUniformLayout(): void;
  51259. /**
  51260. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51261. * @param effect The effect to update
  51262. * @param lightIndex The index of the light in the effect to update
  51263. * @returns The point light
  51264. */
  51265. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51266. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51267. /**
  51268. * Prepares the list of defines specific to the light type.
  51269. * @param defines the list of defines
  51270. * @param lightIndex defines the index of the light for the effect
  51271. */
  51272. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51273. }
  51274. }
  51275. declare module BABYLON {
  51276. /**
  51277. * Header information of HDR texture files.
  51278. */
  51279. export interface HDRInfo {
  51280. /**
  51281. * The height of the texture in pixels.
  51282. */
  51283. height: number;
  51284. /**
  51285. * The width of the texture in pixels.
  51286. */
  51287. width: number;
  51288. /**
  51289. * The index of the beginning of the data in the binary file.
  51290. */
  51291. dataPosition: number;
  51292. }
  51293. /**
  51294. * This groups tools to convert HDR texture to native colors array.
  51295. */
  51296. export class HDRTools {
  51297. private static Ldexp;
  51298. private static Rgbe2float;
  51299. private static readStringLine;
  51300. /**
  51301. * Reads header information from an RGBE texture stored in a native array.
  51302. * More information on this format are available here:
  51303. * https://en.wikipedia.org/wiki/RGBE_image_format
  51304. *
  51305. * @param uint8array The binary file stored in native array.
  51306. * @return The header information.
  51307. */
  51308. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51309. /**
  51310. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51311. * This RGBE texture needs to store the information as a panorama.
  51312. *
  51313. * More information on this format are available here:
  51314. * https://en.wikipedia.org/wiki/RGBE_image_format
  51315. *
  51316. * @param buffer The binary file stored in an array buffer.
  51317. * @param size The expected size of the extracted cubemap.
  51318. * @return The Cube Map information.
  51319. */
  51320. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51321. /**
  51322. * Returns the pixels data extracted from an RGBE texture.
  51323. * This pixels will be stored left to right up to down in the R G B order in one array.
  51324. *
  51325. * More information on this format are available here:
  51326. * https://en.wikipedia.org/wiki/RGBE_image_format
  51327. *
  51328. * @param uint8array The binary file stored in an array buffer.
  51329. * @param hdrInfo The header information of the file.
  51330. * @return The pixels data in RGB right to left up to down order.
  51331. */
  51332. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51333. private static RGBE_ReadPixels_RLE;
  51334. }
  51335. }
  51336. declare module BABYLON {
  51337. /**
  51338. * This represents a texture coming from an HDR input.
  51339. *
  51340. * The only supported format is currently panorama picture stored in RGBE format.
  51341. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51342. */
  51343. export class HDRCubeTexture extends BaseTexture {
  51344. private static _facesMapping;
  51345. private _generateHarmonics;
  51346. private _noMipmap;
  51347. private _textureMatrix;
  51348. private _size;
  51349. private _onLoad;
  51350. private _onError;
  51351. /**
  51352. * The texture URL.
  51353. */
  51354. url: string;
  51355. /**
  51356. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51357. */
  51358. coordinatesMode: number;
  51359. protected _isBlocking: boolean;
  51360. /**
  51361. * Sets wether or not the texture is blocking during loading.
  51362. */
  51363. /**
  51364. * Gets wether or not the texture is blocking during loading.
  51365. */
  51366. isBlocking: boolean;
  51367. protected _rotationY: number;
  51368. /**
  51369. * Sets texture matrix rotation angle around Y axis in radians.
  51370. */
  51371. /**
  51372. * Gets texture matrix rotation angle around Y axis radians.
  51373. */
  51374. rotationY: number;
  51375. /**
  51376. * Gets or sets the center of the bounding box associated with the cube texture
  51377. * It must define where the camera used to render the texture was set
  51378. */
  51379. boundingBoxPosition: Vector3;
  51380. private _boundingBoxSize;
  51381. /**
  51382. * Gets or sets the size of the bounding box associated with the cube texture
  51383. * When defined, the cubemap will switch to local mode
  51384. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51385. * @example https://www.babylonjs-playground.com/#RNASML
  51386. */
  51387. boundingBoxSize: Vector3;
  51388. /**
  51389. * Instantiates an HDRTexture from the following parameters.
  51390. *
  51391. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51392. * @param scene The scene the texture will be used in
  51393. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51394. * @param noMipmap Forces to not generate the mipmap if true
  51395. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51396. * @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)
  51397. * @param reserved Reserved flag for internal use.
  51398. */
  51399. 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>);
  51400. /**
  51401. * Get the current class name of the texture useful for serialization or dynamic coding.
  51402. * @returns "HDRCubeTexture"
  51403. */
  51404. getClassName(): string;
  51405. /**
  51406. * Occurs when the file is raw .hdr file.
  51407. */
  51408. private loadTexture;
  51409. clone(): HDRCubeTexture;
  51410. delayLoad(): void;
  51411. /**
  51412. * Get the texture reflection matrix used to rotate/transform the reflection.
  51413. * @returns the reflection matrix
  51414. */
  51415. getReflectionTextureMatrix(): Matrix;
  51416. /**
  51417. * Set the texture reflection matrix used to rotate/transform the reflection.
  51418. * @param value Define the reflection matrix to set
  51419. */
  51420. setReflectionTextureMatrix(value: Matrix): void;
  51421. /**
  51422. * Parses a JSON representation of an HDR Texture in order to create the texture
  51423. * @param parsedTexture Define the JSON representation
  51424. * @param scene Define the scene the texture should be created in
  51425. * @param rootUrl Define the root url in case we need to load relative dependencies
  51426. * @returns the newly created texture after parsing
  51427. */
  51428. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51429. serialize(): any;
  51430. }
  51431. }
  51432. declare module BABYLON {
  51433. /**
  51434. * Class used to control physics engine
  51435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51436. */
  51437. export class PhysicsEngine implements IPhysicsEngine {
  51438. private _physicsPlugin;
  51439. /**
  51440. * Global value used to control the smallest number supported by the simulation
  51441. */
  51442. static Epsilon: number;
  51443. private _impostors;
  51444. private _joints;
  51445. /**
  51446. * Gets the gravity vector used by the simulation
  51447. */
  51448. gravity: Vector3;
  51449. /**
  51450. * Factory used to create the default physics plugin.
  51451. * @returns The default physics plugin
  51452. */
  51453. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51454. /**
  51455. * Creates a new Physics Engine
  51456. * @param gravity defines the gravity vector used by the simulation
  51457. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51458. */
  51459. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51460. /**
  51461. * Sets the gravity vector used by the simulation
  51462. * @param gravity defines the gravity vector to use
  51463. */
  51464. setGravity(gravity: Vector3): void;
  51465. /**
  51466. * Set the time step of the physics engine.
  51467. * Default is 1/60.
  51468. * To slow it down, enter 1/600 for example.
  51469. * To speed it up, 1/30
  51470. * @param newTimeStep defines the new timestep to apply to this world.
  51471. */
  51472. setTimeStep(newTimeStep?: number): void;
  51473. /**
  51474. * Get the time step of the physics engine.
  51475. * @returns the current time step
  51476. */
  51477. getTimeStep(): number;
  51478. /**
  51479. * Release all resources
  51480. */
  51481. dispose(): void;
  51482. /**
  51483. * Gets the name of the current physics plugin
  51484. * @returns the name of the plugin
  51485. */
  51486. getPhysicsPluginName(): string;
  51487. /**
  51488. * Adding a new impostor for the impostor tracking.
  51489. * This will be done by the impostor itself.
  51490. * @param impostor the impostor to add
  51491. */
  51492. addImpostor(impostor: PhysicsImpostor): void;
  51493. /**
  51494. * Remove an impostor from the engine.
  51495. * This impostor and its mesh will not longer be updated by the physics engine.
  51496. * @param impostor the impostor to remove
  51497. */
  51498. removeImpostor(impostor: PhysicsImpostor): void;
  51499. /**
  51500. * Add a joint to the physics engine
  51501. * @param mainImpostor defines the main impostor to which the joint is added.
  51502. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51503. * @param joint defines the joint that will connect both impostors.
  51504. */
  51505. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51506. /**
  51507. * Removes a joint from the simulation
  51508. * @param mainImpostor defines the impostor used with the joint
  51509. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51510. * @param joint defines the joint to remove
  51511. */
  51512. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51513. /**
  51514. * Called by the scene. No need to call it.
  51515. * @param delta defines the timespam between frames
  51516. */
  51517. _step(delta: number): void;
  51518. /**
  51519. * Gets the current plugin used to run the simulation
  51520. * @returns current plugin
  51521. */
  51522. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51523. /**
  51524. * Gets the list of physic impostors
  51525. * @returns an array of PhysicsImpostor
  51526. */
  51527. getImpostors(): Array<PhysicsImpostor>;
  51528. /**
  51529. * Gets the impostor for a physics enabled object
  51530. * @param object defines the object impersonated by the impostor
  51531. * @returns the PhysicsImpostor or null if not found
  51532. */
  51533. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51534. /**
  51535. * Gets the impostor for a physics body object
  51536. * @param body defines physics body used by the impostor
  51537. * @returns the PhysicsImpostor or null if not found
  51538. */
  51539. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51540. /**
  51541. * Does a raycast in the physics world
  51542. * @param from when should the ray start?
  51543. * @param to when should the ray end?
  51544. * @returns PhysicsRaycastResult
  51545. */
  51546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51547. }
  51548. }
  51549. declare module BABYLON {
  51550. /** @hidden */
  51551. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51552. private _useDeltaForWorldStep;
  51553. world: any;
  51554. name: string;
  51555. private _physicsMaterials;
  51556. private _fixedTimeStep;
  51557. private _cannonRaycastResult;
  51558. private _raycastResult;
  51559. private _physicsBodysToRemoveAfterStep;
  51560. BJSCANNON: any;
  51561. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51562. setGravity(gravity: Vector3): void;
  51563. setTimeStep(timeStep: number): void;
  51564. getTimeStep(): number;
  51565. executeStep(delta: number): void;
  51566. private _removeMarkedPhysicsBodiesFromWorld;
  51567. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51568. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51569. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51570. private _processChildMeshes;
  51571. removePhysicsBody(impostor: PhysicsImpostor): void;
  51572. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51573. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51574. private _addMaterial;
  51575. private _checkWithEpsilon;
  51576. private _createShape;
  51577. private _createHeightmap;
  51578. private _minus90X;
  51579. private _plus90X;
  51580. private _tmpPosition;
  51581. private _tmpDeltaPosition;
  51582. private _tmpUnityRotation;
  51583. private _updatePhysicsBodyTransformation;
  51584. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51585. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51586. isSupported(): boolean;
  51587. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51588. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51589. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51590. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51591. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51592. getBodyMass(impostor: PhysicsImpostor): number;
  51593. getBodyFriction(impostor: PhysicsImpostor): number;
  51594. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51595. getBodyRestitution(impostor: PhysicsImpostor): number;
  51596. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51597. sleepBody(impostor: PhysicsImpostor): void;
  51598. wakeUpBody(impostor: PhysicsImpostor): void;
  51599. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51600. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51601. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51602. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51603. getRadius(impostor: PhysicsImpostor): number;
  51604. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51605. dispose(): void;
  51606. private _extendNamespace;
  51607. /**
  51608. * Does a raycast in the physics world
  51609. * @param from when should the ray start?
  51610. * @param to when should the ray end?
  51611. * @returns PhysicsRaycastResult
  51612. */
  51613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51614. }
  51615. }
  51616. declare module BABYLON {
  51617. /** @hidden */
  51618. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51619. world: any;
  51620. name: string;
  51621. BJSOIMO: any;
  51622. private _raycastResult;
  51623. constructor(iterations?: number, oimoInjection?: any);
  51624. setGravity(gravity: Vector3): void;
  51625. setTimeStep(timeStep: number): void;
  51626. getTimeStep(): number;
  51627. private _tmpImpostorsArray;
  51628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51632. private _tmpPositionVector;
  51633. removePhysicsBody(impostor: PhysicsImpostor): void;
  51634. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51635. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51636. isSupported(): boolean;
  51637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51638. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51639. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51640. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51641. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51642. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51643. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51644. getBodyMass(impostor: PhysicsImpostor): number;
  51645. getBodyFriction(impostor: PhysicsImpostor): number;
  51646. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51647. getBodyRestitution(impostor: PhysicsImpostor): number;
  51648. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51649. sleepBody(impostor: PhysicsImpostor): void;
  51650. wakeUpBody(impostor: PhysicsImpostor): void;
  51651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51652. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51655. getRadius(impostor: PhysicsImpostor): number;
  51656. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51657. dispose(): void;
  51658. /**
  51659. * Does a raycast in the physics world
  51660. * @param from when should the ray start?
  51661. * @param to when should the ray end?
  51662. * @returns PhysicsRaycastResult
  51663. */
  51664. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51665. }
  51666. }
  51667. declare module BABYLON {
  51668. /**
  51669. * Class containing static functions to help procedurally build meshes
  51670. */
  51671. export class RibbonBuilder {
  51672. /**
  51673. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51674. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51675. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51676. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51677. * * 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
  51678. * * 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
  51679. * * 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
  51680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51681. * * 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
  51682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51683. * * 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
  51684. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51685. * * 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
  51686. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51688. * @param name defines the name of the mesh
  51689. * @param options defines the options used to create the mesh
  51690. * @param scene defines the hosting scene
  51691. * @returns the ribbon mesh
  51692. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51693. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51694. */
  51695. static CreateRibbon(name: string, options: {
  51696. pathArray: Vector3[][];
  51697. closeArray?: boolean;
  51698. closePath?: boolean;
  51699. offset?: number;
  51700. updatable?: boolean;
  51701. sideOrientation?: number;
  51702. frontUVs?: Vector4;
  51703. backUVs?: Vector4;
  51704. instance?: Mesh;
  51705. invertUV?: boolean;
  51706. uvs?: Vector2[];
  51707. colors?: Color4[];
  51708. }, scene?: Nullable<Scene>): Mesh;
  51709. }
  51710. }
  51711. declare module BABYLON {
  51712. /**
  51713. * Class containing static functions to help procedurally build meshes
  51714. */
  51715. export class ShapeBuilder {
  51716. /**
  51717. * 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.
  51718. * * 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.
  51719. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51720. * * 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.
  51721. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51722. * * 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
  51723. * * 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
  51724. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51726. * * 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
  51727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51729. * @param name defines the name of the mesh
  51730. * @param options defines the options used to create the mesh
  51731. * @param scene defines the hosting scene
  51732. * @returns the extruded shape mesh
  51733. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51734. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51735. */
  51736. static ExtrudeShape(name: string, options: {
  51737. shape: Vector3[];
  51738. path: Vector3[];
  51739. scale?: number;
  51740. rotation?: number;
  51741. cap?: number;
  51742. updatable?: boolean;
  51743. sideOrientation?: number;
  51744. frontUVs?: Vector4;
  51745. backUVs?: Vector4;
  51746. instance?: Mesh;
  51747. invertUV?: boolean;
  51748. }, scene?: Nullable<Scene>): Mesh;
  51749. /**
  51750. * Creates an custom extruded shape mesh.
  51751. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51752. * * 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.
  51753. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51754. * * 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
  51755. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51756. * * 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
  51757. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51758. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51759. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51760. * * 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
  51761. * * 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
  51762. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51764. * * 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
  51765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51767. * @param name defines the name of the mesh
  51768. * @param options defines the options used to create the mesh
  51769. * @param scene defines the hosting scene
  51770. * @returns the custom extruded shape mesh
  51771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51774. */
  51775. static ExtrudeShapeCustom(name: string, options: {
  51776. shape: Vector3[];
  51777. path: Vector3[];
  51778. scaleFunction?: any;
  51779. rotationFunction?: any;
  51780. ribbonCloseArray?: boolean;
  51781. ribbonClosePath?: boolean;
  51782. cap?: number;
  51783. updatable?: boolean;
  51784. sideOrientation?: number;
  51785. frontUVs?: Vector4;
  51786. backUVs?: Vector4;
  51787. instance?: Mesh;
  51788. invertUV?: boolean;
  51789. }, scene?: Nullable<Scene>): Mesh;
  51790. private static _ExtrudeShapeGeneric;
  51791. }
  51792. }
  51793. declare module BABYLON {
  51794. /**
  51795. * AmmoJS Physics plugin
  51796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51797. * @see https://github.com/kripken/ammo.js/
  51798. */
  51799. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51800. private _useDeltaForWorldStep;
  51801. /**
  51802. * Reference to the Ammo library
  51803. */
  51804. bjsAMMO: any;
  51805. /**
  51806. * Created ammoJS world which physics bodies are added to
  51807. */
  51808. world: any;
  51809. /**
  51810. * Name of the plugin
  51811. */
  51812. name: string;
  51813. private _timeStep;
  51814. private _fixedTimeStep;
  51815. private _maxSteps;
  51816. private _tmpQuaternion;
  51817. private _tmpAmmoTransform;
  51818. private _tmpAmmoQuaternion;
  51819. private _tmpAmmoConcreteContactResultCallback;
  51820. private _collisionConfiguration;
  51821. private _dispatcher;
  51822. private _overlappingPairCache;
  51823. private _solver;
  51824. private _softBodySolver;
  51825. private _tmpAmmoVectorA;
  51826. private _tmpAmmoVectorB;
  51827. private _tmpAmmoVectorC;
  51828. private _tmpAmmoVectorD;
  51829. private _tmpContactCallbackResult;
  51830. private _tmpAmmoVectorRCA;
  51831. private _tmpAmmoVectorRCB;
  51832. private _raycastResult;
  51833. private static readonly DISABLE_COLLISION_FLAG;
  51834. private static readonly KINEMATIC_FLAG;
  51835. private static readonly DISABLE_DEACTIVATION_FLAG;
  51836. /**
  51837. * Initializes the ammoJS plugin
  51838. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51839. * @param ammoInjection can be used to inject your own ammo reference
  51840. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51841. */
  51842. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51843. /**
  51844. * Sets the gravity of the physics world (m/(s^2))
  51845. * @param gravity Gravity to set
  51846. */
  51847. setGravity(gravity: Vector3): void;
  51848. /**
  51849. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51850. * @param timeStep timestep to use in seconds
  51851. */
  51852. setTimeStep(timeStep: number): void;
  51853. /**
  51854. * 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)
  51855. * @param fixedTimeStep fixedTimeStep to use in seconds
  51856. */
  51857. setFixedTimeStep(fixedTimeStep: number): void;
  51858. /**
  51859. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51860. * @param maxSteps the maximum number of steps by the physics engine per frame
  51861. */
  51862. setMaxSteps(maxSteps: number): void;
  51863. /**
  51864. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51865. * @returns the current timestep in seconds
  51866. */
  51867. getTimeStep(): number;
  51868. private _isImpostorInContact;
  51869. private _isImpostorPairInContact;
  51870. private _stepSimulation;
  51871. /**
  51872. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51873. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51874. * After the step the babylon meshes are set to the position of the physics imposters
  51875. * @param delta amount of time to step forward
  51876. * @param impostors array of imposters to update before/after the step
  51877. */
  51878. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51879. /**
  51880. * Update babylon mesh to match physics world object
  51881. * @param impostor imposter to match
  51882. */
  51883. private _afterSoftStep;
  51884. /**
  51885. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51886. * @param impostor imposter to match
  51887. */
  51888. private _ropeStep;
  51889. /**
  51890. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51891. * @param impostor imposter to match
  51892. */
  51893. private _softbodyOrClothStep;
  51894. private _tmpVector;
  51895. private _tmpMatrix;
  51896. /**
  51897. * Applies an impulse on the imposter
  51898. * @param impostor imposter to apply impulse to
  51899. * @param force amount of force to be applied to the imposter
  51900. * @param contactPoint the location to apply the impulse on the imposter
  51901. */
  51902. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51903. /**
  51904. * Applies a force on the imposter
  51905. * @param impostor imposter to apply force
  51906. * @param force amount of force to be applied to the imposter
  51907. * @param contactPoint the location to apply the force on the imposter
  51908. */
  51909. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51910. /**
  51911. * Creates a physics body using the plugin
  51912. * @param impostor the imposter to create the physics body on
  51913. */
  51914. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51915. /**
  51916. * Removes the physics body from the imposter and disposes of the body's memory
  51917. * @param impostor imposter to remove the physics body from
  51918. */
  51919. removePhysicsBody(impostor: PhysicsImpostor): void;
  51920. /**
  51921. * Generates a joint
  51922. * @param impostorJoint the imposter joint to create the joint with
  51923. */
  51924. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51925. /**
  51926. * Removes a joint
  51927. * @param impostorJoint the imposter joint to remove the joint from
  51928. */
  51929. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51930. private _addMeshVerts;
  51931. /**
  51932. * Initialise the soft body vertices to match its object's (mesh) vertices
  51933. * Softbody vertices (nodes) are in world space and to match this
  51934. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51935. * @param impostor to create the softbody for
  51936. */
  51937. private _softVertexData;
  51938. /**
  51939. * Create an impostor's soft body
  51940. * @param impostor to create the softbody for
  51941. */
  51942. private _createSoftbody;
  51943. /**
  51944. * Create cloth for an impostor
  51945. * @param impostor to create the softbody for
  51946. */
  51947. private _createCloth;
  51948. /**
  51949. * Create rope for an impostor
  51950. * @param impostor to create the softbody for
  51951. */
  51952. private _createRope;
  51953. private _addHullVerts;
  51954. private _createShape;
  51955. /**
  51956. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51957. * @param impostor imposter containing the physics body and babylon object
  51958. */
  51959. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51960. /**
  51961. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51962. * @param impostor imposter containing the physics body and babylon object
  51963. * @param newPosition new position
  51964. * @param newRotation new rotation
  51965. */
  51966. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51967. /**
  51968. * If this plugin is supported
  51969. * @returns true if its supported
  51970. */
  51971. isSupported(): boolean;
  51972. /**
  51973. * Sets the linear velocity of the physics body
  51974. * @param impostor imposter to set the velocity on
  51975. * @param velocity velocity to set
  51976. */
  51977. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51978. /**
  51979. * Sets the angular velocity of the physics body
  51980. * @param impostor imposter to set the velocity on
  51981. * @param velocity velocity to set
  51982. */
  51983. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51984. /**
  51985. * gets the linear velocity
  51986. * @param impostor imposter to get linear velocity from
  51987. * @returns linear velocity
  51988. */
  51989. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51990. /**
  51991. * gets the angular velocity
  51992. * @param impostor imposter to get angular velocity from
  51993. * @returns angular velocity
  51994. */
  51995. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51996. /**
  51997. * Sets the mass of physics body
  51998. * @param impostor imposter to set the mass on
  51999. * @param mass mass to set
  52000. */
  52001. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52002. /**
  52003. * Gets the mass of the physics body
  52004. * @param impostor imposter to get the mass from
  52005. * @returns mass
  52006. */
  52007. getBodyMass(impostor: PhysicsImpostor): number;
  52008. /**
  52009. * Gets friction of the impostor
  52010. * @param impostor impostor to get friction from
  52011. * @returns friction value
  52012. */
  52013. getBodyFriction(impostor: PhysicsImpostor): number;
  52014. /**
  52015. * Sets friction of the impostor
  52016. * @param impostor impostor to set friction on
  52017. * @param friction friction value
  52018. */
  52019. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52020. /**
  52021. * Gets restitution of the impostor
  52022. * @param impostor impostor to get restitution from
  52023. * @returns restitution value
  52024. */
  52025. getBodyRestitution(impostor: PhysicsImpostor): number;
  52026. /**
  52027. * Sets resitution of the impostor
  52028. * @param impostor impostor to set resitution on
  52029. * @param restitution resitution value
  52030. */
  52031. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52032. /**
  52033. * Gets pressure inside the impostor
  52034. * @param impostor impostor to get pressure from
  52035. * @returns pressure value
  52036. */
  52037. getBodyPressure(impostor: PhysicsImpostor): number;
  52038. /**
  52039. * Sets pressure inside a soft body impostor
  52040. * Cloth and rope must remain 0 pressure
  52041. * @param impostor impostor to set pressure on
  52042. * @param pressure pressure value
  52043. */
  52044. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52045. /**
  52046. * Gets stiffness of the impostor
  52047. * @param impostor impostor to get stiffness from
  52048. * @returns pressure value
  52049. */
  52050. getBodyStiffness(impostor: PhysicsImpostor): number;
  52051. /**
  52052. * Sets stiffness of the impostor
  52053. * @param impostor impostor to set stiffness on
  52054. * @param stiffness stiffness value from 0 to 1
  52055. */
  52056. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52057. /**
  52058. * Gets velocityIterations of the impostor
  52059. * @param impostor impostor to get velocity iterations from
  52060. * @returns velocityIterations value
  52061. */
  52062. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52063. /**
  52064. * Sets velocityIterations of the impostor
  52065. * @param impostor impostor to set velocity iterations on
  52066. * @param velocityIterations velocityIterations value
  52067. */
  52068. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52069. /**
  52070. * Gets positionIterations of the impostor
  52071. * @param impostor impostor to get position iterations from
  52072. * @returns positionIterations value
  52073. */
  52074. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52075. /**
  52076. * Sets positionIterations of the impostor
  52077. * @param impostor impostor to set position on
  52078. * @param positionIterations positionIterations value
  52079. */
  52080. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52081. /**
  52082. * Append an anchor to a cloth object
  52083. * @param impostor is the cloth impostor to add anchor to
  52084. * @param otherImpostor is the rigid impostor to anchor to
  52085. * @param width ratio across width from 0 to 1
  52086. * @param height ratio up height from 0 to 1
  52087. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52088. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52089. */
  52090. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52091. /**
  52092. * Append an hook to a rope object
  52093. * @param impostor is the rope impostor to add hook to
  52094. * @param otherImpostor is the rigid impostor to hook to
  52095. * @param length ratio along the rope from 0 to 1
  52096. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52098. */
  52099. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52100. /**
  52101. * Sleeps the physics body and stops it from being active
  52102. * @param impostor impostor to sleep
  52103. */
  52104. sleepBody(impostor: PhysicsImpostor): void;
  52105. /**
  52106. * Activates the physics body
  52107. * @param impostor impostor to activate
  52108. */
  52109. wakeUpBody(impostor: PhysicsImpostor): void;
  52110. /**
  52111. * Updates the distance parameters of the joint
  52112. * @param joint joint to update
  52113. * @param maxDistance maximum distance of the joint
  52114. * @param minDistance minimum distance of the joint
  52115. */
  52116. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52117. /**
  52118. * Sets a motor on the joint
  52119. * @param joint joint to set motor on
  52120. * @param speed speed of the motor
  52121. * @param maxForce maximum force of the motor
  52122. * @param motorIndex index of the motor
  52123. */
  52124. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52125. /**
  52126. * Sets the motors limit
  52127. * @param joint joint to set limit on
  52128. * @param upperLimit upper limit
  52129. * @param lowerLimit lower limit
  52130. */
  52131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52132. /**
  52133. * Syncs the position and rotation of a mesh with the impostor
  52134. * @param mesh mesh to sync
  52135. * @param impostor impostor to update the mesh with
  52136. */
  52137. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52138. /**
  52139. * Gets the radius of the impostor
  52140. * @param impostor impostor to get radius from
  52141. * @returns the radius
  52142. */
  52143. getRadius(impostor: PhysicsImpostor): number;
  52144. /**
  52145. * Gets the box size of the impostor
  52146. * @param impostor impostor to get box size from
  52147. * @param result the resulting box size
  52148. */
  52149. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52150. /**
  52151. * Disposes of the impostor
  52152. */
  52153. dispose(): void;
  52154. /**
  52155. * Does a raycast in the physics world
  52156. * @param from when should the ray start?
  52157. * @param to when should the ray end?
  52158. * @returns PhysicsRaycastResult
  52159. */
  52160. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. interface AbstractScene {
  52165. /**
  52166. * The list of reflection probes added to the scene
  52167. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52168. */
  52169. reflectionProbes: Array<ReflectionProbe>;
  52170. /**
  52171. * Removes the given reflection probe from this scene.
  52172. * @param toRemove The reflection probe to remove
  52173. * @returns The index of the removed reflection probe
  52174. */
  52175. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52176. /**
  52177. * Adds the given reflection probe to this scene.
  52178. * @param newReflectionProbe The reflection probe to add
  52179. */
  52180. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52181. }
  52182. /**
  52183. * Class used to generate realtime reflection / refraction cube textures
  52184. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52185. */
  52186. export class ReflectionProbe {
  52187. /** defines the name of the probe */
  52188. name: string;
  52189. private _scene;
  52190. private _renderTargetTexture;
  52191. private _projectionMatrix;
  52192. private _viewMatrix;
  52193. private _target;
  52194. private _add;
  52195. private _attachedMesh;
  52196. private _invertYAxis;
  52197. /** Gets or sets probe position (center of the cube map) */
  52198. position: Vector3;
  52199. /**
  52200. * Creates a new reflection probe
  52201. * @param name defines the name of the probe
  52202. * @param size defines the texture resolution (for each face)
  52203. * @param scene defines the hosting scene
  52204. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52205. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52206. */
  52207. constructor(
  52208. /** defines the name of the probe */
  52209. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52210. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52211. samples: number;
  52212. /** Gets or sets the refresh rate to use (on every frame by default) */
  52213. refreshRate: number;
  52214. /**
  52215. * Gets the hosting scene
  52216. * @returns a Scene
  52217. */
  52218. getScene(): Scene;
  52219. /** Gets the internal CubeTexture used to render to */
  52220. readonly cubeTexture: RenderTargetTexture;
  52221. /** Gets the list of meshes to render */
  52222. readonly renderList: Nullable<AbstractMesh[]>;
  52223. /**
  52224. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52225. * @param mesh defines the mesh to attach to
  52226. */
  52227. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52228. /**
  52229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52230. * @param renderingGroupId The rendering group id corresponding to its index
  52231. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52232. */
  52233. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52234. /**
  52235. * Clean all associated resources
  52236. */
  52237. dispose(): void;
  52238. /**
  52239. * Converts the reflection probe information to a readable string for debug purpose.
  52240. * @param fullDetails Supports for multiple levels of logging within scene loading
  52241. * @returns the human readable reflection probe info
  52242. */
  52243. toString(fullDetails?: boolean): string;
  52244. /**
  52245. * Get the class name of the relfection probe.
  52246. * @returns "ReflectionProbe"
  52247. */
  52248. getClassName(): string;
  52249. /**
  52250. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52251. * @returns The JSON representation of the texture
  52252. */
  52253. serialize(): any;
  52254. /**
  52255. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52256. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52257. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52258. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52259. * @returns The parsed reflection probe if successful
  52260. */
  52261. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52262. }
  52263. }
  52264. declare module BABYLON {
  52265. /** @hidden */
  52266. export var _BabylonLoaderRegistered: boolean;
  52267. /**
  52268. * Helps setting up some configuration for the babylon file loader.
  52269. */
  52270. export class BabylonFileLoaderConfiguration {
  52271. /**
  52272. * The loader does not allow injecting custom physix engine into the plugins.
  52273. * Unfortunately in ES6, we need to manually inject them into the plugin.
  52274. * So you could set this variable to your engine import to make it work.
  52275. */
  52276. static LoaderInjectedPhysicsEngine: any;
  52277. }
  52278. }
  52279. declare module BABYLON {
  52280. /**
  52281. * The Physically based simple base material of BJS.
  52282. *
  52283. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52284. * It is used as the base class for both the specGloss and metalRough conventions.
  52285. */
  52286. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52287. /**
  52288. * Number of Simultaneous lights allowed on the material.
  52289. */
  52290. maxSimultaneousLights: number;
  52291. /**
  52292. * If sets to true, disables all the lights affecting the material.
  52293. */
  52294. disableLighting: boolean;
  52295. /**
  52296. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52297. */
  52298. environmentTexture: BaseTexture;
  52299. /**
  52300. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52301. */
  52302. invertNormalMapX: boolean;
  52303. /**
  52304. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52305. */
  52306. invertNormalMapY: boolean;
  52307. /**
  52308. * Normal map used in the model.
  52309. */
  52310. normalTexture: BaseTexture;
  52311. /**
  52312. * Emissivie color used to self-illuminate the model.
  52313. */
  52314. emissiveColor: Color3;
  52315. /**
  52316. * Emissivie texture used to self-illuminate the model.
  52317. */
  52318. emissiveTexture: BaseTexture;
  52319. /**
  52320. * Occlusion Channel Strenght.
  52321. */
  52322. occlusionStrength: number;
  52323. /**
  52324. * Occlusion Texture of the material (adding extra occlusion effects).
  52325. */
  52326. occlusionTexture: BaseTexture;
  52327. /**
  52328. * Defines the alpha limits in alpha test mode.
  52329. */
  52330. alphaCutOff: number;
  52331. /**
  52332. * Gets the current double sided mode.
  52333. */
  52334. /**
  52335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52336. */
  52337. doubleSided: boolean;
  52338. /**
  52339. * Stores the pre-calculated light information of a mesh in a texture.
  52340. */
  52341. lightmapTexture: BaseTexture;
  52342. /**
  52343. * If true, the light map contains occlusion information instead of lighting info.
  52344. */
  52345. useLightmapAsShadowmap: boolean;
  52346. /**
  52347. * Instantiates a new PBRMaterial instance.
  52348. *
  52349. * @param name The material name
  52350. * @param scene The scene the material will be use in.
  52351. */
  52352. constructor(name: string, scene: Scene);
  52353. getClassName(): string;
  52354. }
  52355. }
  52356. declare module BABYLON {
  52357. /**
  52358. * The PBR material of BJS following the metal roughness convention.
  52359. *
  52360. * This fits to the PBR convention in the GLTF definition:
  52361. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52362. */
  52363. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52364. /**
  52365. * The base color has two different interpretations depending on the value of metalness.
  52366. * When the material is a metal, the base color is the specific measured reflectance value
  52367. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52368. * of the material.
  52369. */
  52370. baseColor: Color3;
  52371. /**
  52372. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52373. * well as opacity information in the alpha channel.
  52374. */
  52375. baseTexture: BaseTexture;
  52376. /**
  52377. * Specifies the metallic scalar value of the material.
  52378. * Can also be used to scale the metalness values of the metallic texture.
  52379. */
  52380. metallic: number;
  52381. /**
  52382. * Specifies the roughness scalar value of the material.
  52383. * Can also be used to scale the roughness values of the metallic texture.
  52384. */
  52385. roughness: number;
  52386. /**
  52387. * Texture containing both the metallic value in the B channel and the
  52388. * roughness value in the G channel to keep better precision.
  52389. */
  52390. metallicRoughnessTexture: BaseTexture;
  52391. /**
  52392. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52393. *
  52394. * @param name The material name
  52395. * @param scene The scene the material will be use in.
  52396. */
  52397. constructor(name: string, scene: Scene);
  52398. /**
  52399. * Return the currrent class name of the material.
  52400. */
  52401. getClassName(): string;
  52402. /**
  52403. * Makes a duplicate of the current material.
  52404. * @param name - name to use for the new material.
  52405. */
  52406. clone(name: string): PBRMetallicRoughnessMaterial;
  52407. /**
  52408. * Serialize the material to a parsable JSON object.
  52409. */
  52410. serialize(): any;
  52411. /**
  52412. * Parses a JSON object correponding to the serialize function.
  52413. */
  52414. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52415. }
  52416. }
  52417. declare module BABYLON {
  52418. /**
  52419. * The PBR material of BJS following the specular glossiness convention.
  52420. *
  52421. * This fits to the PBR convention in the GLTF definition:
  52422. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52423. */
  52424. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52425. /**
  52426. * Specifies the diffuse color of the material.
  52427. */
  52428. diffuseColor: Color3;
  52429. /**
  52430. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52431. * channel.
  52432. */
  52433. diffuseTexture: BaseTexture;
  52434. /**
  52435. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52436. */
  52437. specularColor: Color3;
  52438. /**
  52439. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52440. */
  52441. glossiness: number;
  52442. /**
  52443. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52444. */
  52445. specularGlossinessTexture: BaseTexture;
  52446. /**
  52447. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52448. *
  52449. * @param name The material name
  52450. * @param scene The scene the material will be use in.
  52451. */
  52452. constructor(name: string, scene: Scene);
  52453. /**
  52454. * Return the currrent class name of the material.
  52455. */
  52456. getClassName(): string;
  52457. /**
  52458. * Makes a duplicate of the current material.
  52459. * @param name - name to use for the new material.
  52460. */
  52461. clone(name: string): PBRSpecularGlossinessMaterial;
  52462. /**
  52463. * Serialize the material to a parsable JSON object.
  52464. */
  52465. serialize(): any;
  52466. /**
  52467. * Parses a JSON object correponding to the serialize function.
  52468. */
  52469. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52470. }
  52471. }
  52472. declare module BABYLON {
  52473. /**
  52474. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52475. * It can help converting any input color in a desired output one. This can then be used to create effects
  52476. * from sepia, black and white to sixties or futuristic rendering...
  52477. *
  52478. * The only supported format is currently 3dl.
  52479. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52480. */
  52481. export class ColorGradingTexture extends BaseTexture {
  52482. /**
  52483. * The current texture matrix. (will always be identity in color grading texture)
  52484. */
  52485. private _textureMatrix;
  52486. /**
  52487. * The texture URL.
  52488. */
  52489. url: string;
  52490. /**
  52491. * Empty line regex stored for GC.
  52492. */
  52493. private static _noneEmptyLineRegex;
  52494. private _engine;
  52495. /**
  52496. * Instantiates a ColorGradingTexture from the following parameters.
  52497. *
  52498. * @param url The location of the color gradind data (currently only supporting 3dl)
  52499. * @param scene The scene the texture will be used in
  52500. */
  52501. constructor(url: string, scene: Scene);
  52502. /**
  52503. * Returns the texture matrix used in most of the material.
  52504. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52505. */
  52506. getTextureMatrix(): Matrix;
  52507. /**
  52508. * Occurs when the file being loaded is a .3dl LUT file.
  52509. */
  52510. private load3dlTexture;
  52511. /**
  52512. * Starts the loading process of the texture.
  52513. */
  52514. private loadTexture;
  52515. /**
  52516. * Clones the color gradind texture.
  52517. */
  52518. clone(): ColorGradingTexture;
  52519. /**
  52520. * Called during delayed load for textures.
  52521. */
  52522. delayLoad(): void;
  52523. /**
  52524. * Parses a color grading texture serialized by Babylon.
  52525. * @param parsedTexture The texture information being parsedTexture
  52526. * @param scene The scene to load the texture in
  52527. * @param rootUrl The root url of the data assets to load
  52528. * @return A color gradind texture
  52529. */
  52530. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52531. /**
  52532. * Serializes the LUT texture to json format.
  52533. */
  52534. serialize(): any;
  52535. }
  52536. }
  52537. declare module BABYLON {
  52538. /**
  52539. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52540. */
  52541. export class EquiRectangularCubeTexture extends BaseTexture {
  52542. /** The six faces of the cube. */
  52543. private static _FacesMapping;
  52544. private _noMipmap;
  52545. private _onLoad;
  52546. private _onError;
  52547. /** The size of the cubemap. */
  52548. private _size;
  52549. /** The buffer of the image. */
  52550. private _buffer;
  52551. /** The width of the input image. */
  52552. private _width;
  52553. /** The height of the input image. */
  52554. private _height;
  52555. /** The URL to the image. */
  52556. url: string;
  52557. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52558. coordinatesMode: number;
  52559. /**
  52560. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52561. * @param url The location of the image
  52562. * @param scene The scene the texture will be used in
  52563. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52564. * @param noMipmap Forces to not generate the mipmap if true
  52565. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52566. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52567. * @param onLoad — defines a callback called when texture is loaded
  52568. * @param onError — defines a callback called if there is an error
  52569. */
  52570. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52571. /**
  52572. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52573. */
  52574. private loadImage;
  52575. /**
  52576. * Convert the image buffer into a cubemap and create a CubeTexture.
  52577. */
  52578. private loadTexture;
  52579. /**
  52580. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52581. * @param buffer The ArrayBuffer that should be converted.
  52582. * @returns The buffer as Float32Array.
  52583. */
  52584. private getFloat32ArrayFromArrayBuffer;
  52585. /**
  52586. * Get the current class name of the texture useful for serialization or dynamic coding.
  52587. * @returns "EquiRectangularCubeTexture"
  52588. */
  52589. getClassName(): string;
  52590. /**
  52591. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52592. * @returns A clone of the current EquiRectangularCubeTexture.
  52593. */
  52594. clone(): EquiRectangularCubeTexture;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /**
  52599. * Based on jsTGALoader - Javascript loader for TGA file
  52600. * By Vincent Thibault
  52601. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52602. */
  52603. export class TGATools {
  52604. private static _TYPE_INDEXED;
  52605. private static _TYPE_RGB;
  52606. private static _TYPE_GREY;
  52607. private static _TYPE_RLE_INDEXED;
  52608. private static _TYPE_RLE_RGB;
  52609. private static _TYPE_RLE_GREY;
  52610. private static _ORIGIN_MASK;
  52611. private static _ORIGIN_SHIFT;
  52612. private static _ORIGIN_BL;
  52613. private static _ORIGIN_BR;
  52614. private static _ORIGIN_UL;
  52615. private static _ORIGIN_UR;
  52616. /**
  52617. * Gets the header of a TGA file
  52618. * @param data defines the TGA data
  52619. * @returns the header
  52620. */
  52621. static GetTGAHeader(data: Uint8Array): any;
  52622. /**
  52623. * Uploads TGA content to a Babylon Texture
  52624. * @hidden
  52625. */
  52626. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52627. /** @hidden */
  52628. 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;
  52629. /** @hidden */
  52630. 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;
  52631. /** @hidden */
  52632. 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;
  52633. /** @hidden */
  52634. 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;
  52635. /** @hidden */
  52636. 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;
  52637. /** @hidden */
  52638. 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;
  52639. }
  52640. }
  52641. declare module BABYLON {
  52642. /**
  52643. * Implementation of the TGA Texture Loader.
  52644. * @hidden
  52645. */
  52646. export class _TGATextureLoader implements IInternalTextureLoader {
  52647. /**
  52648. * Defines wether the loader supports cascade loading the different faces.
  52649. */
  52650. readonly supportCascades: boolean;
  52651. /**
  52652. * This returns if the loader support the current file information.
  52653. * @param extension defines the file extension of the file being loaded
  52654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52655. * @param fallback defines the fallback internal texture if any
  52656. * @param isBase64 defines whether the texture is encoded as a base64
  52657. * @param isBuffer defines whether the texture data are stored as a buffer
  52658. * @returns true if the loader can load the specified file
  52659. */
  52660. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52661. /**
  52662. * Transform the url before loading if required.
  52663. * @param rootUrl the url of the texture
  52664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52665. * @returns the transformed texture
  52666. */
  52667. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52668. /**
  52669. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52670. * @param rootUrl the url of the texture
  52671. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52672. * @returns the fallback texture
  52673. */
  52674. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52675. /**
  52676. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52677. * @param data contains the texture data
  52678. * @param texture defines the BabylonJS internal texture
  52679. * @param createPolynomials will be true if polynomials have been requested
  52680. * @param onLoad defines the callback to trigger once the texture is ready
  52681. * @param onError defines the callback to trigger in case of error
  52682. */
  52683. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52684. /**
  52685. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52686. * @param data contains the texture data
  52687. * @param texture defines the BabylonJS internal texture
  52688. * @param callback defines the method to call once ready to upload
  52689. */
  52690. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * Info about the .basis files
  52696. */
  52697. class BasisFileInfo {
  52698. /**
  52699. * If the file has alpha
  52700. */
  52701. hasAlpha: boolean;
  52702. /**
  52703. * Info about each image of the basis file
  52704. */
  52705. images: Array<{
  52706. levels: Array<{
  52707. width: number;
  52708. height: number;
  52709. transcodedPixels: ArrayBufferView;
  52710. }>;
  52711. }>;
  52712. }
  52713. /**
  52714. * Result of transcoding a basis file
  52715. */
  52716. class TranscodeResult {
  52717. /**
  52718. * Info about the .basis file
  52719. */
  52720. fileInfo: BasisFileInfo;
  52721. /**
  52722. * Format to use when loading the file
  52723. */
  52724. format: number;
  52725. }
  52726. /**
  52727. * Configuration options for the Basis transcoder
  52728. */
  52729. export class BasisTranscodeConfiguration {
  52730. /**
  52731. * Supported compression formats used to determine the supported output format of the transcoder
  52732. */
  52733. supportedCompressionFormats?: {
  52734. /**
  52735. * etc1 compression format
  52736. */
  52737. etc1?: boolean;
  52738. /**
  52739. * s3tc compression format
  52740. */
  52741. s3tc?: boolean;
  52742. /**
  52743. * pvrtc compression format
  52744. */
  52745. pvrtc?: boolean;
  52746. /**
  52747. * etc2 compression format
  52748. */
  52749. etc2?: boolean;
  52750. };
  52751. /**
  52752. * If mipmap levels should be loaded for transcoded images (Default: true)
  52753. */
  52754. loadMipmapLevels?: boolean;
  52755. /**
  52756. * Index of a single image to load (Default: all images)
  52757. */
  52758. loadSingleImage?: number;
  52759. }
  52760. /**
  52761. * Used to load .Basis files
  52762. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52763. */
  52764. export class BasisTools {
  52765. private static _IgnoreSupportedFormats;
  52766. /**
  52767. * URL to use when loading the basis transcoder
  52768. */
  52769. static JSModuleURL: string;
  52770. /**
  52771. * URL to use when loading the wasm module for the transcoder
  52772. */
  52773. static WasmModuleURL: string;
  52774. /**
  52775. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52776. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52777. * @returns internal format corresponding to the Basis format
  52778. */
  52779. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52780. private static _WorkerPromise;
  52781. private static _Worker;
  52782. private static _actionId;
  52783. private static _CreateWorkerAsync;
  52784. /**
  52785. * Transcodes a loaded image file to compressed pixel data
  52786. * @param imageData image data to transcode
  52787. * @param config configuration options for the transcoding
  52788. * @returns a promise resulting in the transcoded image
  52789. */
  52790. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52791. /**
  52792. * Loads a texture from the transcode result
  52793. * @param texture texture load to
  52794. * @param transcodeResult the result of transcoding the basis file to load from
  52795. */
  52796. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52797. }
  52798. }
  52799. declare module BABYLON {
  52800. /**
  52801. * Loader for .basis file format
  52802. */
  52803. export class _BasisTextureLoader implements IInternalTextureLoader {
  52804. /**
  52805. * Defines whether the loader supports cascade loading the different faces.
  52806. */
  52807. readonly supportCascades: boolean;
  52808. /**
  52809. * This returns if the loader support the current file information.
  52810. * @param extension defines the file extension of the file being loaded
  52811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52812. * @param fallback defines the fallback internal texture if any
  52813. * @param isBase64 defines whether the texture is encoded as a base64
  52814. * @param isBuffer defines whether the texture data are stored as a buffer
  52815. * @returns true if the loader can load the specified file
  52816. */
  52817. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52818. /**
  52819. * Transform the url before loading if required.
  52820. * @param rootUrl the url of the texture
  52821. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52822. * @returns the transformed texture
  52823. */
  52824. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52825. /**
  52826. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52827. * @param rootUrl the url of the texture
  52828. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52829. * @returns the fallback texture
  52830. */
  52831. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52832. /**
  52833. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52834. * @param data contains the texture data
  52835. * @param texture defines the BabylonJS internal texture
  52836. * @param createPolynomials will be true if polynomials have been requested
  52837. * @param onLoad defines the callback to trigger once the texture is ready
  52838. * @param onError defines the callback to trigger in case of error
  52839. */
  52840. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52841. /**
  52842. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52843. * @param data contains the texture data
  52844. * @param texture defines the BabylonJS internal texture
  52845. * @param callback defines the method to call once ready to upload
  52846. */
  52847. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52848. }
  52849. }
  52850. declare module BABYLON {
  52851. /**
  52852. * 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.
  52853. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52854. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52855. */
  52856. export class CustomProceduralTexture extends ProceduralTexture {
  52857. private _animate;
  52858. private _time;
  52859. private _config;
  52860. private _texturePath;
  52861. /**
  52862. * Instantiates a new Custom Procedural Texture.
  52863. * 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.
  52864. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52865. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52866. * @param name Define the name of the texture
  52867. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52868. * @param size Define the size of the texture to create
  52869. * @param scene Define the scene the texture belongs to
  52870. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52871. * @param generateMipMaps Define if the texture should creates mip maps or not
  52872. */
  52873. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52874. private _loadJson;
  52875. /**
  52876. * Is the texture ready to be used ? (rendered at least once)
  52877. * @returns true if ready, otherwise, false.
  52878. */
  52879. isReady(): boolean;
  52880. /**
  52881. * Render the texture to its associated render target.
  52882. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52883. */
  52884. render(useCameraPostProcess?: boolean): void;
  52885. /**
  52886. * Update the list of dependant textures samplers in the shader.
  52887. */
  52888. updateTextures(): void;
  52889. /**
  52890. * Update the uniform values of the procedural texture in the shader.
  52891. */
  52892. updateShaderUniforms(): void;
  52893. /**
  52894. * Define if the texture animates or not.
  52895. */
  52896. animate: boolean;
  52897. }
  52898. }
  52899. declare module BABYLON {
  52900. /** @hidden */
  52901. export var noisePixelShader: {
  52902. name: string;
  52903. shader: string;
  52904. };
  52905. }
  52906. declare module BABYLON {
  52907. /**
  52908. * Class used to generate noise procedural textures
  52909. */
  52910. export class NoiseProceduralTexture extends ProceduralTexture {
  52911. private _time;
  52912. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52913. brightness: number;
  52914. /** Defines the number of octaves to process */
  52915. octaves: number;
  52916. /** Defines the level of persistence (0.8 by default) */
  52917. persistence: number;
  52918. /** Gets or sets animation speed factor (default is 1) */
  52919. animationSpeedFactor: number;
  52920. /**
  52921. * Creates a new NoiseProceduralTexture
  52922. * @param name defines the name fo the texture
  52923. * @param size defines the size of the texture (default is 256)
  52924. * @param scene defines the hosting scene
  52925. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52926. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52927. */
  52928. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52929. private _updateShaderUniforms;
  52930. protected _getDefines(): string;
  52931. /** Generate the current state of the procedural texture */
  52932. render(useCameraPostProcess?: boolean): void;
  52933. /**
  52934. * Serializes this noise procedural texture
  52935. * @returns a serialized noise procedural texture object
  52936. */
  52937. serialize(): any;
  52938. /**
  52939. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52940. * @param parsedTexture defines parsed texture data
  52941. * @param scene defines the current scene
  52942. * @param rootUrl defines the root URL containing noise procedural texture information
  52943. * @returns a parsed NoiseProceduralTexture
  52944. */
  52945. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52946. }
  52947. }
  52948. declare module BABYLON {
  52949. /**
  52950. * Raw cube texture where the raw buffers are passed in
  52951. */
  52952. export class RawCubeTexture extends CubeTexture {
  52953. /**
  52954. * Creates a cube texture where the raw buffers are passed in.
  52955. * @param scene defines the scene the texture is attached to
  52956. * @param data defines the array of data to use to create each face
  52957. * @param size defines the size of the textures
  52958. * @param format defines the format of the data
  52959. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52960. * @param generateMipMaps defines if the engine should generate the mip levels
  52961. * @param invertY defines if data must be stored with Y axis inverted
  52962. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52963. * @param compression defines the compression used (null by default)
  52964. */
  52965. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52966. /**
  52967. * Updates the raw cube texture.
  52968. * @param data defines the data to store
  52969. * @param format defines the data format
  52970. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52971. * @param invertY defines if data must be stored with Y axis inverted
  52972. * @param compression defines the compression used (null by default)
  52973. * @param level defines which level of the texture to update
  52974. */
  52975. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52976. /**
  52977. * Updates a raw cube texture with RGBD encoded data.
  52978. * @param data defines the array of data [mipmap][face] to use to create each face
  52979. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52980. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52981. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52982. * @returns a promsie that resolves when the operation is complete
  52983. */
  52984. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52985. /**
  52986. * Clones the raw cube texture.
  52987. * @return a new cube texture
  52988. */
  52989. clone(): CubeTexture;
  52990. /** @hidden */
  52991. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52992. }
  52993. }
  52994. declare module BABYLON {
  52995. /**
  52996. * Class used to store 3D textures containing user data
  52997. */
  52998. export class RawTexture3D extends Texture {
  52999. /** Gets or sets the texture format to use */
  53000. format: number;
  53001. private _engine;
  53002. /**
  53003. * Create a new RawTexture3D
  53004. * @param data defines the data of the texture
  53005. * @param width defines the width of the texture
  53006. * @param height defines the height of the texture
  53007. * @param depth defines the depth of the texture
  53008. * @param format defines the texture format to use
  53009. * @param scene defines the hosting scene
  53010. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53011. * @param invertY defines if texture must be stored with Y axis inverted
  53012. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53013. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53014. */
  53015. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53016. /** Gets or sets the texture format to use */
  53017. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53018. /**
  53019. * Update the texture with new data
  53020. * @param data defines the data to store in the texture
  53021. */
  53022. update(data: ArrayBufferView): void;
  53023. }
  53024. }
  53025. declare module BABYLON {
  53026. /**
  53027. * Class used to store 2D array textures containing user data
  53028. */
  53029. export class RawTexture2DArray extends Texture {
  53030. /** Gets or sets the texture format to use */
  53031. format: number;
  53032. private _engine;
  53033. /**
  53034. * Create a new RawTexture2DArray
  53035. * @param data defines the data of the texture
  53036. * @param width defines the width of the texture
  53037. * @param height defines the height of the texture
  53038. * @param depth defines the number of layers of the texture
  53039. * @param format defines the texture format to use
  53040. * @param scene defines the hosting scene
  53041. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53042. * @param invertY defines if texture must be stored with Y axis inverted
  53043. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53044. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53045. */
  53046. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53047. /** Gets or sets the texture format to use */
  53048. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53049. /**
  53050. * Update the texture with new data
  53051. * @param data defines the data to store in the texture
  53052. */
  53053. update(data: ArrayBufferView): void;
  53054. }
  53055. }
  53056. declare module BABYLON {
  53057. /**
  53058. * Creates a refraction texture used by refraction channel of the standard material.
  53059. * It is like a mirror but to see through a material.
  53060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53061. */
  53062. export class RefractionTexture extends RenderTargetTexture {
  53063. /**
  53064. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53065. * 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.
  53066. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53067. */
  53068. refractionPlane: Plane;
  53069. /**
  53070. * Define how deep under the surface we should see.
  53071. */
  53072. depth: number;
  53073. /**
  53074. * Creates a refraction texture used by refraction channel of the standard material.
  53075. * It is like a mirror but to see through a material.
  53076. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53077. * @param name Define the texture name
  53078. * @param size Define the size of the underlying texture
  53079. * @param scene Define the scene the refraction belongs to
  53080. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53081. */
  53082. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53083. /**
  53084. * Clone the refraction texture.
  53085. * @returns the cloned texture
  53086. */
  53087. clone(): RefractionTexture;
  53088. /**
  53089. * Serialize the texture to a JSON representation you could use in Parse later on
  53090. * @returns the serialized JSON representation
  53091. */
  53092. serialize(): any;
  53093. }
  53094. }
  53095. declare module BABYLON {
  53096. /**
  53097. * Defines the options related to the creation of an HtmlElementTexture
  53098. */
  53099. export interface IHtmlElementTextureOptions {
  53100. /**
  53101. * Defines wether mip maps should be created or not.
  53102. */
  53103. generateMipMaps?: boolean;
  53104. /**
  53105. * Defines the sampling mode of the texture.
  53106. */
  53107. samplingMode?: number;
  53108. /**
  53109. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53110. */
  53111. engine: Nullable<ThinEngine>;
  53112. /**
  53113. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53114. */
  53115. scene: Nullable<Scene>;
  53116. }
  53117. /**
  53118. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53119. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53120. * is automatically managed.
  53121. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53122. * in your application.
  53123. *
  53124. * As the update is not automatic, you need to call them manually.
  53125. */
  53126. export class HtmlElementTexture extends BaseTexture {
  53127. /**
  53128. * The texture URL.
  53129. */
  53130. element: HTMLVideoElement | HTMLCanvasElement;
  53131. private static readonly DefaultOptions;
  53132. private _textureMatrix;
  53133. private _engine;
  53134. private _isVideo;
  53135. private _generateMipMaps;
  53136. private _samplingMode;
  53137. /**
  53138. * Instantiates a HtmlElementTexture from the following parameters.
  53139. *
  53140. * @param name Defines the name of the texture
  53141. * @param element Defines the video or canvas the texture is filled with
  53142. * @param options Defines the other none mandatory texture creation options
  53143. */
  53144. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53145. private _createInternalTexture;
  53146. /**
  53147. * Returns the texture matrix used in most of the material.
  53148. */
  53149. getTextureMatrix(): Matrix;
  53150. /**
  53151. * Updates the content of the texture.
  53152. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53153. */
  53154. update(invertY?: Nullable<boolean>): void;
  53155. }
  53156. }
  53157. declare module BABYLON {
  53158. /**
  53159. * Enum used to define the target of a block
  53160. */
  53161. export enum NodeMaterialBlockTargets {
  53162. /** Vertex shader */
  53163. Vertex = 1,
  53164. /** Fragment shader */
  53165. Fragment = 2,
  53166. /** Neutral */
  53167. Neutral = 4,
  53168. /** Vertex and Fragment */
  53169. VertexAndFragment = 3
  53170. }
  53171. }
  53172. declare module BABYLON {
  53173. /**
  53174. * Defines the kind of connection point for node based material
  53175. */
  53176. export enum NodeMaterialBlockConnectionPointTypes {
  53177. /** Float */
  53178. Float = 1,
  53179. /** Int */
  53180. Int = 2,
  53181. /** Vector2 */
  53182. Vector2 = 4,
  53183. /** Vector3 */
  53184. Vector3 = 8,
  53185. /** Vector4 */
  53186. Vector4 = 16,
  53187. /** Color3 */
  53188. Color3 = 32,
  53189. /** Color4 */
  53190. Color4 = 64,
  53191. /** Matrix */
  53192. Matrix = 128,
  53193. /** Detect type based on connection */
  53194. AutoDetect = 1024,
  53195. /** Output type that will be defined by input type */
  53196. BasedOnInput = 2048
  53197. }
  53198. }
  53199. declare module BABYLON {
  53200. /**
  53201. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53202. */
  53203. export enum NodeMaterialBlockConnectionPointMode {
  53204. /** Value is an uniform */
  53205. Uniform = 0,
  53206. /** Value is a mesh attribute */
  53207. Attribute = 1,
  53208. /** Value is a varying between vertex and fragment shaders */
  53209. Varying = 2,
  53210. /** Mode is undefined */
  53211. Undefined = 3
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Enum used to define system values e.g. values automatically provided by the system
  53217. */
  53218. export enum NodeMaterialSystemValues {
  53219. /** World */
  53220. World = 1,
  53221. /** View */
  53222. View = 2,
  53223. /** Projection */
  53224. Projection = 3,
  53225. /** ViewProjection */
  53226. ViewProjection = 4,
  53227. /** WorldView */
  53228. WorldView = 5,
  53229. /** WorldViewProjection */
  53230. WorldViewProjection = 6,
  53231. /** CameraPosition */
  53232. CameraPosition = 7,
  53233. /** Fog Color */
  53234. FogColor = 8,
  53235. /** Delta time */
  53236. DeltaTime = 9
  53237. }
  53238. }
  53239. declare module BABYLON {
  53240. /**
  53241. * Root class for all node material optimizers
  53242. */
  53243. export class NodeMaterialOptimizer {
  53244. /**
  53245. * Function used to optimize a NodeMaterial graph
  53246. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53247. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53248. */
  53249. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53250. }
  53251. }
  53252. declare module BABYLON {
  53253. /**
  53254. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53255. */
  53256. export class TransformBlock extends NodeMaterialBlock {
  53257. /**
  53258. * Defines the value to use to complement W value to transform it to a Vector4
  53259. */
  53260. complementW: number;
  53261. /**
  53262. * Defines the value to use to complement z value to transform it to a Vector4
  53263. */
  53264. complementZ: number;
  53265. /**
  53266. * Creates a new TransformBlock
  53267. * @param name defines the block name
  53268. */
  53269. constructor(name: string);
  53270. /**
  53271. * Gets the current class name
  53272. * @returns the class name
  53273. */
  53274. getClassName(): string;
  53275. /**
  53276. * Gets the vector input
  53277. */
  53278. readonly vector: NodeMaterialConnectionPoint;
  53279. /**
  53280. * Gets the output component
  53281. */
  53282. readonly output: NodeMaterialConnectionPoint;
  53283. /**
  53284. * Gets the matrix transform input
  53285. */
  53286. readonly transform: NodeMaterialConnectionPoint;
  53287. protected _buildBlock(state: NodeMaterialBuildState): this;
  53288. serialize(): any;
  53289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53290. protected _dumpPropertiesCode(): string;
  53291. }
  53292. }
  53293. declare module BABYLON {
  53294. /**
  53295. * Block used to output the vertex position
  53296. */
  53297. export class VertexOutputBlock extends NodeMaterialBlock {
  53298. /**
  53299. * Creates a new VertexOutputBlock
  53300. * @param name defines the block name
  53301. */
  53302. constructor(name: string);
  53303. /**
  53304. * Gets the current class name
  53305. * @returns the class name
  53306. */
  53307. getClassName(): string;
  53308. /**
  53309. * Gets the vector input component
  53310. */
  53311. readonly vector: NodeMaterialConnectionPoint;
  53312. protected _buildBlock(state: NodeMaterialBuildState): this;
  53313. }
  53314. }
  53315. declare module BABYLON {
  53316. /**
  53317. * Block used to output the final color
  53318. */
  53319. export class FragmentOutputBlock extends NodeMaterialBlock {
  53320. /**
  53321. * Create a new FragmentOutputBlock
  53322. * @param name defines the block name
  53323. */
  53324. constructor(name: string);
  53325. /**
  53326. * Gets the current class name
  53327. * @returns the class name
  53328. */
  53329. getClassName(): string;
  53330. /**
  53331. * Gets the rgba input component
  53332. */
  53333. readonly rgba: NodeMaterialConnectionPoint;
  53334. /**
  53335. * Gets the rgb input component
  53336. */
  53337. readonly rgb: NodeMaterialConnectionPoint;
  53338. /**
  53339. * Gets the a input component
  53340. */
  53341. readonly a: NodeMaterialConnectionPoint;
  53342. protected _buildBlock(state: NodeMaterialBuildState): this;
  53343. }
  53344. }
  53345. declare module BABYLON {
  53346. /**
  53347. * Block used to read a reflection texture from a sampler
  53348. */
  53349. export class ReflectionTextureBlock extends NodeMaterialBlock {
  53350. private _define3DName;
  53351. private _defineCubicName;
  53352. private _defineExplicitName;
  53353. private _defineProjectionName;
  53354. private _defineLocalCubicName;
  53355. private _defineSphericalName;
  53356. private _definePlanarName;
  53357. private _defineEquirectangularName;
  53358. private _defineMirroredEquirectangularFixedName;
  53359. private _defineEquirectangularFixedName;
  53360. private _defineSkyboxName;
  53361. private _cubeSamplerName;
  53362. private _2DSamplerName;
  53363. private _positionUVWName;
  53364. private _directionWName;
  53365. private _reflectionCoordsName;
  53366. private _reflection2DCoordsName;
  53367. private _reflectionColorName;
  53368. private _reflectionMatrixName;
  53369. /**
  53370. * Gets or sets the texture associated with the node
  53371. */
  53372. texture: Nullable<BaseTexture>;
  53373. /**
  53374. * Create a new TextureBlock
  53375. * @param name defines the block name
  53376. */
  53377. constructor(name: string);
  53378. /**
  53379. * Gets the current class name
  53380. * @returns the class name
  53381. */
  53382. getClassName(): string;
  53383. /**
  53384. * Gets the world position input component
  53385. */
  53386. readonly position: NodeMaterialConnectionPoint;
  53387. /**
  53388. * Gets the world position input component
  53389. */
  53390. readonly worldPosition: NodeMaterialConnectionPoint;
  53391. /**
  53392. * Gets the world normal input component
  53393. */
  53394. readonly worldNormal: NodeMaterialConnectionPoint;
  53395. /**
  53396. * Gets the world input component
  53397. */
  53398. readonly world: NodeMaterialConnectionPoint;
  53399. /**
  53400. * Gets the camera (or eye) position component
  53401. */
  53402. readonly cameraPosition: NodeMaterialConnectionPoint;
  53403. /**
  53404. * Gets the view input component
  53405. */
  53406. readonly view: NodeMaterialConnectionPoint;
  53407. /**
  53408. * Gets the rgb output component
  53409. */
  53410. readonly rgb: NodeMaterialConnectionPoint;
  53411. /**
  53412. * Gets the r output component
  53413. */
  53414. readonly r: NodeMaterialConnectionPoint;
  53415. /**
  53416. * Gets the g output component
  53417. */
  53418. readonly g: NodeMaterialConnectionPoint;
  53419. /**
  53420. * Gets the b output component
  53421. */
  53422. readonly b: NodeMaterialConnectionPoint;
  53423. autoConfigure(material: NodeMaterial): void;
  53424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53425. isReady(): boolean;
  53426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53427. private _injectVertexCode;
  53428. private _writeOutput;
  53429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53430. protected _dumpPropertiesCode(): string;
  53431. serialize(): any;
  53432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53433. }
  53434. }
  53435. declare module BABYLON {
  53436. /**
  53437. * Interface used to configure the node material editor
  53438. */
  53439. export interface INodeMaterialEditorOptions {
  53440. /** Define the URl to load node editor script */
  53441. editorURL?: string;
  53442. }
  53443. /** @hidden */
  53444. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53445. /** BONES */
  53446. NUM_BONE_INFLUENCERS: number;
  53447. BonesPerMesh: number;
  53448. BONETEXTURE: boolean;
  53449. /** MORPH TARGETS */
  53450. MORPHTARGETS: boolean;
  53451. MORPHTARGETS_NORMAL: boolean;
  53452. MORPHTARGETS_TANGENT: boolean;
  53453. MORPHTARGETS_UV: boolean;
  53454. NUM_MORPH_INFLUENCERS: number;
  53455. /** IMAGE PROCESSING */
  53456. IMAGEPROCESSING: boolean;
  53457. VIGNETTE: boolean;
  53458. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53459. VIGNETTEBLENDMODEOPAQUE: boolean;
  53460. TONEMAPPING: boolean;
  53461. TONEMAPPING_ACES: boolean;
  53462. CONTRAST: boolean;
  53463. EXPOSURE: boolean;
  53464. COLORCURVES: boolean;
  53465. COLORGRADING: boolean;
  53466. COLORGRADING3D: boolean;
  53467. SAMPLER3DGREENDEPTH: boolean;
  53468. SAMPLER3DBGRMAP: boolean;
  53469. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53470. /** MISC. */
  53471. BUMPDIRECTUV: number;
  53472. constructor();
  53473. setValue(name: string, value: boolean): void;
  53474. }
  53475. /**
  53476. * Class used to configure NodeMaterial
  53477. */
  53478. export interface INodeMaterialOptions {
  53479. /**
  53480. * Defines if blocks should emit comments
  53481. */
  53482. emitComments: boolean;
  53483. }
  53484. /**
  53485. * Class used to create a node based material built by assembling shader blocks
  53486. */
  53487. export class NodeMaterial extends PushMaterial {
  53488. private static _BuildIdGenerator;
  53489. private _options;
  53490. private _vertexCompilationState;
  53491. private _fragmentCompilationState;
  53492. private _sharedData;
  53493. private _buildId;
  53494. private _buildWasSuccessful;
  53495. private _cachedWorldViewMatrix;
  53496. private _cachedWorldViewProjectionMatrix;
  53497. private _optimizers;
  53498. private _animationFrame;
  53499. /** Define the URl to load node editor script */
  53500. static EditorURL: string;
  53501. private BJSNODEMATERIALEDITOR;
  53502. /** Get the inspector from bundle or global */
  53503. private _getGlobalNodeMaterialEditor;
  53504. /**
  53505. * 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)
  53506. */
  53507. ignoreAlpha: boolean;
  53508. /**
  53509. * Defines the maximum number of lights that can be used in the material
  53510. */
  53511. maxSimultaneousLights: number;
  53512. /**
  53513. * Observable raised when the material is built
  53514. */
  53515. onBuildObservable: Observable<NodeMaterial>;
  53516. /**
  53517. * Gets or sets the root nodes of the material vertex shader
  53518. */
  53519. _vertexOutputNodes: NodeMaterialBlock[];
  53520. /**
  53521. * Gets or sets the root nodes of the material fragment (pixel) shader
  53522. */
  53523. _fragmentOutputNodes: NodeMaterialBlock[];
  53524. /** Gets or sets options to control the node material overall behavior */
  53525. options: INodeMaterialOptions;
  53526. /**
  53527. * Default configuration related to image processing available in the standard Material.
  53528. */
  53529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53530. /**
  53531. * Gets the image processing configuration used either in this material.
  53532. */
  53533. /**
  53534. * Sets the Default image processing configuration used either in the this material.
  53535. *
  53536. * If sets to null, the scene one is in use.
  53537. */
  53538. imageProcessingConfiguration: ImageProcessingConfiguration;
  53539. /**
  53540. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53541. */
  53542. attachedBlocks: NodeMaterialBlock[];
  53543. /**
  53544. * Create a new node based material
  53545. * @param name defines the material name
  53546. * @param scene defines the hosting scene
  53547. * @param options defines creation option
  53548. */
  53549. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53550. /**
  53551. * Gets the current class name of the material e.g. "NodeMaterial"
  53552. * @returns the class name
  53553. */
  53554. getClassName(): string;
  53555. /**
  53556. * Keep track of the image processing observer to allow dispose and replace.
  53557. */
  53558. private _imageProcessingObserver;
  53559. /**
  53560. * Attaches a new image processing configuration to the Standard Material.
  53561. * @param configuration
  53562. */
  53563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53564. /**
  53565. * Get a block by its name
  53566. * @param name defines the name of the block to retrieve
  53567. * @returns the required block or null if not found
  53568. */
  53569. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53570. /**
  53571. * Get a block by its name
  53572. * @param predicate defines the predicate used to find the good candidate
  53573. * @returns the required block or null if not found
  53574. */
  53575. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53576. /**
  53577. * Get an input block by its name
  53578. * @param predicate defines the predicate used to find the good candidate
  53579. * @returns the required input block or null if not found
  53580. */
  53581. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53582. /**
  53583. * Gets the list of input blocks attached to this material
  53584. * @returns an array of InputBlocks
  53585. */
  53586. getInputBlocks(): InputBlock[];
  53587. /**
  53588. * Adds a new optimizer to the list of optimizers
  53589. * @param optimizer defines the optimizers to add
  53590. * @returns the current material
  53591. */
  53592. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53593. /**
  53594. * Remove an optimizer from the list of optimizers
  53595. * @param optimizer defines the optimizers to remove
  53596. * @returns the current material
  53597. */
  53598. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53599. /**
  53600. * Add a new block to the list of output nodes
  53601. * @param node defines the node to add
  53602. * @returns the current material
  53603. */
  53604. addOutputNode(node: NodeMaterialBlock): this;
  53605. /**
  53606. * Remove a block from the list of root nodes
  53607. * @param node defines the node to remove
  53608. * @returns the current material
  53609. */
  53610. removeOutputNode(node: NodeMaterialBlock): this;
  53611. private _addVertexOutputNode;
  53612. private _removeVertexOutputNode;
  53613. private _addFragmentOutputNode;
  53614. private _removeFragmentOutputNode;
  53615. /**
  53616. * Specifies if the material will require alpha blending
  53617. * @returns a boolean specifying if alpha blending is needed
  53618. */
  53619. needAlphaBlending(): boolean;
  53620. /**
  53621. * Specifies if this material should be rendered in alpha test mode
  53622. * @returns a boolean specifying if an alpha test is needed.
  53623. */
  53624. needAlphaTesting(): boolean;
  53625. private _initializeBlock;
  53626. private _resetDualBlocks;
  53627. /**
  53628. * Build the material and generates the inner effect
  53629. * @param verbose defines if the build should log activity
  53630. */
  53631. build(verbose?: boolean): void;
  53632. /**
  53633. * Runs an otpimization phase to try to improve the shader code
  53634. */
  53635. optimize(): void;
  53636. private _prepareDefinesForAttributes;
  53637. /**
  53638. * Get if the submesh is ready to be used and all its information available.
  53639. * Child classes can use it to update shaders
  53640. * @param mesh defines the mesh to check
  53641. * @param subMesh defines which submesh to check
  53642. * @param useInstances specifies that instances should be used
  53643. * @returns a boolean indicating that the submesh is ready or not
  53644. */
  53645. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53646. /**
  53647. * Get a string representing the shaders built by the current node graph
  53648. */
  53649. readonly compiledShaders: string;
  53650. /**
  53651. * Binds the world matrix to the material
  53652. * @param world defines the world transformation matrix
  53653. */
  53654. bindOnlyWorldMatrix(world: Matrix): void;
  53655. /**
  53656. * Binds the submesh to this material by preparing the effect and shader to draw
  53657. * @param world defines the world transformation matrix
  53658. * @param mesh defines the mesh containing the submesh
  53659. * @param subMesh defines the submesh to bind the material to
  53660. */
  53661. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53662. /**
  53663. * Gets the active textures from the material
  53664. * @returns an array of textures
  53665. */
  53666. getActiveTextures(): BaseTexture[];
  53667. /**
  53668. * Gets the list of texture blocks
  53669. * @returns an array of texture blocks
  53670. */
  53671. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53672. /**
  53673. * Specifies if the material uses a texture
  53674. * @param texture defines the texture to check against the material
  53675. * @returns a boolean specifying if the material uses the texture
  53676. */
  53677. hasTexture(texture: BaseTexture): boolean;
  53678. /**
  53679. * Disposes the material
  53680. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53681. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53682. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53683. */
  53684. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53685. /** Creates the node editor window. */
  53686. private _createNodeEditor;
  53687. /**
  53688. * Launch the node material editor
  53689. * @param config Define the configuration of the editor
  53690. * @return a promise fulfilled when the node editor is visible
  53691. */
  53692. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53693. /**
  53694. * Clear the current material
  53695. */
  53696. clear(): void;
  53697. /**
  53698. * Clear the current material and set it to a default state
  53699. */
  53700. setToDefault(): void;
  53701. /**
  53702. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53703. * @param url defines the url to load from
  53704. * @returns a promise that will fullfil when the material is fully loaded
  53705. */
  53706. loadAsync(url: string): Promise<void>;
  53707. private _gatherBlocks;
  53708. /**
  53709. * Generate a string containing the code declaration required to create an equivalent of this material
  53710. * @returns a string
  53711. */
  53712. generateCode(): string;
  53713. /**
  53714. * Serializes this material in a JSON representation
  53715. * @returns the serialized material object
  53716. */
  53717. serialize(): any;
  53718. private _restoreConnections;
  53719. /**
  53720. * Clear the current graph and load a new one from a serialization object
  53721. * @param source defines the JSON representation of the material
  53722. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53723. */
  53724. loadFromSerialization(source: any, rootUrl?: string): void;
  53725. /**
  53726. * Creates a node material from parsed material data
  53727. * @param source defines the JSON representation of the material
  53728. * @param scene defines the hosting scene
  53729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53730. * @returns a new node material
  53731. */
  53732. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53733. /**
  53734. * Creates a new node material set to default basic configuration
  53735. * @param name defines the name of the material
  53736. * @param scene defines the hosting scene
  53737. * @returns a new NodeMaterial
  53738. */
  53739. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53740. }
  53741. }
  53742. declare module BABYLON {
  53743. /**
  53744. * Block used to read a texture from a sampler
  53745. */
  53746. export class TextureBlock extends NodeMaterialBlock {
  53747. private _defineName;
  53748. private _linearDefineName;
  53749. private _samplerName;
  53750. private _transformedUVName;
  53751. private _textureTransformName;
  53752. private _textureInfoName;
  53753. private _mainUVName;
  53754. private _mainUVDefineName;
  53755. /**
  53756. * Gets or sets the texture associated with the node
  53757. */
  53758. texture: Nullable<Texture>;
  53759. /**
  53760. * Create a new TextureBlock
  53761. * @param name defines the block name
  53762. */
  53763. constructor(name: string);
  53764. /**
  53765. * Gets the current class name
  53766. * @returns the class name
  53767. */
  53768. getClassName(): string;
  53769. /**
  53770. * Gets the uv input component
  53771. */
  53772. readonly uv: NodeMaterialConnectionPoint;
  53773. /**
  53774. * Gets the rgba output component
  53775. */
  53776. readonly rgba: NodeMaterialConnectionPoint;
  53777. /**
  53778. * Gets the rgb output component
  53779. */
  53780. readonly rgb: NodeMaterialConnectionPoint;
  53781. /**
  53782. * Gets the r output component
  53783. */
  53784. readonly r: NodeMaterialConnectionPoint;
  53785. /**
  53786. * Gets the g output component
  53787. */
  53788. readonly g: NodeMaterialConnectionPoint;
  53789. /**
  53790. * Gets the b output component
  53791. */
  53792. readonly b: NodeMaterialConnectionPoint;
  53793. /**
  53794. * Gets the a output component
  53795. */
  53796. readonly a: NodeMaterialConnectionPoint;
  53797. readonly target: NodeMaterialBlockTargets;
  53798. autoConfigure(material: NodeMaterial): void;
  53799. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53800. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53801. isReady(): boolean;
  53802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53803. private readonly _isMixed;
  53804. private _injectVertexCode;
  53805. private _writeOutput;
  53806. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53807. protected _dumpPropertiesCode(): string;
  53808. serialize(): any;
  53809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53810. }
  53811. }
  53812. declare module BABYLON {
  53813. /**
  53814. * Class used to store shared data between 2 NodeMaterialBuildState
  53815. */
  53816. export class NodeMaterialBuildStateSharedData {
  53817. /**
  53818. * Gets the list of emitted varyings
  53819. */
  53820. temps: string[];
  53821. /**
  53822. * Gets the list of emitted varyings
  53823. */
  53824. varyings: string[];
  53825. /**
  53826. * Gets the varying declaration string
  53827. */
  53828. varyingDeclaration: string;
  53829. /**
  53830. * Input blocks
  53831. */
  53832. inputBlocks: InputBlock[];
  53833. /**
  53834. * Input blocks
  53835. */
  53836. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53837. /**
  53838. * Bindable blocks (Blocks that need to set data to the effect)
  53839. */
  53840. bindableBlocks: NodeMaterialBlock[];
  53841. /**
  53842. * List of blocks that can provide a compilation fallback
  53843. */
  53844. blocksWithFallbacks: NodeMaterialBlock[];
  53845. /**
  53846. * List of blocks that can provide a define update
  53847. */
  53848. blocksWithDefines: NodeMaterialBlock[];
  53849. /**
  53850. * List of blocks that can provide a repeatable content
  53851. */
  53852. repeatableContentBlocks: NodeMaterialBlock[];
  53853. /**
  53854. * List of blocks that can provide a dynamic list of uniforms
  53855. */
  53856. dynamicUniformBlocks: NodeMaterialBlock[];
  53857. /**
  53858. * List of blocks that can block the isReady function for the material
  53859. */
  53860. blockingBlocks: NodeMaterialBlock[];
  53861. /**
  53862. * Gets the list of animated inputs
  53863. */
  53864. animatedInputs: InputBlock[];
  53865. /**
  53866. * Build Id used to avoid multiple recompilations
  53867. */
  53868. buildId: number;
  53869. /** List of emitted variables */
  53870. variableNames: {
  53871. [key: string]: number;
  53872. };
  53873. /** List of emitted defines */
  53874. defineNames: {
  53875. [key: string]: number;
  53876. };
  53877. /** Should emit comments? */
  53878. emitComments: boolean;
  53879. /** Emit build activity */
  53880. verbose: boolean;
  53881. /** Gets or sets the hosting scene */
  53882. scene: Scene;
  53883. /**
  53884. * Gets the compilation hints emitted at compilation time
  53885. */
  53886. hints: {
  53887. needWorldViewMatrix: boolean;
  53888. needWorldViewProjectionMatrix: boolean;
  53889. needAlphaBlending: boolean;
  53890. needAlphaTesting: boolean;
  53891. };
  53892. /**
  53893. * List of compilation checks
  53894. */
  53895. checks: {
  53896. emitVertex: boolean;
  53897. emitFragment: boolean;
  53898. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53899. };
  53900. /** Creates a new shared data */
  53901. constructor();
  53902. /**
  53903. * Emits console errors and exceptions if there is a failing check
  53904. */
  53905. emitErrors(): void;
  53906. }
  53907. }
  53908. declare module BABYLON {
  53909. /**
  53910. * Class used to store node based material build state
  53911. */
  53912. export class NodeMaterialBuildState {
  53913. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53914. supportUniformBuffers: boolean;
  53915. /**
  53916. * Gets the list of emitted attributes
  53917. */
  53918. attributes: string[];
  53919. /**
  53920. * Gets the list of emitted uniforms
  53921. */
  53922. uniforms: string[];
  53923. /**
  53924. * Gets the list of emitted constants
  53925. */
  53926. constants: string[];
  53927. /**
  53928. * Gets the list of emitted samplers
  53929. */
  53930. samplers: string[];
  53931. /**
  53932. * Gets the list of emitted functions
  53933. */
  53934. functions: {
  53935. [key: string]: string;
  53936. };
  53937. /**
  53938. * Gets the list of emitted extensions
  53939. */
  53940. extensions: {
  53941. [key: string]: string;
  53942. };
  53943. /**
  53944. * Gets the target of the compilation state
  53945. */
  53946. target: NodeMaterialBlockTargets;
  53947. /**
  53948. * Gets the list of emitted counters
  53949. */
  53950. counters: {
  53951. [key: string]: number;
  53952. };
  53953. /**
  53954. * Shared data between multiple NodeMaterialBuildState instances
  53955. */
  53956. sharedData: NodeMaterialBuildStateSharedData;
  53957. /** @hidden */
  53958. _vertexState: NodeMaterialBuildState;
  53959. /** @hidden */
  53960. _attributeDeclaration: string;
  53961. /** @hidden */
  53962. _uniformDeclaration: string;
  53963. /** @hidden */
  53964. _constantDeclaration: string;
  53965. /** @hidden */
  53966. _samplerDeclaration: string;
  53967. /** @hidden */
  53968. _varyingTransfer: string;
  53969. private _repeatableContentAnchorIndex;
  53970. /** @hidden */
  53971. _builtCompilationString: string;
  53972. /**
  53973. * Gets the emitted compilation strings
  53974. */
  53975. compilationString: string;
  53976. /**
  53977. * Finalize the compilation strings
  53978. * @param state defines the current compilation state
  53979. */
  53980. finalize(state: NodeMaterialBuildState): void;
  53981. /** @hidden */
  53982. readonly _repeatableContentAnchor: string;
  53983. /** @hidden */
  53984. _getFreeVariableName(prefix: string): string;
  53985. /** @hidden */
  53986. _getFreeDefineName(prefix: string): string;
  53987. /** @hidden */
  53988. _excludeVariableName(name: string): void;
  53989. /** @hidden */
  53990. _emit2DSampler(name: string): void;
  53991. /** @hidden */
  53992. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53993. /** @hidden */
  53994. _emitExtension(name: string, extension: string): void;
  53995. /** @hidden */
  53996. _emitFunction(name: string, code: string, comments: string): void;
  53997. /** @hidden */
  53998. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53999. replaceStrings?: {
  54000. search: RegExp;
  54001. replace: string;
  54002. }[];
  54003. repeatKey?: string;
  54004. }): string;
  54005. /** @hidden */
  54006. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54007. repeatKey?: string;
  54008. removeAttributes?: boolean;
  54009. removeUniforms?: boolean;
  54010. removeVaryings?: boolean;
  54011. removeIfDef?: boolean;
  54012. replaceStrings?: {
  54013. search: RegExp;
  54014. replace: string;
  54015. }[];
  54016. }, storeKey?: string): void;
  54017. /** @hidden */
  54018. _registerTempVariable(name: string): boolean;
  54019. /** @hidden */
  54020. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  54021. /** @hidden */
  54022. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54023. /** @hidden */
  54024. _emitFloat(value: number): string;
  54025. }
  54026. }
  54027. declare module BABYLON {
  54028. /**
  54029. * Defines a block that can be used inside a node based material
  54030. */
  54031. export class NodeMaterialBlock {
  54032. private _buildId;
  54033. private _buildTarget;
  54034. private _target;
  54035. private _isFinalMerger;
  54036. private _isInput;
  54037. protected _isUnique: boolean;
  54038. /** @hidden */
  54039. _codeVariableName: string;
  54040. /** @hidden */
  54041. _inputs: NodeMaterialConnectionPoint[];
  54042. /** @hidden */
  54043. _outputs: NodeMaterialConnectionPoint[];
  54044. /** @hidden */
  54045. _preparationId: number;
  54046. /**
  54047. * Gets or sets the name of the block
  54048. */
  54049. name: string;
  54050. /**
  54051. * Gets or sets the unique id of the node
  54052. */
  54053. uniqueId: number;
  54054. /**
  54055. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  54056. */
  54057. readonly isUnique: boolean;
  54058. /**
  54059. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54060. */
  54061. readonly isFinalMerger: boolean;
  54062. /**
  54063. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54064. */
  54065. readonly isInput: boolean;
  54066. /**
  54067. * Gets or sets the build Id
  54068. */
  54069. buildId: number;
  54070. /**
  54071. * Gets or sets the target of the block
  54072. */
  54073. target: NodeMaterialBlockTargets;
  54074. /**
  54075. * Gets the list of input points
  54076. */
  54077. readonly inputs: NodeMaterialConnectionPoint[];
  54078. /** Gets the list of output points */
  54079. readonly outputs: NodeMaterialConnectionPoint[];
  54080. /**
  54081. * Find an input by its name
  54082. * @param name defines the name of the input to look for
  54083. * @returns the input or null if not found
  54084. */
  54085. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54086. /**
  54087. * Find an output by its name
  54088. * @param name defines the name of the outputto look for
  54089. * @returns the output or null if not found
  54090. */
  54091. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54092. /**
  54093. * Creates a new NodeMaterialBlock
  54094. * @param name defines the block name
  54095. * @param target defines the target of that block (Vertex by default)
  54096. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54097. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54098. */
  54099. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54100. /**
  54101. * Initialize the block and prepare the context for build
  54102. * @param state defines the state that will be used for the build
  54103. */
  54104. initialize(state: NodeMaterialBuildState): void;
  54105. /**
  54106. * Bind data to effect. Will only be called for blocks with isBindable === true
  54107. * @param effect defines the effect to bind data to
  54108. * @param nodeMaterial defines the hosting NodeMaterial
  54109. * @param mesh defines the mesh that will be rendered
  54110. */
  54111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54112. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54113. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54114. protected _writeFloat(value: number): string;
  54115. /**
  54116. * Gets the current class name e.g. "NodeMaterialBlock"
  54117. * @returns the class name
  54118. */
  54119. getClassName(): string;
  54120. /**
  54121. * Register a new input. Must be called inside a block constructor
  54122. * @param name defines the connection point name
  54123. * @param type defines the connection point type
  54124. * @param isOptional defines a boolean indicating that this input can be omitted
  54125. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54126. * @returns the current block
  54127. */
  54128. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54129. /**
  54130. * Register a new output. Must be called inside a block constructor
  54131. * @param name defines the connection point name
  54132. * @param type defines the connection point type
  54133. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  54134. * @returns the current block
  54135. */
  54136. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54137. /**
  54138. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54139. * @param forOutput defines an optional connection point to check compatibility with
  54140. * @returns the first available input or null
  54141. */
  54142. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54143. /**
  54144. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54145. * @param forBlock defines an optional block to check compatibility with
  54146. * @returns the first available input or null
  54147. */
  54148. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54149. /**
  54150. * Gets the sibling of the given output
  54151. * @param current defines the current output
  54152. * @returns the next output in the list or null
  54153. */
  54154. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  54155. /**
  54156. * Connect current block with another block
  54157. * @param other defines the block to connect with
  54158. * @param options define the various options to help pick the right connections
  54159. * @returns the current block
  54160. */
  54161. connectTo(other: NodeMaterialBlock, options?: {
  54162. input?: string;
  54163. output?: string;
  54164. outputSwizzle?: string;
  54165. }): this | undefined;
  54166. protected _buildBlock(state: NodeMaterialBuildState): void;
  54167. /**
  54168. * Add uniforms, samplers and uniform buffers at compilation time
  54169. * @param state defines the state to update
  54170. * @param nodeMaterial defines the node material requesting the update
  54171. * @param defines defines the material defines to update
  54172. * @param uniformBuffers defines the list of uniform buffer names
  54173. */
  54174. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54175. /**
  54176. * Add potential fallbacks if shader compilation fails
  54177. * @param mesh defines the mesh to be rendered
  54178. * @param fallbacks defines the current prioritized list of fallbacks
  54179. */
  54180. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54181. /**
  54182. * Initialize defines for shader compilation
  54183. * @param mesh defines the mesh to be rendered
  54184. * @param nodeMaterial defines the node material requesting the update
  54185. * @param defines defines the material defines to update
  54186. * @param useInstances specifies that instances should be used
  54187. */
  54188. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54189. /**
  54190. * Update defines for shader compilation
  54191. * @param mesh defines the mesh to be rendered
  54192. * @param nodeMaterial defines the node material requesting the update
  54193. * @param defines defines the material defines to update
  54194. * @param useInstances specifies that instances should be used
  54195. */
  54196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54197. /**
  54198. * Lets the block try to connect some inputs automatically
  54199. * @param material defines the hosting NodeMaterial
  54200. */
  54201. autoConfigure(material: NodeMaterial): void;
  54202. /**
  54203. * Function called when a block is declared as repeatable content generator
  54204. * @param vertexShaderState defines the current compilation state for the vertex shader
  54205. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54206. * @param mesh defines the mesh to be rendered
  54207. * @param defines defines the material defines to update
  54208. */
  54209. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54210. /**
  54211. * Checks if the block is ready
  54212. * @param mesh defines the mesh to be rendered
  54213. * @param nodeMaterial defines the node material requesting the update
  54214. * @param defines defines the material defines to update
  54215. * @param useInstances specifies that instances should be used
  54216. * @returns true if the block is ready
  54217. */
  54218. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54219. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  54220. private _processBuild;
  54221. /**
  54222. * Compile the current node and generate the shader code
  54223. * @param state defines the current compilation state (uniforms, samplers, current string)
  54224. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  54225. * @returns true if already built
  54226. */
  54227. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  54228. protected _inputRename(name: string): string;
  54229. protected _outputRename(name: string): string;
  54230. protected _dumpPropertiesCode(): string;
  54231. /** @hidden */
  54232. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  54233. /** @hidden */
  54234. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  54235. /**
  54236. * Clone the current block to a new identical block
  54237. * @param scene defines the hosting scene
  54238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54239. * @returns a copy of the current block
  54240. */
  54241. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  54242. /**
  54243. * Serializes this block in a JSON representation
  54244. * @returns the serialized block object
  54245. */
  54246. serialize(): any;
  54247. /** @hidden */
  54248. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54249. /**
  54250. * Release resources
  54251. */
  54252. dispose(): void;
  54253. }
  54254. }
  54255. declare module BABYLON {
  54256. /**
  54257. * Enum defining the type of animations supported by InputBlock
  54258. */
  54259. export enum AnimatedInputBlockTypes {
  54260. /** No animation */
  54261. None = 0,
  54262. /** Time based animation. Will only work for floats */
  54263. Time = 1
  54264. }
  54265. }
  54266. declare module BABYLON {
  54267. /**
  54268. * Block used to expose an input value
  54269. */
  54270. export class InputBlock extends NodeMaterialBlock {
  54271. private _mode;
  54272. private _associatedVariableName;
  54273. private _storedValue;
  54274. private _valueCallback;
  54275. private _type;
  54276. private _animationType;
  54277. /** Gets or set a value used to limit the range of float values */
  54278. min: number;
  54279. /** Gets or set a value used to limit the range of float values */
  54280. max: number;
  54281. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  54282. matrixMode: number;
  54283. /** @hidden */
  54284. _systemValue: Nullable<NodeMaterialSystemValues>;
  54285. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  54286. visibleInInspector: boolean;
  54287. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  54288. isConstant: boolean;
  54289. /**
  54290. * Gets or sets the connection point type (default is float)
  54291. */
  54292. readonly type: NodeMaterialBlockConnectionPointTypes;
  54293. /**
  54294. * Creates a new InputBlock
  54295. * @param name defines the block name
  54296. * @param target defines the target of that block (Vertex by default)
  54297. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54298. */
  54299. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54300. /**
  54301. * Gets the output component
  54302. */
  54303. readonly output: NodeMaterialConnectionPoint;
  54304. /**
  54305. * Set the source of this connection point to a vertex attribute
  54306. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54307. * @returns the current connection point
  54308. */
  54309. setAsAttribute(attributeName?: string): InputBlock;
  54310. /**
  54311. * Set the source of this connection point to a system value
  54312. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  54313. * @returns the current connection point
  54314. */
  54315. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  54316. /**
  54317. * Gets or sets the value of that point.
  54318. * Please note that this value will be ignored if valueCallback is defined
  54319. */
  54320. value: any;
  54321. /**
  54322. * Gets or sets a callback used to get the value of that point.
  54323. * Please note that setting this value will force the connection point to ignore the value property
  54324. */
  54325. valueCallback: () => any;
  54326. /**
  54327. * Gets or sets the associated variable name in the shader
  54328. */
  54329. associatedVariableName: string;
  54330. /** Gets or sets the type of animation applied to the input */
  54331. animationType: AnimatedInputBlockTypes;
  54332. /**
  54333. * Gets a boolean indicating that this connection point not defined yet
  54334. */
  54335. readonly isUndefined: boolean;
  54336. /**
  54337. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54338. * In this case the connection point name must be the name of the uniform to use.
  54339. * Can only be set on inputs
  54340. */
  54341. isUniform: boolean;
  54342. /**
  54343. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54344. * In this case the connection point name must be the name of the attribute to use
  54345. * Can only be set on inputs
  54346. */
  54347. isAttribute: boolean;
  54348. /**
  54349. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54350. * Can only be set on exit points
  54351. */
  54352. isVarying: boolean;
  54353. /**
  54354. * Gets a boolean indicating that the current connection point is a system value
  54355. */
  54356. readonly isSystemValue: boolean;
  54357. /**
  54358. * Gets or sets the current well known value or null if not defined as a system value
  54359. */
  54360. systemValue: Nullable<NodeMaterialSystemValues>;
  54361. /**
  54362. * Gets the current class name
  54363. * @returns the class name
  54364. */
  54365. getClassName(): string;
  54366. /**
  54367. * Animate the input if animationType !== None
  54368. * @param scene defines the rendering scene
  54369. */
  54370. animate(scene: Scene): void;
  54371. private _emitDefine;
  54372. initialize(state: NodeMaterialBuildState): void;
  54373. /**
  54374. * Set the input block to its default value (based on its type)
  54375. */
  54376. setDefaultValue(): void;
  54377. private _emitConstant;
  54378. private _emit;
  54379. /** @hidden */
  54380. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54381. /** @hidden */
  54382. _transmit(effect: Effect, scene: Scene): void;
  54383. protected _buildBlock(state: NodeMaterialBuildState): void;
  54384. protected _dumpPropertiesCode(): string;
  54385. serialize(): any;
  54386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54387. }
  54388. }
  54389. declare module BABYLON {
  54390. /**
  54391. * Enum used to define the compatibility state between two connection points
  54392. */
  54393. export enum NodeMaterialConnectionPointCompatibilityStates {
  54394. /** Points are compatibles */
  54395. Compatible = 0,
  54396. /** Points are incompatible because of their types */
  54397. TypeIncompatible = 1,
  54398. /** Points are incompatible because of their targets (vertex vs fragment) */
  54399. TargetIncompatible = 2
  54400. }
  54401. /**
  54402. * Defines a connection point for a block
  54403. */
  54404. export class NodeMaterialConnectionPoint {
  54405. /** @hidden */
  54406. _ownerBlock: NodeMaterialBlock;
  54407. /** @hidden */
  54408. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54409. private _endpoints;
  54410. private _associatedVariableName;
  54411. /** @hidden */
  54412. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54413. /** @hidden */
  54414. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54415. private _type;
  54416. /** @hidden */
  54417. _enforceAssociatedVariableName: boolean;
  54418. /**
  54419. * Gets or sets the additional types supported by this connection point
  54420. */
  54421. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54422. /**
  54423. * Gets or sets the additional types excluded by this connection point
  54424. */
  54425. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54426. /**
  54427. * Observable triggered when this point is connected
  54428. */
  54429. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  54430. /**
  54431. * Gets or sets the associated variable name in the shader
  54432. */
  54433. associatedVariableName: string;
  54434. /**
  54435. * Gets or sets the connection point type (default is float)
  54436. */
  54437. type: NodeMaterialBlockConnectionPointTypes;
  54438. /**
  54439. * Gets or sets the connection point name
  54440. */
  54441. name: string;
  54442. /**
  54443. * Gets or sets a boolean indicating that this connection point can be omitted
  54444. */
  54445. isOptional: boolean;
  54446. /**
  54447. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54448. */
  54449. define: string;
  54450. /** @hidden */
  54451. _prioritizeVertex: boolean;
  54452. private _target;
  54453. /** Gets or sets the target of that connection point */
  54454. target: NodeMaterialBlockTargets;
  54455. /**
  54456. * Gets a boolean indicating that the current point is connected
  54457. */
  54458. readonly isConnected: boolean;
  54459. /**
  54460. * Gets a boolean indicating that the current point is connected to an input block
  54461. */
  54462. readonly isConnectedToInputBlock: boolean;
  54463. /**
  54464. * Gets a the connected input block (if any)
  54465. */
  54466. readonly connectInputBlock: Nullable<InputBlock>;
  54467. /** Get the other side of the connection (if any) */
  54468. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54469. /** Get the block that owns this connection point */
  54470. readonly ownerBlock: NodeMaterialBlock;
  54471. /** Get the block connected on the other side of this connection (if any) */
  54472. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54473. /** Get the block connected on the endpoints of this connection (if any) */
  54474. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54475. /** Gets the list of connected endpoints */
  54476. readonly endpoints: NodeMaterialConnectionPoint[];
  54477. /** Gets a boolean indicating if that output point is connected to at least one input */
  54478. readonly hasEndpoints: boolean;
  54479. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54480. readonly isConnectedInVertexShader: boolean;
  54481. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54482. readonly isConnectedInFragmentShader: boolean;
  54483. /**
  54484. * Creates a new connection point
  54485. * @param name defines the connection point name
  54486. * @param ownerBlock defines the block hosting this connection point
  54487. */
  54488. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54489. /**
  54490. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54491. * @returns the class name
  54492. */
  54493. getClassName(): string;
  54494. /**
  54495. * Gets a boolean indicating if the current point can be connected to another point
  54496. * @param connectionPoint defines the other connection point
  54497. * @returns a boolean
  54498. */
  54499. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54500. /**
  54501. * Gets a number indicating if the current point can be connected to another point
  54502. * @param connectionPoint defines the other connection point
  54503. * @returns a number defining the compatibility state
  54504. */
  54505. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  54506. /**
  54507. * Connect this point to another connection point
  54508. * @param connectionPoint defines the other connection point
  54509. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54510. * @returns the current connection point
  54511. */
  54512. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54513. /**
  54514. * Disconnect this point from one of his endpoint
  54515. * @param endpoint defines the other connection point
  54516. * @returns the current connection point
  54517. */
  54518. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54519. /**
  54520. * Serializes this point in a JSON representation
  54521. * @returns the serialized point object
  54522. */
  54523. serialize(): any;
  54524. /**
  54525. * Release resources
  54526. */
  54527. dispose(): void;
  54528. }
  54529. }
  54530. declare module BABYLON {
  54531. /**
  54532. * Block used to add support for vertex skinning (bones)
  54533. */
  54534. export class BonesBlock extends NodeMaterialBlock {
  54535. /**
  54536. * Creates a new BonesBlock
  54537. * @param name defines the block name
  54538. */
  54539. constructor(name: string);
  54540. /**
  54541. * Initialize the block and prepare the context for build
  54542. * @param state defines the state that will be used for the build
  54543. */
  54544. initialize(state: NodeMaterialBuildState): void;
  54545. /**
  54546. * Gets the current class name
  54547. * @returns the class name
  54548. */
  54549. getClassName(): string;
  54550. /**
  54551. * Gets the matrix indices input component
  54552. */
  54553. readonly matricesIndices: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the matrix weights input component
  54556. */
  54557. readonly matricesWeights: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the extra matrix indices input component
  54560. */
  54561. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54562. /**
  54563. * Gets the extra matrix weights input component
  54564. */
  54565. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54566. /**
  54567. * Gets the world input component
  54568. */
  54569. readonly world: NodeMaterialConnectionPoint;
  54570. /**
  54571. * Gets the output component
  54572. */
  54573. readonly output: NodeMaterialConnectionPoint;
  54574. autoConfigure(material: NodeMaterial): void;
  54575. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54576. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54578. protected _buildBlock(state: NodeMaterialBuildState): this;
  54579. }
  54580. }
  54581. declare module BABYLON {
  54582. /**
  54583. * Block used to add support for instances
  54584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54585. */
  54586. export class InstancesBlock extends NodeMaterialBlock {
  54587. /**
  54588. * Creates a new InstancesBlock
  54589. * @param name defines the block name
  54590. */
  54591. constructor(name: string);
  54592. /**
  54593. * Gets the current class name
  54594. * @returns the class name
  54595. */
  54596. getClassName(): string;
  54597. /**
  54598. * Gets the first world row input component
  54599. */
  54600. readonly world0: NodeMaterialConnectionPoint;
  54601. /**
  54602. * Gets the second world row input component
  54603. */
  54604. readonly world1: NodeMaterialConnectionPoint;
  54605. /**
  54606. * Gets the third world row input component
  54607. */
  54608. readonly world2: NodeMaterialConnectionPoint;
  54609. /**
  54610. * Gets the forth world row input component
  54611. */
  54612. readonly world3: NodeMaterialConnectionPoint;
  54613. /**
  54614. * Gets the world input component
  54615. */
  54616. readonly world: NodeMaterialConnectionPoint;
  54617. /**
  54618. * Gets the output component
  54619. */
  54620. readonly output: NodeMaterialConnectionPoint;
  54621. autoConfigure(material: NodeMaterial): void;
  54622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54623. protected _buildBlock(state: NodeMaterialBuildState): this;
  54624. }
  54625. }
  54626. declare module BABYLON {
  54627. /**
  54628. * Block used to add morph targets support to vertex shader
  54629. */
  54630. export class MorphTargetsBlock extends NodeMaterialBlock {
  54631. private _repeatableContentAnchor;
  54632. private _repeatebleContentGenerated;
  54633. /**
  54634. * Create a new MorphTargetsBlock
  54635. * @param name defines the block name
  54636. */
  54637. constructor(name: string);
  54638. /**
  54639. * Gets the current class name
  54640. * @returns the class name
  54641. */
  54642. getClassName(): string;
  54643. /**
  54644. * Gets the position input component
  54645. */
  54646. readonly position: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the normal input component
  54649. */
  54650. readonly normal: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the tangent input component
  54653. */
  54654. readonly tangent: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the tangent input component
  54657. */
  54658. readonly uv: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the position output component
  54661. */
  54662. readonly positionOutput: NodeMaterialConnectionPoint;
  54663. /**
  54664. * Gets the normal output component
  54665. */
  54666. readonly normalOutput: NodeMaterialConnectionPoint;
  54667. /**
  54668. * Gets the tangent output component
  54669. */
  54670. readonly tangentOutput: NodeMaterialConnectionPoint;
  54671. /**
  54672. * Gets the tangent output component
  54673. */
  54674. readonly uvOutput: NodeMaterialConnectionPoint;
  54675. initialize(state: NodeMaterialBuildState): void;
  54676. autoConfigure(material: NodeMaterial): void;
  54677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54679. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54680. protected _buildBlock(state: NodeMaterialBuildState): this;
  54681. }
  54682. }
  54683. declare module BABYLON {
  54684. /**
  54685. * Block used to get data information from a light
  54686. */
  54687. export class LightInformationBlock extends NodeMaterialBlock {
  54688. private _lightDataUniformName;
  54689. private _lightColorUniformName;
  54690. private _lightTypeDefineName;
  54691. /**
  54692. * Gets or sets the light associated with this block
  54693. */
  54694. light: Nullable<Light>;
  54695. /**
  54696. * Creates a new LightInformationBlock
  54697. * @param name defines the block name
  54698. */
  54699. constructor(name: string);
  54700. /**
  54701. * Gets the current class name
  54702. * @returns the class name
  54703. */
  54704. getClassName(): string;
  54705. /**
  54706. * Gets the world position input component
  54707. */
  54708. readonly worldPosition: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the direction output component
  54711. */
  54712. readonly direction: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the direction output component
  54715. */
  54716. readonly color: NodeMaterialConnectionPoint;
  54717. /**
  54718. * Gets the direction output component
  54719. */
  54720. readonly intensity: NodeMaterialConnectionPoint;
  54721. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54723. protected _buildBlock(state: NodeMaterialBuildState): this;
  54724. serialize(): any;
  54725. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54726. }
  54727. }
  54728. declare module BABYLON {
  54729. /**
  54730. * Block used to add image processing support to fragment shader
  54731. */
  54732. export class ImageProcessingBlock extends NodeMaterialBlock {
  54733. /**
  54734. * Create a new ImageProcessingBlock
  54735. * @param name defines the block name
  54736. */
  54737. constructor(name: string);
  54738. /**
  54739. * Gets the current class name
  54740. * @returns the class name
  54741. */
  54742. getClassName(): string;
  54743. /**
  54744. * Gets the color input component
  54745. */
  54746. readonly color: NodeMaterialConnectionPoint;
  54747. /**
  54748. * Gets the output component
  54749. */
  54750. readonly output: NodeMaterialConnectionPoint;
  54751. /**
  54752. * Initialize the block and prepare the context for build
  54753. * @param state defines the state that will be used for the build
  54754. */
  54755. initialize(state: NodeMaterialBuildState): void;
  54756. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54759. protected _buildBlock(state: NodeMaterialBuildState): this;
  54760. }
  54761. }
  54762. declare module BABYLON {
  54763. /**
  54764. * Block used to pertub normals based on a normal map
  54765. */
  54766. export class PerturbNormalBlock extends NodeMaterialBlock {
  54767. private _tangentSpaceParameterName;
  54768. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54769. invertX: boolean;
  54770. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54771. invertY: boolean;
  54772. /**
  54773. * Create a new PerturbNormalBlock
  54774. * @param name defines the block name
  54775. */
  54776. constructor(name: string);
  54777. /**
  54778. * Gets the current class name
  54779. * @returns the class name
  54780. */
  54781. getClassName(): string;
  54782. /**
  54783. * Gets the world position input component
  54784. */
  54785. readonly worldPosition: NodeMaterialConnectionPoint;
  54786. /**
  54787. * Gets the world normal input component
  54788. */
  54789. readonly worldNormal: NodeMaterialConnectionPoint;
  54790. /**
  54791. * Gets the uv input component
  54792. */
  54793. readonly uv: NodeMaterialConnectionPoint;
  54794. /**
  54795. * Gets the normal map color input component
  54796. */
  54797. readonly normalMapColor: NodeMaterialConnectionPoint;
  54798. /**
  54799. * Gets the strength input component
  54800. */
  54801. readonly strength: NodeMaterialConnectionPoint;
  54802. /**
  54803. * Gets the output component
  54804. */
  54805. readonly output: NodeMaterialConnectionPoint;
  54806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54808. autoConfigure(material: NodeMaterial): void;
  54809. protected _buildBlock(state: NodeMaterialBuildState): this;
  54810. protected _dumpPropertiesCode(): string;
  54811. serialize(): any;
  54812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54813. }
  54814. }
  54815. declare module BABYLON {
  54816. /**
  54817. * Block used to discard a pixel if a value is smaller than a cutoff
  54818. */
  54819. export class DiscardBlock extends NodeMaterialBlock {
  54820. /**
  54821. * Create a new DiscardBlock
  54822. * @param name defines the block name
  54823. */
  54824. constructor(name: string);
  54825. /**
  54826. * Gets the current class name
  54827. * @returns the class name
  54828. */
  54829. getClassName(): string;
  54830. /**
  54831. * Gets the color input component
  54832. */
  54833. readonly value: NodeMaterialConnectionPoint;
  54834. /**
  54835. * Gets the cutoff input component
  54836. */
  54837. readonly cutoff: NodeMaterialConnectionPoint;
  54838. protected _buildBlock(state: NodeMaterialBuildState): this;
  54839. }
  54840. }
  54841. declare module BABYLON {
  54842. /**
  54843. * Block used to test if the fragment shader is front facing
  54844. */
  54845. export class FrontFacingBlock extends NodeMaterialBlock {
  54846. /**
  54847. * Creates a new FrontFacingBlock
  54848. * @param name defines the block name
  54849. */
  54850. constructor(name: string);
  54851. /**
  54852. * Gets the current class name
  54853. * @returns the class name
  54854. */
  54855. getClassName(): string;
  54856. /**
  54857. * Gets the output component
  54858. */
  54859. readonly output: NodeMaterialConnectionPoint;
  54860. protected _buildBlock(state: NodeMaterialBuildState): this;
  54861. }
  54862. }
  54863. declare module BABYLON {
  54864. /**
  54865. * Block used to add support for scene fog
  54866. */
  54867. export class FogBlock extends NodeMaterialBlock {
  54868. private _fogDistanceName;
  54869. private _fogParameters;
  54870. /**
  54871. * Create a new FogBlock
  54872. * @param name defines the block name
  54873. */
  54874. constructor(name: string);
  54875. /**
  54876. * Gets the current class name
  54877. * @returns the class name
  54878. */
  54879. getClassName(): string;
  54880. /**
  54881. * Gets the world position input component
  54882. */
  54883. readonly worldPosition: NodeMaterialConnectionPoint;
  54884. /**
  54885. * Gets the view input component
  54886. */
  54887. readonly view: NodeMaterialConnectionPoint;
  54888. /**
  54889. * Gets the color input component
  54890. */
  54891. readonly input: NodeMaterialConnectionPoint;
  54892. /**
  54893. * Gets the fog color input component
  54894. */
  54895. readonly fogColor: NodeMaterialConnectionPoint;
  54896. /**
  54897. * Gets the output component
  54898. */
  54899. readonly output: NodeMaterialConnectionPoint;
  54900. autoConfigure(material: NodeMaterial): void;
  54901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54903. protected _buildBlock(state: NodeMaterialBuildState): this;
  54904. }
  54905. }
  54906. declare module BABYLON {
  54907. /**
  54908. * Block used to add light in the fragment shader
  54909. */
  54910. export class LightBlock extends NodeMaterialBlock {
  54911. private _lightId;
  54912. /**
  54913. * Gets or sets the light associated with this block
  54914. */
  54915. light: Nullable<Light>;
  54916. /**
  54917. * Create a new LightBlock
  54918. * @param name defines the block name
  54919. */
  54920. constructor(name: string);
  54921. /**
  54922. * Gets the current class name
  54923. * @returns the class name
  54924. */
  54925. getClassName(): string;
  54926. /**
  54927. * Gets the world position input component
  54928. */
  54929. readonly worldPosition: NodeMaterialConnectionPoint;
  54930. /**
  54931. * Gets the world normal input component
  54932. */
  54933. readonly worldNormal: NodeMaterialConnectionPoint;
  54934. /**
  54935. * Gets the camera (or eye) position component
  54936. */
  54937. readonly cameraPosition: NodeMaterialConnectionPoint;
  54938. /**
  54939. * Gets the glossiness component
  54940. */
  54941. readonly glossiness: NodeMaterialConnectionPoint;
  54942. /**
  54943. * Gets the glossinness power component
  54944. */
  54945. readonly glossPower: NodeMaterialConnectionPoint;
  54946. /**
  54947. * Gets the diffuse color component
  54948. */
  54949. readonly diffuseColor: NodeMaterialConnectionPoint;
  54950. /**
  54951. * Gets the specular color component
  54952. */
  54953. readonly specularColor: NodeMaterialConnectionPoint;
  54954. /**
  54955. * Gets the diffuse output component
  54956. */
  54957. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54958. /**
  54959. * Gets the specular output component
  54960. */
  54961. readonly specularOutput: NodeMaterialConnectionPoint;
  54962. autoConfigure(material: NodeMaterial): void;
  54963. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54964. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54966. private _injectVertexCode;
  54967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54968. serialize(): any;
  54969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54970. }
  54971. }
  54972. declare module BABYLON {
  54973. /**
  54974. * Block used to multiply 2 values
  54975. */
  54976. export class MultiplyBlock extends NodeMaterialBlock {
  54977. /**
  54978. * Creates a new MultiplyBlock
  54979. * @param name defines the block name
  54980. */
  54981. constructor(name: string);
  54982. /**
  54983. * Gets the current class name
  54984. * @returns the class name
  54985. */
  54986. getClassName(): string;
  54987. /**
  54988. * Gets the left operand input component
  54989. */
  54990. readonly left: NodeMaterialConnectionPoint;
  54991. /**
  54992. * Gets the right operand input component
  54993. */
  54994. readonly right: NodeMaterialConnectionPoint;
  54995. /**
  54996. * Gets the output component
  54997. */
  54998. readonly output: NodeMaterialConnectionPoint;
  54999. protected _buildBlock(state: NodeMaterialBuildState): this;
  55000. }
  55001. }
  55002. declare module BABYLON {
  55003. /**
  55004. * Block used to add 2 vectors
  55005. */
  55006. export class AddBlock extends NodeMaterialBlock {
  55007. /**
  55008. * Creates a new AddBlock
  55009. * @param name defines the block name
  55010. */
  55011. constructor(name: string);
  55012. /**
  55013. * Gets the current class name
  55014. * @returns the class name
  55015. */
  55016. getClassName(): string;
  55017. /**
  55018. * Gets the left operand input component
  55019. */
  55020. readonly left: NodeMaterialConnectionPoint;
  55021. /**
  55022. * Gets the right operand input component
  55023. */
  55024. readonly right: NodeMaterialConnectionPoint;
  55025. /**
  55026. * Gets the output component
  55027. */
  55028. readonly output: NodeMaterialConnectionPoint;
  55029. protected _buildBlock(state: NodeMaterialBuildState): this;
  55030. }
  55031. }
  55032. declare module BABYLON {
  55033. /**
  55034. * Block used to scale a vector by a float
  55035. */
  55036. export class ScaleBlock extends NodeMaterialBlock {
  55037. /**
  55038. * Creates a new ScaleBlock
  55039. * @param name defines the block name
  55040. */
  55041. constructor(name: string);
  55042. /**
  55043. * Gets the current class name
  55044. * @returns the class name
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Gets the input component
  55049. */
  55050. readonly input: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the factor input component
  55053. */
  55054. readonly factor: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the output component
  55057. */
  55058. readonly output: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Block used to clamp a float
  55065. */
  55066. export class ClampBlock extends NodeMaterialBlock {
  55067. /** Gets or sets the minimum range */
  55068. minimum: number;
  55069. /** Gets or sets the maximum range */
  55070. maximum: number;
  55071. /**
  55072. * Creates a new ClampBlock
  55073. * @param name defines the block name
  55074. */
  55075. constructor(name: string);
  55076. /**
  55077. * Gets the current class name
  55078. * @returns the class name
  55079. */
  55080. getClassName(): string;
  55081. /**
  55082. * Gets the value input component
  55083. */
  55084. readonly value: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the output component
  55087. */
  55088. readonly output: NodeMaterialConnectionPoint;
  55089. protected _buildBlock(state: NodeMaterialBuildState): this;
  55090. protected _dumpPropertiesCode(): string;
  55091. serialize(): any;
  55092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55093. }
  55094. }
  55095. declare module BABYLON {
  55096. /**
  55097. * Block used to apply a cross product between 2 vectors
  55098. */
  55099. export class CrossBlock extends NodeMaterialBlock {
  55100. /**
  55101. * Creates a new CrossBlock
  55102. * @param name defines the block name
  55103. */
  55104. constructor(name: string);
  55105. /**
  55106. * Gets the current class name
  55107. * @returns the class name
  55108. */
  55109. getClassName(): string;
  55110. /**
  55111. * Gets the left operand input component
  55112. */
  55113. readonly left: NodeMaterialConnectionPoint;
  55114. /**
  55115. * Gets the right operand input component
  55116. */
  55117. readonly right: NodeMaterialConnectionPoint;
  55118. /**
  55119. * Gets the output component
  55120. */
  55121. readonly output: NodeMaterialConnectionPoint;
  55122. protected _buildBlock(state: NodeMaterialBuildState): this;
  55123. }
  55124. }
  55125. declare module BABYLON {
  55126. /**
  55127. * Block used to apply a dot product between 2 vectors
  55128. */
  55129. export class DotBlock extends NodeMaterialBlock {
  55130. /**
  55131. * Creates a new DotBlock
  55132. * @param name defines the block name
  55133. */
  55134. constructor(name: string);
  55135. /**
  55136. * Gets the current class name
  55137. * @returns the class name
  55138. */
  55139. getClassName(): string;
  55140. /**
  55141. * Gets the left operand input component
  55142. */
  55143. readonly left: NodeMaterialConnectionPoint;
  55144. /**
  55145. * Gets the right operand input component
  55146. */
  55147. readonly right: NodeMaterialConnectionPoint;
  55148. /**
  55149. * Gets the output component
  55150. */
  55151. readonly output: NodeMaterialConnectionPoint;
  55152. protected _buildBlock(state: NodeMaterialBuildState): this;
  55153. }
  55154. }
  55155. declare module BABYLON {
  55156. /**
  55157. * Block used to remap a float from a range to a new one
  55158. */
  55159. export class RemapBlock extends NodeMaterialBlock {
  55160. /**
  55161. * Gets or sets the source range
  55162. */
  55163. sourceRange: Vector2;
  55164. /**
  55165. * Gets or sets the target range
  55166. */
  55167. targetRange: Vector2;
  55168. /**
  55169. * Creates a new RemapBlock
  55170. * @param name defines the block name
  55171. */
  55172. constructor(name: string);
  55173. /**
  55174. * Gets the current class name
  55175. * @returns the class name
  55176. */
  55177. getClassName(): string;
  55178. /**
  55179. * Gets the input component
  55180. */
  55181. readonly input: NodeMaterialConnectionPoint;
  55182. /**
  55183. * Gets the source min input component
  55184. */
  55185. readonly sourceMin: NodeMaterialConnectionPoint;
  55186. /**
  55187. * Gets the source max input component
  55188. */
  55189. readonly sourceMax: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the target min input component
  55192. */
  55193. readonly targetMin: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the target max input component
  55196. */
  55197. readonly targetMax: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the output component
  55200. */
  55201. readonly output: NodeMaterialConnectionPoint;
  55202. protected _buildBlock(state: NodeMaterialBuildState): this;
  55203. protected _dumpPropertiesCode(): string;
  55204. serialize(): any;
  55205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55206. }
  55207. }
  55208. declare module BABYLON {
  55209. /**
  55210. * Block used to normalize a vector
  55211. */
  55212. export class NormalizeBlock extends NodeMaterialBlock {
  55213. /**
  55214. * Creates a new NormalizeBlock
  55215. * @param name defines the block name
  55216. */
  55217. constructor(name: string);
  55218. /**
  55219. * Gets the current class name
  55220. * @returns the class name
  55221. */
  55222. getClassName(): string;
  55223. /**
  55224. * Gets the input component
  55225. */
  55226. readonly input: NodeMaterialConnectionPoint;
  55227. /**
  55228. * Gets the output component
  55229. */
  55230. readonly output: NodeMaterialConnectionPoint;
  55231. protected _buildBlock(state: NodeMaterialBuildState): this;
  55232. }
  55233. }
  55234. declare module BABYLON {
  55235. /**
  55236. * Operations supported by the Trigonometry block
  55237. */
  55238. export enum TrigonometryBlockOperations {
  55239. /** Cos */
  55240. Cos = 0,
  55241. /** Sin */
  55242. Sin = 1,
  55243. /** Abs */
  55244. Abs = 2,
  55245. /** Exp */
  55246. Exp = 3,
  55247. /** Exp2 */
  55248. Exp2 = 4,
  55249. /** Round */
  55250. Round = 5,
  55251. /** Floor */
  55252. Floor = 6,
  55253. /** Ceiling */
  55254. Ceiling = 7,
  55255. /** Square root */
  55256. Sqrt = 8,
  55257. /** Log */
  55258. Log = 9,
  55259. /** Tangent */
  55260. Tan = 10,
  55261. /** Arc tangent */
  55262. ArcTan = 11,
  55263. /** Arc cosinus */
  55264. ArcCos = 12,
  55265. /** Arc sinus */
  55266. ArcSin = 13,
  55267. /** Fraction */
  55268. Fract = 14,
  55269. /** Sign */
  55270. Sign = 15,
  55271. /** To radians (from degrees) */
  55272. Radians = 16,
  55273. /** To degrees (from radians) */
  55274. Degrees = 17
  55275. }
  55276. /**
  55277. * Block used to apply trigonometry operation to floats
  55278. */
  55279. export class TrigonometryBlock extends NodeMaterialBlock {
  55280. /**
  55281. * Gets or sets the operation applied by the block
  55282. */
  55283. operation: TrigonometryBlockOperations;
  55284. /**
  55285. * Creates a new TrigonometryBlock
  55286. * @param name defines the block name
  55287. */
  55288. constructor(name: string);
  55289. /**
  55290. * Gets the current class name
  55291. * @returns the class name
  55292. */
  55293. getClassName(): string;
  55294. /**
  55295. * Gets the input component
  55296. */
  55297. readonly input: NodeMaterialConnectionPoint;
  55298. /**
  55299. * Gets the output component
  55300. */
  55301. readonly output: NodeMaterialConnectionPoint;
  55302. protected _buildBlock(state: NodeMaterialBuildState): this;
  55303. serialize(): any;
  55304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55305. }
  55306. }
  55307. declare module BABYLON {
  55308. /**
  55309. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55310. */
  55311. export class ColorMergerBlock extends NodeMaterialBlock {
  55312. /**
  55313. * Create a new ColorMergerBlock
  55314. * @param name defines the block name
  55315. */
  55316. constructor(name: string);
  55317. /**
  55318. * Gets the current class name
  55319. * @returns the class name
  55320. */
  55321. getClassName(): string;
  55322. /**
  55323. * Gets the r component (input)
  55324. */
  55325. readonly r: NodeMaterialConnectionPoint;
  55326. /**
  55327. * Gets the g component (input)
  55328. */
  55329. readonly g: NodeMaterialConnectionPoint;
  55330. /**
  55331. * Gets the b component (input)
  55332. */
  55333. readonly b: NodeMaterialConnectionPoint;
  55334. /**
  55335. * Gets the a component (input)
  55336. */
  55337. readonly a: NodeMaterialConnectionPoint;
  55338. /**
  55339. * Gets the rgba component (output)
  55340. */
  55341. readonly rgba: NodeMaterialConnectionPoint;
  55342. /**
  55343. * Gets the rgb component (output)
  55344. */
  55345. readonly rgb: NodeMaterialConnectionPoint;
  55346. protected _buildBlock(state: NodeMaterialBuildState): this;
  55347. }
  55348. }
  55349. declare module BABYLON {
  55350. /**
  55351. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55352. */
  55353. export class VectorMergerBlock extends NodeMaterialBlock {
  55354. /**
  55355. * Create a new VectorMergerBlock
  55356. * @param name defines the block name
  55357. */
  55358. constructor(name: string);
  55359. /**
  55360. * Gets the current class name
  55361. * @returns the class name
  55362. */
  55363. getClassName(): string;
  55364. /**
  55365. * Gets the x component (input)
  55366. */
  55367. readonly x: NodeMaterialConnectionPoint;
  55368. /**
  55369. * Gets the y component (input)
  55370. */
  55371. readonly y: NodeMaterialConnectionPoint;
  55372. /**
  55373. * Gets the z component (input)
  55374. */
  55375. readonly z: NodeMaterialConnectionPoint;
  55376. /**
  55377. * Gets the w component (input)
  55378. */
  55379. readonly w: NodeMaterialConnectionPoint;
  55380. /**
  55381. * Gets the xyzw component (output)
  55382. */
  55383. readonly xyzw: NodeMaterialConnectionPoint;
  55384. /**
  55385. * Gets the xyz component (output)
  55386. */
  55387. readonly xyz: NodeMaterialConnectionPoint;
  55388. /**
  55389. * Gets the xy component (output)
  55390. */
  55391. readonly xy: NodeMaterialConnectionPoint;
  55392. protected _buildBlock(state: NodeMaterialBuildState): this;
  55393. }
  55394. }
  55395. declare module BABYLON {
  55396. /**
  55397. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55398. */
  55399. export class ColorSplitterBlock extends NodeMaterialBlock {
  55400. /**
  55401. * Create a new ColorSplitterBlock
  55402. * @param name defines the block name
  55403. */
  55404. constructor(name: string);
  55405. /**
  55406. * Gets the current class name
  55407. * @returns the class name
  55408. */
  55409. getClassName(): string;
  55410. /**
  55411. * Gets the rgba component (input)
  55412. */
  55413. readonly rgba: NodeMaterialConnectionPoint;
  55414. /**
  55415. * Gets the rgb component (input)
  55416. */
  55417. readonly rgbIn: NodeMaterialConnectionPoint;
  55418. /**
  55419. * Gets the rgb component (output)
  55420. */
  55421. readonly rgbOut: NodeMaterialConnectionPoint;
  55422. /**
  55423. * Gets the r component (output)
  55424. */
  55425. readonly r: NodeMaterialConnectionPoint;
  55426. /**
  55427. * Gets the g component (output)
  55428. */
  55429. readonly g: NodeMaterialConnectionPoint;
  55430. /**
  55431. * Gets the b component (output)
  55432. */
  55433. readonly b: NodeMaterialConnectionPoint;
  55434. /**
  55435. * Gets the a component (output)
  55436. */
  55437. readonly a: NodeMaterialConnectionPoint;
  55438. protected _inputRename(name: string): string;
  55439. protected _outputRename(name: string): string;
  55440. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55441. }
  55442. }
  55443. declare module BABYLON {
  55444. /**
  55445. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55446. */
  55447. export class VectorSplitterBlock extends NodeMaterialBlock {
  55448. /**
  55449. * Create a new VectorSplitterBlock
  55450. * @param name defines the block name
  55451. */
  55452. constructor(name: string);
  55453. /**
  55454. * Gets the current class name
  55455. * @returns the class name
  55456. */
  55457. getClassName(): string;
  55458. /**
  55459. * Gets the xyzw component (input)
  55460. */
  55461. readonly xyzw: NodeMaterialConnectionPoint;
  55462. /**
  55463. * Gets the xyz component (input)
  55464. */
  55465. readonly xyzIn: NodeMaterialConnectionPoint;
  55466. /**
  55467. * Gets the xy component (input)
  55468. */
  55469. readonly xyIn: NodeMaterialConnectionPoint;
  55470. /**
  55471. * Gets the xyz component (output)
  55472. */
  55473. readonly xyzOut: NodeMaterialConnectionPoint;
  55474. /**
  55475. * Gets the xy component (output)
  55476. */
  55477. readonly xyOut: NodeMaterialConnectionPoint;
  55478. /**
  55479. * Gets the x component (output)
  55480. */
  55481. readonly x: NodeMaterialConnectionPoint;
  55482. /**
  55483. * Gets the y component (output)
  55484. */
  55485. readonly y: NodeMaterialConnectionPoint;
  55486. /**
  55487. * Gets the z component (output)
  55488. */
  55489. readonly z: NodeMaterialConnectionPoint;
  55490. /**
  55491. * Gets the w component (output)
  55492. */
  55493. readonly w: NodeMaterialConnectionPoint;
  55494. protected _inputRename(name: string): string;
  55495. protected _outputRename(name: string): string;
  55496. protected _buildBlock(state: NodeMaterialBuildState): this;
  55497. }
  55498. }
  55499. declare module BABYLON {
  55500. /**
  55501. * Block used to lerp between 2 values
  55502. */
  55503. export class LerpBlock extends NodeMaterialBlock {
  55504. /**
  55505. * Creates a new LerpBlock
  55506. * @param name defines the block name
  55507. */
  55508. constructor(name: string);
  55509. /**
  55510. * Gets the current class name
  55511. * @returns the class name
  55512. */
  55513. getClassName(): string;
  55514. /**
  55515. * Gets the left operand input component
  55516. */
  55517. readonly left: NodeMaterialConnectionPoint;
  55518. /**
  55519. * Gets the right operand input component
  55520. */
  55521. readonly right: NodeMaterialConnectionPoint;
  55522. /**
  55523. * Gets the gradient operand input component
  55524. */
  55525. readonly gradient: NodeMaterialConnectionPoint;
  55526. /**
  55527. * Gets the output component
  55528. */
  55529. readonly output: NodeMaterialConnectionPoint;
  55530. protected _buildBlock(state: NodeMaterialBuildState): this;
  55531. }
  55532. }
  55533. declare module BABYLON {
  55534. /**
  55535. * Block used to divide 2 vectors
  55536. */
  55537. export class DivideBlock extends NodeMaterialBlock {
  55538. /**
  55539. * Creates a new DivideBlock
  55540. * @param name defines the block name
  55541. */
  55542. constructor(name: string);
  55543. /**
  55544. * Gets the current class name
  55545. * @returns the class name
  55546. */
  55547. getClassName(): string;
  55548. /**
  55549. * Gets the left operand input component
  55550. */
  55551. readonly left: NodeMaterialConnectionPoint;
  55552. /**
  55553. * Gets the right operand input component
  55554. */
  55555. readonly right: NodeMaterialConnectionPoint;
  55556. /**
  55557. * Gets the output component
  55558. */
  55559. readonly output: NodeMaterialConnectionPoint;
  55560. protected _buildBlock(state: NodeMaterialBuildState): this;
  55561. }
  55562. }
  55563. declare module BABYLON {
  55564. /**
  55565. * Block used to subtract 2 vectors
  55566. */
  55567. export class SubtractBlock extends NodeMaterialBlock {
  55568. /**
  55569. * Creates a new SubtractBlock
  55570. * @param name defines the block name
  55571. */
  55572. constructor(name: string);
  55573. /**
  55574. * Gets the current class name
  55575. * @returns the class name
  55576. */
  55577. getClassName(): string;
  55578. /**
  55579. * Gets the left operand input component
  55580. */
  55581. readonly left: NodeMaterialConnectionPoint;
  55582. /**
  55583. * Gets the right operand input component
  55584. */
  55585. readonly right: NodeMaterialConnectionPoint;
  55586. /**
  55587. * Gets the output component
  55588. */
  55589. readonly output: NodeMaterialConnectionPoint;
  55590. protected _buildBlock(state: NodeMaterialBuildState): this;
  55591. }
  55592. }
  55593. declare module BABYLON {
  55594. /**
  55595. * Block used to step a value
  55596. */
  55597. export class StepBlock extends NodeMaterialBlock {
  55598. /**
  55599. * Creates a new StepBlock
  55600. * @param name defines the block name
  55601. */
  55602. constructor(name: string);
  55603. /**
  55604. * Gets the current class name
  55605. * @returns the class name
  55606. */
  55607. getClassName(): string;
  55608. /**
  55609. * Gets the value operand input component
  55610. */
  55611. readonly value: NodeMaterialConnectionPoint;
  55612. /**
  55613. * Gets the edge operand input component
  55614. */
  55615. readonly edge: NodeMaterialConnectionPoint;
  55616. /**
  55617. * Gets the output component
  55618. */
  55619. readonly output: NodeMaterialConnectionPoint;
  55620. protected _buildBlock(state: NodeMaterialBuildState): this;
  55621. }
  55622. }
  55623. declare module BABYLON {
  55624. /**
  55625. * Block used to get the opposite (1 - x) of a value
  55626. */
  55627. export class OneMinusBlock extends NodeMaterialBlock {
  55628. /**
  55629. * Creates a new OneMinusBlock
  55630. * @param name defines the block name
  55631. */
  55632. constructor(name: string);
  55633. /**
  55634. * Gets the current class name
  55635. * @returns the class name
  55636. */
  55637. getClassName(): string;
  55638. /**
  55639. * Gets the input component
  55640. */
  55641. readonly input: NodeMaterialConnectionPoint;
  55642. /**
  55643. * Gets the output component
  55644. */
  55645. readonly output: NodeMaterialConnectionPoint;
  55646. protected _buildBlock(state: NodeMaterialBuildState): this;
  55647. }
  55648. }
  55649. declare module BABYLON {
  55650. /**
  55651. * Block used to get the view direction
  55652. */
  55653. export class ViewDirectionBlock extends NodeMaterialBlock {
  55654. /**
  55655. * Creates a new ViewDirectionBlock
  55656. * @param name defines the block name
  55657. */
  55658. constructor(name: string);
  55659. /**
  55660. * Gets the current class name
  55661. * @returns the class name
  55662. */
  55663. getClassName(): string;
  55664. /**
  55665. * Gets the world position component
  55666. */
  55667. readonly worldPosition: NodeMaterialConnectionPoint;
  55668. /**
  55669. * Gets the camera position component
  55670. */
  55671. readonly cameraPosition: NodeMaterialConnectionPoint;
  55672. /**
  55673. * Gets the output component
  55674. */
  55675. readonly output: NodeMaterialConnectionPoint;
  55676. autoConfigure(material: NodeMaterial): void;
  55677. protected _buildBlock(state: NodeMaterialBuildState): this;
  55678. }
  55679. }
  55680. declare module BABYLON {
  55681. /**
  55682. * Block used to compute fresnel value
  55683. */
  55684. export class FresnelBlock extends NodeMaterialBlock {
  55685. /**
  55686. * Create a new FresnelBlock
  55687. * @param name defines the block name
  55688. */
  55689. constructor(name: string);
  55690. /**
  55691. * Gets the current class name
  55692. * @returns the class name
  55693. */
  55694. getClassName(): string;
  55695. /**
  55696. * Gets the world normal input component
  55697. */
  55698. readonly worldNormal: NodeMaterialConnectionPoint;
  55699. /**
  55700. * Gets the view direction input component
  55701. */
  55702. readonly viewDirection: NodeMaterialConnectionPoint;
  55703. /**
  55704. * Gets the bias input component
  55705. */
  55706. readonly bias: NodeMaterialConnectionPoint;
  55707. /**
  55708. * Gets the camera (or eye) position component
  55709. */
  55710. readonly power: NodeMaterialConnectionPoint;
  55711. /**
  55712. * Gets the fresnel output component
  55713. */
  55714. readonly fresnel: NodeMaterialConnectionPoint;
  55715. autoConfigure(material: NodeMaterial): void;
  55716. protected _buildBlock(state: NodeMaterialBuildState): this;
  55717. }
  55718. }
  55719. declare module BABYLON {
  55720. /**
  55721. * Block used to get the max of 2 values
  55722. */
  55723. export class MaxBlock extends NodeMaterialBlock {
  55724. /**
  55725. * Creates a new MaxBlock
  55726. * @param name defines the block name
  55727. */
  55728. constructor(name: string);
  55729. /**
  55730. * Gets the current class name
  55731. * @returns the class name
  55732. */
  55733. getClassName(): string;
  55734. /**
  55735. * Gets the left operand input component
  55736. */
  55737. readonly left: NodeMaterialConnectionPoint;
  55738. /**
  55739. * Gets the right operand input component
  55740. */
  55741. readonly right: NodeMaterialConnectionPoint;
  55742. /**
  55743. * Gets the output component
  55744. */
  55745. readonly output: NodeMaterialConnectionPoint;
  55746. protected _buildBlock(state: NodeMaterialBuildState): this;
  55747. }
  55748. }
  55749. declare module BABYLON {
  55750. /**
  55751. * Block used to get the min of 2 values
  55752. */
  55753. export class MinBlock extends NodeMaterialBlock {
  55754. /**
  55755. * Creates a new MinBlock
  55756. * @param name defines the block name
  55757. */
  55758. constructor(name: string);
  55759. /**
  55760. * Gets the current class name
  55761. * @returns the class name
  55762. */
  55763. getClassName(): string;
  55764. /**
  55765. * Gets the left operand input component
  55766. */
  55767. readonly left: NodeMaterialConnectionPoint;
  55768. /**
  55769. * Gets the right operand input component
  55770. */
  55771. readonly right: NodeMaterialConnectionPoint;
  55772. /**
  55773. * Gets the output component
  55774. */
  55775. readonly output: NodeMaterialConnectionPoint;
  55776. protected _buildBlock(state: NodeMaterialBuildState): this;
  55777. }
  55778. }
  55779. declare module BABYLON {
  55780. /**
  55781. * Block used to get the distance between 2 values
  55782. */
  55783. export class DistanceBlock extends NodeMaterialBlock {
  55784. /**
  55785. * Creates a new DistanceBlock
  55786. * @param name defines the block name
  55787. */
  55788. constructor(name: string);
  55789. /**
  55790. * Gets the current class name
  55791. * @returns the class name
  55792. */
  55793. getClassName(): string;
  55794. /**
  55795. * Gets the left operand input component
  55796. */
  55797. readonly left: NodeMaterialConnectionPoint;
  55798. /**
  55799. * Gets the right operand input component
  55800. */
  55801. readonly right: NodeMaterialConnectionPoint;
  55802. /**
  55803. * Gets the output component
  55804. */
  55805. readonly output: NodeMaterialConnectionPoint;
  55806. protected _buildBlock(state: NodeMaterialBuildState): this;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /**
  55811. * Block used to get the length of a vector
  55812. */
  55813. export class LengthBlock extends NodeMaterialBlock {
  55814. /**
  55815. * Creates a new LengthBlock
  55816. * @param name defines the block name
  55817. */
  55818. constructor(name: string);
  55819. /**
  55820. * Gets the current class name
  55821. * @returns the class name
  55822. */
  55823. getClassName(): string;
  55824. /**
  55825. * Gets the value input component
  55826. */
  55827. readonly value: NodeMaterialConnectionPoint;
  55828. /**
  55829. * Gets the output component
  55830. */
  55831. readonly output: NodeMaterialConnectionPoint;
  55832. protected _buildBlock(state: NodeMaterialBuildState): this;
  55833. }
  55834. }
  55835. declare module BABYLON {
  55836. /**
  55837. * Block used to get negative version of a value (i.e. x * -1)
  55838. */
  55839. export class NegateBlock extends NodeMaterialBlock {
  55840. /**
  55841. * Creates a new NegateBlock
  55842. * @param name defines the block name
  55843. */
  55844. constructor(name: string);
  55845. /**
  55846. * Gets the current class name
  55847. * @returns the class name
  55848. */
  55849. getClassName(): string;
  55850. /**
  55851. * Gets the value input component
  55852. */
  55853. readonly value: NodeMaterialConnectionPoint;
  55854. /**
  55855. * Gets the output component
  55856. */
  55857. readonly output: NodeMaterialConnectionPoint;
  55858. protected _buildBlock(state: NodeMaterialBuildState): this;
  55859. }
  55860. }
  55861. declare module BABYLON {
  55862. /**
  55863. * Block used to get the value of the first parameter raised to the power of the second
  55864. */
  55865. export class PowBlock extends NodeMaterialBlock {
  55866. /**
  55867. * Creates a new PowBlock
  55868. * @param name defines the block name
  55869. */
  55870. constructor(name: string);
  55871. /**
  55872. * Gets the current class name
  55873. * @returns the class name
  55874. */
  55875. getClassName(): string;
  55876. /**
  55877. * Gets the value operand input component
  55878. */
  55879. readonly value: NodeMaterialConnectionPoint;
  55880. /**
  55881. * Gets the power operand input component
  55882. */
  55883. readonly power: NodeMaterialConnectionPoint;
  55884. /**
  55885. * Gets the output component
  55886. */
  55887. readonly output: NodeMaterialConnectionPoint;
  55888. protected _buildBlock(state: NodeMaterialBuildState): this;
  55889. }
  55890. }
  55891. declare module BABYLON {
  55892. /**
  55893. * Block used to get a random number
  55894. */
  55895. export class RandomNumberBlock extends NodeMaterialBlock {
  55896. /**
  55897. * Creates a new RandomNumberBlock
  55898. * @param name defines the block name
  55899. */
  55900. constructor(name: string);
  55901. /**
  55902. * Gets the current class name
  55903. * @returns the class name
  55904. */
  55905. getClassName(): string;
  55906. /**
  55907. * Gets the seed input component
  55908. */
  55909. readonly seed: NodeMaterialConnectionPoint;
  55910. /**
  55911. * Gets the output component
  55912. */
  55913. readonly output: NodeMaterialConnectionPoint;
  55914. protected _buildBlock(state: NodeMaterialBuildState): this;
  55915. }
  55916. }
  55917. declare module BABYLON {
  55918. /**
  55919. * Block used to compute arc tangent of 2 values
  55920. */
  55921. export class ArcTan2Block extends NodeMaterialBlock {
  55922. /**
  55923. * Creates a new ArcTan2Block
  55924. * @param name defines the block name
  55925. */
  55926. constructor(name: string);
  55927. /**
  55928. * Gets the current class name
  55929. * @returns the class name
  55930. */
  55931. getClassName(): string;
  55932. /**
  55933. * Gets the x operand input component
  55934. */
  55935. readonly x: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the y operand input component
  55938. */
  55939. readonly y: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the output component
  55942. */
  55943. readonly output: NodeMaterialConnectionPoint;
  55944. protected _buildBlock(state: NodeMaterialBuildState): this;
  55945. }
  55946. }
  55947. declare module BABYLON {
  55948. /**
  55949. * Block used to smooth step a value
  55950. */
  55951. export class SmoothStepBlock extends NodeMaterialBlock {
  55952. /**
  55953. * Creates a new SmoothStepBlock
  55954. * @param name defines the block name
  55955. */
  55956. constructor(name: string);
  55957. /**
  55958. * Gets the current class name
  55959. * @returns the class name
  55960. */
  55961. getClassName(): string;
  55962. /**
  55963. * Gets the value operand input component
  55964. */
  55965. readonly value: NodeMaterialConnectionPoint;
  55966. /**
  55967. * Gets the first edge operand input component
  55968. */
  55969. readonly edge0: NodeMaterialConnectionPoint;
  55970. /**
  55971. * Gets the second edge operand input component
  55972. */
  55973. readonly edge1: NodeMaterialConnectionPoint;
  55974. /**
  55975. * Gets the output component
  55976. */
  55977. readonly output: NodeMaterialConnectionPoint;
  55978. protected _buildBlock(state: NodeMaterialBuildState): this;
  55979. }
  55980. }
  55981. declare module BABYLON {
  55982. /**
  55983. * Block used to get the reciprocal (1 / x) of a value
  55984. */
  55985. export class ReciprocalBlock extends NodeMaterialBlock {
  55986. /**
  55987. * Creates a new ReciprocalBlock
  55988. * @param name defines the block name
  55989. */
  55990. constructor(name: string);
  55991. /**
  55992. * Gets the current class name
  55993. * @returns the class name
  55994. */
  55995. getClassName(): string;
  55996. /**
  55997. * Gets the input component
  55998. */
  55999. readonly input: NodeMaterialConnectionPoint;
  56000. /**
  56001. * Gets the output component
  56002. */
  56003. readonly output: NodeMaterialConnectionPoint;
  56004. protected _buildBlock(state: NodeMaterialBuildState): this;
  56005. }
  56006. }
  56007. declare module BABYLON {
  56008. /**
  56009. * Block used to replace a color by another one
  56010. */
  56011. export class ReplaceColorBlock extends NodeMaterialBlock {
  56012. /**
  56013. * Creates a new ReplaceColorBlock
  56014. * @param name defines the block name
  56015. */
  56016. constructor(name: string);
  56017. /**
  56018. * Gets the current class name
  56019. * @returns the class name
  56020. */
  56021. getClassName(): string;
  56022. /**
  56023. * Gets the value input component
  56024. */
  56025. readonly value: NodeMaterialConnectionPoint;
  56026. /**
  56027. * Gets the reference input component
  56028. */
  56029. readonly reference: NodeMaterialConnectionPoint;
  56030. /**
  56031. * Gets the distance input component
  56032. */
  56033. readonly distance: NodeMaterialConnectionPoint;
  56034. /**
  56035. * Gets the replacement input component
  56036. */
  56037. readonly replacement: NodeMaterialConnectionPoint;
  56038. /**
  56039. * Gets the output component
  56040. */
  56041. readonly output: NodeMaterialConnectionPoint;
  56042. protected _buildBlock(state: NodeMaterialBuildState): this;
  56043. }
  56044. }
  56045. declare module BABYLON {
  56046. /**
  56047. * Block used to posterize a value
  56048. * @see https://en.wikipedia.org/wiki/Posterization
  56049. */
  56050. export class PosterizeBlock extends NodeMaterialBlock {
  56051. /**
  56052. * Creates a new PosterizeBlock
  56053. * @param name defines the block name
  56054. */
  56055. constructor(name: string);
  56056. /**
  56057. * Gets the current class name
  56058. * @returns the class name
  56059. */
  56060. getClassName(): string;
  56061. /**
  56062. * Gets the value input component
  56063. */
  56064. readonly value: NodeMaterialConnectionPoint;
  56065. /**
  56066. * Gets the steps input component
  56067. */
  56068. readonly steps: NodeMaterialConnectionPoint;
  56069. /**
  56070. * Gets the output component
  56071. */
  56072. readonly output: NodeMaterialConnectionPoint;
  56073. protected _buildBlock(state: NodeMaterialBuildState): this;
  56074. }
  56075. }
  56076. declare module BABYLON {
  56077. /**
  56078. * Operations supported by the Wave block
  56079. */
  56080. export enum WaveBlockKind {
  56081. /** SawTooth */
  56082. SawTooth = 0,
  56083. /** Square */
  56084. Square = 1,
  56085. /** Triangle */
  56086. Triangle = 2
  56087. }
  56088. /**
  56089. * Block used to apply wave operation to floats
  56090. */
  56091. export class WaveBlock extends NodeMaterialBlock {
  56092. /**
  56093. * Gets or sets the kibnd of wave to be applied by the block
  56094. */
  56095. kind: WaveBlockKind;
  56096. /**
  56097. * Creates a new WaveBlock
  56098. * @param name defines the block name
  56099. */
  56100. constructor(name: string);
  56101. /**
  56102. * Gets the current class name
  56103. * @returns the class name
  56104. */
  56105. getClassName(): string;
  56106. /**
  56107. * Gets the input component
  56108. */
  56109. readonly input: NodeMaterialConnectionPoint;
  56110. /**
  56111. * Gets the output component
  56112. */
  56113. readonly output: NodeMaterialConnectionPoint;
  56114. protected _buildBlock(state: NodeMaterialBuildState): this;
  56115. serialize(): any;
  56116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56117. }
  56118. }
  56119. declare module BABYLON {
  56120. /**
  56121. * Class used to store a color step for the GradientBlock
  56122. */
  56123. export class GradientBlockColorStep {
  56124. /**
  56125. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56126. */
  56127. step: number;
  56128. /**
  56129. * Gets or sets the color associated with this step
  56130. */
  56131. color: Color3;
  56132. /**
  56133. * Creates a new GradientBlockColorStep
  56134. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  56135. * @param color defines the color associated with this step
  56136. */
  56137. constructor(
  56138. /**
  56139. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  56140. */
  56141. step: number,
  56142. /**
  56143. * Gets or sets the color associated with this step
  56144. */
  56145. color: Color3);
  56146. }
  56147. /**
  56148. * Block used to return a color from a gradient based on an input value between 0 and 1
  56149. */
  56150. export class GradientBlock extends NodeMaterialBlock {
  56151. /**
  56152. * Gets or sets the list of color steps
  56153. */
  56154. colorSteps: GradientBlockColorStep[];
  56155. /**
  56156. * Creates a new GradientBlock
  56157. * @param name defines the block name
  56158. */
  56159. constructor(name: string);
  56160. /**
  56161. * Gets the current class name
  56162. * @returns the class name
  56163. */
  56164. getClassName(): string;
  56165. /**
  56166. * Gets the gradient input component
  56167. */
  56168. readonly gradient: NodeMaterialConnectionPoint;
  56169. /**
  56170. * Gets the output component
  56171. */
  56172. readonly output: NodeMaterialConnectionPoint;
  56173. private _writeColorConstant;
  56174. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56175. serialize(): any;
  56176. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56177. protected _dumpPropertiesCode(): string;
  56178. }
  56179. }
  56180. declare module BABYLON {
  56181. /**
  56182. * Block used to normalize lerp between 2 values
  56183. */
  56184. export class NLerpBlock extends NodeMaterialBlock {
  56185. /**
  56186. * Creates a new NLerpBlock
  56187. * @param name defines the block name
  56188. */
  56189. constructor(name: string);
  56190. /**
  56191. * Gets the current class name
  56192. * @returns the class name
  56193. */
  56194. getClassName(): string;
  56195. /**
  56196. * Gets the left operand input component
  56197. */
  56198. readonly left: NodeMaterialConnectionPoint;
  56199. /**
  56200. * Gets the right operand input component
  56201. */
  56202. readonly right: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the gradient operand input component
  56205. */
  56206. readonly gradient: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the output component
  56209. */
  56210. readonly output: NodeMaterialConnectionPoint;
  56211. protected _buildBlock(state: NodeMaterialBuildState): this;
  56212. }
  56213. }
  56214. declare module BABYLON {
  56215. /**
  56216. * Effect Render Options
  56217. */
  56218. export interface IEffectRendererOptions {
  56219. /**
  56220. * Defines the vertices positions.
  56221. */
  56222. positions?: number[];
  56223. /**
  56224. * Defines the indices.
  56225. */
  56226. indices?: number[];
  56227. }
  56228. /**
  56229. * Helper class to render one or more effects
  56230. */
  56231. export class EffectRenderer {
  56232. private engine;
  56233. private static _DefaultOptions;
  56234. private _vertexBuffers;
  56235. private _indexBuffer;
  56236. private _ringBufferIndex;
  56237. private _ringScreenBuffer;
  56238. private _fullscreenViewport;
  56239. private _getNextFrameBuffer;
  56240. /**
  56241. * Creates an effect renderer
  56242. * @param engine the engine to use for rendering
  56243. * @param options defines the options of the effect renderer
  56244. */
  56245. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  56246. /**
  56247. * Sets the current viewport in normalized coordinates 0-1
  56248. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  56249. */
  56250. setViewport(viewport?: Viewport): void;
  56251. /**
  56252. * Binds the embedded attributes buffer to the effect.
  56253. * @param effect Defines the effect to bind the attributes for
  56254. */
  56255. bindBuffers(effect: Effect): void;
  56256. /**
  56257. * Sets the current effect wrapper to use during draw.
  56258. * The effect needs to be ready before calling this api.
  56259. * This also sets the default full screen position attribute.
  56260. * @param effectWrapper Defines the effect to draw with
  56261. */
  56262. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  56263. /**
  56264. * Draws a full screen quad.
  56265. */
  56266. draw(): void;
  56267. /**
  56268. * renders one or more effects to a specified texture
  56269. * @param effectWrappers list of effects to renderer
  56270. * @param outputTexture texture to draw to, if null it will render to the screen
  56271. */
  56272. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  56273. /**
  56274. * Disposes of the effect renderer
  56275. */
  56276. dispose(): void;
  56277. }
  56278. /**
  56279. * Options to create an EffectWrapper
  56280. */
  56281. interface EffectWrapperCreationOptions {
  56282. /**
  56283. * Engine to use to create the effect
  56284. */
  56285. engine: ThinEngine;
  56286. /**
  56287. * Fragment shader for the effect
  56288. */
  56289. fragmentShader: string;
  56290. /**
  56291. * Vertex shader for the effect
  56292. */
  56293. vertexShader?: string;
  56294. /**
  56295. * Attributes to use in the shader
  56296. */
  56297. attributeNames?: Array<string>;
  56298. /**
  56299. * Uniforms to use in the shader
  56300. */
  56301. uniformNames?: Array<string>;
  56302. /**
  56303. * Texture sampler names to use in the shader
  56304. */
  56305. samplerNames?: Array<string>;
  56306. /**
  56307. * The friendly name of the effect displayed in Spector.
  56308. */
  56309. name?: string;
  56310. }
  56311. /**
  56312. * Wraps an effect to be used for rendering
  56313. */
  56314. export class EffectWrapper {
  56315. /**
  56316. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  56317. */
  56318. onApplyObservable: Observable<{}>;
  56319. /**
  56320. * The underlying effect
  56321. */
  56322. effect: Effect;
  56323. /**
  56324. * Creates an effect to be renderer
  56325. * @param creationOptions options to create the effect
  56326. */
  56327. constructor(creationOptions: EffectWrapperCreationOptions);
  56328. /**
  56329. * Disposes of the effect wrapper
  56330. */
  56331. dispose(): void;
  56332. }
  56333. }
  56334. declare module BABYLON {
  56335. /**
  56336. * Helper class to push actions to a pool of workers.
  56337. */
  56338. export class WorkerPool implements IDisposable {
  56339. private _workerInfos;
  56340. private _pendingActions;
  56341. /**
  56342. * Constructor
  56343. * @param workers Array of workers to use for actions
  56344. */
  56345. constructor(workers: Array<Worker>);
  56346. /**
  56347. * Terminates all workers and clears any pending actions.
  56348. */
  56349. dispose(): void;
  56350. /**
  56351. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56352. * pended until a worker has completed its action.
  56353. * @param action The action to perform. Call onComplete when the action is complete.
  56354. */
  56355. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56356. private _execute;
  56357. }
  56358. }
  56359. declare module BABYLON {
  56360. /**
  56361. * Configuration for Draco compression
  56362. */
  56363. export interface IDracoCompressionConfiguration {
  56364. /**
  56365. * Configuration for the decoder.
  56366. */
  56367. decoder: {
  56368. /**
  56369. * The url to the WebAssembly module.
  56370. */
  56371. wasmUrl?: string;
  56372. /**
  56373. * The url to the WebAssembly binary.
  56374. */
  56375. wasmBinaryUrl?: string;
  56376. /**
  56377. * The url to the fallback JavaScript module.
  56378. */
  56379. fallbackUrl?: string;
  56380. };
  56381. }
  56382. /**
  56383. * Draco compression (https://google.github.io/draco/)
  56384. *
  56385. * This class wraps the Draco module.
  56386. *
  56387. * **Encoder**
  56388. *
  56389. * The encoder is not currently implemented.
  56390. *
  56391. * **Decoder**
  56392. *
  56393. * 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.
  56394. *
  56395. * To update the configuration, use the following code:
  56396. * ```javascript
  56397. * DracoCompression.Configuration = {
  56398. * decoder: {
  56399. * wasmUrl: "<url to the WebAssembly library>",
  56400. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56401. * fallbackUrl: "<url to the fallback JavaScript library>",
  56402. * }
  56403. * };
  56404. * ```
  56405. *
  56406. * 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.
  56407. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56408. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56409. *
  56410. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56411. * ```javascript
  56412. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56413. * ```
  56414. *
  56415. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56416. */
  56417. export class DracoCompression implements IDisposable {
  56418. private _workerPoolPromise?;
  56419. private _decoderModulePromise?;
  56420. /**
  56421. * The configuration. Defaults to the following urls:
  56422. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56423. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56424. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56425. */
  56426. static Configuration: IDracoCompressionConfiguration;
  56427. /**
  56428. * Returns true if the decoder configuration is available.
  56429. */
  56430. static readonly DecoderAvailable: boolean;
  56431. /**
  56432. * Default number of workers to create when creating the draco compression object.
  56433. */
  56434. static DefaultNumWorkers: number;
  56435. private static GetDefaultNumWorkers;
  56436. private static _Default;
  56437. /**
  56438. * Default instance for the draco compression object.
  56439. */
  56440. static readonly Default: DracoCompression;
  56441. /**
  56442. * Constructor
  56443. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56444. */
  56445. constructor(numWorkers?: number);
  56446. /**
  56447. * Stop all async operations and release resources.
  56448. */
  56449. dispose(): void;
  56450. /**
  56451. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56452. * @returns a promise that resolves when ready
  56453. */
  56454. whenReadyAsync(): Promise<void>;
  56455. /**
  56456. * Decode Draco compressed mesh data to vertex data.
  56457. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56458. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56459. * @returns A promise that resolves with the decoded vertex data
  56460. */
  56461. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56462. [kind: string]: number;
  56463. }): Promise<VertexData>;
  56464. }
  56465. }
  56466. declare module BABYLON {
  56467. /**
  56468. * Class for building Constructive Solid Geometry
  56469. */
  56470. export class CSG {
  56471. private polygons;
  56472. /**
  56473. * The world matrix
  56474. */
  56475. matrix: Matrix;
  56476. /**
  56477. * Stores the position
  56478. */
  56479. position: Vector3;
  56480. /**
  56481. * Stores the rotation
  56482. */
  56483. rotation: Vector3;
  56484. /**
  56485. * Stores the rotation quaternion
  56486. */
  56487. rotationQuaternion: Nullable<Quaternion>;
  56488. /**
  56489. * Stores the scaling vector
  56490. */
  56491. scaling: Vector3;
  56492. /**
  56493. * Convert the Mesh to CSG
  56494. * @param mesh The Mesh to convert to CSG
  56495. * @returns A new CSG from the Mesh
  56496. */
  56497. static FromMesh(mesh: Mesh): CSG;
  56498. /**
  56499. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56500. * @param polygons Polygons used to construct a CSG solid
  56501. */
  56502. private static FromPolygons;
  56503. /**
  56504. * Clones, or makes a deep copy, of the CSG
  56505. * @returns A new CSG
  56506. */
  56507. clone(): CSG;
  56508. /**
  56509. * Unions this CSG with another CSG
  56510. * @param csg The CSG to union against this CSG
  56511. * @returns The unioned CSG
  56512. */
  56513. union(csg: CSG): CSG;
  56514. /**
  56515. * Unions this CSG with another CSG in place
  56516. * @param csg The CSG to union against this CSG
  56517. */
  56518. unionInPlace(csg: CSG): void;
  56519. /**
  56520. * Subtracts this CSG with another CSG
  56521. * @param csg The CSG to subtract against this CSG
  56522. * @returns A new CSG
  56523. */
  56524. subtract(csg: CSG): CSG;
  56525. /**
  56526. * Subtracts this CSG with another CSG in place
  56527. * @param csg The CSG to subtact against this CSG
  56528. */
  56529. subtractInPlace(csg: CSG): void;
  56530. /**
  56531. * Intersect this CSG with another CSG
  56532. * @param csg The CSG to intersect against this CSG
  56533. * @returns A new CSG
  56534. */
  56535. intersect(csg: CSG): CSG;
  56536. /**
  56537. * Intersects this CSG with another CSG in place
  56538. * @param csg The CSG to intersect against this CSG
  56539. */
  56540. intersectInPlace(csg: CSG): void;
  56541. /**
  56542. * Return a new CSG solid with solid and empty space switched. This solid is
  56543. * not modified.
  56544. * @returns A new CSG solid with solid and empty space switched
  56545. */
  56546. inverse(): CSG;
  56547. /**
  56548. * Inverses the CSG in place
  56549. */
  56550. inverseInPlace(): void;
  56551. /**
  56552. * This is used to keep meshes transformations so they can be restored
  56553. * when we build back a Babylon Mesh
  56554. * NB : All CSG operations are performed in world coordinates
  56555. * @param csg The CSG to copy the transform attributes from
  56556. * @returns This CSG
  56557. */
  56558. copyTransformAttributes(csg: CSG): CSG;
  56559. /**
  56560. * Build Raw mesh from CSG
  56561. * Coordinates here are in world space
  56562. * @param name The name of the mesh geometry
  56563. * @param scene The Scene
  56564. * @param keepSubMeshes Specifies if the submeshes should be kept
  56565. * @returns A new Mesh
  56566. */
  56567. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56568. /**
  56569. * Build Mesh from CSG taking material and transforms into account
  56570. * @param name The name of the Mesh
  56571. * @param material The material of the Mesh
  56572. * @param scene The Scene
  56573. * @param keepSubMeshes Specifies if submeshes should be kept
  56574. * @returns The new Mesh
  56575. */
  56576. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56577. }
  56578. }
  56579. declare module BABYLON {
  56580. /**
  56581. * Class used to create a trail following a mesh
  56582. */
  56583. export class TrailMesh extends Mesh {
  56584. private _generator;
  56585. private _autoStart;
  56586. private _running;
  56587. private _diameter;
  56588. private _length;
  56589. private _sectionPolygonPointsCount;
  56590. private _sectionVectors;
  56591. private _sectionNormalVectors;
  56592. private _beforeRenderObserver;
  56593. /**
  56594. * @constructor
  56595. * @param name The value used by scene.getMeshByName() to do a lookup.
  56596. * @param generator The mesh to generate a trail.
  56597. * @param scene The scene to add this mesh to.
  56598. * @param diameter Diameter of trailing mesh. Default is 1.
  56599. * @param length Length of trailing mesh. Default is 60.
  56600. * @param autoStart Automatically start trailing mesh. Default true.
  56601. */
  56602. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56603. /**
  56604. * "TrailMesh"
  56605. * @returns "TrailMesh"
  56606. */
  56607. getClassName(): string;
  56608. private _createMesh;
  56609. /**
  56610. * Start trailing mesh.
  56611. */
  56612. start(): void;
  56613. /**
  56614. * Stop trailing mesh.
  56615. */
  56616. stop(): void;
  56617. /**
  56618. * Update trailing mesh geometry.
  56619. */
  56620. update(): void;
  56621. /**
  56622. * Returns a new TrailMesh object.
  56623. * @param name is a string, the name given to the new mesh
  56624. * @param newGenerator use new generator object for cloned trail mesh
  56625. * @returns a new mesh
  56626. */
  56627. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56628. /**
  56629. * Serializes this trail mesh
  56630. * @param serializationObject object to write serialization to
  56631. */
  56632. serialize(serializationObject: any): void;
  56633. /**
  56634. * Parses a serialized trail mesh
  56635. * @param parsedMesh the serialized mesh
  56636. * @param scene the scene to create the trail mesh in
  56637. * @returns the created trail mesh
  56638. */
  56639. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56640. }
  56641. }
  56642. declare module BABYLON {
  56643. /**
  56644. * Class containing static functions to help procedurally build meshes
  56645. */
  56646. export class TiledBoxBuilder {
  56647. /**
  56648. * Creates a box mesh
  56649. * 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)
  56650. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56652. * * 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
  56653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56654. * @param name defines the name of the mesh
  56655. * @param options defines the options used to create the mesh
  56656. * @param scene defines the hosting scene
  56657. * @returns the box mesh
  56658. */
  56659. static CreateTiledBox(name: string, options: {
  56660. pattern?: number;
  56661. width?: number;
  56662. height?: number;
  56663. depth?: number;
  56664. tileSize?: number;
  56665. tileWidth?: number;
  56666. tileHeight?: number;
  56667. alignHorizontal?: number;
  56668. alignVertical?: number;
  56669. faceUV?: Vector4[];
  56670. faceColors?: Color4[];
  56671. sideOrientation?: number;
  56672. updatable?: boolean;
  56673. }, scene?: Nullable<Scene>): Mesh;
  56674. }
  56675. }
  56676. declare module BABYLON {
  56677. /**
  56678. * Class containing static functions to help procedurally build meshes
  56679. */
  56680. export class TorusKnotBuilder {
  56681. /**
  56682. * Creates a torus knot mesh
  56683. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56684. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56685. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56686. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56688. * * 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
  56689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56690. * @param name defines the name of the mesh
  56691. * @param options defines the options used to create the mesh
  56692. * @param scene defines the hosting scene
  56693. * @returns the torus knot mesh
  56694. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56695. */
  56696. static CreateTorusKnot(name: string, options: {
  56697. radius?: number;
  56698. tube?: number;
  56699. radialSegments?: number;
  56700. tubularSegments?: number;
  56701. p?: number;
  56702. q?: number;
  56703. updatable?: boolean;
  56704. sideOrientation?: number;
  56705. frontUVs?: Vector4;
  56706. backUVs?: Vector4;
  56707. }, scene: any): Mesh;
  56708. }
  56709. }
  56710. declare module BABYLON {
  56711. /**
  56712. * Polygon
  56713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56714. */
  56715. export class Polygon {
  56716. /**
  56717. * Creates a rectangle
  56718. * @param xmin bottom X coord
  56719. * @param ymin bottom Y coord
  56720. * @param xmax top X coord
  56721. * @param ymax top Y coord
  56722. * @returns points that make the resulting rectation
  56723. */
  56724. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56725. /**
  56726. * Creates a circle
  56727. * @param radius radius of circle
  56728. * @param cx scale in x
  56729. * @param cy scale in y
  56730. * @param numberOfSides number of sides that make up the circle
  56731. * @returns points that make the resulting circle
  56732. */
  56733. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56734. /**
  56735. * Creates a polygon from input string
  56736. * @param input Input polygon data
  56737. * @returns the parsed points
  56738. */
  56739. static Parse(input: string): Vector2[];
  56740. /**
  56741. * Starts building a polygon from x and y coordinates
  56742. * @param x x coordinate
  56743. * @param y y coordinate
  56744. * @returns the started path2
  56745. */
  56746. static StartingAt(x: number, y: number): Path2;
  56747. }
  56748. /**
  56749. * Builds a polygon
  56750. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56751. */
  56752. export class PolygonMeshBuilder {
  56753. private _points;
  56754. private _outlinepoints;
  56755. private _holes;
  56756. private _name;
  56757. private _scene;
  56758. private _epoints;
  56759. private _eholes;
  56760. private _addToepoint;
  56761. /**
  56762. * Babylon reference to the earcut plugin.
  56763. */
  56764. bjsEarcut: any;
  56765. /**
  56766. * Creates a PolygonMeshBuilder
  56767. * @param name name of the builder
  56768. * @param contours Path of the polygon
  56769. * @param scene scene to add to when creating the mesh
  56770. * @param earcutInjection can be used to inject your own earcut reference
  56771. */
  56772. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56773. /**
  56774. * Adds a whole within the polygon
  56775. * @param hole Array of points defining the hole
  56776. * @returns this
  56777. */
  56778. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56779. /**
  56780. * Creates the polygon
  56781. * @param updatable If the mesh should be updatable
  56782. * @param depth The depth of the mesh created
  56783. * @returns the created mesh
  56784. */
  56785. build(updatable?: boolean, depth?: number): Mesh;
  56786. /**
  56787. * Creates the polygon
  56788. * @param depth The depth of the mesh created
  56789. * @returns the created VertexData
  56790. */
  56791. buildVertexData(depth?: number): VertexData;
  56792. /**
  56793. * Adds a side to the polygon
  56794. * @param positions points that make the polygon
  56795. * @param normals normals of the polygon
  56796. * @param uvs uvs of the polygon
  56797. * @param indices indices of the polygon
  56798. * @param bounds bounds of the polygon
  56799. * @param points points of the polygon
  56800. * @param depth depth of the polygon
  56801. * @param flip flip of the polygon
  56802. */
  56803. private addSide;
  56804. }
  56805. }
  56806. declare module BABYLON {
  56807. /**
  56808. * Class containing static functions to help procedurally build meshes
  56809. */
  56810. export class PolygonBuilder {
  56811. /**
  56812. * Creates a polygon mesh
  56813. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56814. * * 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
  56815. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  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. * * 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)
  56818. * * Remember you can only change the shape positions, not their number when updating a polygon
  56819. * @param name defines the name of the mesh
  56820. * @param options defines the options used to create the mesh
  56821. * @param scene defines the hosting scene
  56822. * @param earcutInjection can be used to inject your own earcut reference
  56823. * @returns the polygon mesh
  56824. */
  56825. static CreatePolygon(name: string, options: {
  56826. shape: Vector3[];
  56827. holes?: Vector3[][];
  56828. depth?: number;
  56829. faceUV?: Vector4[];
  56830. faceColors?: Color4[];
  56831. updatable?: boolean;
  56832. sideOrientation?: number;
  56833. frontUVs?: Vector4;
  56834. backUVs?: Vector4;
  56835. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56836. /**
  56837. * Creates an extruded polygon mesh, with depth in the Y direction.
  56838. * * 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)
  56839. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56840. * @param name defines the name of the mesh
  56841. * @param options defines the options used to create the mesh
  56842. * @param scene defines the hosting scene
  56843. * @param earcutInjection can be used to inject your own earcut reference
  56844. * @returns the polygon mesh
  56845. */
  56846. static ExtrudePolygon(name: string, options: {
  56847. shape: Vector3[];
  56848. holes?: Vector3[][];
  56849. depth?: number;
  56850. faceUV?: Vector4[];
  56851. faceColors?: Color4[];
  56852. updatable?: boolean;
  56853. sideOrientation?: number;
  56854. frontUVs?: Vector4;
  56855. backUVs?: Vector4;
  56856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56857. }
  56858. }
  56859. declare module BABYLON {
  56860. /**
  56861. * Class containing static functions to help procedurally build meshes
  56862. */
  56863. export class LatheBuilder {
  56864. /**
  56865. * Creates lathe mesh.
  56866. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56867. * * 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
  56868. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56869. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56870. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56871. * * 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
  56872. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56873. * * 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
  56874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56875. * * 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
  56876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56878. * @param name defines the name of the mesh
  56879. * @param options defines the options used to create the mesh
  56880. * @param scene defines the hosting scene
  56881. * @returns the lathe mesh
  56882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56883. */
  56884. static CreateLathe(name: string, options: {
  56885. shape: Vector3[];
  56886. radius?: number;
  56887. tessellation?: number;
  56888. clip?: number;
  56889. arc?: number;
  56890. closed?: boolean;
  56891. updatable?: boolean;
  56892. sideOrientation?: number;
  56893. frontUVs?: Vector4;
  56894. backUVs?: Vector4;
  56895. cap?: number;
  56896. invertUV?: boolean;
  56897. }, scene?: Nullable<Scene>): Mesh;
  56898. }
  56899. }
  56900. declare module BABYLON {
  56901. /**
  56902. * Class containing static functions to help procedurally build meshes
  56903. */
  56904. export class TiledPlaneBuilder {
  56905. /**
  56906. * Creates a tiled plane mesh
  56907. * * The parameter `pattern` will, depending on value, do nothing or
  56908. * * * flip (reflect about central vertical) alternate tiles across and up
  56909. * * * flip every tile on alternate rows
  56910. * * * rotate (180 degs) alternate tiles across and up
  56911. * * * rotate every tile on alternate rows
  56912. * * * flip and rotate alternate tiles across and up
  56913. * * * flip and rotate every tile on alternate rows
  56914. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56915. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56916. * * 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
  56917. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56918. * * 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)
  56919. * * 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)
  56920. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56921. * @param name defines the name of the mesh
  56922. * @param options defines the options used to create the mesh
  56923. * @param scene defines the hosting scene
  56924. * @returns the box mesh
  56925. */
  56926. static CreateTiledPlane(name: string, options: {
  56927. pattern?: number;
  56928. tileSize?: number;
  56929. tileWidth?: number;
  56930. tileHeight?: number;
  56931. size?: number;
  56932. width?: number;
  56933. height?: number;
  56934. alignHorizontal?: number;
  56935. alignVertical?: number;
  56936. sideOrientation?: number;
  56937. frontUVs?: Vector4;
  56938. backUVs?: Vector4;
  56939. updatable?: boolean;
  56940. }, scene?: Nullable<Scene>): Mesh;
  56941. }
  56942. }
  56943. declare module BABYLON {
  56944. /**
  56945. * Class containing static functions to help procedurally build meshes
  56946. */
  56947. export class TubeBuilder {
  56948. /**
  56949. * Creates a tube mesh.
  56950. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56951. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56952. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56953. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56954. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56955. * * 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)
  56956. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56957. * * 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
  56958. * * 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
  56959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56960. * * 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
  56961. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56963. * @param name defines the name of the mesh
  56964. * @param options defines the options used to create the mesh
  56965. * @param scene defines the hosting scene
  56966. * @returns the tube mesh
  56967. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56968. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56969. */
  56970. static CreateTube(name: string, options: {
  56971. path: Vector3[];
  56972. radius?: number;
  56973. tessellation?: number;
  56974. radiusFunction?: {
  56975. (i: number, distance: number): number;
  56976. };
  56977. cap?: number;
  56978. arc?: number;
  56979. updatable?: boolean;
  56980. sideOrientation?: number;
  56981. frontUVs?: Vector4;
  56982. backUVs?: Vector4;
  56983. instance?: Mesh;
  56984. invertUV?: boolean;
  56985. }, scene?: Nullable<Scene>): Mesh;
  56986. }
  56987. }
  56988. declare module BABYLON {
  56989. /**
  56990. * Class containing static functions to help procedurally build meshes
  56991. */
  56992. export class IcoSphereBuilder {
  56993. /**
  56994. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56995. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56996. * * 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`)
  56997. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56998. * * 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
  56999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57000. * * 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
  57001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57002. * @param name defines the name of the mesh
  57003. * @param options defines the options used to create the mesh
  57004. * @param scene defines the hosting scene
  57005. * @returns the icosahedron mesh
  57006. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57007. */
  57008. static CreateIcoSphere(name: string, options: {
  57009. radius?: number;
  57010. radiusX?: number;
  57011. radiusY?: number;
  57012. radiusZ?: number;
  57013. flat?: boolean;
  57014. subdivisions?: number;
  57015. sideOrientation?: number;
  57016. frontUVs?: Vector4;
  57017. backUVs?: Vector4;
  57018. updatable?: boolean;
  57019. }, scene?: Nullable<Scene>): Mesh;
  57020. }
  57021. }
  57022. declare module BABYLON {
  57023. /**
  57024. * Class containing static functions to help procedurally build meshes
  57025. */
  57026. export class DecalBuilder {
  57027. /**
  57028. * Creates a decal mesh.
  57029. * 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
  57030. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57031. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57032. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57033. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57034. * @param name defines the name of the mesh
  57035. * @param sourceMesh defines the mesh where the decal must be applied
  57036. * @param options defines the options used to create the mesh
  57037. * @param scene defines the hosting scene
  57038. * @returns the decal mesh
  57039. * @see https://doc.babylonjs.com/how_to/decals
  57040. */
  57041. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57042. position?: Vector3;
  57043. normal?: Vector3;
  57044. size?: Vector3;
  57045. angle?: number;
  57046. }): Mesh;
  57047. }
  57048. }
  57049. declare module BABYLON {
  57050. /**
  57051. * Class containing static functions to help procedurally build meshes
  57052. */
  57053. export class MeshBuilder {
  57054. /**
  57055. * Creates a box mesh
  57056. * * The parameter `size` sets the size (float) of each box side (default 1)
  57057. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57058. * * 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)
  57059. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57061. * * 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
  57062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57063. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57064. * @param name defines the name of the mesh
  57065. * @param options defines the options used to create the mesh
  57066. * @param scene defines the hosting scene
  57067. * @returns the box mesh
  57068. */
  57069. static CreateBox(name: string, options: {
  57070. size?: number;
  57071. width?: number;
  57072. height?: number;
  57073. depth?: number;
  57074. faceUV?: Vector4[];
  57075. faceColors?: Color4[];
  57076. sideOrientation?: number;
  57077. frontUVs?: Vector4;
  57078. backUVs?: Vector4;
  57079. updatable?: boolean;
  57080. }, scene?: Nullable<Scene>): Mesh;
  57081. /**
  57082. * Creates a tiled box mesh
  57083. * * faceTiles sets the pattern, tile size and number of tiles for a face
  57084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57085. * @param name defines the name of the mesh
  57086. * @param options defines the options used to create the mesh
  57087. * @param scene defines the hosting scene
  57088. * @returns the tiled box mesh
  57089. */
  57090. static CreateTiledBox(name: string, options: {
  57091. pattern?: number;
  57092. size?: number;
  57093. width?: number;
  57094. height?: number;
  57095. depth: number;
  57096. tileSize?: number;
  57097. tileWidth?: number;
  57098. tileHeight?: number;
  57099. faceUV?: Vector4[];
  57100. faceColors?: Color4[];
  57101. alignHorizontal?: number;
  57102. alignVertical?: number;
  57103. sideOrientation?: number;
  57104. updatable?: boolean;
  57105. }, scene?: Nullable<Scene>): Mesh;
  57106. /**
  57107. * Creates a sphere mesh
  57108. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  57109. * * 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`)
  57110. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  57111. * * 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
  57112. * * 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)
  57113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57114. * * 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
  57115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57116. * @param name defines the name of the mesh
  57117. * @param options defines the options used to create the mesh
  57118. * @param scene defines the hosting scene
  57119. * @returns the sphere mesh
  57120. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  57121. */
  57122. static CreateSphere(name: string, options: {
  57123. segments?: number;
  57124. diameter?: number;
  57125. diameterX?: number;
  57126. diameterY?: number;
  57127. diameterZ?: number;
  57128. arc?: number;
  57129. slice?: number;
  57130. sideOrientation?: number;
  57131. frontUVs?: Vector4;
  57132. backUVs?: Vector4;
  57133. updatable?: boolean;
  57134. }, scene?: Nullable<Scene>): Mesh;
  57135. /**
  57136. * Creates a plane polygonal mesh. By default, this is a disc
  57137. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  57138. * * 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
  57139. * * 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
  57140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57141. * * 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
  57142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57143. * @param name defines the name of the mesh
  57144. * @param options defines the options used to create the mesh
  57145. * @param scene defines the hosting scene
  57146. * @returns the plane polygonal mesh
  57147. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  57148. */
  57149. static CreateDisc(name: string, options: {
  57150. radius?: number;
  57151. tessellation?: number;
  57152. arc?: number;
  57153. updatable?: boolean;
  57154. sideOrientation?: number;
  57155. frontUVs?: Vector4;
  57156. backUVs?: Vector4;
  57157. }, scene?: Nullable<Scene>): Mesh;
  57158. /**
  57159. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  57160. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  57161. * * 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`)
  57162. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  57163. * * 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
  57164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57165. * * 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
  57166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57167. * @param name defines the name of the mesh
  57168. * @param options defines the options used to create the mesh
  57169. * @param scene defines the hosting scene
  57170. * @returns the icosahedron mesh
  57171. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  57172. */
  57173. static CreateIcoSphere(name: string, options: {
  57174. radius?: number;
  57175. radiusX?: number;
  57176. radiusY?: number;
  57177. radiusZ?: number;
  57178. flat?: boolean;
  57179. subdivisions?: number;
  57180. sideOrientation?: number;
  57181. frontUVs?: Vector4;
  57182. backUVs?: Vector4;
  57183. updatable?: boolean;
  57184. }, scene?: Nullable<Scene>): Mesh;
  57185. /**
  57186. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57187. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57188. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57189. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57190. * * 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
  57191. * * 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
  57192. * * 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
  57193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57194. * * 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
  57195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57196. * * 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
  57197. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57198. * * 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
  57199. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57201. * @param name defines the name of the mesh
  57202. * @param options defines the options used to create the mesh
  57203. * @param scene defines the hosting scene
  57204. * @returns the ribbon mesh
  57205. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57206. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57207. */
  57208. static CreateRibbon(name: string, options: {
  57209. pathArray: Vector3[][];
  57210. closeArray?: boolean;
  57211. closePath?: boolean;
  57212. offset?: number;
  57213. updatable?: boolean;
  57214. sideOrientation?: number;
  57215. frontUVs?: Vector4;
  57216. backUVs?: Vector4;
  57217. instance?: Mesh;
  57218. invertUV?: boolean;
  57219. uvs?: Vector2[];
  57220. colors?: Color4[];
  57221. }, scene?: Nullable<Scene>): Mesh;
  57222. /**
  57223. * Creates a cylinder or a cone mesh
  57224. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  57225. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  57226. * * 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.
  57227. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  57228. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  57229. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  57230. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  57231. * * 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).
  57232. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  57233. * * 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).
  57234. * * 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
  57235. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  57236. * * 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
  57237. * * 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.
  57238. * * If `enclose` is false, a ring surface is one element.
  57239. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  57240. * * 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
  57241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57242. * * 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
  57243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57244. * @param name defines the name of the mesh
  57245. * @param options defines the options used to create the mesh
  57246. * @param scene defines the hosting scene
  57247. * @returns the cylinder mesh
  57248. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  57249. */
  57250. static CreateCylinder(name: string, options: {
  57251. height?: number;
  57252. diameterTop?: number;
  57253. diameterBottom?: number;
  57254. diameter?: number;
  57255. tessellation?: number;
  57256. subdivisions?: number;
  57257. arc?: number;
  57258. faceColors?: Color4[];
  57259. faceUV?: Vector4[];
  57260. updatable?: boolean;
  57261. hasRings?: boolean;
  57262. enclose?: boolean;
  57263. cap?: number;
  57264. sideOrientation?: number;
  57265. frontUVs?: Vector4;
  57266. backUVs?: Vector4;
  57267. }, scene?: Nullable<Scene>): Mesh;
  57268. /**
  57269. * Creates a torus mesh
  57270. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  57271. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57272. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57274. * * 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
  57275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57276. * @param name defines the name of the mesh
  57277. * @param options defines the options used to create the mesh
  57278. * @param scene defines the hosting scene
  57279. * @returns the torus mesh
  57280. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57281. */
  57282. static CreateTorus(name: string, options: {
  57283. diameter?: number;
  57284. thickness?: number;
  57285. tessellation?: number;
  57286. updatable?: boolean;
  57287. sideOrientation?: number;
  57288. frontUVs?: Vector4;
  57289. backUVs?: Vector4;
  57290. }, scene?: Nullable<Scene>): Mesh;
  57291. /**
  57292. * Creates a torus knot mesh
  57293. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57294. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57295. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57296. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57298. * * 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
  57299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57300. * @param name defines the name of the mesh
  57301. * @param options defines the options used to create the mesh
  57302. * @param scene defines the hosting scene
  57303. * @returns the torus knot mesh
  57304. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57305. */
  57306. static CreateTorusKnot(name: string, options: {
  57307. radius?: number;
  57308. tube?: number;
  57309. radialSegments?: number;
  57310. tubularSegments?: number;
  57311. p?: number;
  57312. q?: number;
  57313. updatable?: boolean;
  57314. sideOrientation?: number;
  57315. frontUVs?: Vector4;
  57316. backUVs?: Vector4;
  57317. }, scene?: Nullable<Scene>): Mesh;
  57318. /**
  57319. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57320. * * 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
  57321. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57322. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57323. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57324. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57325. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57326. * * 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
  57327. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57330. * @param name defines the name of the new line system
  57331. * @param options defines the options used to create the line system
  57332. * @param scene defines the hosting scene
  57333. * @returns a new line system mesh
  57334. */
  57335. static CreateLineSystem(name: string, options: {
  57336. lines: Vector3[][];
  57337. updatable?: boolean;
  57338. instance?: Nullable<LinesMesh>;
  57339. colors?: Nullable<Color4[][]>;
  57340. useVertexAlpha?: boolean;
  57341. }, scene: Nullable<Scene>): LinesMesh;
  57342. /**
  57343. * Creates a line mesh
  57344. * 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
  57345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57346. * * The parameter `points` is an array successive Vector3
  57347. * * 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
  57348. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57349. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57350. * * When updating an instance, remember that only point positions can change, not the number of points
  57351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57353. * @param name defines the name of the new line system
  57354. * @param options defines the options used to create the line system
  57355. * @param scene defines the hosting scene
  57356. * @returns a new line mesh
  57357. */
  57358. static CreateLines(name: string, options: {
  57359. points: Vector3[];
  57360. updatable?: boolean;
  57361. instance?: Nullable<LinesMesh>;
  57362. colors?: Color4[];
  57363. useVertexAlpha?: boolean;
  57364. }, scene?: Nullable<Scene>): LinesMesh;
  57365. /**
  57366. * Creates a dashed line mesh
  57367. * * 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
  57368. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57369. * * The parameter `points` is an array successive Vector3
  57370. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57371. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57372. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57373. * * 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
  57374. * * When updating an instance, remember that only point positions can change, not the number of points
  57375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57376. * @param name defines the name of the mesh
  57377. * @param options defines the options used to create the mesh
  57378. * @param scene defines the hosting scene
  57379. * @returns the dashed line mesh
  57380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57381. */
  57382. static CreateDashedLines(name: string, options: {
  57383. points: Vector3[];
  57384. dashSize?: number;
  57385. gapSize?: number;
  57386. dashNb?: number;
  57387. updatable?: boolean;
  57388. instance?: LinesMesh;
  57389. }, scene?: Nullable<Scene>): LinesMesh;
  57390. /**
  57391. * 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.
  57392. * * 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.
  57393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57394. * * 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.
  57395. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57396. * * 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
  57397. * * 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
  57398. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57400. * * 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
  57401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57403. * @param name defines the name of the mesh
  57404. * @param options defines the options used to create the mesh
  57405. * @param scene defines the hosting scene
  57406. * @returns the extruded shape mesh
  57407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57409. */
  57410. static ExtrudeShape(name: string, options: {
  57411. shape: Vector3[];
  57412. path: Vector3[];
  57413. scale?: number;
  57414. rotation?: number;
  57415. cap?: number;
  57416. updatable?: boolean;
  57417. sideOrientation?: number;
  57418. frontUVs?: Vector4;
  57419. backUVs?: Vector4;
  57420. instance?: Mesh;
  57421. invertUV?: boolean;
  57422. }, scene?: Nullable<Scene>): Mesh;
  57423. /**
  57424. * Creates an custom extruded shape mesh.
  57425. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57426. * * 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.
  57427. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57428. * * 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
  57429. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57430. * * 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
  57431. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57432. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57433. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57434. * * 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
  57435. * * 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
  57436. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57438. * * 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
  57439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57441. * @param name defines the name of the mesh
  57442. * @param options defines the options used to create the mesh
  57443. * @param scene defines the hosting scene
  57444. * @returns the custom extruded shape mesh
  57445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57448. */
  57449. static ExtrudeShapeCustom(name: string, options: {
  57450. shape: Vector3[];
  57451. path: Vector3[];
  57452. scaleFunction?: any;
  57453. rotationFunction?: any;
  57454. ribbonCloseArray?: boolean;
  57455. ribbonClosePath?: boolean;
  57456. cap?: number;
  57457. updatable?: boolean;
  57458. sideOrientation?: number;
  57459. frontUVs?: Vector4;
  57460. backUVs?: Vector4;
  57461. instance?: Mesh;
  57462. invertUV?: boolean;
  57463. }, scene?: Nullable<Scene>): Mesh;
  57464. /**
  57465. * Creates lathe mesh.
  57466. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57467. * * 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
  57468. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57469. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57470. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57471. * * 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
  57472. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57473. * * 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
  57474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57475. * * 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
  57476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57478. * @param name defines the name of the mesh
  57479. * @param options defines the options used to create the mesh
  57480. * @param scene defines the hosting scene
  57481. * @returns the lathe mesh
  57482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57483. */
  57484. static CreateLathe(name: string, options: {
  57485. shape: Vector3[];
  57486. radius?: number;
  57487. tessellation?: number;
  57488. clip?: number;
  57489. arc?: number;
  57490. closed?: boolean;
  57491. updatable?: boolean;
  57492. sideOrientation?: number;
  57493. frontUVs?: Vector4;
  57494. backUVs?: Vector4;
  57495. cap?: number;
  57496. invertUV?: boolean;
  57497. }, scene?: Nullable<Scene>): Mesh;
  57498. /**
  57499. * Creates a tiled plane mesh
  57500. * * You can set a limited pattern arrangement with the tiles
  57501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57502. * * 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
  57503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57504. * @param name defines the name of the mesh
  57505. * @param options defines the options used to create the mesh
  57506. * @param scene defines the hosting scene
  57507. * @returns the plane mesh
  57508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57509. */
  57510. static CreateTiledPlane(name: string, options: {
  57511. pattern?: number;
  57512. tileSize?: number;
  57513. tileWidth?: number;
  57514. tileHeight?: number;
  57515. size?: number;
  57516. width?: number;
  57517. height?: number;
  57518. alignHorizontal?: number;
  57519. alignVertical?: number;
  57520. sideOrientation?: number;
  57521. frontUVs?: Vector4;
  57522. backUVs?: Vector4;
  57523. updatable?: boolean;
  57524. }, scene?: Nullable<Scene>): Mesh;
  57525. /**
  57526. * Creates a plane mesh
  57527. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57528. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57529. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57531. * * 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
  57532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57533. * @param name defines the name of the mesh
  57534. * @param options defines the options used to create the mesh
  57535. * @param scene defines the hosting scene
  57536. * @returns the plane mesh
  57537. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57538. */
  57539. static CreatePlane(name: string, options: {
  57540. size?: number;
  57541. width?: number;
  57542. height?: number;
  57543. sideOrientation?: number;
  57544. frontUVs?: Vector4;
  57545. backUVs?: Vector4;
  57546. updatable?: boolean;
  57547. sourcePlane?: Plane;
  57548. }, scene?: Nullable<Scene>): Mesh;
  57549. /**
  57550. * Creates a ground mesh
  57551. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57552. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57554. * @param name defines the name of the mesh
  57555. * @param options defines the options used to create the mesh
  57556. * @param scene defines the hosting scene
  57557. * @returns the ground mesh
  57558. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57559. */
  57560. static CreateGround(name: string, options: {
  57561. width?: number;
  57562. height?: number;
  57563. subdivisions?: number;
  57564. subdivisionsX?: number;
  57565. subdivisionsY?: number;
  57566. updatable?: boolean;
  57567. }, scene?: Nullable<Scene>): Mesh;
  57568. /**
  57569. * Creates a tiled ground mesh
  57570. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57571. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57572. * * 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
  57573. * * 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
  57574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57575. * @param name defines the name of the mesh
  57576. * @param options defines the options used to create the mesh
  57577. * @param scene defines the hosting scene
  57578. * @returns the tiled ground mesh
  57579. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57580. */
  57581. static CreateTiledGround(name: string, options: {
  57582. xmin: number;
  57583. zmin: number;
  57584. xmax: number;
  57585. zmax: number;
  57586. subdivisions?: {
  57587. w: number;
  57588. h: number;
  57589. };
  57590. precision?: {
  57591. w: number;
  57592. h: number;
  57593. };
  57594. updatable?: boolean;
  57595. }, scene?: Nullable<Scene>): Mesh;
  57596. /**
  57597. * Creates a ground mesh from a height map
  57598. * * The parameter `url` sets the URL of the height map image resource.
  57599. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57600. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57601. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57602. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57603. * * 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.
  57604. * * 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).
  57605. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57607. * @param name defines the name of the mesh
  57608. * @param url defines the url to the height map
  57609. * @param options defines the options used to create the mesh
  57610. * @param scene defines the hosting scene
  57611. * @returns the ground mesh
  57612. * @see https://doc.babylonjs.com/babylon101/height_map
  57613. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57614. */
  57615. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57616. width?: number;
  57617. height?: number;
  57618. subdivisions?: number;
  57619. minHeight?: number;
  57620. maxHeight?: number;
  57621. colorFilter?: Color3;
  57622. alphaFilter?: number;
  57623. updatable?: boolean;
  57624. onReady?: (mesh: GroundMesh) => void;
  57625. }, scene?: Nullable<Scene>): GroundMesh;
  57626. /**
  57627. * Creates a polygon mesh
  57628. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57629. * * 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
  57630. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57632. * * 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)
  57633. * * Remember you can only change the shape positions, not their number when updating a polygon
  57634. * @param name defines the name of the mesh
  57635. * @param options defines the options used to create the mesh
  57636. * @param scene defines the hosting scene
  57637. * @param earcutInjection can be used to inject your own earcut reference
  57638. * @returns the polygon mesh
  57639. */
  57640. static CreatePolygon(name: string, options: {
  57641. shape: Vector3[];
  57642. holes?: Vector3[][];
  57643. depth?: number;
  57644. faceUV?: Vector4[];
  57645. faceColors?: Color4[];
  57646. updatable?: boolean;
  57647. sideOrientation?: number;
  57648. frontUVs?: Vector4;
  57649. backUVs?: Vector4;
  57650. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57651. /**
  57652. * Creates an extruded polygon mesh, with depth in the Y direction.
  57653. * * 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)
  57654. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57655. * @param name defines the name of the mesh
  57656. * @param options defines the options used to create the mesh
  57657. * @param scene defines the hosting scene
  57658. * @param earcutInjection can be used to inject your own earcut reference
  57659. * @returns the polygon mesh
  57660. */
  57661. static ExtrudePolygon(name: string, options: {
  57662. shape: Vector3[];
  57663. holes?: Vector3[][];
  57664. depth?: number;
  57665. faceUV?: Vector4[];
  57666. faceColors?: Color4[];
  57667. updatable?: boolean;
  57668. sideOrientation?: number;
  57669. frontUVs?: Vector4;
  57670. backUVs?: Vector4;
  57671. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57672. /**
  57673. * Creates a tube mesh.
  57674. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57675. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57676. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57677. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57678. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57679. * * 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)
  57680. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57681. * * 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
  57682. * * 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
  57683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57684. * * 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
  57685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57687. * @param name defines the name of the mesh
  57688. * @param options defines the options used to create the mesh
  57689. * @param scene defines the hosting scene
  57690. * @returns the tube mesh
  57691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57692. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57693. */
  57694. static CreateTube(name: string, options: {
  57695. path: Vector3[];
  57696. radius?: number;
  57697. tessellation?: number;
  57698. radiusFunction?: {
  57699. (i: number, distance: number): number;
  57700. };
  57701. cap?: number;
  57702. arc?: number;
  57703. updatable?: boolean;
  57704. sideOrientation?: number;
  57705. frontUVs?: Vector4;
  57706. backUVs?: Vector4;
  57707. instance?: Mesh;
  57708. invertUV?: boolean;
  57709. }, scene?: Nullable<Scene>): Mesh;
  57710. /**
  57711. * Creates a polyhedron mesh
  57712. * * 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
  57713. * * The parameter `size` (positive float, default 1) sets the polygon size
  57714. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57715. * * 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`
  57716. * * 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
  57717. * * 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)`)
  57718. * * 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
  57719. * * 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
  57720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57721. * * 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
  57722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57723. * @param name defines the name of the mesh
  57724. * @param options defines the options used to create the mesh
  57725. * @param scene defines the hosting scene
  57726. * @returns the polyhedron mesh
  57727. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57728. */
  57729. static CreatePolyhedron(name: string, options: {
  57730. type?: number;
  57731. size?: number;
  57732. sizeX?: number;
  57733. sizeY?: number;
  57734. sizeZ?: number;
  57735. custom?: any;
  57736. faceUV?: Vector4[];
  57737. faceColors?: Color4[];
  57738. flat?: boolean;
  57739. updatable?: boolean;
  57740. sideOrientation?: number;
  57741. frontUVs?: Vector4;
  57742. backUVs?: Vector4;
  57743. }, scene?: Nullable<Scene>): Mesh;
  57744. /**
  57745. * Creates a decal mesh.
  57746. * 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
  57747. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57748. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57749. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57750. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57751. * @param name defines the name of the mesh
  57752. * @param sourceMesh defines the mesh where the decal must be applied
  57753. * @param options defines the options used to create the mesh
  57754. * @param scene defines the hosting scene
  57755. * @returns the decal mesh
  57756. * @see https://doc.babylonjs.com/how_to/decals
  57757. */
  57758. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57759. position?: Vector3;
  57760. normal?: Vector3;
  57761. size?: Vector3;
  57762. angle?: number;
  57763. }): Mesh;
  57764. }
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * A simplifier interface for future simplification implementations
  57769. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57770. */
  57771. export interface ISimplifier {
  57772. /**
  57773. * Simplification of a given mesh according to the given settings.
  57774. * Since this requires computation, it is assumed that the function runs async.
  57775. * @param settings The settings of the simplification, including quality and distance
  57776. * @param successCallback A callback that will be called after the mesh was simplified.
  57777. * @param errorCallback in case of an error, this callback will be called. optional.
  57778. */
  57779. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57780. }
  57781. /**
  57782. * Expected simplification settings.
  57783. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57784. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57785. */
  57786. export interface ISimplificationSettings {
  57787. /**
  57788. * Gets or sets the expected quality
  57789. */
  57790. quality: number;
  57791. /**
  57792. * Gets or sets the distance when this optimized version should be used
  57793. */
  57794. distance: number;
  57795. /**
  57796. * Gets an already optimized mesh
  57797. */
  57798. optimizeMesh?: boolean;
  57799. }
  57800. /**
  57801. * Class used to specify simplification options
  57802. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57803. */
  57804. export class SimplificationSettings implements ISimplificationSettings {
  57805. /** expected quality */
  57806. quality: number;
  57807. /** distance when this optimized version should be used */
  57808. distance: number;
  57809. /** already optimized mesh */
  57810. optimizeMesh?: boolean | undefined;
  57811. /**
  57812. * Creates a SimplificationSettings
  57813. * @param quality expected quality
  57814. * @param distance distance when this optimized version should be used
  57815. * @param optimizeMesh already optimized mesh
  57816. */
  57817. constructor(
  57818. /** expected quality */
  57819. quality: number,
  57820. /** distance when this optimized version should be used */
  57821. distance: number,
  57822. /** already optimized mesh */
  57823. optimizeMesh?: boolean | undefined);
  57824. }
  57825. /**
  57826. * Interface used to define a simplification task
  57827. */
  57828. export interface ISimplificationTask {
  57829. /**
  57830. * Array of settings
  57831. */
  57832. settings: Array<ISimplificationSettings>;
  57833. /**
  57834. * Simplification type
  57835. */
  57836. simplificationType: SimplificationType;
  57837. /**
  57838. * Mesh to simplify
  57839. */
  57840. mesh: Mesh;
  57841. /**
  57842. * Callback called on success
  57843. */
  57844. successCallback?: () => void;
  57845. /**
  57846. * Defines if parallel processing can be used
  57847. */
  57848. parallelProcessing: boolean;
  57849. }
  57850. /**
  57851. * Queue used to order the simplification tasks
  57852. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57853. */
  57854. export class SimplificationQueue {
  57855. private _simplificationArray;
  57856. /**
  57857. * Gets a boolean indicating that the process is still running
  57858. */
  57859. running: boolean;
  57860. /**
  57861. * Creates a new queue
  57862. */
  57863. constructor();
  57864. /**
  57865. * Adds a new simplification task
  57866. * @param task defines a task to add
  57867. */
  57868. addTask(task: ISimplificationTask): void;
  57869. /**
  57870. * Execute next task
  57871. */
  57872. executeNext(): void;
  57873. /**
  57874. * Execute a simplification task
  57875. * @param task defines the task to run
  57876. */
  57877. runSimplification(task: ISimplificationTask): void;
  57878. private getSimplifier;
  57879. }
  57880. /**
  57881. * The implemented types of simplification
  57882. * At the moment only Quadratic Error Decimation is implemented
  57883. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57884. */
  57885. export enum SimplificationType {
  57886. /** Quadratic error decimation */
  57887. QUADRATIC = 0
  57888. }
  57889. }
  57890. declare module BABYLON {
  57891. interface Scene {
  57892. /** @hidden (Backing field) */
  57893. _simplificationQueue: SimplificationQueue;
  57894. /**
  57895. * Gets or sets the simplification queue attached to the scene
  57896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57897. */
  57898. simplificationQueue: SimplificationQueue;
  57899. }
  57900. interface Mesh {
  57901. /**
  57902. * Simplify the mesh according to the given array of settings.
  57903. * Function will return immediately and will simplify async
  57904. * @param settings a collection of simplification settings
  57905. * @param parallelProcessing should all levels calculate parallel or one after the other
  57906. * @param simplificationType the type of simplification to run
  57907. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57908. * @returns the current mesh
  57909. */
  57910. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57911. }
  57912. /**
  57913. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57914. * created in a scene
  57915. */
  57916. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57917. /**
  57918. * The component name helpfull to identify the component in the list of scene components.
  57919. */
  57920. readonly name: string;
  57921. /**
  57922. * The scene the component belongs to.
  57923. */
  57924. scene: Scene;
  57925. /**
  57926. * Creates a new instance of the component for the given scene
  57927. * @param scene Defines the scene to register the component in
  57928. */
  57929. constructor(scene: Scene);
  57930. /**
  57931. * Registers the component in a given scene
  57932. */
  57933. register(): void;
  57934. /**
  57935. * Rebuilds the elements related to this component in case of
  57936. * context lost for instance.
  57937. */
  57938. rebuild(): void;
  57939. /**
  57940. * Disposes the component and the associated ressources
  57941. */
  57942. dispose(): void;
  57943. private _beforeCameraUpdate;
  57944. }
  57945. }
  57946. declare module BABYLON {
  57947. /**
  57948. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57949. */
  57950. export interface INavigationEnginePlugin {
  57951. /**
  57952. * plugin name
  57953. */
  57954. name: string;
  57955. /**
  57956. * Creates a navigation mesh
  57957. * @param meshes array of all the geometry used to compute the navigatio mesh
  57958. * @param parameters bunch of parameters used to filter geometry
  57959. */
  57960. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57961. /**
  57962. * Create a navigation mesh debug mesh
  57963. * @param scene is where the mesh will be added
  57964. * @returns debug display mesh
  57965. */
  57966. createDebugNavMesh(scene: Scene): Mesh;
  57967. /**
  57968. * Get a navigation mesh constrained position, closest to the parameter position
  57969. * @param position world position
  57970. * @returns the closest point to position constrained by the navigation mesh
  57971. */
  57972. getClosestPoint(position: Vector3): Vector3;
  57973. /**
  57974. * Get a navigation mesh constrained position, within a particular radius
  57975. * @param position world position
  57976. * @param maxRadius the maximum distance to the constrained world position
  57977. * @returns the closest point to position constrained by the navigation mesh
  57978. */
  57979. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57980. /**
  57981. * Compute the final position from a segment made of destination-position
  57982. * @param position world position
  57983. * @param destination world position
  57984. * @returns the resulting point along the navmesh
  57985. */
  57986. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57987. /**
  57988. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57989. * @param start world position
  57990. * @param end world position
  57991. * @returns array containing world position composing the path
  57992. */
  57993. computePath(start: Vector3, end: Vector3): Vector3[];
  57994. /**
  57995. * If this plugin is supported
  57996. * @returns true if plugin is supported
  57997. */
  57998. isSupported(): boolean;
  57999. /**
  58000. * Create a new Crowd so you can add agents
  58001. * @param maxAgents the maximum agent count in the crowd
  58002. * @param maxAgentRadius the maximum radius an agent can have
  58003. * @param scene to attach the crowd to
  58004. * @returns the crowd you can add agents to
  58005. */
  58006. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58007. /**
  58008. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58009. * The queries will try to find a solution within those bounds
  58010. * default is (1,1,1)
  58011. * @param extent x,y,z value that define the extent around the queries point of reference
  58012. */
  58013. setDefaultQueryExtent(extent: Vector3): void;
  58014. /**
  58015. * Get the Bounding box extent specified by setDefaultQueryExtent
  58016. * @returns the box extent values
  58017. */
  58018. getDefaultQueryExtent(): Vector3;
  58019. /**
  58020. * Release all resources
  58021. */
  58022. dispose(): void;
  58023. }
  58024. /**
  58025. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  58026. */
  58027. export interface ICrowd {
  58028. /**
  58029. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58030. * You can attach anything to that node. The node position is updated in the scene update tick.
  58031. * @param pos world position that will be constrained by the navigation mesh
  58032. * @param parameters agent parameters
  58033. * @param transform hooked to the agent that will be update by the scene
  58034. * @returns agent index
  58035. */
  58036. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58037. /**
  58038. * Returns the agent position in world space
  58039. * @param index agent index returned by addAgent
  58040. * @returns world space position
  58041. */
  58042. getAgentPosition(index: number): Vector3;
  58043. /**
  58044. * Gets the agent velocity in world space
  58045. * @param index agent index returned by addAgent
  58046. * @returns world space velocity
  58047. */
  58048. getAgentVelocity(index: number): Vector3;
  58049. /**
  58050. * remove a particular agent previously created
  58051. * @param index agent index returned by addAgent
  58052. */
  58053. removeAgent(index: number): void;
  58054. /**
  58055. * get the list of all agents attached to this crowd
  58056. * @returns list of agent indices
  58057. */
  58058. getAgents(): number[];
  58059. /**
  58060. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58061. * @param deltaTime in seconds
  58062. */
  58063. update(deltaTime: number): void;
  58064. /**
  58065. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58066. * @param index agent index returned by addAgent
  58067. * @param destination targeted world position
  58068. */
  58069. agentGoto(index: number, destination: Vector3): void;
  58070. /**
  58071. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58072. * The queries will try to find a solution within those bounds
  58073. * default is (1,1,1)
  58074. * @param extent x,y,z value that define the extent around the queries point of reference
  58075. */
  58076. setDefaultQueryExtent(extent: Vector3): void;
  58077. /**
  58078. * Get the Bounding box extent specified by setDefaultQueryExtent
  58079. * @returns the box extent values
  58080. */
  58081. getDefaultQueryExtent(): Vector3;
  58082. /**
  58083. * Release all resources
  58084. */
  58085. dispose(): void;
  58086. }
  58087. /**
  58088. * Configures an agent
  58089. */
  58090. export interface IAgentParameters {
  58091. /**
  58092. * Agent radius. [Limit: >= 0]
  58093. */
  58094. radius: number;
  58095. /**
  58096. * Agent height. [Limit: > 0]
  58097. */
  58098. height: number;
  58099. /**
  58100. * Maximum allowed acceleration. [Limit: >= 0]
  58101. */
  58102. maxAcceleration: number;
  58103. /**
  58104. * Maximum allowed speed. [Limit: >= 0]
  58105. */
  58106. maxSpeed: number;
  58107. /**
  58108. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  58109. */
  58110. collisionQueryRange: number;
  58111. /**
  58112. * The path visibility optimization range. [Limit: > 0]
  58113. */
  58114. pathOptimizationRange: number;
  58115. /**
  58116. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  58117. */
  58118. separationWeight: number;
  58119. }
  58120. /**
  58121. * Configures the navigation mesh creation
  58122. */
  58123. export interface INavMeshParameters {
  58124. /**
  58125. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  58126. */
  58127. cs: number;
  58128. /**
  58129. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  58130. */
  58131. ch: number;
  58132. /**
  58133. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  58134. */
  58135. walkableSlopeAngle: number;
  58136. /**
  58137. * Minimum floor to 'ceiling' height that will still allow the floor area to
  58138. * be considered walkable. [Limit: >= 3] [Units: vx]
  58139. */
  58140. walkableHeight: number;
  58141. /**
  58142. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  58143. */
  58144. walkableClimb: number;
  58145. /**
  58146. * The distance to erode/shrink the walkable area of the heightfield away from
  58147. * obstructions. [Limit: >=0] [Units: vx]
  58148. */
  58149. walkableRadius: number;
  58150. /**
  58151. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  58152. */
  58153. maxEdgeLen: number;
  58154. /**
  58155. * The maximum distance a simplfied contour's border edges should deviate
  58156. * the original raw contour. [Limit: >=0] [Units: vx]
  58157. */
  58158. maxSimplificationError: number;
  58159. /**
  58160. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  58161. */
  58162. minRegionArea: number;
  58163. /**
  58164. * Any regions with a span count smaller than this value will, if possible,
  58165. * be merged with larger regions. [Limit: >=0] [Units: vx]
  58166. */
  58167. mergeRegionArea: number;
  58168. /**
  58169. * The maximum number of vertices allowed for polygons generated during the
  58170. * contour to polygon conversion process. [Limit: >= 3]
  58171. */
  58172. maxVertsPerPoly: number;
  58173. /**
  58174. * Sets the sampling distance to use when generating the detail mesh.
  58175. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  58176. */
  58177. detailSampleDist: number;
  58178. /**
  58179. * The maximum distance the detail mesh surface should deviate from heightfield
  58180. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  58181. */
  58182. detailSampleMaxError: number;
  58183. }
  58184. }
  58185. declare module BABYLON {
  58186. /**
  58187. * RecastJS navigation plugin
  58188. */
  58189. export class RecastJSPlugin implements INavigationEnginePlugin {
  58190. /**
  58191. * Reference to the Recast library
  58192. */
  58193. bjsRECAST: any;
  58194. /**
  58195. * plugin name
  58196. */
  58197. name: string;
  58198. /**
  58199. * the first navmesh created. We might extend this to support multiple navmeshes
  58200. */
  58201. navMesh: any;
  58202. /**
  58203. * Initializes the recastJS plugin
  58204. * @param recastInjection can be used to inject your own recast reference
  58205. */
  58206. constructor(recastInjection?: any);
  58207. /**
  58208. * Creates a navigation mesh
  58209. * @param meshes array of all the geometry used to compute the navigatio mesh
  58210. * @param parameters bunch of parameters used to filter geometry
  58211. */
  58212. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  58213. /**
  58214. * Create a navigation mesh debug mesh
  58215. * @param scene is where the mesh will be added
  58216. * @returns debug display mesh
  58217. */
  58218. createDebugNavMesh(scene: Scene): Mesh;
  58219. /**
  58220. * Get a navigation mesh constrained position, closest to the parameter position
  58221. * @param position world position
  58222. * @returns the closest point to position constrained by the navigation mesh
  58223. */
  58224. getClosestPoint(position: Vector3): Vector3;
  58225. /**
  58226. * Get a navigation mesh constrained position, within a particular radius
  58227. * @param position world position
  58228. * @param maxRadius the maximum distance to the constrained world position
  58229. * @returns the closest point to position constrained by the navigation mesh
  58230. */
  58231. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  58232. /**
  58233. * Compute the final position from a segment made of destination-position
  58234. * @param position world position
  58235. * @param destination world position
  58236. * @returns the resulting point along the navmesh
  58237. */
  58238. moveAlong(position: Vector3, destination: Vector3): Vector3;
  58239. /**
  58240. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  58241. * @param start world position
  58242. * @param end world position
  58243. * @returns array containing world position composing the path
  58244. */
  58245. computePath(start: Vector3, end: Vector3): Vector3[];
  58246. /**
  58247. * Create a new Crowd so you can add agents
  58248. * @param maxAgents the maximum agent count in the crowd
  58249. * @param maxAgentRadius the maximum radius an agent can have
  58250. * @param scene to attach the crowd to
  58251. * @returns the crowd you can add agents to
  58252. */
  58253. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58254. /**
  58255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58256. * The queries will try to find a solution within those bounds
  58257. * default is (1,1,1)
  58258. * @param extent x,y,z value that define the extent around the queries point of reference
  58259. */
  58260. setDefaultQueryExtent(extent: Vector3): void;
  58261. /**
  58262. * Get the Bounding box extent specified by setDefaultQueryExtent
  58263. * @returns the box extent values
  58264. */
  58265. getDefaultQueryExtent(): Vector3;
  58266. /**
  58267. * Disposes
  58268. */
  58269. dispose(): void;
  58270. /**
  58271. * If this plugin is supported
  58272. * @returns true if plugin is supported
  58273. */
  58274. isSupported(): boolean;
  58275. }
  58276. /**
  58277. * Recast detour crowd implementation
  58278. */
  58279. export class RecastJSCrowd implements ICrowd {
  58280. /**
  58281. * Recast/detour plugin
  58282. */
  58283. bjsRECASTPlugin: RecastJSPlugin;
  58284. /**
  58285. * Link to the detour crowd
  58286. */
  58287. recastCrowd: any;
  58288. /**
  58289. * One transform per agent
  58290. */
  58291. transforms: TransformNode[];
  58292. /**
  58293. * All agents created
  58294. */
  58295. agents: number[];
  58296. /**
  58297. * Link to the scene is kept to unregister the crowd from the scene
  58298. */
  58299. private _scene;
  58300. /**
  58301. * Observer for crowd updates
  58302. */
  58303. private _onBeforeAnimationsObserver;
  58304. /**
  58305. * Constructor
  58306. * @param plugin recastJS plugin
  58307. * @param maxAgents the maximum agent count in the crowd
  58308. * @param maxAgentRadius the maximum radius an agent can have
  58309. * @param scene to attach the crowd to
  58310. * @returns the crowd you can add agents to
  58311. */
  58312. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58313. /**
  58314. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58315. * You can attach anything to that node. The node position is updated in the scene update tick.
  58316. * @param pos world position that will be constrained by the navigation mesh
  58317. * @param parameters agent parameters
  58318. * @param transform hooked to the agent that will be update by the scene
  58319. * @returns agent index
  58320. */
  58321. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58322. /**
  58323. * Returns the agent position in world space
  58324. * @param index agent index returned by addAgent
  58325. * @returns world space position
  58326. */
  58327. getAgentPosition(index: number): Vector3;
  58328. /**
  58329. * Returns the agent velocity in world space
  58330. * @param index agent index returned by addAgent
  58331. * @returns world space velocity
  58332. */
  58333. getAgentVelocity(index: number): Vector3;
  58334. /**
  58335. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58336. * @param index agent index returned by addAgent
  58337. * @param destination targeted world position
  58338. */
  58339. agentGoto(index: number, destination: Vector3): void;
  58340. /**
  58341. * remove a particular agent previously created
  58342. * @param index agent index returned by addAgent
  58343. */
  58344. removeAgent(index: number): void;
  58345. /**
  58346. * get the list of all agents attached to this crowd
  58347. * @returns list of agent indices
  58348. */
  58349. getAgents(): number[];
  58350. /**
  58351. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58352. * @param deltaTime in seconds
  58353. */
  58354. update(deltaTime: number): void;
  58355. /**
  58356. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  58357. * The queries will try to find a solution within those bounds
  58358. * default is (1,1,1)
  58359. * @param extent x,y,z value that define the extent around the queries point of reference
  58360. */
  58361. setDefaultQueryExtent(extent: Vector3): void;
  58362. /**
  58363. * Get the Bounding box extent specified by setDefaultQueryExtent
  58364. * @returns the box extent values
  58365. */
  58366. getDefaultQueryExtent(): Vector3;
  58367. /**
  58368. * Release all resources
  58369. */
  58370. dispose(): void;
  58371. }
  58372. }
  58373. declare module BABYLON {
  58374. /**
  58375. * Class used to enable access to IndexedDB
  58376. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58377. */
  58378. export class Database implements IOfflineProvider {
  58379. private _callbackManifestChecked;
  58380. private _currentSceneUrl;
  58381. private _db;
  58382. private _enableSceneOffline;
  58383. private _enableTexturesOffline;
  58384. private _manifestVersionFound;
  58385. private _mustUpdateRessources;
  58386. private _hasReachedQuota;
  58387. private _isSupported;
  58388. private _idbFactory;
  58389. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58390. private static IsUASupportingBlobStorage;
  58391. /**
  58392. * Gets a boolean indicating if Database storate is enabled (off by default)
  58393. */
  58394. static IDBStorageEnabled: boolean;
  58395. /**
  58396. * Gets a boolean indicating if scene must be saved in the database
  58397. */
  58398. readonly enableSceneOffline: boolean;
  58399. /**
  58400. * Gets a boolean indicating if textures must be saved in the database
  58401. */
  58402. readonly enableTexturesOffline: boolean;
  58403. /**
  58404. * Creates a new Database
  58405. * @param urlToScene defines the url to load the scene
  58406. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58407. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58408. */
  58409. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58410. private static _ParseURL;
  58411. private static _ReturnFullUrlLocation;
  58412. private _checkManifestFile;
  58413. /**
  58414. * Open the database and make it available
  58415. * @param successCallback defines the callback to call on success
  58416. * @param errorCallback defines the callback to call on error
  58417. */
  58418. open(successCallback: () => void, errorCallback: () => void): void;
  58419. /**
  58420. * Loads an image from the database
  58421. * @param url defines the url to load from
  58422. * @param image defines the target DOM image
  58423. */
  58424. loadImage(url: string, image: HTMLImageElement): void;
  58425. private _loadImageFromDBAsync;
  58426. private _saveImageIntoDBAsync;
  58427. private _checkVersionFromDB;
  58428. private _loadVersionFromDBAsync;
  58429. private _saveVersionIntoDBAsync;
  58430. /**
  58431. * Loads a file from database
  58432. * @param url defines the URL to load from
  58433. * @param sceneLoaded defines a callback to call on success
  58434. * @param progressCallBack defines a callback to call when progress changed
  58435. * @param errorCallback defines a callback to call on error
  58436. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58437. */
  58438. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58439. private _loadFileAsync;
  58440. private _saveFileAsync;
  58441. /**
  58442. * Validates if xhr data is correct
  58443. * @param xhr defines the request to validate
  58444. * @param dataType defines the expected data type
  58445. * @returns true if data is correct
  58446. */
  58447. private static _ValidateXHRData;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /** @hidden */
  58452. export var gpuUpdateParticlesPixelShader: {
  58453. name: string;
  58454. shader: string;
  58455. };
  58456. }
  58457. declare module BABYLON {
  58458. /** @hidden */
  58459. export var gpuUpdateParticlesVertexShader: {
  58460. name: string;
  58461. shader: string;
  58462. };
  58463. }
  58464. declare module BABYLON {
  58465. /** @hidden */
  58466. export var clipPlaneFragmentDeclaration2: {
  58467. name: string;
  58468. shader: string;
  58469. };
  58470. }
  58471. declare module BABYLON {
  58472. /** @hidden */
  58473. export var gpuRenderParticlesPixelShader: {
  58474. name: string;
  58475. shader: string;
  58476. };
  58477. }
  58478. declare module BABYLON {
  58479. /** @hidden */
  58480. export var clipPlaneVertexDeclaration2: {
  58481. name: string;
  58482. shader: string;
  58483. };
  58484. }
  58485. declare module BABYLON {
  58486. /** @hidden */
  58487. export var gpuRenderParticlesVertexShader: {
  58488. name: string;
  58489. shader: string;
  58490. };
  58491. }
  58492. declare module BABYLON {
  58493. /**
  58494. * This represents a GPU particle system in Babylon
  58495. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58496. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58497. */
  58498. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58499. /**
  58500. * The layer mask we are rendering the particles through.
  58501. */
  58502. layerMask: number;
  58503. private _capacity;
  58504. private _activeCount;
  58505. private _currentActiveCount;
  58506. private _accumulatedCount;
  58507. private _renderEffect;
  58508. private _updateEffect;
  58509. private _buffer0;
  58510. private _buffer1;
  58511. private _spriteBuffer;
  58512. private _updateVAO;
  58513. private _renderVAO;
  58514. private _targetIndex;
  58515. private _sourceBuffer;
  58516. private _targetBuffer;
  58517. private _engine;
  58518. private _currentRenderId;
  58519. private _started;
  58520. private _stopped;
  58521. private _timeDelta;
  58522. private _randomTexture;
  58523. private _randomTexture2;
  58524. private _attributesStrideSize;
  58525. private _updateEffectOptions;
  58526. private _randomTextureSize;
  58527. private _actualFrame;
  58528. private readonly _rawTextureWidth;
  58529. /**
  58530. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58531. */
  58532. static readonly IsSupported: boolean;
  58533. /**
  58534. * An event triggered when the system is disposed.
  58535. */
  58536. onDisposeObservable: Observable<GPUParticleSystem>;
  58537. /**
  58538. * Gets the maximum number of particles active at the same time.
  58539. * @returns The max number of active particles.
  58540. */
  58541. getCapacity(): number;
  58542. /**
  58543. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58544. * to override the particles.
  58545. */
  58546. forceDepthWrite: boolean;
  58547. /**
  58548. * Gets or set the number of active particles
  58549. */
  58550. activeParticleCount: number;
  58551. private _preWarmDone;
  58552. /**
  58553. * Is this system ready to be used/rendered
  58554. * @return true if the system is ready
  58555. */
  58556. isReady(): boolean;
  58557. /**
  58558. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58559. * @returns True if it has been started, otherwise false.
  58560. */
  58561. isStarted(): boolean;
  58562. /**
  58563. * Starts the particle system and begins to emit
  58564. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58565. */
  58566. start(delay?: number): void;
  58567. /**
  58568. * Stops the particle system.
  58569. */
  58570. stop(): void;
  58571. /**
  58572. * Remove all active particles
  58573. */
  58574. reset(): void;
  58575. /**
  58576. * Returns the string "GPUParticleSystem"
  58577. * @returns a string containing the class name
  58578. */
  58579. getClassName(): string;
  58580. private _colorGradientsTexture;
  58581. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58582. /**
  58583. * Adds a new color gradient
  58584. * @param gradient defines the gradient to use (between 0 and 1)
  58585. * @param color1 defines the color to affect to the specified gradient
  58586. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58587. * @returns the current particle system
  58588. */
  58589. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58590. /**
  58591. * Remove a specific color gradient
  58592. * @param gradient defines the gradient to remove
  58593. * @returns the current particle system
  58594. */
  58595. removeColorGradient(gradient: number): GPUParticleSystem;
  58596. private _angularSpeedGradientsTexture;
  58597. private _sizeGradientsTexture;
  58598. private _velocityGradientsTexture;
  58599. private _limitVelocityGradientsTexture;
  58600. private _dragGradientsTexture;
  58601. private _addFactorGradient;
  58602. /**
  58603. * Adds a new size gradient
  58604. * @param gradient defines the gradient to use (between 0 and 1)
  58605. * @param factor defines the size factor to affect to the specified gradient
  58606. * @returns the current particle system
  58607. */
  58608. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58609. /**
  58610. * Remove a specific size gradient
  58611. * @param gradient defines the gradient to remove
  58612. * @returns the current particle system
  58613. */
  58614. removeSizeGradient(gradient: number): GPUParticleSystem;
  58615. /**
  58616. * Adds a new angular speed gradient
  58617. * @param gradient defines the gradient to use (between 0 and 1)
  58618. * @param factor defines the angular speed to affect to the specified gradient
  58619. * @returns the current particle system
  58620. */
  58621. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58622. /**
  58623. * Remove a specific angular speed gradient
  58624. * @param gradient defines the gradient to remove
  58625. * @returns the current particle system
  58626. */
  58627. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58628. /**
  58629. * Adds a new velocity gradient
  58630. * @param gradient defines the gradient to use (between 0 and 1)
  58631. * @param factor defines the velocity to affect to the specified gradient
  58632. * @returns the current particle system
  58633. */
  58634. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58635. /**
  58636. * Remove a specific velocity gradient
  58637. * @param gradient defines the gradient to remove
  58638. * @returns the current particle system
  58639. */
  58640. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58641. /**
  58642. * Adds a new limit velocity gradient
  58643. * @param gradient defines the gradient to use (between 0 and 1)
  58644. * @param factor defines the limit velocity value to affect to the specified gradient
  58645. * @returns the current particle system
  58646. */
  58647. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58648. /**
  58649. * Remove a specific limit velocity gradient
  58650. * @param gradient defines the gradient to remove
  58651. * @returns the current particle system
  58652. */
  58653. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58654. /**
  58655. * Adds a new drag gradient
  58656. * @param gradient defines the gradient to use (between 0 and 1)
  58657. * @param factor defines the drag value to affect to the specified gradient
  58658. * @returns the current particle system
  58659. */
  58660. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58661. /**
  58662. * Remove a specific drag gradient
  58663. * @param gradient defines the gradient to remove
  58664. * @returns the current particle system
  58665. */
  58666. removeDragGradient(gradient: number): GPUParticleSystem;
  58667. /**
  58668. * Not supported by GPUParticleSystem
  58669. * @param gradient defines the gradient to use (between 0 and 1)
  58670. * @param factor defines the emit rate value to affect to the specified gradient
  58671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58672. * @returns the current particle system
  58673. */
  58674. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58675. /**
  58676. * Not supported by GPUParticleSystem
  58677. * @param gradient defines the gradient to remove
  58678. * @returns the current particle system
  58679. */
  58680. removeEmitRateGradient(gradient: number): IParticleSystem;
  58681. /**
  58682. * Not supported by GPUParticleSystem
  58683. * @param gradient defines the gradient to use (between 0 and 1)
  58684. * @param factor defines the start size value to affect to the specified gradient
  58685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58686. * @returns the current particle system
  58687. */
  58688. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58689. /**
  58690. * Not supported by GPUParticleSystem
  58691. * @param gradient defines the gradient to remove
  58692. * @returns the current particle system
  58693. */
  58694. removeStartSizeGradient(gradient: number): IParticleSystem;
  58695. /**
  58696. * Not supported by GPUParticleSystem
  58697. * @param gradient defines the gradient to use (between 0 and 1)
  58698. * @param min defines the color remap minimal range
  58699. * @param max defines the color remap maximal range
  58700. * @returns the current particle system
  58701. */
  58702. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58703. /**
  58704. * Not supported by GPUParticleSystem
  58705. * @param gradient defines the gradient to remove
  58706. * @returns the current particle system
  58707. */
  58708. removeColorRemapGradient(): IParticleSystem;
  58709. /**
  58710. * Not supported by GPUParticleSystem
  58711. * @param gradient defines the gradient to use (between 0 and 1)
  58712. * @param min defines the alpha remap minimal range
  58713. * @param max defines the alpha remap maximal range
  58714. * @returns the current particle system
  58715. */
  58716. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58717. /**
  58718. * Not supported by GPUParticleSystem
  58719. * @param gradient defines the gradient to remove
  58720. * @returns the current particle system
  58721. */
  58722. removeAlphaRemapGradient(): IParticleSystem;
  58723. /**
  58724. * Not supported by GPUParticleSystem
  58725. * @param gradient defines the gradient to use (between 0 and 1)
  58726. * @param color defines the color to affect to the specified gradient
  58727. * @returns the current particle system
  58728. */
  58729. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58730. /**
  58731. * Not supported by GPUParticleSystem
  58732. * @param gradient defines the gradient to remove
  58733. * @returns the current particle system
  58734. */
  58735. removeRampGradient(): IParticleSystem;
  58736. /**
  58737. * Not supported by GPUParticleSystem
  58738. * @returns the list of ramp gradients
  58739. */
  58740. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58741. /**
  58742. * Not supported by GPUParticleSystem
  58743. * Gets or sets a boolean indicating that ramp gradients must be used
  58744. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58745. */
  58746. useRampGradients: boolean;
  58747. /**
  58748. * Not supported by GPUParticleSystem
  58749. * @param gradient defines the gradient to use (between 0 and 1)
  58750. * @param factor defines the life time factor to affect to the specified gradient
  58751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58752. * @returns the current particle system
  58753. */
  58754. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58755. /**
  58756. * Not supported by GPUParticleSystem
  58757. * @param gradient defines the gradient to remove
  58758. * @returns the current particle system
  58759. */
  58760. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58761. /**
  58762. * Instantiates a GPU particle system.
  58763. * 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.
  58764. * @param name The name of the particle system
  58765. * @param options The options used to create the system
  58766. * @param scene The scene the particle system belongs to
  58767. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58768. */
  58769. constructor(name: string, options: Partial<{
  58770. capacity: number;
  58771. randomTextureSize: number;
  58772. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58773. protected _reset(): void;
  58774. private _createUpdateVAO;
  58775. private _createRenderVAO;
  58776. private _initialize;
  58777. /** @hidden */
  58778. _recreateUpdateEffect(): void;
  58779. /** @hidden */
  58780. _recreateRenderEffect(): void;
  58781. /**
  58782. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58783. * @param preWarm defines if we are in the pre-warmimg phase
  58784. */
  58785. animate(preWarm?: boolean): void;
  58786. private _createFactorGradientTexture;
  58787. private _createSizeGradientTexture;
  58788. private _createAngularSpeedGradientTexture;
  58789. private _createVelocityGradientTexture;
  58790. private _createLimitVelocityGradientTexture;
  58791. private _createDragGradientTexture;
  58792. private _createColorGradientTexture;
  58793. /**
  58794. * Renders the particle system in its current state
  58795. * @param preWarm defines if the system should only update the particles but not render them
  58796. * @returns the current number of particles
  58797. */
  58798. render(preWarm?: boolean): number;
  58799. /**
  58800. * Rebuilds the particle system
  58801. */
  58802. rebuild(): void;
  58803. private _releaseBuffers;
  58804. private _releaseVAOs;
  58805. /**
  58806. * Disposes the particle system and free the associated resources
  58807. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58808. */
  58809. dispose(disposeTexture?: boolean): void;
  58810. /**
  58811. * Clones the particle system.
  58812. * @param name The name of the cloned object
  58813. * @param newEmitter The new emitter to use
  58814. * @returns the cloned particle system
  58815. */
  58816. clone(name: string, newEmitter: any): GPUParticleSystem;
  58817. /**
  58818. * Serializes the particle system to a JSON object.
  58819. * @returns the JSON object
  58820. */
  58821. serialize(): any;
  58822. /**
  58823. * Parses a JSON object to create a GPU particle system.
  58824. * @param parsedParticleSystem The JSON object to parse
  58825. * @param scene The scene to create the particle system in
  58826. * @param rootUrl The root url to use to load external dependencies like texture
  58827. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58828. * @returns the parsed GPU particle system
  58829. */
  58830. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58831. }
  58832. }
  58833. declare module BABYLON {
  58834. /**
  58835. * Represents a set of particle systems working together to create a specific effect
  58836. */
  58837. export class ParticleSystemSet implements IDisposable {
  58838. /**
  58839. * Gets or sets base Assets URL
  58840. */
  58841. static BaseAssetsUrl: string;
  58842. private _emitterCreationOptions;
  58843. private _emitterNode;
  58844. /**
  58845. * Gets the particle system list
  58846. */
  58847. systems: IParticleSystem[];
  58848. /**
  58849. * Gets the emitter node used with this set
  58850. */
  58851. readonly emitterNode: Nullable<TransformNode>;
  58852. /**
  58853. * Creates a new emitter mesh as a sphere
  58854. * @param options defines the options used to create the sphere
  58855. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58856. * @param scene defines the hosting scene
  58857. */
  58858. setEmitterAsSphere(options: {
  58859. diameter: number;
  58860. segments: number;
  58861. color: Color3;
  58862. }, renderingGroupId: number, scene: Scene): void;
  58863. /**
  58864. * Starts all particle systems of the set
  58865. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58866. */
  58867. start(emitter?: AbstractMesh): void;
  58868. /**
  58869. * Release all associated resources
  58870. */
  58871. dispose(): void;
  58872. /**
  58873. * Serialize the set into a JSON compatible object
  58874. * @returns a JSON compatible representation of the set
  58875. */
  58876. serialize(): any;
  58877. /**
  58878. * Parse a new ParticleSystemSet from a serialized source
  58879. * @param data defines a JSON compatible representation of the set
  58880. * @param scene defines the hosting scene
  58881. * @param gpu defines if we want GPU particles or CPU particles
  58882. * @returns a new ParticleSystemSet
  58883. */
  58884. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58885. }
  58886. }
  58887. declare module BABYLON {
  58888. /**
  58889. * This class is made for on one-liner static method to help creating particle system set.
  58890. */
  58891. export class ParticleHelper {
  58892. /**
  58893. * Gets or sets base Assets URL
  58894. */
  58895. static BaseAssetsUrl: string;
  58896. /**
  58897. * Create a default particle system that you can tweak
  58898. * @param emitter defines the emitter to use
  58899. * @param capacity defines the system capacity (default is 500 particles)
  58900. * @param scene defines the hosting scene
  58901. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58902. * @returns the new Particle system
  58903. */
  58904. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58905. /**
  58906. * This is the main static method (one-liner) of this helper to create different particle systems
  58907. * @param type This string represents the type to the particle system to create
  58908. * @param scene The scene where the particle system should live
  58909. * @param gpu If the system will use gpu
  58910. * @returns the ParticleSystemSet created
  58911. */
  58912. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58913. /**
  58914. * Static function used to export a particle system to a ParticleSystemSet variable.
  58915. * Please note that the emitter shape is not exported
  58916. * @param systems defines the particle systems to export
  58917. * @returns the created particle system set
  58918. */
  58919. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58920. }
  58921. }
  58922. declare module BABYLON {
  58923. interface Engine {
  58924. /**
  58925. * Create an effect to use with particle systems.
  58926. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58927. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58928. * @param uniformsNames defines a list of attribute names
  58929. * @param samplers defines an array of string used to represent textures
  58930. * @param defines defines the string containing the defines to use to compile the shaders
  58931. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58932. * @param onCompiled defines a function to call when the effect creation is successful
  58933. * @param onError defines a function to call when the effect creation has failed
  58934. * @returns the new Effect
  58935. */
  58936. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58937. }
  58938. interface Mesh {
  58939. /**
  58940. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58941. * @returns an array of IParticleSystem
  58942. */
  58943. getEmittedParticleSystems(): IParticleSystem[];
  58944. /**
  58945. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58946. * @returns an array of IParticleSystem
  58947. */
  58948. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58949. }
  58950. /**
  58951. * @hidden
  58952. */
  58953. export var _IDoNeedToBeInTheBuild: number;
  58954. }
  58955. declare module BABYLON {
  58956. /** Defines the 4 color options */
  58957. export enum PointColor {
  58958. /** color value */
  58959. Color = 2,
  58960. /** uv value */
  58961. UV = 1,
  58962. /** random value */
  58963. Random = 0,
  58964. /** stated value */
  58965. Stated = 3
  58966. }
  58967. /**
  58968. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58969. * 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.
  58970. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58971. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58972. *
  58973. * Full documentation here : TO BE ENTERED
  58974. */
  58975. export class PointsCloudSystem implements IDisposable {
  58976. /**
  58977. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58978. * Example : var p = SPS.particles[i];
  58979. */
  58980. particles: CloudPoint[];
  58981. /**
  58982. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58983. */
  58984. nbParticles: number;
  58985. /**
  58986. * This a counter for your own usage. It's not set by any SPS functions.
  58987. */
  58988. counter: number;
  58989. /**
  58990. * The PCS name. This name is also given to the underlying mesh.
  58991. */
  58992. name: string;
  58993. /**
  58994. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58995. */
  58996. mesh: Mesh;
  58997. /**
  58998. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58999. * Please read :
  59000. */
  59001. vars: any;
  59002. /**
  59003. * @hidden
  59004. */
  59005. _size: number;
  59006. private _scene;
  59007. private _promises;
  59008. private _positions;
  59009. private _indices;
  59010. private _normals;
  59011. private _colors;
  59012. private _uvs;
  59013. private _indices32;
  59014. private _positions32;
  59015. private _colors32;
  59016. private _uvs32;
  59017. private _updatable;
  59018. private _isVisibilityBoxLocked;
  59019. private _alwaysVisible;
  59020. private _groups;
  59021. private _groupCounter;
  59022. private _computeParticleColor;
  59023. private _computeParticleTexture;
  59024. private _computeParticleRotation;
  59025. private _computeBoundingBox;
  59026. private _isReady;
  59027. /**
  59028. * Creates a PCS (Points Cloud System) object
  59029. * @param name (String) is the PCS name, this will be the underlying mesh name
  59030. * @param pointSize (number) is the size for each point
  59031. * @param scene (Scene) is the scene in which the PCS is added
  59032. * @param options defines the options of the PCS e.g.
  59033. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  59034. */
  59035. constructor(name: string, pointSize: number, scene: Scene, options?: {
  59036. updatable?: boolean;
  59037. });
  59038. /**
  59039. * Builds the PCS underlying mesh. Returns a standard Mesh.
  59040. * If no points were added to the PCS, the returned mesh is just a single point.
  59041. * @returns a promise for the created mesh
  59042. */
  59043. buildMeshAsync(): Promise<Mesh>;
  59044. /**
  59045. * @hidden
  59046. */
  59047. private _buildMesh;
  59048. private _addParticle;
  59049. private _randomUnitVector;
  59050. private _getColorIndicesForCoord;
  59051. private _setPointsColorOrUV;
  59052. private _colorFromTexture;
  59053. private _calculateDensity;
  59054. /**
  59055. * Adds points to the PCS in random positions within a unit sphere
  59056. * @param nb (positive integer) the number of particles to be created from this model
  59057. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  59058. * @returns the number of groups in the system
  59059. */
  59060. addPoints(nb: number, pointFunction?: any): number;
  59061. /**
  59062. * Adds points to the PCS from the surface of the model shape
  59063. * @param mesh is any Mesh object that will be used as a surface model for the points
  59064. * @param nb (positive integer) the number of particles to be created from this model
  59065. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59066. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59067. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59068. * @returns the number of groups in the system
  59069. */
  59070. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59071. /**
  59072. * Adds points to the PCS inside the model shape
  59073. * @param mesh is any Mesh object that will be used as a surface model for the points
  59074. * @param nb (positive integer) the number of particles to be created from this model
  59075. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  59076. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  59077. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  59078. * @returns the number of groups in the system
  59079. */
  59080. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  59081. /**
  59082. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  59083. * This method calls `updateParticle()` for each particle of the SPS.
  59084. * For an animated SPS, it is usually called within the render loop.
  59085. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  59086. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  59087. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  59088. * @returns the PCS.
  59089. */
  59090. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  59091. /**
  59092. * Disposes the PCS.
  59093. */
  59094. dispose(): void;
  59095. /**
  59096. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  59097. * doc :
  59098. * @returns the PCS.
  59099. */
  59100. refreshVisibleSize(): PointsCloudSystem;
  59101. /**
  59102. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  59103. * @param size the size (float) of the visibility box
  59104. * note : this doesn't lock the PCS mesh bounding box.
  59105. * doc :
  59106. */
  59107. setVisibilityBox(size: number): void;
  59108. /**
  59109. * Gets whether the PCS is always visible or not
  59110. * doc :
  59111. */
  59112. /**
  59113. * Sets the PCS as always visible or not
  59114. * doc :
  59115. */
  59116. isAlwaysVisible: boolean;
  59117. /**
  59118. * Tells to `setParticles()` to compute the particle rotations or not
  59119. * Default value : false. The PCS is faster when it's set to false
  59120. * Note : particle rotations are only applied to parent particles
  59121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  59122. */
  59123. computeParticleRotation: boolean;
  59124. /**
  59125. * Tells to `setParticles()` to compute the particle colors or not.
  59126. * Default value : true. The PCS is faster when it's set to false.
  59127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59128. */
  59129. /**
  59130. * Gets if `setParticles()` computes the particle colors or not.
  59131. * Default value : false. The PCS is faster when it's set to false.
  59132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  59133. */
  59134. computeParticleColor: boolean;
  59135. /**
  59136. * Gets if `setParticles()` computes the particle textures or not.
  59137. * Default value : false. The PCS is faster when it's set to false.
  59138. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  59139. */
  59140. computeParticleTexture: boolean;
  59141. /**
  59142. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  59143. */
  59144. /**
  59145. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  59146. */
  59147. computeBoundingBox: boolean;
  59148. /**
  59149. * This function does nothing. It may be overwritten to set all the particle first values.
  59150. * The PCS doesn't call this function, you may have to call it by your own.
  59151. * doc :
  59152. */
  59153. initParticles(): void;
  59154. /**
  59155. * This function does nothing. It may be overwritten to recycle a particle
  59156. * The PCS doesn't call this function, you can to call it
  59157. * doc :
  59158. * @param particle The particle to recycle
  59159. * @returns the recycled particle
  59160. */
  59161. recycleParticle(particle: CloudPoint): CloudPoint;
  59162. /**
  59163. * Updates a particle : this function should be overwritten by the user.
  59164. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  59165. * doc :
  59166. * @example : just set a particle position or velocity and recycle conditions
  59167. * @param particle The particle to update
  59168. * @returns the updated particle
  59169. */
  59170. updateParticle(particle: CloudPoint): CloudPoint;
  59171. /**
  59172. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  59173. * This does nothing and may be overwritten by the user.
  59174. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59175. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59176. * @param update the boolean update value actually passed to setParticles()
  59177. */
  59178. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59179. /**
  59180. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  59181. * This will be passed three parameters.
  59182. * This does nothing and may be overwritten by the user.
  59183. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  59184. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  59185. * @param update the boolean update value actually passed to setParticles()
  59186. */
  59187. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  59188. }
  59189. }
  59190. declare module BABYLON {
  59191. /**
  59192. * Represents one particle of a points cloud system.
  59193. */
  59194. export class CloudPoint {
  59195. /**
  59196. * particle global index
  59197. */
  59198. idx: number;
  59199. /**
  59200. * The color of the particle
  59201. */
  59202. color: Nullable<Color4>;
  59203. /**
  59204. * The world space position of the particle.
  59205. */
  59206. position: Vector3;
  59207. /**
  59208. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  59209. */
  59210. rotation: Vector3;
  59211. /**
  59212. * The world space rotation quaternion of the particle.
  59213. */
  59214. rotationQuaternion: Nullable<Quaternion>;
  59215. /**
  59216. * The uv of the particle.
  59217. */
  59218. uv: Nullable<Vector2>;
  59219. /**
  59220. * The current speed of the particle.
  59221. */
  59222. velocity: Vector3;
  59223. /**
  59224. * The pivot point in the particle local space.
  59225. */
  59226. pivot: Vector3;
  59227. /**
  59228. * Must the particle be translated from its pivot point in its local space ?
  59229. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  59230. * Default : false
  59231. */
  59232. translateFromPivot: boolean;
  59233. /**
  59234. * Index of this particle in the global "positions" array (Internal use)
  59235. * @hidden
  59236. */
  59237. _pos: number;
  59238. /**
  59239. * @hidden Index of this particle in the global "indices" array (Internal use)
  59240. */
  59241. _ind: number;
  59242. /**
  59243. * Group this particle belongs to
  59244. */
  59245. _group: PointsGroup;
  59246. /**
  59247. * Group id of this particle
  59248. */
  59249. groupId: number;
  59250. /**
  59251. * Index of the particle in its group id (Internal use)
  59252. */
  59253. idxInGroup: number;
  59254. /**
  59255. * @hidden Particle BoundingInfo object (Internal use)
  59256. */
  59257. _boundingInfo: BoundingInfo;
  59258. /**
  59259. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  59260. */
  59261. _pcs: PointsCloudSystem;
  59262. /**
  59263. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  59264. */
  59265. _stillInvisible: boolean;
  59266. /**
  59267. * @hidden Last computed particle rotation matrix
  59268. */
  59269. _rotationMatrix: number[];
  59270. /**
  59271. * Parent particle Id, if any.
  59272. * Default null.
  59273. */
  59274. parentId: Nullable<number>;
  59275. /**
  59276. * @hidden Internal global position in the PCS.
  59277. */
  59278. _globalPosition: Vector3;
  59279. /**
  59280. * Creates a Point Cloud object.
  59281. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  59282. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  59283. * @param group (PointsGroup) is the group the particle belongs to
  59284. * @param groupId (integer) is the group identifier in the PCS.
  59285. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  59286. * @param pcs defines the PCS it is associated to
  59287. */
  59288. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  59289. /**
  59290. * get point size
  59291. */
  59292. /**
  59293. * Set point size
  59294. */
  59295. size: Vector3;
  59296. /**
  59297. * Legacy support, changed quaternion to rotationQuaternion
  59298. */
  59299. /**
  59300. * Legacy support, changed quaternion to rotationQuaternion
  59301. */
  59302. quaternion: Nullable<Quaternion>;
  59303. /**
  59304. * Returns a boolean. True if the particle intersects a mesh, else false
  59305. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  59306. * @param target is the object (point or mesh) what the intersection is computed against
  59307. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  59308. * @returns true if it intersects
  59309. */
  59310. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  59311. /**
  59312. * get the rotation matrix of the particle
  59313. * @hidden
  59314. */
  59315. getRotationMatrix(m: Matrix): void;
  59316. }
  59317. /**
  59318. * Represents a group of points in a points cloud system
  59319. * * PCS internal tool, don't use it manually.
  59320. */
  59321. export class PointsGroup {
  59322. /**
  59323. * The group id
  59324. * @hidden
  59325. */
  59326. groupID: number;
  59327. /**
  59328. * image data for group (internal use)
  59329. * @hidden
  59330. */
  59331. _groupImageData: Nullable<ArrayBufferView>;
  59332. /**
  59333. * Image Width (internal use)
  59334. * @hidden
  59335. */
  59336. _groupImgWidth: number;
  59337. /**
  59338. * Image Height (internal use)
  59339. * @hidden
  59340. */
  59341. _groupImgHeight: number;
  59342. /**
  59343. * Custom position function (internal use)
  59344. * @hidden
  59345. */
  59346. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  59347. /**
  59348. * density per facet for surface points
  59349. * @hidden
  59350. */
  59351. _groupDensity: number[];
  59352. /**
  59353. * Only when points are colored by texture carries pointer to texture list array
  59354. * @hidden
  59355. */
  59356. _textureNb: number;
  59357. /**
  59358. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  59359. * PCS internal tool, don't use it manually.
  59360. * @hidden
  59361. */
  59362. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  59363. }
  59364. }
  59365. declare module BABYLON {
  59366. interface Scene {
  59367. /** @hidden (Backing field) */
  59368. _physicsEngine: Nullable<IPhysicsEngine>;
  59369. /**
  59370. * Gets the current physics engine
  59371. * @returns a IPhysicsEngine or null if none attached
  59372. */
  59373. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  59374. /**
  59375. * Enables physics to the current scene
  59376. * @param gravity defines the scene's gravity for the physics engine
  59377. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  59378. * @return a boolean indicating if the physics engine was initialized
  59379. */
  59380. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  59381. /**
  59382. * Disables and disposes the physics engine associated with the scene
  59383. */
  59384. disablePhysicsEngine(): void;
  59385. /**
  59386. * Gets a boolean indicating if there is an active physics engine
  59387. * @returns a boolean indicating if there is an active physics engine
  59388. */
  59389. isPhysicsEnabled(): boolean;
  59390. /**
  59391. * Deletes a physics compound impostor
  59392. * @param compound defines the compound to delete
  59393. */
  59394. deleteCompoundImpostor(compound: any): void;
  59395. /**
  59396. * An event triggered when physic simulation is about to be run
  59397. */
  59398. onBeforePhysicsObservable: Observable<Scene>;
  59399. /**
  59400. * An event triggered when physic simulation has been done
  59401. */
  59402. onAfterPhysicsObservable: Observable<Scene>;
  59403. }
  59404. interface AbstractMesh {
  59405. /** @hidden */
  59406. _physicsImpostor: Nullable<PhysicsImpostor>;
  59407. /**
  59408. * Gets or sets impostor used for physic simulation
  59409. * @see http://doc.babylonjs.com/features/physics_engine
  59410. */
  59411. physicsImpostor: Nullable<PhysicsImpostor>;
  59412. /**
  59413. * Gets the current physics impostor
  59414. * @see http://doc.babylonjs.com/features/physics_engine
  59415. * @returns a physics impostor or null
  59416. */
  59417. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  59418. /** Apply a physic impulse to the mesh
  59419. * @param force defines the force to apply
  59420. * @param contactPoint defines where to apply the force
  59421. * @returns the current mesh
  59422. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59423. */
  59424. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  59425. /**
  59426. * Creates a physic joint between two meshes
  59427. * @param otherMesh defines the other mesh to use
  59428. * @param pivot1 defines the pivot to use on this mesh
  59429. * @param pivot2 defines the pivot to use on the other mesh
  59430. * @param options defines additional options (can be plugin dependent)
  59431. * @returns the current mesh
  59432. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  59433. */
  59434. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  59435. /** @hidden */
  59436. _disposePhysicsObserver: Nullable<Observer<Node>>;
  59437. }
  59438. /**
  59439. * Defines the physics engine scene component responsible to manage a physics engine
  59440. */
  59441. export class PhysicsEngineSceneComponent implements ISceneComponent {
  59442. /**
  59443. * The component name helpful to identify the component in the list of scene components.
  59444. */
  59445. readonly name: string;
  59446. /**
  59447. * The scene the component belongs to.
  59448. */
  59449. scene: Scene;
  59450. /**
  59451. * Creates a new instance of the component for the given scene
  59452. * @param scene Defines the scene to register the component in
  59453. */
  59454. constructor(scene: Scene);
  59455. /**
  59456. * Registers the component in a given scene
  59457. */
  59458. register(): void;
  59459. /**
  59460. * Rebuilds the elements related to this component in case of
  59461. * context lost for instance.
  59462. */
  59463. rebuild(): void;
  59464. /**
  59465. * Disposes the component and the associated ressources
  59466. */
  59467. dispose(): void;
  59468. }
  59469. }
  59470. declare module BABYLON {
  59471. /**
  59472. * A helper for physics simulations
  59473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59474. */
  59475. export class PhysicsHelper {
  59476. private _scene;
  59477. private _physicsEngine;
  59478. /**
  59479. * Initializes the Physics helper
  59480. * @param scene Babylon.js scene
  59481. */
  59482. constructor(scene: Scene);
  59483. /**
  59484. * Applies a radial explosion impulse
  59485. * @param origin the origin of the explosion
  59486. * @param radiusOrEventOptions the radius or the options of radial explosion
  59487. * @param strength the explosion strength
  59488. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59489. * @returns A physics radial explosion event, or null
  59490. */
  59491. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59492. /**
  59493. * Applies a radial explosion force
  59494. * @param origin the origin of the explosion
  59495. * @param radiusOrEventOptions the radius or the options of radial explosion
  59496. * @param strength the explosion strength
  59497. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59498. * @returns A physics radial explosion event, or null
  59499. */
  59500. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  59501. /**
  59502. * Creates a gravitational field
  59503. * @param origin the origin of the explosion
  59504. * @param radiusOrEventOptions the radius or the options of radial explosion
  59505. * @param strength the explosion strength
  59506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59507. * @returns A physics gravitational field event, or null
  59508. */
  59509. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59510. /**
  59511. * Creates a physics updraft event
  59512. * @param origin the origin of the updraft
  59513. * @param radiusOrEventOptions the radius or the options of the updraft
  59514. * @param strength the strength of the updraft
  59515. * @param height the height of the updraft
  59516. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59517. * @returns A physics updraft event, or null
  59518. */
  59519. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59520. /**
  59521. * Creates a physics vortex event
  59522. * @param origin the of the vortex
  59523. * @param radiusOrEventOptions the radius or the options of the vortex
  59524. * @param strength the strength of the vortex
  59525. * @param height the height of the vortex
  59526. * @returns a Physics vortex event, or null
  59527. * A physics vortex event or null
  59528. */
  59529. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59530. }
  59531. /**
  59532. * Represents a physics radial explosion event
  59533. */
  59534. class PhysicsRadialExplosionEvent {
  59535. private _scene;
  59536. private _options;
  59537. private _sphere;
  59538. private _dataFetched;
  59539. /**
  59540. * Initializes a radial explosioin event
  59541. * @param _scene BabylonJS scene
  59542. * @param _options The options for the vortex event
  59543. */
  59544. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59545. /**
  59546. * Returns the data related to the radial explosion event (sphere).
  59547. * @returns The radial explosion event data
  59548. */
  59549. getData(): PhysicsRadialExplosionEventData;
  59550. /**
  59551. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59552. * @param impostor A physics imposter
  59553. * @param origin the origin of the explosion
  59554. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59555. */
  59556. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59557. /**
  59558. * Triggers affecterd impostors callbacks
  59559. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59560. */
  59561. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59562. /**
  59563. * Disposes the sphere.
  59564. * @param force Specifies if the sphere should be disposed by force
  59565. */
  59566. dispose(force?: boolean): void;
  59567. /*** Helpers ***/
  59568. private _prepareSphere;
  59569. private _intersectsWithSphere;
  59570. }
  59571. /**
  59572. * Represents a gravitational field event
  59573. */
  59574. class PhysicsGravitationalFieldEvent {
  59575. private _physicsHelper;
  59576. private _scene;
  59577. private _origin;
  59578. private _options;
  59579. private _tickCallback;
  59580. private _sphere;
  59581. private _dataFetched;
  59582. /**
  59583. * Initializes the physics gravitational field event
  59584. * @param _physicsHelper A physics helper
  59585. * @param _scene BabylonJS scene
  59586. * @param _origin The origin position of the gravitational field event
  59587. * @param _options The options for the vortex event
  59588. */
  59589. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59590. /**
  59591. * Returns the data related to the gravitational field event (sphere).
  59592. * @returns A gravitational field event
  59593. */
  59594. getData(): PhysicsGravitationalFieldEventData;
  59595. /**
  59596. * Enables the gravitational field.
  59597. */
  59598. enable(): void;
  59599. /**
  59600. * Disables the gravitational field.
  59601. */
  59602. disable(): void;
  59603. /**
  59604. * Disposes the sphere.
  59605. * @param force The force to dispose from the gravitational field event
  59606. */
  59607. dispose(force?: boolean): void;
  59608. private _tick;
  59609. }
  59610. /**
  59611. * Represents a physics updraft event
  59612. */
  59613. class PhysicsUpdraftEvent {
  59614. private _scene;
  59615. private _origin;
  59616. private _options;
  59617. private _physicsEngine;
  59618. private _originTop;
  59619. private _originDirection;
  59620. private _tickCallback;
  59621. private _cylinder;
  59622. private _cylinderPosition;
  59623. private _dataFetched;
  59624. /**
  59625. * Initializes the physics updraft event
  59626. * @param _scene BabylonJS scene
  59627. * @param _origin The origin position of the updraft
  59628. * @param _options The options for the updraft event
  59629. */
  59630. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59631. /**
  59632. * Returns the data related to the updraft event (cylinder).
  59633. * @returns A physics updraft event
  59634. */
  59635. getData(): PhysicsUpdraftEventData;
  59636. /**
  59637. * Enables the updraft.
  59638. */
  59639. enable(): void;
  59640. /**
  59641. * Disables the updraft.
  59642. */
  59643. disable(): void;
  59644. /**
  59645. * Disposes the cylinder.
  59646. * @param force Specifies if the updraft should be disposed by force
  59647. */
  59648. dispose(force?: boolean): void;
  59649. private getImpostorHitData;
  59650. private _tick;
  59651. /*** Helpers ***/
  59652. private _prepareCylinder;
  59653. private _intersectsWithCylinder;
  59654. }
  59655. /**
  59656. * Represents a physics vortex event
  59657. */
  59658. class PhysicsVortexEvent {
  59659. private _scene;
  59660. private _origin;
  59661. private _options;
  59662. private _physicsEngine;
  59663. private _originTop;
  59664. private _tickCallback;
  59665. private _cylinder;
  59666. private _cylinderPosition;
  59667. private _dataFetched;
  59668. /**
  59669. * Initializes the physics vortex event
  59670. * @param _scene The BabylonJS scene
  59671. * @param _origin The origin position of the vortex
  59672. * @param _options The options for the vortex event
  59673. */
  59674. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59675. /**
  59676. * Returns the data related to the vortex event (cylinder).
  59677. * @returns The physics vortex event data
  59678. */
  59679. getData(): PhysicsVortexEventData;
  59680. /**
  59681. * Enables the vortex.
  59682. */
  59683. enable(): void;
  59684. /**
  59685. * Disables the cortex.
  59686. */
  59687. disable(): void;
  59688. /**
  59689. * Disposes the sphere.
  59690. * @param force
  59691. */
  59692. dispose(force?: boolean): void;
  59693. private getImpostorHitData;
  59694. private _tick;
  59695. /*** Helpers ***/
  59696. private _prepareCylinder;
  59697. private _intersectsWithCylinder;
  59698. }
  59699. /**
  59700. * Options fot the radial explosion event
  59701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59702. */
  59703. export class PhysicsRadialExplosionEventOptions {
  59704. /**
  59705. * The radius of the sphere for the radial explosion.
  59706. */
  59707. radius: number;
  59708. /**
  59709. * The strenth of the explosion.
  59710. */
  59711. strength: number;
  59712. /**
  59713. * The strenght of the force in correspondence to the distance of the affected object
  59714. */
  59715. falloff: PhysicsRadialImpulseFalloff;
  59716. /**
  59717. * Sphere options for the radial explosion.
  59718. */
  59719. sphere: {
  59720. segments: number;
  59721. diameter: number;
  59722. };
  59723. /**
  59724. * Sphere options for the radial explosion.
  59725. */
  59726. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59727. }
  59728. /**
  59729. * Options fot the updraft event
  59730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59731. */
  59732. export class PhysicsUpdraftEventOptions {
  59733. /**
  59734. * The radius of the cylinder for the vortex
  59735. */
  59736. radius: number;
  59737. /**
  59738. * The strenth of the updraft.
  59739. */
  59740. strength: number;
  59741. /**
  59742. * The height of the cylinder for the updraft.
  59743. */
  59744. height: number;
  59745. /**
  59746. * The mode for the the updraft.
  59747. */
  59748. updraftMode: PhysicsUpdraftMode;
  59749. }
  59750. /**
  59751. * Options fot the vortex event
  59752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59753. */
  59754. export class PhysicsVortexEventOptions {
  59755. /**
  59756. * The radius of the cylinder for the vortex
  59757. */
  59758. radius: number;
  59759. /**
  59760. * The strenth of the vortex.
  59761. */
  59762. strength: number;
  59763. /**
  59764. * The height of the cylinder for the vortex.
  59765. */
  59766. height: number;
  59767. /**
  59768. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59769. */
  59770. centripetalForceThreshold: number;
  59771. /**
  59772. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59773. */
  59774. centripetalForceMultiplier: number;
  59775. /**
  59776. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59777. */
  59778. centrifugalForceMultiplier: number;
  59779. /**
  59780. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59781. */
  59782. updraftForceMultiplier: number;
  59783. }
  59784. /**
  59785. * The strenght of the force in correspondence to the distance of the affected object
  59786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59787. */
  59788. export enum PhysicsRadialImpulseFalloff {
  59789. /** Defines that impulse is constant in strength across it's whole radius */
  59790. Constant = 0,
  59791. /** Defines that impulse gets weaker if it's further from the origin */
  59792. Linear = 1
  59793. }
  59794. /**
  59795. * The strength of the force in correspondence to the distance of the affected object
  59796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59797. */
  59798. export enum PhysicsUpdraftMode {
  59799. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59800. Center = 0,
  59801. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59802. Perpendicular = 1
  59803. }
  59804. /**
  59805. * Interface for a physics hit data
  59806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59807. */
  59808. export interface PhysicsHitData {
  59809. /**
  59810. * The force applied at the contact point
  59811. */
  59812. force: Vector3;
  59813. /**
  59814. * The contact point
  59815. */
  59816. contactPoint: Vector3;
  59817. /**
  59818. * The distance from the origin to the contact point
  59819. */
  59820. distanceFromOrigin: number;
  59821. }
  59822. /**
  59823. * Interface for radial explosion event data
  59824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59825. */
  59826. export interface PhysicsRadialExplosionEventData {
  59827. /**
  59828. * A sphere used for the radial explosion event
  59829. */
  59830. sphere: Mesh;
  59831. }
  59832. /**
  59833. * Interface for gravitational field event data
  59834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59835. */
  59836. export interface PhysicsGravitationalFieldEventData {
  59837. /**
  59838. * A sphere mesh used for the gravitational field event
  59839. */
  59840. sphere: Mesh;
  59841. }
  59842. /**
  59843. * Interface for updraft event data
  59844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59845. */
  59846. export interface PhysicsUpdraftEventData {
  59847. /**
  59848. * A cylinder used for the updraft event
  59849. */
  59850. cylinder: Mesh;
  59851. }
  59852. /**
  59853. * Interface for vortex event data
  59854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59855. */
  59856. export interface PhysicsVortexEventData {
  59857. /**
  59858. * A cylinder used for the vortex event
  59859. */
  59860. cylinder: Mesh;
  59861. }
  59862. /**
  59863. * Interface for an affected physics impostor
  59864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59865. */
  59866. export interface PhysicsAffectedImpostorWithData {
  59867. /**
  59868. * The impostor affected by the effect
  59869. */
  59870. impostor: PhysicsImpostor;
  59871. /**
  59872. * The data about the hit/horce from the explosion
  59873. */
  59874. hitData: PhysicsHitData;
  59875. }
  59876. }
  59877. declare module BABYLON {
  59878. /** @hidden */
  59879. export var blackAndWhitePixelShader: {
  59880. name: string;
  59881. shader: string;
  59882. };
  59883. }
  59884. declare module BABYLON {
  59885. /**
  59886. * Post process used to render in black and white
  59887. */
  59888. export class BlackAndWhitePostProcess extends PostProcess {
  59889. /**
  59890. * Linear about to convert he result to black and white (default: 1)
  59891. */
  59892. degree: number;
  59893. /**
  59894. * Creates a black and white post process
  59895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59896. * @param name The name of the effect.
  59897. * @param options The required width/height ratio to downsize to before computing the render pass.
  59898. * @param camera The camera to apply the render pass to.
  59899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59900. * @param engine The engine which the post process will be applied. (default: current engine)
  59901. * @param reusable If the post process can be reused on the same frame. (default: false)
  59902. */
  59903. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59904. }
  59905. }
  59906. declare module BABYLON {
  59907. /**
  59908. * This represents a set of one or more post processes in Babylon.
  59909. * A post process can be used to apply a shader to a texture after it is rendered.
  59910. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59911. */
  59912. export class PostProcessRenderEffect {
  59913. private _postProcesses;
  59914. private _getPostProcesses;
  59915. private _singleInstance;
  59916. private _cameras;
  59917. private _indicesForCamera;
  59918. /**
  59919. * Name of the effect
  59920. * @hidden
  59921. */
  59922. _name: string;
  59923. /**
  59924. * Instantiates a post process render effect.
  59925. * A post process can be used to apply a shader to a texture after it is rendered.
  59926. * @param engine The engine the effect is tied to
  59927. * @param name The name of the effect
  59928. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59929. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59930. */
  59931. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59932. /**
  59933. * Checks if all the post processes in the effect are supported.
  59934. */
  59935. readonly isSupported: boolean;
  59936. /**
  59937. * Updates the current state of the effect
  59938. * @hidden
  59939. */
  59940. _update(): void;
  59941. /**
  59942. * Attaches the effect on cameras
  59943. * @param cameras The camera to attach to.
  59944. * @hidden
  59945. */
  59946. _attachCameras(cameras: Camera): void;
  59947. /**
  59948. * Attaches the effect on cameras
  59949. * @param cameras The camera to attach to.
  59950. * @hidden
  59951. */
  59952. _attachCameras(cameras: Camera[]): void;
  59953. /**
  59954. * Detaches the effect on cameras
  59955. * @param cameras The camera to detatch from.
  59956. * @hidden
  59957. */
  59958. _detachCameras(cameras: Camera): void;
  59959. /**
  59960. * Detatches the effect on cameras
  59961. * @param cameras The camera to detatch from.
  59962. * @hidden
  59963. */
  59964. _detachCameras(cameras: Camera[]): void;
  59965. /**
  59966. * Enables the effect on given cameras
  59967. * @param cameras The camera to enable.
  59968. * @hidden
  59969. */
  59970. _enable(cameras: Camera): void;
  59971. /**
  59972. * Enables the effect on given cameras
  59973. * @param cameras The camera to enable.
  59974. * @hidden
  59975. */
  59976. _enable(cameras: Nullable<Camera[]>): void;
  59977. /**
  59978. * Disables the effect on the given cameras
  59979. * @param cameras The camera to disable.
  59980. * @hidden
  59981. */
  59982. _disable(cameras: Camera): void;
  59983. /**
  59984. * Disables the effect on the given cameras
  59985. * @param cameras The camera to disable.
  59986. * @hidden
  59987. */
  59988. _disable(cameras: Nullable<Camera[]>): void;
  59989. /**
  59990. * Gets a list of the post processes contained in the effect.
  59991. * @param camera The camera to get the post processes on.
  59992. * @returns The list of the post processes in the effect.
  59993. */
  59994. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. /** @hidden */
  59999. export var extractHighlightsPixelShader: {
  60000. name: string;
  60001. shader: string;
  60002. };
  60003. }
  60004. declare module BABYLON {
  60005. /**
  60006. * 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.
  60007. */
  60008. export class ExtractHighlightsPostProcess extends PostProcess {
  60009. /**
  60010. * The luminance threshold, pixels below this value will be set to black.
  60011. */
  60012. threshold: number;
  60013. /** @hidden */
  60014. _exposure: number;
  60015. /**
  60016. * Post process which has the input texture to be used when performing highlight extraction
  60017. * @hidden
  60018. */
  60019. _inputPostProcess: Nullable<PostProcess>;
  60020. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60021. }
  60022. }
  60023. declare module BABYLON {
  60024. /** @hidden */
  60025. export var bloomMergePixelShader: {
  60026. name: string;
  60027. shader: string;
  60028. };
  60029. }
  60030. declare module BABYLON {
  60031. /**
  60032. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60033. */
  60034. export class BloomMergePostProcess extends PostProcess {
  60035. /** Weight of the bloom to be added to the original input. */
  60036. weight: number;
  60037. /**
  60038. * Creates a new instance of @see BloomMergePostProcess
  60039. * @param name The name of the effect.
  60040. * @param originalFromInput Post process which's input will be used for the merge.
  60041. * @param blurred Blurred highlights post process which's output will be used.
  60042. * @param weight Weight of the bloom to be added to the original input.
  60043. * @param options The required width/height ratio to downsize to before computing the render pass.
  60044. * @param camera The camera to apply the render pass to.
  60045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60046. * @param engine The engine which the post process will be applied. (default: current engine)
  60047. * @param reusable If the post process can be reused on the same frame. (default: false)
  60048. * @param textureType Type of textures used when performing the post process. (default: 0)
  60049. * @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)
  60050. */
  60051. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60052. /** Weight of the bloom to be added to the original input. */
  60053. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60059. */
  60060. export class BloomEffect extends PostProcessRenderEffect {
  60061. private bloomScale;
  60062. /**
  60063. * @hidden Internal
  60064. */
  60065. _effects: Array<PostProcess>;
  60066. /**
  60067. * @hidden Internal
  60068. */
  60069. _downscale: ExtractHighlightsPostProcess;
  60070. private _blurX;
  60071. private _blurY;
  60072. private _merge;
  60073. /**
  60074. * The luminance threshold to find bright areas of the image to bloom.
  60075. */
  60076. threshold: number;
  60077. /**
  60078. * The strength of the bloom.
  60079. */
  60080. weight: number;
  60081. /**
  60082. * Specifies the size of the bloom blur kernel, relative to the final output size
  60083. */
  60084. kernel: number;
  60085. /**
  60086. * Creates a new instance of @see BloomEffect
  60087. * @param scene The scene the effect belongs to.
  60088. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60089. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60090. * @param bloomWeight The the strength of bloom.
  60091. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60092. * @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)
  60093. */
  60094. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60095. /**
  60096. * Disposes each of the internal effects for a given camera.
  60097. * @param camera The camera to dispose the effect on.
  60098. */
  60099. disposeEffects(camera: Camera): void;
  60100. /**
  60101. * @hidden Internal
  60102. */
  60103. _updateEffects(): void;
  60104. /**
  60105. * Internal
  60106. * @returns if all the contained post processes are ready.
  60107. * @hidden
  60108. */
  60109. _isReady(): boolean;
  60110. }
  60111. }
  60112. declare module BABYLON {
  60113. /** @hidden */
  60114. export var chromaticAberrationPixelShader: {
  60115. name: string;
  60116. shader: string;
  60117. };
  60118. }
  60119. declare module BABYLON {
  60120. /**
  60121. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60122. */
  60123. export class ChromaticAberrationPostProcess extends PostProcess {
  60124. /**
  60125. * The amount of seperation of rgb channels (default: 30)
  60126. */
  60127. aberrationAmount: number;
  60128. /**
  60129. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60130. */
  60131. radialIntensity: number;
  60132. /**
  60133. * 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))
  60134. */
  60135. direction: Vector2;
  60136. /**
  60137. * 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))
  60138. */
  60139. centerPosition: Vector2;
  60140. /**
  60141. * Creates a new instance ChromaticAberrationPostProcess
  60142. * @param name The name of the effect.
  60143. * @param screenWidth The width of the screen to apply the effect on.
  60144. * @param screenHeight The height of the screen to apply the effect on.
  60145. * @param options The required width/height ratio to downsize to before computing the render pass.
  60146. * @param camera The camera to apply the render pass to.
  60147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60148. * @param engine The engine which the post process will be applied. (default: current engine)
  60149. * @param reusable If the post process can be reused on the same frame. (default: false)
  60150. * @param textureType Type of textures used when performing the post process. (default: 0)
  60151. * @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)
  60152. */
  60153. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /** @hidden */
  60158. export var circleOfConfusionPixelShader: {
  60159. name: string;
  60160. shader: string;
  60161. };
  60162. }
  60163. declare module BABYLON {
  60164. /**
  60165. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60166. */
  60167. export class CircleOfConfusionPostProcess extends PostProcess {
  60168. /**
  60169. * 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.
  60170. */
  60171. lensSize: number;
  60172. /**
  60173. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60174. */
  60175. fStop: number;
  60176. /**
  60177. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60178. */
  60179. focusDistance: number;
  60180. /**
  60181. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60182. */
  60183. focalLength: number;
  60184. private _depthTexture;
  60185. /**
  60186. * Creates a new instance CircleOfConfusionPostProcess
  60187. * @param name The name of the effect.
  60188. * @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.
  60189. * @param options The required width/height ratio to downsize to before computing the render pass.
  60190. * @param camera The camera to apply the render pass to.
  60191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60192. * @param engine The engine which the post process will be applied. (default: current engine)
  60193. * @param reusable If the post process can be reused on the same frame. (default: false)
  60194. * @param textureType Type of textures used when performing the post process. (default: 0)
  60195. * @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)
  60196. */
  60197. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60198. /**
  60199. * 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.
  60200. */
  60201. depthTexture: RenderTargetTexture;
  60202. }
  60203. }
  60204. declare module BABYLON {
  60205. /** @hidden */
  60206. export var colorCorrectionPixelShader: {
  60207. name: string;
  60208. shader: string;
  60209. };
  60210. }
  60211. declare module BABYLON {
  60212. /**
  60213. *
  60214. * This post-process allows the modification of rendered colors by using
  60215. * a 'look-up table' (LUT). This effect is also called Color Grading.
  60216. *
  60217. * The object needs to be provided an url to a texture containing the color
  60218. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  60219. * Use an image editing software to tweak the LUT to match your needs.
  60220. *
  60221. * For an example of a color LUT, see here:
  60222. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  60223. * For explanations on color grading, see here:
  60224. * @see http://udn.epicgames.com/Three/ColorGrading.html
  60225. *
  60226. */
  60227. export class ColorCorrectionPostProcess extends PostProcess {
  60228. private _colorTableTexture;
  60229. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60230. }
  60231. }
  60232. declare module BABYLON {
  60233. /** @hidden */
  60234. export var convolutionPixelShader: {
  60235. name: string;
  60236. shader: string;
  60237. };
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  60242. * input texture to perform effects such as edge detection or sharpening
  60243. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60244. */
  60245. export class ConvolutionPostProcess extends PostProcess {
  60246. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60247. kernel: number[];
  60248. /**
  60249. * Creates a new instance ConvolutionPostProcess
  60250. * @param name The name of the effect.
  60251. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  60252. * @param options The required width/height ratio to downsize to before computing the render pass.
  60253. * @param camera The camera to apply the render pass to.
  60254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60255. * @param engine The engine which the post process will be applied. (default: current engine)
  60256. * @param reusable If the post process can be reused on the same frame. (default: false)
  60257. * @param textureType Type of textures used when performing the post process. (default: 0)
  60258. */
  60259. constructor(name: string,
  60260. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  60261. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60262. /**
  60263. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60264. */
  60265. static EdgeDetect0Kernel: number[];
  60266. /**
  60267. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60268. */
  60269. static EdgeDetect1Kernel: number[];
  60270. /**
  60271. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60272. */
  60273. static EdgeDetect2Kernel: number[];
  60274. /**
  60275. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60276. */
  60277. static SharpenKernel: number[];
  60278. /**
  60279. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60280. */
  60281. static EmbossKernel: number[];
  60282. /**
  60283. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  60284. */
  60285. static GaussianKernel: number[];
  60286. }
  60287. }
  60288. declare module BABYLON {
  60289. /**
  60290. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  60291. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  60292. * based on samples that have a large difference in distance than the center pixel.
  60293. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  60294. */
  60295. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  60296. direction: Vector2;
  60297. /**
  60298. * Creates a new instance CircleOfConfusionPostProcess
  60299. * @param name The name of the effect.
  60300. * @param scene The scene the effect belongs to.
  60301. * @param direction The direction the blur should be applied.
  60302. * @param kernel The size of the kernel used to blur.
  60303. * @param options The required width/height ratio to downsize to before computing the render pass.
  60304. * @param camera The camera to apply the render pass to.
  60305. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  60306. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  60307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60308. * @param engine The engine which the post process will be applied. (default: current engine)
  60309. * @param reusable If the post process can be reused on the same frame. (default: false)
  60310. * @param textureType Type of textures used when performing the post process. (default: 0)
  60311. * @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)
  60312. */
  60313. 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);
  60314. }
  60315. }
  60316. declare module BABYLON {
  60317. /** @hidden */
  60318. export var depthOfFieldMergePixelShader: {
  60319. name: string;
  60320. shader: string;
  60321. };
  60322. }
  60323. declare module BABYLON {
  60324. /**
  60325. * Options to be set when merging outputs from the default pipeline.
  60326. */
  60327. export class DepthOfFieldMergePostProcessOptions {
  60328. /**
  60329. * The original image to merge on top of
  60330. */
  60331. originalFromInput: PostProcess;
  60332. /**
  60333. * Parameters to perform the merge of the depth of field effect
  60334. */
  60335. depthOfField?: {
  60336. circleOfConfusion: PostProcess;
  60337. blurSteps: Array<PostProcess>;
  60338. };
  60339. /**
  60340. * Parameters to perform the merge of bloom effect
  60341. */
  60342. bloom?: {
  60343. blurred: PostProcess;
  60344. weight: number;
  60345. };
  60346. }
  60347. /**
  60348. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60349. */
  60350. export class DepthOfFieldMergePostProcess extends PostProcess {
  60351. private blurSteps;
  60352. /**
  60353. * Creates a new instance of DepthOfFieldMergePostProcess
  60354. * @param name The name of the effect.
  60355. * @param originalFromInput Post process which's input will be used for the merge.
  60356. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  60357. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  60358. * @param options The required width/height ratio to downsize to before computing the render pass.
  60359. * @param camera The camera to apply the render pass to.
  60360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60361. * @param engine The engine which the post process will be applied. (default: current engine)
  60362. * @param reusable If the post process can be reused on the same frame. (default: false)
  60363. * @param textureType Type of textures used when performing the post process. (default: 0)
  60364. * @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)
  60365. */
  60366. 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);
  60367. /**
  60368. * Updates the effect with the current post process compile time values and recompiles the shader.
  60369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  60370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  60371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  60372. * @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
  60373. * @param onCompiled Called when the shader has been compiled.
  60374. * @param onError Called if there is an error when compiling a shader.
  60375. */
  60376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  60377. }
  60378. }
  60379. declare module BABYLON {
  60380. /**
  60381. * Specifies the level of max blur that should be applied when using the depth of field effect
  60382. */
  60383. export enum DepthOfFieldEffectBlurLevel {
  60384. /**
  60385. * Subtle blur
  60386. */
  60387. Low = 0,
  60388. /**
  60389. * Medium blur
  60390. */
  60391. Medium = 1,
  60392. /**
  60393. * Large blur
  60394. */
  60395. High = 2
  60396. }
  60397. /**
  60398. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  60399. */
  60400. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  60401. private _circleOfConfusion;
  60402. /**
  60403. * @hidden Internal, blurs from high to low
  60404. */
  60405. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  60406. private _depthOfFieldBlurY;
  60407. private _dofMerge;
  60408. /**
  60409. * @hidden Internal post processes in depth of field effect
  60410. */
  60411. _effects: Array<PostProcess>;
  60412. /**
  60413. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  60414. */
  60415. focalLength: number;
  60416. /**
  60417. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60418. */
  60419. fStop: number;
  60420. /**
  60421. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60422. */
  60423. focusDistance: number;
  60424. /**
  60425. * 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.
  60426. */
  60427. lensSize: number;
  60428. /**
  60429. * Creates a new instance DepthOfFieldEffect
  60430. * @param scene The scene the effect belongs to.
  60431. * @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.
  60432. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60433. * @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)
  60434. */
  60435. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  60436. /**
  60437. * Get the current class name of the current effet
  60438. * @returns "DepthOfFieldEffect"
  60439. */
  60440. getClassName(): string;
  60441. /**
  60442. * 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.
  60443. */
  60444. depthTexture: RenderTargetTexture;
  60445. /**
  60446. * Disposes each of the internal effects for a given camera.
  60447. * @param camera The camera to dispose the effect on.
  60448. */
  60449. disposeEffects(camera: Camera): void;
  60450. /**
  60451. * @hidden Internal
  60452. */
  60453. _updateEffects(): void;
  60454. /**
  60455. * Internal
  60456. * @returns if all the contained post processes are ready.
  60457. * @hidden
  60458. */
  60459. _isReady(): boolean;
  60460. }
  60461. }
  60462. declare module BABYLON {
  60463. /** @hidden */
  60464. export var displayPassPixelShader: {
  60465. name: string;
  60466. shader: string;
  60467. };
  60468. }
  60469. declare module BABYLON {
  60470. /**
  60471. * DisplayPassPostProcess which produces an output the same as it's input
  60472. */
  60473. export class DisplayPassPostProcess extends PostProcess {
  60474. /**
  60475. * Creates the DisplayPassPostProcess
  60476. * @param name The name of the effect.
  60477. * @param options The required width/height ratio to downsize to before computing the render pass.
  60478. * @param camera The camera to apply the render pass to.
  60479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60480. * @param engine The engine which the post process will be applied. (default: current engine)
  60481. * @param reusable If the post process can be reused on the same frame. (default: false)
  60482. */
  60483. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60484. }
  60485. }
  60486. declare module BABYLON {
  60487. /** @hidden */
  60488. export var filterPixelShader: {
  60489. name: string;
  60490. shader: string;
  60491. };
  60492. }
  60493. declare module BABYLON {
  60494. /**
  60495. * Applies a kernel filter to the image
  60496. */
  60497. export class FilterPostProcess extends PostProcess {
  60498. /** The matrix to be applied to the image */
  60499. kernelMatrix: Matrix;
  60500. /**
  60501. *
  60502. * @param name The name of the effect.
  60503. * @param kernelMatrix The matrix to be applied to the image
  60504. * @param options The required width/height ratio to downsize to before computing the render pass.
  60505. * @param camera The camera to apply the render pass to.
  60506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60507. * @param engine The engine which the post process will be applied. (default: current engine)
  60508. * @param reusable If the post process can be reused on the same frame. (default: false)
  60509. */
  60510. constructor(name: string,
  60511. /** The matrix to be applied to the image */
  60512. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60513. }
  60514. }
  60515. declare module BABYLON {
  60516. /** @hidden */
  60517. export var fxaaPixelShader: {
  60518. name: string;
  60519. shader: string;
  60520. };
  60521. }
  60522. declare module BABYLON {
  60523. /** @hidden */
  60524. export var fxaaVertexShader: {
  60525. name: string;
  60526. shader: string;
  60527. };
  60528. }
  60529. declare module BABYLON {
  60530. /**
  60531. * Fxaa post process
  60532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60533. */
  60534. export class FxaaPostProcess extends PostProcess {
  60535. /** @hidden */
  60536. texelWidth: number;
  60537. /** @hidden */
  60538. texelHeight: number;
  60539. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60540. private _getDefines;
  60541. }
  60542. }
  60543. declare module BABYLON {
  60544. /** @hidden */
  60545. export var grainPixelShader: {
  60546. name: string;
  60547. shader: string;
  60548. };
  60549. }
  60550. declare module BABYLON {
  60551. /**
  60552. * The GrainPostProcess adds noise to the image at mid luminance levels
  60553. */
  60554. export class GrainPostProcess extends PostProcess {
  60555. /**
  60556. * The intensity of the grain added (default: 30)
  60557. */
  60558. intensity: number;
  60559. /**
  60560. * If the grain should be randomized on every frame
  60561. */
  60562. animated: boolean;
  60563. /**
  60564. * Creates a new instance of @see GrainPostProcess
  60565. * @param name The name of the effect.
  60566. * @param options The required width/height ratio to downsize to before computing the render pass.
  60567. * @param camera The camera to apply the render pass to.
  60568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60569. * @param engine The engine which the post process will be applied. (default: current engine)
  60570. * @param reusable If the post process can be reused on the same frame. (default: false)
  60571. * @param textureType Type of textures used when performing the post process. (default: 0)
  60572. * @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)
  60573. */
  60574. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60575. }
  60576. }
  60577. declare module BABYLON {
  60578. /** @hidden */
  60579. export var highlightsPixelShader: {
  60580. name: string;
  60581. shader: string;
  60582. };
  60583. }
  60584. declare module BABYLON {
  60585. /**
  60586. * Extracts highlights from the image
  60587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60588. */
  60589. export class HighlightsPostProcess extends PostProcess {
  60590. /**
  60591. * Extracts highlights from the image
  60592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60593. * @param name The name of the effect.
  60594. * @param options The required width/height ratio to downsize to before computing the render pass.
  60595. * @param camera The camera to apply the render pass to.
  60596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60597. * @param engine The engine which the post process will be applied. (default: current engine)
  60598. * @param reusable If the post process can be reused on the same frame. (default: false)
  60599. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60600. */
  60601. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60602. }
  60603. }
  60604. declare module BABYLON {
  60605. /** @hidden */
  60606. export var mrtFragmentDeclaration: {
  60607. name: string;
  60608. shader: string;
  60609. };
  60610. }
  60611. declare module BABYLON {
  60612. /** @hidden */
  60613. export var geometryPixelShader: {
  60614. name: string;
  60615. shader: string;
  60616. };
  60617. }
  60618. declare module BABYLON {
  60619. /** @hidden */
  60620. export var geometryVertexShader: {
  60621. name: string;
  60622. shader: string;
  60623. };
  60624. }
  60625. declare module BABYLON {
  60626. /** @hidden */
  60627. interface ISavedTransformationMatrix {
  60628. world: Matrix;
  60629. viewProjection: Matrix;
  60630. }
  60631. /**
  60632. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60633. */
  60634. export class GeometryBufferRenderer {
  60635. /**
  60636. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60637. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60638. */
  60639. static readonly POSITION_TEXTURE_TYPE: number;
  60640. /**
  60641. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60642. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60643. */
  60644. static readonly VELOCITY_TEXTURE_TYPE: number;
  60645. /**
  60646. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60647. * in order to compute objects velocities when enableVelocity is set to "true"
  60648. * @hidden
  60649. */
  60650. _previousTransformationMatrices: {
  60651. [index: number]: ISavedTransformationMatrix;
  60652. };
  60653. /**
  60654. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60655. * in order to compute objects velocities when enableVelocity is set to "true"
  60656. * @hidden
  60657. */
  60658. _previousBonesTransformationMatrices: {
  60659. [index: number]: Float32Array;
  60660. };
  60661. /**
  60662. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60663. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60664. */
  60665. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60666. private _scene;
  60667. private _multiRenderTarget;
  60668. private _ratio;
  60669. private _enablePosition;
  60670. private _enableVelocity;
  60671. private _positionIndex;
  60672. private _velocityIndex;
  60673. protected _effect: Effect;
  60674. protected _cachedDefines: string;
  60675. /**
  60676. * Set the render list (meshes to be rendered) used in the G buffer.
  60677. */
  60678. renderList: Mesh[];
  60679. /**
  60680. * Gets wether or not G buffer are supported by the running hardware.
  60681. * This requires draw buffer supports
  60682. */
  60683. readonly isSupported: boolean;
  60684. /**
  60685. * Returns the index of the given texture type in the G-Buffer textures array
  60686. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60687. * @returns the index of the given texture type in the G-Buffer textures array
  60688. */
  60689. getTextureIndex(textureType: number): number;
  60690. /**
  60691. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60692. */
  60693. /**
  60694. * Sets whether or not objects positions are enabled for the G buffer.
  60695. */
  60696. enablePosition: boolean;
  60697. /**
  60698. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60699. */
  60700. /**
  60701. * Sets wether or not objects velocities are enabled for the G buffer.
  60702. */
  60703. enableVelocity: boolean;
  60704. /**
  60705. * Gets the scene associated with the buffer.
  60706. */
  60707. readonly scene: Scene;
  60708. /**
  60709. * Gets the ratio used by the buffer during its creation.
  60710. * How big is the buffer related to the main canvas.
  60711. */
  60712. readonly ratio: number;
  60713. /** @hidden */
  60714. static _SceneComponentInitialization: (scene: Scene) => void;
  60715. /**
  60716. * Creates a new G Buffer for the scene
  60717. * @param scene The scene the buffer belongs to
  60718. * @param ratio How big is the buffer related to the main canvas.
  60719. */
  60720. constructor(scene: Scene, ratio?: number);
  60721. /**
  60722. * Checks wether everything is ready to render a submesh to the G buffer.
  60723. * @param subMesh the submesh to check readiness for
  60724. * @param useInstances is the mesh drawn using instance or not
  60725. * @returns true if ready otherwise false
  60726. */
  60727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60728. /**
  60729. * Gets the current underlying G Buffer.
  60730. * @returns the buffer
  60731. */
  60732. getGBuffer(): MultiRenderTarget;
  60733. /**
  60734. * Gets the number of samples used to render the buffer (anti aliasing).
  60735. */
  60736. /**
  60737. * Sets the number of samples used to render the buffer (anti aliasing).
  60738. */
  60739. samples: number;
  60740. /**
  60741. * Disposes the renderer and frees up associated resources.
  60742. */
  60743. dispose(): void;
  60744. protected _createRenderTargets(): void;
  60745. private _copyBonesTransformationMatrices;
  60746. }
  60747. }
  60748. declare module BABYLON {
  60749. interface Scene {
  60750. /** @hidden (Backing field) */
  60751. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60752. /**
  60753. * Gets or Sets the current geometry buffer associated to the scene.
  60754. */
  60755. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60756. /**
  60757. * Enables a GeometryBufferRender and associates it with the scene
  60758. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60759. * @returns the GeometryBufferRenderer
  60760. */
  60761. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60762. /**
  60763. * Disables the GeometryBufferRender associated with the scene
  60764. */
  60765. disableGeometryBufferRenderer(): void;
  60766. }
  60767. /**
  60768. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60769. * in several rendering techniques.
  60770. */
  60771. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60772. /**
  60773. * The component name helpful to identify the component in the list of scene components.
  60774. */
  60775. readonly name: string;
  60776. /**
  60777. * The scene the component belongs to.
  60778. */
  60779. scene: Scene;
  60780. /**
  60781. * Creates a new instance of the component for the given scene
  60782. * @param scene Defines the scene to register the component in
  60783. */
  60784. constructor(scene: Scene);
  60785. /**
  60786. * Registers the component in a given scene
  60787. */
  60788. register(): void;
  60789. /**
  60790. * Rebuilds the elements related to this component in case of
  60791. * context lost for instance.
  60792. */
  60793. rebuild(): void;
  60794. /**
  60795. * Disposes the component and the associated ressources
  60796. */
  60797. dispose(): void;
  60798. private _gatherRenderTargets;
  60799. }
  60800. }
  60801. declare module BABYLON {
  60802. /** @hidden */
  60803. export var motionBlurPixelShader: {
  60804. name: string;
  60805. shader: string;
  60806. };
  60807. }
  60808. declare module BABYLON {
  60809. /**
  60810. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60811. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60812. * As an example, all you have to do is to create the post-process:
  60813. * var mb = new BABYLON.MotionBlurPostProcess(
  60814. * 'mb', // The name of the effect.
  60815. * scene, // The scene containing the objects to blur according to their velocity.
  60816. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60817. * camera // The camera to apply the render pass to.
  60818. * );
  60819. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60820. */
  60821. export class MotionBlurPostProcess extends PostProcess {
  60822. /**
  60823. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60824. */
  60825. motionStrength: number;
  60826. /**
  60827. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60828. */
  60829. /**
  60830. * Sets the number of iterations to be used for motion blur quality
  60831. */
  60832. motionBlurSamples: number;
  60833. private _motionBlurSamples;
  60834. private _geometryBufferRenderer;
  60835. /**
  60836. * Creates a new instance MotionBlurPostProcess
  60837. * @param name The name of the effect.
  60838. * @param scene The scene containing the objects to blur according to their velocity.
  60839. * @param options The required width/height ratio to downsize to before computing the render pass.
  60840. * @param camera The camera to apply the render pass to.
  60841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60842. * @param engine The engine which the post process will be applied. (default: current engine)
  60843. * @param reusable If the post process can be reused on the same frame. (default: false)
  60844. * @param textureType Type of textures used when performing the post process. (default: 0)
  60845. * @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)
  60846. */
  60847. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60848. /**
  60849. * Excludes the given skinned mesh from computing bones velocities.
  60850. * 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.
  60851. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60852. */
  60853. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60854. /**
  60855. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60856. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60857. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60858. */
  60859. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60860. /**
  60861. * Disposes the post process.
  60862. * @param camera The camera to dispose the post process on.
  60863. */
  60864. dispose(camera?: Camera): void;
  60865. }
  60866. }
  60867. declare module BABYLON {
  60868. /** @hidden */
  60869. export var refractionPixelShader: {
  60870. name: string;
  60871. shader: string;
  60872. };
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * Post process which applies a refractin texture
  60877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60878. */
  60879. export class RefractionPostProcess extends PostProcess {
  60880. /** the base color of the refraction (used to taint the rendering) */
  60881. color: Color3;
  60882. /** simulated refraction depth */
  60883. depth: number;
  60884. /** the coefficient of the base color (0 to remove base color tainting) */
  60885. colorLevel: number;
  60886. private _refTexture;
  60887. private _ownRefractionTexture;
  60888. /**
  60889. * Gets or sets the refraction texture
  60890. * Please note that you are responsible for disposing the texture if you set it manually
  60891. */
  60892. refractionTexture: Texture;
  60893. /**
  60894. * Initializes the RefractionPostProcess
  60895. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60896. * @param name The name of the effect.
  60897. * @param refractionTextureUrl Url of the refraction texture to use
  60898. * @param color the base color of the refraction (used to taint the rendering)
  60899. * @param depth simulated refraction depth
  60900. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60901. * @param camera The camera to apply the render pass to.
  60902. * @param options The required width/height ratio to downsize to before computing the render pass.
  60903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60904. * @param engine The engine which the post process will be applied. (default: current engine)
  60905. * @param reusable If the post process can be reused on the same frame. (default: false)
  60906. */
  60907. constructor(name: string, refractionTextureUrl: string,
  60908. /** the base color of the refraction (used to taint the rendering) */
  60909. color: Color3,
  60910. /** simulated refraction depth */
  60911. depth: number,
  60912. /** the coefficient of the base color (0 to remove base color tainting) */
  60913. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60914. /**
  60915. * Disposes of the post process
  60916. * @param camera Camera to dispose post process on
  60917. */
  60918. dispose(camera: Camera): void;
  60919. }
  60920. }
  60921. declare module BABYLON {
  60922. /** @hidden */
  60923. export var sharpenPixelShader: {
  60924. name: string;
  60925. shader: string;
  60926. };
  60927. }
  60928. declare module BABYLON {
  60929. /**
  60930. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60931. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60932. */
  60933. export class SharpenPostProcess extends PostProcess {
  60934. /**
  60935. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60936. */
  60937. colorAmount: number;
  60938. /**
  60939. * How much sharpness should be applied (default: 0.3)
  60940. */
  60941. edgeAmount: number;
  60942. /**
  60943. * Creates a new instance ConvolutionPostProcess
  60944. * @param name The name of the effect.
  60945. * @param options The required width/height ratio to downsize to before computing the render pass.
  60946. * @param camera The camera to apply the render pass to.
  60947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60948. * @param engine The engine which the post process will be applied. (default: current engine)
  60949. * @param reusable If the post process can be reused on the same frame. (default: false)
  60950. * @param textureType Type of textures used when performing the post process. (default: 0)
  60951. * @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)
  60952. */
  60953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60954. }
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * PostProcessRenderPipeline
  60959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60960. */
  60961. export class PostProcessRenderPipeline {
  60962. private engine;
  60963. private _renderEffects;
  60964. private _renderEffectsForIsolatedPass;
  60965. /**
  60966. * List of inspectable custom properties (used by the Inspector)
  60967. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60968. */
  60969. inspectableCustomProperties: IInspectable[];
  60970. /**
  60971. * @hidden
  60972. */
  60973. protected _cameras: Camera[];
  60974. /** @hidden */
  60975. _name: string;
  60976. /**
  60977. * Gets pipeline name
  60978. */
  60979. readonly name: string;
  60980. /** Gets the list of attached cameras */
  60981. readonly cameras: Camera[];
  60982. /**
  60983. * Initializes a PostProcessRenderPipeline
  60984. * @param engine engine to add the pipeline to
  60985. * @param name name of the pipeline
  60986. */
  60987. constructor(engine: Engine, name: string);
  60988. /**
  60989. * Gets the class name
  60990. * @returns "PostProcessRenderPipeline"
  60991. */
  60992. getClassName(): string;
  60993. /**
  60994. * If all the render effects in the pipeline are supported
  60995. */
  60996. readonly isSupported: boolean;
  60997. /**
  60998. * Adds an effect to the pipeline
  60999. * @param renderEffect the effect to add
  61000. */
  61001. addEffect(renderEffect: PostProcessRenderEffect): void;
  61002. /** @hidden */
  61003. _rebuild(): void;
  61004. /** @hidden */
  61005. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61006. /** @hidden */
  61007. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61008. /** @hidden */
  61009. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61010. /** @hidden */
  61011. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61012. /** @hidden */
  61013. _attachCameras(cameras: Camera, unique: boolean): void;
  61014. /** @hidden */
  61015. _attachCameras(cameras: Camera[], unique: boolean): void;
  61016. /** @hidden */
  61017. _detachCameras(cameras: Camera): void;
  61018. /** @hidden */
  61019. _detachCameras(cameras: Nullable<Camera[]>): void;
  61020. /** @hidden */
  61021. _update(): void;
  61022. /** @hidden */
  61023. _reset(): void;
  61024. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61025. /**
  61026. * Disposes of the pipeline
  61027. */
  61028. dispose(): void;
  61029. }
  61030. }
  61031. declare module BABYLON {
  61032. /**
  61033. * PostProcessRenderPipelineManager class
  61034. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61035. */
  61036. export class PostProcessRenderPipelineManager {
  61037. private _renderPipelines;
  61038. /**
  61039. * Initializes a PostProcessRenderPipelineManager
  61040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61041. */
  61042. constructor();
  61043. /**
  61044. * Gets the list of supported render pipelines
  61045. */
  61046. readonly supportedPipelines: PostProcessRenderPipeline[];
  61047. /**
  61048. * Adds a pipeline to the manager
  61049. * @param renderPipeline The pipeline to add
  61050. */
  61051. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61052. /**
  61053. * Attaches a camera to the pipeline
  61054. * @param renderPipelineName The name of the pipeline to attach to
  61055. * @param cameras the camera to attach
  61056. * @param unique if the camera can be attached multiple times to the pipeline
  61057. */
  61058. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61059. /**
  61060. * Detaches a camera from the pipeline
  61061. * @param renderPipelineName The name of the pipeline to detach from
  61062. * @param cameras the camera to detach
  61063. */
  61064. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61065. /**
  61066. * Enables an effect by name on a pipeline
  61067. * @param renderPipelineName the name of the pipeline to enable the effect in
  61068. * @param renderEffectName the name of the effect to enable
  61069. * @param cameras the cameras that the effect should be enabled on
  61070. */
  61071. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61072. /**
  61073. * Disables an effect by name on a pipeline
  61074. * @param renderPipelineName the name of the pipeline to disable the effect in
  61075. * @param renderEffectName the name of the effect to disable
  61076. * @param cameras the cameras that the effect should be disabled on
  61077. */
  61078. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61079. /**
  61080. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61081. */
  61082. update(): void;
  61083. /** @hidden */
  61084. _rebuild(): void;
  61085. /**
  61086. * Disposes of the manager and pipelines
  61087. */
  61088. dispose(): void;
  61089. }
  61090. }
  61091. declare module BABYLON {
  61092. interface Scene {
  61093. /** @hidden (Backing field) */
  61094. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61095. /**
  61096. * Gets the postprocess render pipeline manager
  61097. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61098. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61099. */
  61100. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  61101. }
  61102. /**
  61103. * Defines the Render Pipeline scene component responsible to rendering pipelines
  61104. */
  61105. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  61106. /**
  61107. * The component name helpfull to identify the component in the list of scene components.
  61108. */
  61109. readonly name: string;
  61110. /**
  61111. * The scene the component belongs to.
  61112. */
  61113. scene: Scene;
  61114. /**
  61115. * Creates a new instance of the component for the given scene
  61116. * @param scene Defines the scene to register the component in
  61117. */
  61118. constructor(scene: Scene);
  61119. /**
  61120. * Registers the component in a given scene
  61121. */
  61122. register(): void;
  61123. /**
  61124. * Rebuilds the elements related to this component in case of
  61125. * context lost for instance.
  61126. */
  61127. rebuild(): void;
  61128. /**
  61129. * Disposes the component and the associated ressources
  61130. */
  61131. dispose(): void;
  61132. private _gatherRenderTargets;
  61133. }
  61134. }
  61135. declare module BABYLON {
  61136. /**
  61137. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  61138. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  61139. */
  61140. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61141. private _scene;
  61142. private _camerasToBeAttached;
  61143. /**
  61144. * ID of the sharpen post process,
  61145. */
  61146. private readonly SharpenPostProcessId;
  61147. /**
  61148. * @ignore
  61149. * ID of the image processing post process;
  61150. */
  61151. readonly ImageProcessingPostProcessId: string;
  61152. /**
  61153. * @ignore
  61154. * ID of the Fast Approximate Anti-Aliasing post process;
  61155. */
  61156. readonly FxaaPostProcessId: string;
  61157. /**
  61158. * ID of the chromatic aberration post process,
  61159. */
  61160. private readonly ChromaticAberrationPostProcessId;
  61161. /**
  61162. * ID of the grain post process
  61163. */
  61164. private readonly GrainPostProcessId;
  61165. /**
  61166. * Sharpen post process which will apply a sharpen convolution to enhance edges
  61167. */
  61168. sharpen: SharpenPostProcess;
  61169. private _sharpenEffect;
  61170. private bloom;
  61171. /**
  61172. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  61173. */
  61174. depthOfField: DepthOfFieldEffect;
  61175. /**
  61176. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61177. */
  61178. fxaa: FxaaPostProcess;
  61179. /**
  61180. * Image post processing pass used to perform operations such as tone mapping or color grading.
  61181. */
  61182. imageProcessing: ImageProcessingPostProcess;
  61183. /**
  61184. * Chromatic aberration post process which will shift rgb colors in the image
  61185. */
  61186. chromaticAberration: ChromaticAberrationPostProcess;
  61187. private _chromaticAberrationEffect;
  61188. /**
  61189. * Grain post process which add noise to the image
  61190. */
  61191. grain: GrainPostProcess;
  61192. private _grainEffect;
  61193. /**
  61194. * Glow post process which adds a glow to emissive areas of the image
  61195. */
  61196. private _glowLayer;
  61197. /**
  61198. * Animations which can be used to tweak settings over a period of time
  61199. */
  61200. animations: Animation[];
  61201. private _imageProcessingConfigurationObserver;
  61202. private _sharpenEnabled;
  61203. private _bloomEnabled;
  61204. private _depthOfFieldEnabled;
  61205. private _depthOfFieldBlurLevel;
  61206. private _fxaaEnabled;
  61207. private _imageProcessingEnabled;
  61208. private _defaultPipelineTextureType;
  61209. private _bloomScale;
  61210. private _chromaticAberrationEnabled;
  61211. private _grainEnabled;
  61212. private _buildAllowed;
  61213. /**
  61214. * Gets active scene
  61215. */
  61216. readonly scene: Scene;
  61217. /**
  61218. * Enable or disable the sharpen process from the pipeline
  61219. */
  61220. sharpenEnabled: boolean;
  61221. private _resizeObserver;
  61222. private _hardwareScaleLevel;
  61223. private _bloomKernel;
  61224. /**
  61225. * Specifies the size of the bloom blur kernel, relative to the final output size
  61226. */
  61227. bloomKernel: number;
  61228. /**
  61229. * Specifies the weight of the bloom in the final rendering
  61230. */
  61231. private _bloomWeight;
  61232. /**
  61233. * Specifies the luma threshold for the area that will be blurred by the bloom
  61234. */
  61235. private _bloomThreshold;
  61236. private _hdr;
  61237. /**
  61238. * The strength of the bloom.
  61239. */
  61240. bloomWeight: number;
  61241. /**
  61242. * The strength of the bloom.
  61243. */
  61244. bloomThreshold: number;
  61245. /**
  61246. * The scale of the bloom, lower value will provide better performance.
  61247. */
  61248. bloomScale: number;
  61249. /**
  61250. * Enable or disable the bloom from the pipeline
  61251. */
  61252. bloomEnabled: boolean;
  61253. private _rebuildBloom;
  61254. /**
  61255. * If the depth of field is enabled.
  61256. */
  61257. depthOfFieldEnabled: boolean;
  61258. /**
  61259. * Blur level of the depth of field effect. (Higher blur will effect performance)
  61260. */
  61261. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  61262. /**
  61263. * If the anti aliasing is enabled.
  61264. */
  61265. fxaaEnabled: boolean;
  61266. private _samples;
  61267. /**
  61268. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61269. */
  61270. samples: number;
  61271. /**
  61272. * If image processing is enabled.
  61273. */
  61274. imageProcessingEnabled: boolean;
  61275. /**
  61276. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  61277. */
  61278. glowLayerEnabled: boolean;
  61279. /**
  61280. * Gets the glow layer (or null if not defined)
  61281. */
  61282. readonly glowLayer: Nullable<GlowLayer>;
  61283. /**
  61284. * Enable or disable the chromaticAberration process from the pipeline
  61285. */
  61286. chromaticAberrationEnabled: boolean;
  61287. /**
  61288. * Enable or disable the grain process from the pipeline
  61289. */
  61290. grainEnabled: boolean;
  61291. /**
  61292. * @constructor
  61293. * @param name - The rendering pipeline name (default: "")
  61294. * @param hdr - If high dynamic range textures should be used (default: true)
  61295. * @param scene - The scene linked to this pipeline (default: the last created scene)
  61296. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  61297. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  61298. */
  61299. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  61300. /**
  61301. * Get the class name
  61302. * @returns "DefaultRenderingPipeline"
  61303. */
  61304. getClassName(): string;
  61305. /**
  61306. * Force the compilation of the entire pipeline.
  61307. */
  61308. prepare(): void;
  61309. private _hasCleared;
  61310. private _prevPostProcess;
  61311. private _prevPrevPostProcess;
  61312. private _setAutoClearAndTextureSharing;
  61313. private _depthOfFieldSceneObserver;
  61314. private _buildPipeline;
  61315. private _disposePostProcesses;
  61316. /**
  61317. * Adds a camera to the pipeline
  61318. * @param camera the camera to be added
  61319. */
  61320. addCamera(camera: Camera): void;
  61321. /**
  61322. * Removes a camera from the pipeline
  61323. * @param camera the camera to remove
  61324. */
  61325. removeCamera(camera: Camera): void;
  61326. /**
  61327. * Dispose of the pipeline and stop all post processes
  61328. */
  61329. dispose(): void;
  61330. /**
  61331. * Serialize the rendering pipeline (Used when exporting)
  61332. * @returns the serialized object
  61333. */
  61334. serialize(): any;
  61335. /**
  61336. * Parse the serialized pipeline
  61337. * @param source Source pipeline.
  61338. * @param scene The scene to load the pipeline to.
  61339. * @param rootUrl The URL of the serialized pipeline.
  61340. * @returns An instantiated pipeline from the serialized object.
  61341. */
  61342. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  61343. }
  61344. }
  61345. declare module BABYLON {
  61346. /** @hidden */
  61347. export var lensHighlightsPixelShader: {
  61348. name: string;
  61349. shader: string;
  61350. };
  61351. }
  61352. declare module BABYLON {
  61353. /** @hidden */
  61354. export var depthOfFieldPixelShader: {
  61355. name: string;
  61356. shader: string;
  61357. };
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * BABYLON.JS Chromatic Aberration GLSL Shader
  61362. * Author: Olivier Guyot
  61363. * Separates very slightly R, G and B colors on the edges of the screen
  61364. * Inspired by Francois Tarlier & Martins Upitis
  61365. */
  61366. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  61367. /**
  61368. * @ignore
  61369. * The chromatic aberration PostProcess id in the pipeline
  61370. */
  61371. LensChromaticAberrationEffect: string;
  61372. /**
  61373. * @ignore
  61374. * The highlights enhancing PostProcess id in the pipeline
  61375. */
  61376. HighlightsEnhancingEffect: string;
  61377. /**
  61378. * @ignore
  61379. * The depth-of-field PostProcess id in the pipeline
  61380. */
  61381. LensDepthOfFieldEffect: string;
  61382. private _scene;
  61383. private _depthTexture;
  61384. private _grainTexture;
  61385. private _chromaticAberrationPostProcess;
  61386. private _highlightsPostProcess;
  61387. private _depthOfFieldPostProcess;
  61388. private _edgeBlur;
  61389. private _grainAmount;
  61390. private _chromaticAberration;
  61391. private _distortion;
  61392. private _highlightsGain;
  61393. private _highlightsThreshold;
  61394. private _dofDistance;
  61395. private _dofAperture;
  61396. private _dofDarken;
  61397. private _dofPentagon;
  61398. private _blurNoise;
  61399. /**
  61400. * @constructor
  61401. *
  61402. * Effect parameters are as follow:
  61403. * {
  61404. * chromatic_aberration: number; // from 0 to x (1 for realism)
  61405. * edge_blur: number; // from 0 to x (1 for realism)
  61406. * distortion: number; // from 0 to x (1 for realism)
  61407. * grain_amount: number; // from 0 to 1
  61408. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  61409. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  61410. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  61411. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  61412. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  61413. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  61414. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  61415. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  61416. * }
  61417. * Note: if an effect parameter is unset, effect is disabled
  61418. *
  61419. * @param name The rendering pipeline name
  61420. * @param parameters - An object containing all parameters (see above)
  61421. * @param scene The scene linked to this pipeline
  61422. * @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)
  61423. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61424. */
  61425. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61426. /**
  61427. * Get the class name
  61428. * @returns "LensRenderingPipeline"
  61429. */
  61430. getClassName(): string;
  61431. /**
  61432. * Gets associated scene
  61433. */
  61434. readonly scene: Scene;
  61435. /**
  61436. * Gets or sets the edge blur
  61437. */
  61438. edgeBlur: number;
  61439. /**
  61440. * Gets or sets the grain amount
  61441. */
  61442. grainAmount: number;
  61443. /**
  61444. * Gets or sets the chromatic aberration amount
  61445. */
  61446. chromaticAberration: number;
  61447. /**
  61448. * Gets or sets the depth of field aperture
  61449. */
  61450. dofAperture: number;
  61451. /**
  61452. * Gets or sets the edge distortion
  61453. */
  61454. edgeDistortion: number;
  61455. /**
  61456. * Gets or sets the depth of field distortion
  61457. */
  61458. dofDistortion: number;
  61459. /**
  61460. * Gets or sets the darken out of focus amount
  61461. */
  61462. darkenOutOfFocus: number;
  61463. /**
  61464. * Gets or sets a boolean indicating if blur noise is enabled
  61465. */
  61466. blurNoise: boolean;
  61467. /**
  61468. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61469. */
  61470. pentagonBokeh: boolean;
  61471. /**
  61472. * Gets or sets the highlight grain amount
  61473. */
  61474. highlightsGain: number;
  61475. /**
  61476. * Gets or sets the highlight threshold
  61477. */
  61478. highlightsThreshold: number;
  61479. /**
  61480. * Sets the amount of blur at the edges
  61481. * @param amount blur amount
  61482. */
  61483. setEdgeBlur(amount: number): void;
  61484. /**
  61485. * Sets edge blur to 0
  61486. */
  61487. disableEdgeBlur(): void;
  61488. /**
  61489. * Sets the amout of grain
  61490. * @param amount Amount of grain
  61491. */
  61492. setGrainAmount(amount: number): void;
  61493. /**
  61494. * Set grain amount to 0
  61495. */
  61496. disableGrain(): void;
  61497. /**
  61498. * Sets the chromatic aberration amount
  61499. * @param amount amount of chromatic aberration
  61500. */
  61501. setChromaticAberration(amount: number): void;
  61502. /**
  61503. * Sets chromatic aberration amount to 0
  61504. */
  61505. disableChromaticAberration(): void;
  61506. /**
  61507. * Sets the EdgeDistortion amount
  61508. * @param amount amount of EdgeDistortion
  61509. */
  61510. setEdgeDistortion(amount: number): void;
  61511. /**
  61512. * Sets edge distortion to 0
  61513. */
  61514. disableEdgeDistortion(): void;
  61515. /**
  61516. * Sets the FocusDistance amount
  61517. * @param amount amount of FocusDistance
  61518. */
  61519. setFocusDistance(amount: number): void;
  61520. /**
  61521. * Disables depth of field
  61522. */
  61523. disableDepthOfField(): void;
  61524. /**
  61525. * Sets the Aperture amount
  61526. * @param amount amount of Aperture
  61527. */
  61528. setAperture(amount: number): void;
  61529. /**
  61530. * Sets the DarkenOutOfFocus amount
  61531. * @param amount amount of DarkenOutOfFocus
  61532. */
  61533. setDarkenOutOfFocus(amount: number): void;
  61534. private _pentagonBokehIsEnabled;
  61535. /**
  61536. * Creates a pentagon bokeh effect
  61537. */
  61538. enablePentagonBokeh(): void;
  61539. /**
  61540. * Disables the pentagon bokeh effect
  61541. */
  61542. disablePentagonBokeh(): void;
  61543. /**
  61544. * Enables noise blur
  61545. */
  61546. enableNoiseBlur(): void;
  61547. /**
  61548. * Disables noise blur
  61549. */
  61550. disableNoiseBlur(): void;
  61551. /**
  61552. * Sets the HighlightsGain amount
  61553. * @param amount amount of HighlightsGain
  61554. */
  61555. setHighlightsGain(amount: number): void;
  61556. /**
  61557. * Sets the HighlightsThreshold amount
  61558. * @param amount amount of HighlightsThreshold
  61559. */
  61560. setHighlightsThreshold(amount: number): void;
  61561. /**
  61562. * Disables highlights
  61563. */
  61564. disableHighlights(): void;
  61565. /**
  61566. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61567. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61568. */
  61569. dispose(disableDepthRender?: boolean): void;
  61570. private _createChromaticAberrationPostProcess;
  61571. private _createHighlightsPostProcess;
  61572. private _createDepthOfFieldPostProcess;
  61573. private _createGrainTexture;
  61574. }
  61575. }
  61576. declare module BABYLON {
  61577. /** @hidden */
  61578. export var ssao2PixelShader: {
  61579. name: string;
  61580. shader: string;
  61581. };
  61582. }
  61583. declare module BABYLON {
  61584. /** @hidden */
  61585. export var ssaoCombinePixelShader: {
  61586. name: string;
  61587. shader: string;
  61588. };
  61589. }
  61590. declare module BABYLON {
  61591. /**
  61592. * Render pipeline to produce ssao effect
  61593. */
  61594. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61595. /**
  61596. * @ignore
  61597. * The PassPostProcess id in the pipeline that contains the original scene color
  61598. */
  61599. SSAOOriginalSceneColorEffect: string;
  61600. /**
  61601. * @ignore
  61602. * The SSAO PostProcess id in the pipeline
  61603. */
  61604. SSAORenderEffect: string;
  61605. /**
  61606. * @ignore
  61607. * The horizontal blur PostProcess id in the pipeline
  61608. */
  61609. SSAOBlurHRenderEffect: string;
  61610. /**
  61611. * @ignore
  61612. * The vertical blur PostProcess id in the pipeline
  61613. */
  61614. SSAOBlurVRenderEffect: string;
  61615. /**
  61616. * @ignore
  61617. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61618. */
  61619. SSAOCombineRenderEffect: string;
  61620. /**
  61621. * The output strength of the SSAO post-process. Default value is 1.0.
  61622. */
  61623. totalStrength: number;
  61624. /**
  61625. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61626. */
  61627. maxZ: number;
  61628. /**
  61629. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61630. */
  61631. minZAspect: number;
  61632. private _samples;
  61633. /**
  61634. * Number of samples used for the SSAO calculations. Default value is 8
  61635. */
  61636. samples: number;
  61637. private _textureSamples;
  61638. /**
  61639. * Number of samples to use for antialiasing
  61640. */
  61641. textureSamples: number;
  61642. /**
  61643. * Ratio object used for SSAO ratio and blur ratio
  61644. */
  61645. private _ratio;
  61646. /**
  61647. * Dynamically generated sphere sampler.
  61648. */
  61649. private _sampleSphere;
  61650. /**
  61651. * Blur filter offsets
  61652. */
  61653. private _samplerOffsets;
  61654. private _expensiveBlur;
  61655. /**
  61656. * If bilateral blur should be used
  61657. */
  61658. expensiveBlur: boolean;
  61659. /**
  61660. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61661. */
  61662. radius: number;
  61663. /**
  61664. * The base color of the SSAO post-process
  61665. * The final result is "base + ssao" between [0, 1]
  61666. */
  61667. base: number;
  61668. /**
  61669. * Support test.
  61670. */
  61671. static readonly IsSupported: boolean;
  61672. private _scene;
  61673. private _depthTexture;
  61674. private _normalTexture;
  61675. private _randomTexture;
  61676. private _originalColorPostProcess;
  61677. private _ssaoPostProcess;
  61678. private _blurHPostProcess;
  61679. private _blurVPostProcess;
  61680. private _ssaoCombinePostProcess;
  61681. private _firstUpdate;
  61682. /**
  61683. * Gets active scene
  61684. */
  61685. readonly scene: Scene;
  61686. /**
  61687. * @constructor
  61688. * @param name The rendering pipeline name
  61689. * @param scene The scene linked to this pipeline
  61690. * @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 }
  61691. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61692. */
  61693. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61694. /**
  61695. * Get the class name
  61696. * @returns "SSAO2RenderingPipeline"
  61697. */
  61698. getClassName(): string;
  61699. /**
  61700. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61701. */
  61702. dispose(disableGeometryBufferRenderer?: boolean): void;
  61703. private _createBlurPostProcess;
  61704. /** @hidden */
  61705. _rebuild(): void;
  61706. private _bits;
  61707. private _radicalInverse_VdC;
  61708. private _hammersley;
  61709. private _hemisphereSample_uniform;
  61710. private _generateHemisphere;
  61711. private _createSSAOPostProcess;
  61712. private _createSSAOCombinePostProcess;
  61713. private _createRandomTexture;
  61714. /**
  61715. * Serialize the rendering pipeline (Used when exporting)
  61716. * @returns the serialized object
  61717. */
  61718. serialize(): any;
  61719. /**
  61720. * Parse the serialized pipeline
  61721. * @param source Source pipeline.
  61722. * @param scene The scene to load the pipeline to.
  61723. * @param rootUrl The URL of the serialized pipeline.
  61724. * @returns An instantiated pipeline from the serialized object.
  61725. */
  61726. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61727. }
  61728. }
  61729. declare module BABYLON {
  61730. /** @hidden */
  61731. export var ssaoPixelShader: {
  61732. name: string;
  61733. shader: string;
  61734. };
  61735. }
  61736. declare module BABYLON {
  61737. /**
  61738. * Render pipeline to produce ssao effect
  61739. */
  61740. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61741. /**
  61742. * @ignore
  61743. * The PassPostProcess id in the pipeline that contains the original scene color
  61744. */
  61745. SSAOOriginalSceneColorEffect: string;
  61746. /**
  61747. * @ignore
  61748. * The SSAO PostProcess id in the pipeline
  61749. */
  61750. SSAORenderEffect: string;
  61751. /**
  61752. * @ignore
  61753. * The horizontal blur PostProcess id in the pipeline
  61754. */
  61755. SSAOBlurHRenderEffect: string;
  61756. /**
  61757. * @ignore
  61758. * The vertical blur PostProcess id in the pipeline
  61759. */
  61760. SSAOBlurVRenderEffect: string;
  61761. /**
  61762. * @ignore
  61763. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61764. */
  61765. SSAOCombineRenderEffect: string;
  61766. /**
  61767. * The output strength of the SSAO post-process. Default value is 1.0.
  61768. */
  61769. totalStrength: number;
  61770. /**
  61771. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61772. */
  61773. radius: number;
  61774. /**
  61775. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61776. * Must not be equal to fallOff and superior to fallOff.
  61777. * Default value is 0.0075
  61778. */
  61779. area: number;
  61780. /**
  61781. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61782. * Must not be equal to area and inferior to area.
  61783. * Default value is 0.000001
  61784. */
  61785. fallOff: number;
  61786. /**
  61787. * The base color of the SSAO post-process
  61788. * The final result is "base + ssao" between [0, 1]
  61789. */
  61790. base: number;
  61791. private _scene;
  61792. private _depthTexture;
  61793. private _randomTexture;
  61794. private _originalColorPostProcess;
  61795. private _ssaoPostProcess;
  61796. private _blurHPostProcess;
  61797. private _blurVPostProcess;
  61798. private _ssaoCombinePostProcess;
  61799. private _firstUpdate;
  61800. /**
  61801. * Gets active scene
  61802. */
  61803. readonly scene: Scene;
  61804. /**
  61805. * @constructor
  61806. * @param name - The rendering pipeline name
  61807. * @param scene - The scene linked to this pipeline
  61808. * @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 }
  61809. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61810. */
  61811. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61812. /**
  61813. * Get the class name
  61814. * @returns "SSAORenderingPipeline"
  61815. */
  61816. getClassName(): string;
  61817. /**
  61818. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61819. */
  61820. dispose(disableDepthRender?: boolean): void;
  61821. private _createBlurPostProcess;
  61822. /** @hidden */
  61823. _rebuild(): void;
  61824. private _createSSAOPostProcess;
  61825. private _createSSAOCombinePostProcess;
  61826. private _createRandomTexture;
  61827. }
  61828. }
  61829. declare module BABYLON {
  61830. /** @hidden */
  61831. export var standardPixelShader: {
  61832. name: string;
  61833. shader: string;
  61834. };
  61835. }
  61836. declare module BABYLON {
  61837. /**
  61838. * Standard rendering pipeline
  61839. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61840. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61841. */
  61842. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61843. /**
  61844. * Public members
  61845. */
  61846. /**
  61847. * Post-process which contains the original scene color before the pipeline applies all the effects
  61848. */
  61849. originalPostProcess: Nullable<PostProcess>;
  61850. /**
  61851. * Post-process used to down scale an image x4
  61852. */
  61853. downSampleX4PostProcess: Nullable<PostProcess>;
  61854. /**
  61855. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61856. */
  61857. brightPassPostProcess: Nullable<PostProcess>;
  61858. /**
  61859. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61860. */
  61861. blurHPostProcesses: PostProcess[];
  61862. /**
  61863. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61864. */
  61865. blurVPostProcesses: PostProcess[];
  61866. /**
  61867. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61868. */
  61869. textureAdderPostProcess: Nullable<PostProcess>;
  61870. /**
  61871. * Post-process used to create volumetric lighting effect
  61872. */
  61873. volumetricLightPostProcess: Nullable<PostProcess>;
  61874. /**
  61875. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61876. */
  61877. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61878. /**
  61879. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61880. */
  61881. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61882. /**
  61883. * Post-process used to merge the volumetric light effect and the real scene color
  61884. */
  61885. volumetricLightMergePostProces: Nullable<PostProcess>;
  61886. /**
  61887. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61888. */
  61889. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61890. /**
  61891. * Base post-process used to calculate the average luminance of the final image for HDR
  61892. */
  61893. luminancePostProcess: Nullable<PostProcess>;
  61894. /**
  61895. * Post-processes used to create down sample post-processes in order to get
  61896. * the average luminance of the final image for HDR
  61897. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61898. */
  61899. luminanceDownSamplePostProcesses: PostProcess[];
  61900. /**
  61901. * Post-process used to create a HDR effect (light adaptation)
  61902. */
  61903. hdrPostProcess: Nullable<PostProcess>;
  61904. /**
  61905. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61906. */
  61907. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61908. /**
  61909. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61910. */
  61911. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61912. /**
  61913. * Post-process used to merge the final HDR post-process and the real scene color
  61914. */
  61915. hdrFinalPostProcess: Nullable<PostProcess>;
  61916. /**
  61917. * Post-process used to create a lens flare effect
  61918. */
  61919. lensFlarePostProcess: Nullable<PostProcess>;
  61920. /**
  61921. * Post-process that merges the result of the lens flare post-process and the real scene color
  61922. */
  61923. lensFlareComposePostProcess: Nullable<PostProcess>;
  61924. /**
  61925. * Post-process used to create a motion blur effect
  61926. */
  61927. motionBlurPostProcess: Nullable<PostProcess>;
  61928. /**
  61929. * Post-process used to create a depth of field effect
  61930. */
  61931. depthOfFieldPostProcess: Nullable<PostProcess>;
  61932. /**
  61933. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61934. */
  61935. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61936. /**
  61937. * Represents the brightness threshold in order to configure the illuminated surfaces
  61938. */
  61939. brightThreshold: number;
  61940. /**
  61941. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61942. */
  61943. blurWidth: number;
  61944. /**
  61945. * Sets if the blur for highlighted surfaces must be only horizontal
  61946. */
  61947. horizontalBlur: boolean;
  61948. /**
  61949. * Gets the overall exposure used by the pipeline
  61950. */
  61951. /**
  61952. * Sets the overall exposure used by the pipeline
  61953. */
  61954. exposure: number;
  61955. /**
  61956. * Texture used typically to simulate "dirty" on camera lens
  61957. */
  61958. lensTexture: Nullable<Texture>;
  61959. /**
  61960. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61961. */
  61962. volumetricLightCoefficient: number;
  61963. /**
  61964. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61965. */
  61966. volumetricLightPower: number;
  61967. /**
  61968. * Used the set the blur intensity to smooth the volumetric lights
  61969. */
  61970. volumetricLightBlurScale: number;
  61971. /**
  61972. * Light (spot or directional) used to generate the volumetric lights rays
  61973. * The source light must have a shadow generate so the pipeline can get its
  61974. * depth map
  61975. */
  61976. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61977. /**
  61978. * For eye adaptation, represents the minimum luminance the eye can see
  61979. */
  61980. hdrMinimumLuminance: number;
  61981. /**
  61982. * For eye adaptation, represents the decrease luminance speed
  61983. */
  61984. hdrDecreaseRate: number;
  61985. /**
  61986. * For eye adaptation, represents the increase luminance speed
  61987. */
  61988. hdrIncreaseRate: number;
  61989. /**
  61990. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61991. */
  61992. /**
  61993. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61994. */
  61995. hdrAutoExposure: boolean;
  61996. /**
  61997. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61998. */
  61999. lensColorTexture: Nullable<Texture>;
  62000. /**
  62001. * The overall strengh for the lens flare effect
  62002. */
  62003. lensFlareStrength: number;
  62004. /**
  62005. * Dispersion coefficient for lens flare ghosts
  62006. */
  62007. lensFlareGhostDispersal: number;
  62008. /**
  62009. * Main lens flare halo width
  62010. */
  62011. lensFlareHaloWidth: number;
  62012. /**
  62013. * Based on the lens distortion effect, defines how much the lens flare result
  62014. * is distorted
  62015. */
  62016. lensFlareDistortionStrength: number;
  62017. /**
  62018. * Configures the blur intensity used for for lens flare (halo)
  62019. */
  62020. lensFlareBlurWidth: number;
  62021. /**
  62022. * Lens star texture must be used to simulate rays on the flares and is available
  62023. * in the documentation
  62024. */
  62025. lensStarTexture: Nullable<Texture>;
  62026. /**
  62027. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62028. * flare effect by taking account of the dirt texture
  62029. */
  62030. lensFlareDirtTexture: Nullable<Texture>;
  62031. /**
  62032. * Represents the focal length for the depth of field effect
  62033. */
  62034. depthOfFieldDistance: number;
  62035. /**
  62036. * Represents the blur intensity for the blurred part of the depth of field effect
  62037. */
  62038. depthOfFieldBlurWidth: number;
  62039. /**
  62040. * Gets how much the image is blurred by the movement while using the motion blur post-process
  62041. */
  62042. /**
  62043. * Sets how much the image is blurred by the movement while using the motion blur post-process
  62044. */
  62045. motionStrength: number;
  62046. /**
  62047. * Gets wether or not the motion blur post-process is object based or screen based.
  62048. */
  62049. /**
  62050. * Sets wether or not the motion blur post-process should be object based or screen based
  62051. */
  62052. objectBasedMotionBlur: boolean;
  62053. /**
  62054. * List of animations for the pipeline (IAnimatable implementation)
  62055. */
  62056. animations: Animation[];
  62057. /**
  62058. * Private members
  62059. */
  62060. private _scene;
  62061. private _currentDepthOfFieldSource;
  62062. private _basePostProcess;
  62063. private _fixedExposure;
  62064. private _currentExposure;
  62065. private _hdrAutoExposure;
  62066. private _hdrCurrentLuminance;
  62067. private _motionStrength;
  62068. private _isObjectBasedMotionBlur;
  62069. private _floatTextureType;
  62070. private _camerasToBeAttached;
  62071. private _ratio;
  62072. private _bloomEnabled;
  62073. private _depthOfFieldEnabled;
  62074. private _vlsEnabled;
  62075. private _lensFlareEnabled;
  62076. private _hdrEnabled;
  62077. private _motionBlurEnabled;
  62078. private _fxaaEnabled;
  62079. private _motionBlurSamples;
  62080. private _volumetricLightStepsCount;
  62081. private _samples;
  62082. /**
  62083. * @ignore
  62084. * Specifies if the bloom pipeline is enabled
  62085. */
  62086. BloomEnabled: boolean;
  62087. /**
  62088. * @ignore
  62089. * Specifies if the depth of field pipeline is enabed
  62090. */
  62091. DepthOfFieldEnabled: boolean;
  62092. /**
  62093. * @ignore
  62094. * Specifies if the lens flare pipeline is enabed
  62095. */
  62096. LensFlareEnabled: boolean;
  62097. /**
  62098. * @ignore
  62099. * Specifies if the HDR pipeline is enabled
  62100. */
  62101. HDREnabled: boolean;
  62102. /**
  62103. * @ignore
  62104. * Specifies if the volumetric lights scattering effect is enabled
  62105. */
  62106. VLSEnabled: boolean;
  62107. /**
  62108. * @ignore
  62109. * Specifies if the motion blur effect is enabled
  62110. */
  62111. MotionBlurEnabled: boolean;
  62112. /**
  62113. * Specifies if anti-aliasing is enabled
  62114. */
  62115. fxaaEnabled: boolean;
  62116. /**
  62117. * Specifies the number of steps used to calculate the volumetric lights
  62118. * Typically in interval [50, 200]
  62119. */
  62120. volumetricLightStepsCount: number;
  62121. /**
  62122. * Specifies the number of samples used for the motion blur effect
  62123. * Typically in interval [16, 64]
  62124. */
  62125. motionBlurSamples: number;
  62126. /**
  62127. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62128. */
  62129. samples: number;
  62130. /**
  62131. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62132. * @constructor
  62133. * @param name The rendering pipeline name
  62134. * @param scene The scene linked to this pipeline
  62135. * @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)
  62136. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  62137. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62138. */
  62139. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  62140. private _buildPipeline;
  62141. private _createDownSampleX4PostProcess;
  62142. private _createBrightPassPostProcess;
  62143. private _createBlurPostProcesses;
  62144. private _createTextureAdderPostProcess;
  62145. private _createVolumetricLightPostProcess;
  62146. private _createLuminancePostProcesses;
  62147. private _createHdrPostProcess;
  62148. private _createLensFlarePostProcess;
  62149. private _createDepthOfFieldPostProcess;
  62150. private _createMotionBlurPostProcess;
  62151. private _getDepthTexture;
  62152. private _disposePostProcesses;
  62153. /**
  62154. * Dispose of the pipeline and stop all post processes
  62155. */
  62156. dispose(): void;
  62157. /**
  62158. * Serialize the rendering pipeline (Used when exporting)
  62159. * @returns the serialized object
  62160. */
  62161. serialize(): any;
  62162. /**
  62163. * Parse the serialized pipeline
  62164. * @param source Source pipeline.
  62165. * @param scene The scene to load the pipeline to.
  62166. * @param rootUrl The URL of the serialized pipeline.
  62167. * @returns An instantiated pipeline from the serialized object.
  62168. */
  62169. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  62170. /**
  62171. * Luminance steps
  62172. */
  62173. static LuminanceSteps: number;
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /** @hidden */
  62178. export var tonemapPixelShader: {
  62179. name: string;
  62180. shader: string;
  62181. };
  62182. }
  62183. declare module BABYLON {
  62184. /** Defines operator used for tonemapping */
  62185. export enum TonemappingOperator {
  62186. /** Hable */
  62187. Hable = 0,
  62188. /** Reinhard */
  62189. Reinhard = 1,
  62190. /** HejiDawson */
  62191. HejiDawson = 2,
  62192. /** Photographic */
  62193. Photographic = 3
  62194. }
  62195. /**
  62196. * Defines a post process to apply tone mapping
  62197. */
  62198. export class TonemapPostProcess extends PostProcess {
  62199. private _operator;
  62200. /** Defines the required exposure adjustement */
  62201. exposureAdjustment: number;
  62202. /**
  62203. * Creates a new TonemapPostProcess
  62204. * @param name defines the name of the postprocess
  62205. * @param _operator defines the operator to use
  62206. * @param exposureAdjustment defines the required exposure adjustement
  62207. * @param camera defines the camera to use (can be null)
  62208. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  62209. * @param engine defines the hosting engine (can be ignore if camera is set)
  62210. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62211. */
  62212. constructor(name: string, _operator: TonemappingOperator,
  62213. /** Defines the required exposure adjustement */
  62214. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  62215. }
  62216. }
  62217. declare module BABYLON {
  62218. /** @hidden */
  62219. export var depthVertexShader: {
  62220. name: string;
  62221. shader: string;
  62222. };
  62223. }
  62224. declare module BABYLON {
  62225. /** @hidden */
  62226. export var volumetricLightScatteringPixelShader: {
  62227. name: string;
  62228. shader: string;
  62229. };
  62230. }
  62231. declare module BABYLON {
  62232. /** @hidden */
  62233. export var volumetricLightScatteringPassVertexShader: {
  62234. name: string;
  62235. shader: string;
  62236. };
  62237. }
  62238. declare module BABYLON {
  62239. /** @hidden */
  62240. export var volumetricLightScatteringPassPixelShader: {
  62241. name: string;
  62242. shader: string;
  62243. };
  62244. }
  62245. declare module BABYLON {
  62246. /**
  62247. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  62248. */
  62249. export class VolumetricLightScatteringPostProcess extends PostProcess {
  62250. private _volumetricLightScatteringPass;
  62251. private _volumetricLightScatteringRTT;
  62252. private _viewPort;
  62253. private _screenCoordinates;
  62254. private _cachedDefines;
  62255. /**
  62256. * If not undefined, the mesh position is computed from the attached node position
  62257. */
  62258. attachedNode: {
  62259. position: Vector3;
  62260. };
  62261. /**
  62262. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  62263. */
  62264. customMeshPosition: Vector3;
  62265. /**
  62266. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  62267. */
  62268. useCustomMeshPosition: boolean;
  62269. /**
  62270. * If the post-process should inverse the light scattering direction
  62271. */
  62272. invert: boolean;
  62273. /**
  62274. * The internal mesh used by the post-process
  62275. */
  62276. mesh: Mesh;
  62277. /**
  62278. * @hidden
  62279. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  62280. */
  62281. useDiffuseColor: boolean;
  62282. /**
  62283. * Array containing the excluded meshes not rendered in the internal pass
  62284. */
  62285. excludedMeshes: AbstractMesh[];
  62286. /**
  62287. * Controls the overall intensity of the post-process
  62288. */
  62289. exposure: number;
  62290. /**
  62291. * Dissipates each sample's contribution in range [0, 1]
  62292. */
  62293. decay: number;
  62294. /**
  62295. * Controls the overall intensity of each sample
  62296. */
  62297. weight: number;
  62298. /**
  62299. * Controls the density of each sample
  62300. */
  62301. density: number;
  62302. /**
  62303. * @constructor
  62304. * @param name The post-process name
  62305. * @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)
  62306. * @param camera The camera that the post-process will be attached to
  62307. * @param mesh The mesh used to create the light scattering
  62308. * @param samples The post-process quality, default 100
  62309. * @param samplingModeThe post-process filtering mode
  62310. * @param engine The babylon engine
  62311. * @param reusable If the post-process is reusable
  62312. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  62313. */
  62314. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  62315. /**
  62316. * Returns the string "VolumetricLightScatteringPostProcess"
  62317. * @returns "VolumetricLightScatteringPostProcess"
  62318. */
  62319. getClassName(): string;
  62320. private _isReady;
  62321. /**
  62322. * Sets the new light position for light scattering effect
  62323. * @param position The new custom light position
  62324. */
  62325. setCustomMeshPosition(position: Vector3): void;
  62326. /**
  62327. * Returns the light position for light scattering effect
  62328. * @return Vector3 The custom light position
  62329. */
  62330. getCustomMeshPosition(): Vector3;
  62331. /**
  62332. * Disposes the internal assets and detaches the post-process from the camera
  62333. */
  62334. dispose(camera: Camera): void;
  62335. /**
  62336. * Returns the render target texture used by the post-process
  62337. * @return the render target texture used by the post-process
  62338. */
  62339. getPass(): RenderTargetTexture;
  62340. private _meshExcluded;
  62341. private _createPass;
  62342. private _updateMeshScreenCoordinates;
  62343. /**
  62344. * Creates a default mesh for the Volumeric Light Scattering post-process
  62345. * @param name The mesh name
  62346. * @param scene The scene where to create the mesh
  62347. * @return the default mesh
  62348. */
  62349. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62350. }
  62351. }
  62352. declare module BABYLON {
  62353. interface Scene {
  62354. /** @hidden (Backing field) */
  62355. _boundingBoxRenderer: BoundingBoxRenderer;
  62356. /** @hidden (Backing field) */
  62357. _forceShowBoundingBoxes: boolean;
  62358. /**
  62359. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62360. */
  62361. forceShowBoundingBoxes: boolean;
  62362. /**
  62363. * Gets the bounding box renderer associated with the scene
  62364. * @returns a BoundingBoxRenderer
  62365. */
  62366. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62367. }
  62368. interface AbstractMesh {
  62369. /** @hidden (Backing field) */
  62370. _showBoundingBox: boolean;
  62371. /**
  62372. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62373. */
  62374. showBoundingBox: boolean;
  62375. }
  62376. /**
  62377. * Component responsible of rendering the bounding box of the meshes in a scene.
  62378. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62379. */
  62380. export class BoundingBoxRenderer implements ISceneComponent {
  62381. /**
  62382. * The component name helpfull to identify the component in the list of scene components.
  62383. */
  62384. readonly name: string;
  62385. /**
  62386. * The scene the component belongs to.
  62387. */
  62388. scene: Scene;
  62389. /**
  62390. * Color of the bounding box lines placed in front of an object
  62391. */
  62392. frontColor: Color3;
  62393. /**
  62394. * Color of the bounding box lines placed behind an object
  62395. */
  62396. backColor: Color3;
  62397. /**
  62398. * Defines if the renderer should show the back lines or not
  62399. */
  62400. showBackLines: boolean;
  62401. /**
  62402. * @hidden
  62403. */
  62404. renderList: SmartArray<BoundingBox>;
  62405. private _colorShader;
  62406. private _vertexBuffers;
  62407. private _indexBuffer;
  62408. private _fillIndexBuffer;
  62409. private _fillIndexData;
  62410. /**
  62411. * Instantiates a new bounding box renderer in a scene.
  62412. * @param scene the scene the renderer renders in
  62413. */
  62414. constructor(scene: Scene);
  62415. /**
  62416. * Registers the component in a given scene
  62417. */
  62418. register(): void;
  62419. private _evaluateSubMesh;
  62420. private _activeMesh;
  62421. private _prepareRessources;
  62422. private _createIndexBuffer;
  62423. /**
  62424. * Rebuilds the elements related to this component in case of
  62425. * context lost for instance.
  62426. */
  62427. rebuild(): void;
  62428. /**
  62429. * @hidden
  62430. */
  62431. reset(): void;
  62432. /**
  62433. * Render the bounding boxes of a specific rendering group
  62434. * @param renderingGroupId defines the rendering group to render
  62435. */
  62436. render(renderingGroupId: number): void;
  62437. /**
  62438. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62439. * @param mesh Define the mesh to render the occlusion bounding box for
  62440. */
  62441. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62442. /**
  62443. * Dispose and release the resources attached to this renderer.
  62444. */
  62445. dispose(): void;
  62446. }
  62447. }
  62448. declare module BABYLON {
  62449. /** @hidden */
  62450. export var depthPixelShader: {
  62451. name: string;
  62452. shader: string;
  62453. };
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * This represents a depth renderer in Babylon.
  62458. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62459. */
  62460. export class DepthRenderer {
  62461. private _scene;
  62462. private _depthMap;
  62463. private _effect;
  62464. private readonly _storeNonLinearDepth;
  62465. private readonly _clearColor;
  62466. /** Get if the depth renderer is using packed depth or not */
  62467. readonly isPacked: boolean;
  62468. private _cachedDefines;
  62469. private _camera;
  62470. /**
  62471. * Specifiess that the depth renderer will only be used within
  62472. * the camera it is created for.
  62473. * This can help forcing its rendering during the camera processing.
  62474. */
  62475. useOnlyInActiveCamera: boolean;
  62476. /** @hidden */
  62477. static _SceneComponentInitialization: (scene: Scene) => void;
  62478. /**
  62479. * Instantiates a depth renderer
  62480. * @param scene The scene the renderer belongs to
  62481. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62482. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62483. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62484. */
  62485. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62486. /**
  62487. * Creates the depth rendering effect and checks if the effect is ready.
  62488. * @param subMesh The submesh to be used to render the depth map of
  62489. * @param useInstances If multiple world instances should be used
  62490. * @returns if the depth renderer is ready to render the depth map
  62491. */
  62492. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62493. /**
  62494. * Gets the texture which the depth map will be written to.
  62495. * @returns The depth map texture
  62496. */
  62497. getDepthMap(): RenderTargetTexture;
  62498. /**
  62499. * Disposes of the depth renderer.
  62500. */
  62501. dispose(): void;
  62502. }
  62503. }
  62504. declare module BABYLON {
  62505. interface Scene {
  62506. /** @hidden (Backing field) */
  62507. _depthRenderer: {
  62508. [id: string]: DepthRenderer;
  62509. };
  62510. /**
  62511. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62512. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62513. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62514. * @returns the created depth renderer
  62515. */
  62516. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62517. /**
  62518. * Disables a depth renderer for a given camera
  62519. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62520. */
  62521. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62522. }
  62523. /**
  62524. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62525. * in several rendering techniques.
  62526. */
  62527. export class DepthRendererSceneComponent implements ISceneComponent {
  62528. /**
  62529. * The component name helpfull to identify the component in the list of scene components.
  62530. */
  62531. readonly name: string;
  62532. /**
  62533. * The scene the component belongs to.
  62534. */
  62535. scene: Scene;
  62536. /**
  62537. * Creates a new instance of the component for the given scene
  62538. * @param scene Defines the scene to register the component in
  62539. */
  62540. constructor(scene: Scene);
  62541. /**
  62542. * Registers the component in a given scene
  62543. */
  62544. register(): void;
  62545. /**
  62546. * Rebuilds the elements related to this component in case of
  62547. * context lost for instance.
  62548. */
  62549. rebuild(): void;
  62550. /**
  62551. * Disposes the component and the associated ressources
  62552. */
  62553. dispose(): void;
  62554. private _gatherRenderTargets;
  62555. private _gatherActiveCameraRenderTargets;
  62556. }
  62557. }
  62558. declare module BABYLON {
  62559. /** @hidden */
  62560. export var outlinePixelShader: {
  62561. name: string;
  62562. shader: string;
  62563. };
  62564. }
  62565. declare module BABYLON {
  62566. /** @hidden */
  62567. export var outlineVertexShader: {
  62568. name: string;
  62569. shader: string;
  62570. };
  62571. }
  62572. declare module BABYLON {
  62573. interface Scene {
  62574. /** @hidden */
  62575. _outlineRenderer: OutlineRenderer;
  62576. /**
  62577. * Gets the outline renderer associated with the scene
  62578. * @returns a OutlineRenderer
  62579. */
  62580. getOutlineRenderer(): OutlineRenderer;
  62581. }
  62582. interface AbstractMesh {
  62583. /** @hidden (Backing field) */
  62584. _renderOutline: boolean;
  62585. /**
  62586. * Gets or sets a boolean indicating if the outline must be rendered as well
  62587. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62588. */
  62589. renderOutline: boolean;
  62590. /** @hidden (Backing field) */
  62591. _renderOverlay: boolean;
  62592. /**
  62593. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62594. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62595. */
  62596. renderOverlay: boolean;
  62597. }
  62598. /**
  62599. * This class is responsible to draw bothe outline/overlay of meshes.
  62600. * It should not be used directly but through the available method on mesh.
  62601. */
  62602. export class OutlineRenderer implements ISceneComponent {
  62603. /**
  62604. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62605. */
  62606. private static _StencilReference;
  62607. /**
  62608. * The name of the component. Each component must have a unique name.
  62609. */
  62610. name: string;
  62611. /**
  62612. * The scene the component belongs to.
  62613. */
  62614. scene: Scene;
  62615. /**
  62616. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62617. */
  62618. zOffset: number;
  62619. private _engine;
  62620. private _effect;
  62621. private _cachedDefines;
  62622. private _savedDepthWrite;
  62623. /**
  62624. * Instantiates a new outline renderer. (There could be only one per scene).
  62625. * @param scene Defines the scene it belongs to
  62626. */
  62627. constructor(scene: Scene);
  62628. /**
  62629. * Register the component to one instance of a scene.
  62630. */
  62631. register(): void;
  62632. /**
  62633. * Rebuilds the elements related to this component in case of
  62634. * context lost for instance.
  62635. */
  62636. rebuild(): void;
  62637. /**
  62638. * Disposes the component and the associated ressources.
  62639. */
  62640. dispose(): void;
  62641. /**
  62642. * Renders the outline in the canvas.
  62643. * @param subMesh Defines the sumesh to render
  62644. * @param batch Defines the batch of meshes in case of instances
  62645. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62646. */
  62647. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62648. /**
  62649. * Returns whether or not the outline renderer is ready for a given submesh.
  62650. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62651. * @param subMesh Defines the submesh to check readyness for
  62652. * @param useInstances Defines wheter wee are trying to render instances or not
  62653. * @returns true if ready otherwise false
  62654. */
  62655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62656. private _beforeRenderingMesh;
  62657. private _afterRenderingMesh;
  62658. }
  62659. }
  62660. declare module BABYLON {
  62661. /**
  62662. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62663. * @see http://doc.babylonjs.com/babylon101/sprites
  62664. */
  62665. export class SpritePackedManager extends SpriteManager {
  62666. /** defines the packed manager's name */
  62667. name: string;
  62668. /**
  62669. * Creates a new sprite manager from a packed sprite sheet
  62670. * @param name defines the manager's name
  62671. * @param imgUrl defines the sprite sheet url
  62672. * @param capacity defines the maximum allowed number of sprites
  62673. * @param scene defines the hosting scene
  62674. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62675. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62676. * @param samplingMode defines the smapling mode to use with spritesheet
  62677. * @param fromPacked set to true; do not alter
  62678. */
  62679. constructor(
  62680. /** defines the packed manager's name */
  62681. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62682. }
  62683. }
  62684. declare module BABYLON {
  62685. /**
  62686. * Defines the list of states available for a task inside a AssetsManager
  62687. */
  62688. export enum AssetTaskState {
  62689. /**
  62690. * Initialization
  62691. */
  62692. INIT = 0,
  62693. /**
  62694. * Running
  62695. */
  62696. RUNNING = 1,
  62697. /**
  62698. * Done
  62699. */
  62700. DONE = 2,
  62701. /**
  62702. * Error
  62703. */
  62704. ERROR = 3
  62705. }
  62706. /**
  62707. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62708. */
  62709. export abstract class AbstractAssetTask {
  62710. /**
  62711. * Task name
  62712. */ name: string;
  62713. /**
  62714. * Callback called when the task is successful
  62715. */
  62716. onSuccess: (task: any) => void;
  62717. /**
  62718. * Callback called when the task is not successful
  62719. */
  62720. onError: (task: any, message?: string, exception?: any) => void;
  62721. /**
  62722. * Creates a new AssetsManager
  62723. * @param name defines the name of the task
  62724. */
  62725. constructor(
  62726. /**
  62727. * Task name
  62728. */ name: string);
  62729. private _isCompleted;
  62730. private _taskState;
  62731. private _errorObject;
  62732. /**
  62733. * Get if the task is completed
  62734. */
  62735. readonly isCompleted: boolean;
  62736. /**
  62737. * Gets the current state of the task
  62738. */
  62739. readonly taskState: AssetTaskState;
  62740. /**
  62741. * Gets the current error object (if task is in error)
  62742. */
  62743. readonly errorObject: {
  62744. message?: string;
  62745. exception?: any;
  62746. };
  62747. /**
  62748. * Internal only
  62749. * @hidden
  62750. */
  62751. _setErrorObject(message?: string, exception?: any): void;
  62752. /**
  62753. * Execute the current task
  62754. * @param scene defines the scene where you want your assets to be loaded
  62755. * @param onSuccess is a callback called when the task is successfully executed
  62756. * @param onError is a callback called if an error occurs
  62757. */
  62758. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62759. /**
  62760. * Execute the current task
  62761. * @param scene defines the scene where you want your assets to be loaded
  62762. * @param onSuccess is a callback called when the task is successfully executed
  62763. * @param onError is a callback called if an error occurs
  62764. */
  62765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62766. /**
  62767. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62768. * This can be used with failed tasks that have the reason for failure fixed.
  62769. */
  62770. reset(): void;
  62771. private onErrorCallback;
  62772. private onDoneCallback;
  62773. }
  62774. /**
  62775. * Define the interface used by progress events raised during assets loading
  62776. */
  62777. export interface IAssetsProgressEvent {
  62778. /**
  62779. * Defines the number of remaining tasks to process
  62780. */
  62781. remainingCount: number;
  62782. /**
  62783. * Defines the total number of tasks
  62784. */
  62785. totalCount: number;
  62786. /**
  62787. * Defines the task that was just processed
  62788. */
  62789. task: AbstractAssetTask;
  62790. }
  62791. /**
  62792. * Class used to share progress information about assets loading
  62793. */
  62794. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62795. /**
  62796. * Defines the number of remaining tasks to process
  62797. */
  62798. remainingCount: number;
  62799. /**
  62800. * Defines the total number of tasks
  62801. */
  62802. totalCount: number;
  62803. /**
  62804. * Defines the task that was just processed
  62805. */
  62806. task: AbstractAssetTask;
  62807. /**
  62808. * Creates a AssetsProgressEvent
  62809. * @param remainingCount defines the number of remaining tasks to process
  62810. * @param totalCount defines the total number of tasks
  62811. * @param task defines the task that was just processed
  62812. */
  62813. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62814. }
  62815. /**
  62816. * Define a task used by AssetsManager to load meshes
  62817. */
  62818. export class MeshAssetTask extends AbstractAssetTask {
  62819. /**
  62820. * Defines the name of the task
  62821. */
  62822. name: string;
  62823. /**
  62824. * Defines the list of mesh's names you want to load
  62825. */
  62826. meshesNames: any;
  62827. /**
  62828. * Defines the root url to use as a base to load your meshes and associated resources
  62829. */
  62830. rootUrl: string;
  62831. /**
  62832. * Defines the filename of the scene to load from
  62833. */
  62834. sceneFilename: string;
  62835. /**
  62836. * Gets the list of loaded meshes
  62837. */
  62838. loadedMeshes: Array<AbstractMesh>;
  62839. /**
  62840. * Gets the list of loaded particle systems
  62841. */
  62842. loadedParticleSystems: Array<IParticleSystem>;
  62843. /**
  62844. * Gets the list of loaded skeletons
  62845. */
  62846. loadedSkeletons: Array<Skeleton>;
  62847. /**
  62848. * Gets the list of loaded animation groups
  62849. */
  62850. loadedAnimationGroups: Array<AnimationGroup>;
  62851. /**
  62852. * Callback called when the task is successful
  62853. */
  62854. onSuccess: (task: MeshAssetTask) => void;
  62855. /**
  62856. * Callback called when the task is successful
  62857. */
  62858. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62859. /**
  62860. * Creates a new MeshAssetTask
  62861. * @param name defines the name of the task
  62862. * @param meshesNames defines the list of mesh's names you want to load
  62863. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62864. * @param sceneFilename defines the filename of the scene to load from
  62865. */
  62866. constructor(
  62867. /**
  62868. * Defines the name of the task
  62869. */
  62870. name: string,
  62871. /**
  62872. * Defines the list of mesh's names you want to load
  62873. */
  62874. meshesNames: any,
  62875. /**
  62876. * Defines the root url to use as a base to load your meshes and associated resources
  62877. */
  62878. rootUrl: string,
  62879. /**
  62880. * Defines the filename of the scene to load from
  62881. */
  62882. sceneFilename: string);
  62883. /**
  62884. * Execute the current task
  62885. * @param scene defines the scene where you want your assets to be loaded
  62886. * @param onSuccess is a callback called when the task is successfully executed
  62887. * @param onError is a callback called if an error occurs
  62888. */
  62889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62890. }
  62891. /**
  62892. * Define a task used by AssetsManager to load text content
  62893. */
  62894. export class TextFileAssetTask extends AbstractAssetTask {
  62895. /**
  62896. * Defines the name of the task
  62897. */
  62898. name: string;
  62899. /**
  62900. * Defines the location of the file to load
  62901. */
  62902. url: string;
  62903. /**
  62904. * Gets the loaded text string
  62905. */
  62906. text: string;
  62907. /**
  62908. * Callback called when the task is successful
  62909. */
  62910. onSuccess: (task: TextFileAssetTask) => void;
  62911. /**
  62912. * Callback called when the task is successful
  62913. */
  62914. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62915. /**
  62916. * Creates a new TextFileAssetTask object
  62917. * @param name defines the name of the task
  62918. * @param url defines the location of the file to load
  62919. */
  62920. constructor(
  62921. /**
  62922. * Defines the name of the task
  62923. */
  62924. name: string,
  62925. /**
  62926. * Defines the location of the file to load
  62927. */
  62928. url: string);
  62929. /**
  62930. * Execute the current task
  62931. * @param scene defines the scene where you want your assets to be loaded
  62932. * @param onSuccess is a callback called when the task is successfully executed
  62933. * @param onError is a callback called if an error occurs
  62934. */
  62935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62936. }
  62937. /**
  62938. * Define a task used by AssetsManager to load binary data
  62939. */
  62940. export class BinaryFileAssetTask extends AbstractAssetTask {
  62941. /**
  62942. * Defines the name of the task
  62943. */
  62944. name: string;
  62945. /**
  62946. * Defines the location of the file to load
  62947. */
  62948. url: string;
  62949. /**
  62950. * Gets the lodaded data (as an array buffer)
  62951. */
  62952. data: ArrayBuffer;
  62953. /**
  62954. * Callback called when the task is successful
  62955. */
  62956. onSuccess: (task: BinaryFileAssetTask) => void;
  62957. /**
  62958. * Callback called when the task is successful
  62959. */
  62960. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62961. /**
  62962. * Creates a new BinaryFileAssetTask object
  62963. * @param name defines the name of the new task
  62964. * @param url defines the location of the file to load
  62965. */
  62966. constructor(
  62967. /**
  62968. * Defines the name of the task
  62969. */
  62970. name: string,
  62971. /**
  62972. * Defines the location of the file to load
  62973. */
  62974. url: string);
  62975. /**
  62976. * Execute the current task
  62977. * @param scene defines the scene where you want your assets to be loaded
  62978. * @param onSuccess is a callback called when the task is successfully executed
  62979. * @param onError is a callback called if an error occurs
  62980. */
  62981. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62982. }
  62983. /**
  62984. * Define a task used by AssetsManager to load images
  62985. */
  62986. export class ImageAssetTask extends AbstractAssetTask {
  62987. /**
  62988. * Defines the name of the task
  62989. */
  62990. name: string;
  62991. /**
  62992. * Defines the location of the image to load
  62993. */
  62994. url: string;
  62995. /**
  62996. * Gets the loaded images
  62997. */
  62998. image: HTMLImageElement;
  62999. /**
  63000. * Callback called when the task is successful
  63001. */
  63002. onSuccess: (task: ImageAssetTask) => void;
  63003. /**
  63004. * Callback called when the task is successful
  63005. */
  63006. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  63007. /**
  63008. * Creates a new ImageAssetTask
  63009. * @param name defines the name of the task
  63010. * @param url defines the location of the image to load
  63011. */
  63012. constructor(
  63013. /**
  63014. * Defines the name of the task
  63015. */
  63016. name: string,
  63017. /**
  63018. * Defines the location of the image to load
  63019. */
  63020. url: string);
  63021. /**
  63022. * Execute the current task
  63023. * @param scene defines the scene where you want your assets to be loaded
  63024. * @param onSuccess is a callback called when the task is successfully executed
  63025. * @param onError is a callback called if an error occurs
  63026. */
  63027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63028. }
  63029. /**
  63030. * Defines the interface used by texture loading tasks
  63031. */
  63032. export interface ITextureAssetTask<TEX extends BaseTexture> {
  63033. /**
  63034. * Gets the loaded texture
  63035. */
  63036. texture: TEX;
  63037. }
  63038. /**
  63039. * Define a task used by AssetsManager to load 2D textures
  63040. */
  63041. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  63042. /**
  63043. * Defines the name of the task
  63044. */
  63045. name: string;
  63046. /**
  63047. * Defines the location of the file to load
  63048. */
  63049. url: string;
  63050. /**
  63051. * Defines if mipmap should not be generated (default is false)
  63052. */
  63053. noMipmap?: boolean | undefined;
  63054. /**
  63055. * Defines if texture must be inverted on Y axis (default is false)
  63056. */
  63057. invertY?: boolean | undefined;
  63058. /**
  63059. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63060. */
  63061. samplingMode: number;
  63062. /**
  63063. * Gets the loaded texture
  63064. */
  63065. texture: Texture;
  63066. /**
  63067. * Callback called when the task is successful
  63068. */
  63069. onSuccess: (task: TextureAssetTask) => void;
  63070. /**
  63071. * Callback called when the task is successful
  63072. */
  63073. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  63074. /**
  63075. * Creates a new TextureAssetTask object
  63076. * @param name defines the name of the task
  63077. * @param url defines the location of the file to load
  63078. * @param noMipmap defines if mipmap should not be generated (default is false)
  63079. * @param invertY defines if texture must be inverted on Y axis (default is false)
  63080. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63081. */
  63082. constructor(
  63083. /**
  63084. * Defines the name of the task
  63085. */
  63086. name: string,
  63087. /**
  63088. * Defines the location of the file to load
  63089. */
  63090. url: string,
  63091. /**
  63092. * Defines if mipmap should not be generated (default is false)
  63093. */
  63094. noMipmap?: boolean | undefined,
  63095. /**
  63096. * Defines if texture must be inverted on Y axis (default is false)
  63097. */
  63098. invertY?: boolean | undefined,
  63099. /**
  63100. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  63101. */
  63102. samplingMode?: number);
  63103. /**
  63104. * Execute the current task
  63105. * @param scene defines the scene where you want your assets to be loaded
  63106. * @param onSuccess is a callback called when the task is successfully executed
  63107. * @param onError is a callback called if an error occurs
  63108. */
  63109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63110. }
  63111. /**
  63112. * Define a task used by AssetsManager to load cube textures
  63113. */
  63114. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  63115. /**
  63116. * Defines the name of the task
  63117. */
  63118. name: string;
  63119. /**
  63120. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63121. */
  63122. url: string;
  63123. /**
  63124. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63125. */
  63126. extensions?: string[] | undefined;
  63127. /**
  63128. * Defines if mipmaps should not be generated (default is false)
  63129. */
  63130. noMipmap?: boolean | undefined;
  63131. /**
  63132. * Defines the explicit list of files (undefined by default)
  63133. */
  63134. files?: string[] | undefined;
  63135. /**
  63136. * Gets the loaded texture
  63137. */
  63138. texture: CubeTexture;
  63139. /**
  63140. * Callback called when the task is successful
  63141. */
  63142. onSuccess: (task: CubeTextureAssetTask) => void;
  63143. /**
  63144. * Callback called when the task is successful
  63145. */
  63146. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  63147. /**
  63148. * Creates a new CubeTextureAssetTask
  63149. * @param name defines the name of the task
  63150. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63151. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63152. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63153. * @param files defines the explicit list of files (undefined by default)
  63154. */
  63155. constructor(
  63156. /**
  63157. * Defines the name of the task
  63158. */
  63159. name: string,
  63160. /**
  63161. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  63162. */
  63163. url: string,
  63164. /**
  63165. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  63166. */
  63167. extensions?: string[] | undefined,
  63168. /**
  63169. * Defines if mipmaps should not be generated (default is false)
  63170. */
  63171. noMipmap?: boolean | undefined,
  63172. /**
  63173. * Defines the explicit list of files (undefined by default)
  63174. */
  63175. files?: string[] | undefined);
  63176. /**
  63177. * Execute the current task
  63178. * @param scene defines the scene where you want your assets to be loaded
  63179. * @param onSuccess is a callback called when the task is successfully executed
  63180. * @param onError is a callback called if an error occurs
  63181. */
  63182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63183. }
  63184. /**
  63185. * Define a task used by AssetsManager to load HDR cube textures
  63186. */
  63187. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  63188. /**
  63189. * Defines the name of the task
  63190. */
  63191. name: string;
  63192. /**
  63193. * Defines the location of the file to load
  63194. */
  63195. url: string;
  63196. /**
  63197. * Defines the desired size (the more it increases the longer the generation will be)
  63198. */
  63199. size: number;
  63200. /**
  63201. * Defines if mipmaps should not be generated (default is false)
  63202. */
  63203. noMipmap: boolean;
  63204. /**
  63205. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63206. */
  63207. generateHarmonics: boolean;
  63208. /**
  63209. * 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)
  63210. */
  63211. gammaSpace: boolean;
  63212. /**
  63213. * Internal Use Only
  63214. */
  63215. reserved: boolean;
  63216. /**
  63217. * Gets the loaded texture
  63218. */
  63219. texture: HDRCubeTexture;
  63220. /**
  63221. * Callback called when the task is successful
  63222. */
  63223. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  63224. /**
  63225. * Callback called when the task is successful
  63226. */
  63227. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  63228. /**
  63229. * Creates a new HDRCubeTextureAssetTask object
  63230. * @param name defines the name of the task
  63231. * @param url defines the location of the file to load
  63232. * @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.
  63233. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63234. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63235. * @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)
  63236. * @param reserved Internal use only
  63237. */
  63238. constructor(
  63239. /**
  63240. * Defines the name of the task
  63241. */
  63242. name: string,
  63243. /**
  63244. * Defines the location of the file to load
  63245. */
  63246. url: string,
  63247. /**
  63248. * Defines the desired size (the more it increases the longer the generation will be)
  63249. */
  63250. size: number,
  63251. /**
  63252. * Defines if mipmaps should not be generated (default is false)
  63253. */
  63254. noMipmap?: boolean,
  63255. /**
  63256. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  63257. */
  63258. generateHarmonics?: boolean,
  63259. /**
  63260. * 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)
  63261. */
  63262. gammaSpace?: boolean,
  63263. /**
  63264. * Internal Use Only
  63265. */
  63266. reserved?: boolean);
  63267. /**
  63268. * Execute the current task
  63269. * @param scene defines the scene where you want your assets to be loaded
  63270. * @param onSuccess is a callback called when the task is successfully executed
  63271. * @param onError is a callback called if an error occurs
  63272. */
  63273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63274. }
  63275. /**
  63276. * Define a task used by AssetsManager to load Equirectangular cube textures
  63277. */
  63278. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63279. /**
  63280. * Defines the name of the task
  63281. */
  63282. name: string;
  63283. /**
  63284. * Defines the location of the file to load
  63285. */
  63286. url: string;
  63287. /**
  63288. * Defines the desired size (the more it increases the longer the generation will be)
  63289. */
  63290. size: number;
  63291. /**
  63292. * Defines if mipmaps should not be generated (default is false)
  63293. */
  63294. noMipmap: boolean;
  63295. /**
  63296. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63297. * but the standard material would require them in Gamma space) (default is true)
  63298. */
  63299. gammaSpace: boolean;
  63300. /**
  63301. * Gets the loaded texture
  63302. */
  63303. texture: EquiRectangularCubeTexture;
  63304. /**
  63305. * Callback called when the task is successful
  63306. */
  63307. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63308. /**
  63309. * Callback called when the task is successful
  63310. */
  63311. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63312. /**
  63313. * Creates a new EquiRectangularCubeTextureAssetTask object
  63314. * @param name defines the name of the task
  63315. * @param url defines the location of the file to load
  63316. * @param size defines the desired size (the more it increases the longer the generation will be)
  63317. * If the size is omitted this implies you are using a preprocessed cubemap.
  63318. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63319. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63320. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63321. * (default is true)
  63322. */
  63323. constructor(
  63324. /**
  63325. * Defines the name of the task
  63326. */
  63327. name: string,
  63328. /**
  63329. * Defines the location of the file to load
  63330. */
  63331. url: string,
  63332. /**
  63333. * Defines the desired size (the more it increases the longer the generation will be)
  63334. */
  63335. size: number,
  63336. /**
  63337. * Defines if mipmaps should not be generated (default is false)
  63338. */
  63339. noMipmap?: boolean,
  63340. /**
  63341. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63342. * but the standard material would require them in Gamma space) (default is true)
  63343. */
  63344. gammaSpace?: boolean);
  63345. /**
  63346. * Execute the current task
  63347. * @param scene defines the scene where you want your assets to be loaded
  63348. * @param onSuccess is a callback called when the task is successfully executed
  63349. * @param onError is a callback called if an error occurs
  63350. */
  63351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63352. }
  63353. /**
  63354. * This class can be used to easily import assets into a scene
  63355. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63356. */
  63357. export class AssetsManager {
  63358. private _scene;
  63359. private _isLoading;
  63360. protected _tasks: AbstractAssetTask[];
  63361. protected _waitingTasksCount: number;
  63362. protected _totalTasksCount: number;
  63363. /**
  63364. * Callback called when all tasks are processed
  63365. */
  63366. onFinish: (tasks: AbstractAssetTask[]) => void;
  63367. /**
  63368. * Callback called when a task is successful
  63369. */
  63370. onTaskSuccess: (task: AbstractAssetTask) => void;
  63371. /**
  63372. * Callback called when a task had an error
  63373. */
  63374. onTaskError: (task: AbstractAssetTask) => void;
  63375. /**
  63376. * Callback called when a task is done (whatever the result is)
  63377. */
  63378. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63379. /**
  63380. * Observable called when all tasks are processed
  63381. */
  63382. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63383. /**
  63384. * Observable called when a task had an error
  63385. */
  63386. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63387. /**
  63388. * Observable called when all tasks were executed
  63389. */
  63390. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63391. /**
  63392. * Observable called when a task is done (whatever the result is)
  63393. */
  63394. onProgressObservable: Observable<IAssetsProgressEvent>;
  63395. /**
  63396. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63398. */
  63399. useDefaultLoadingScreen: boolean;
  63400. /**
  63401. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63402. * when all assets have been downloaded.
  63403. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63404. */
  63405. autoHideLoadingUI: boolean;
  63406. /**
  63407. * Creates a new AssetsManager
  63408. * @param scene defines the scene to work on
  63409. */
  63410. constructor(scene: Scene);
  63411. /**
  63412. * Add a MeshAssetTask to the list of active tasks
  63413. * @param taskName defines the name of the new task
  63414. * @param meshesNames defines the name of meshes to load
  63415. * @param rootUrl defines the root url to use to locate files
  63416. * @param sceneFilename defines the filename of the scene file
  63417. * @returns a new MeshAssetTask object
  63418. */
  63419. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63420. /**
  63421. * Add a TextFileAssetTask to the list of active tasks
  63422. * @param taskName defines the name of the new task
  63423. * @param url defines the url of the file to load
  63424. * @returns a new TextFileAssetTask object
  63425. */
  63426. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63427. /**
  63428. * Add a BinaryFileAssetTask to the list of active tasks
  63429. * @param taskName defines the name of the new task
  63430. * @param url defines the url of the file to load
  63431. * @returns a new BinaryFileAssetTask object
  63432. */
  63433. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63434. /**
  63435. * Add a ImageAssetTask to the list of active tasks
  63436. * @param taskName defines the name of the new task
  63437. * @param url defines the url of the file to load
  63438. * @returns a new ImageAssetTask object
  63439. */
  63440. addImageTask(taskName: string, url: string): ImageAssetTask;
  63441. /**
  63442. * Add a TextureAssetTask to the list of active tasks
  63443. * @param taskName defines the name of the new task
  63444. * @param url defines the url of the file to load
  63445. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63446. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63447. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63448. * @returns a new TextureAssetTask object
  63449. */
  63450. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63451. /**
  63452. * Add a CubeTextureAssetTask to the list of active tasks
  63453. * @param taskName defines the name of the new task
  63454. * @param url defines the url of the file to load
  63455. * @param extensions defines the extension to use to load the cube map (can be null)
  63456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63457. * @param files defines the list of files to load (can be null)
  63458. * @returns a new CubeTextureAssetTask object
  63459. */
  63460. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63461. /**
  63462. *
  63463. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63464. * @param taskName defines the name of the new task
  63465. * @param url defines the url of the file to load
  63466. * @param size defines the size you want for the cubemap (can be null)
  63467. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63468. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63469. * @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)
  63470. * @param reserved Internal use only
  63471. * @returns a new HDRCubeTextureAssetTask object
  63472. */
  63473. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63474. /**
  63475. *
  63476. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63477. * @param taskName defines the name of the new task
  63478. * @param url defines the url of the file to load
  63479. * @param size defines the size you want for the cubemap (can be null)
  63480. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63481. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63482. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63483. * @returns a new EquiRectangularCubeTextureAssetTask object
  63484. */
  63485. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63486. /**
  63487. * Remove a task from the assets manager.
  63488. * @param task the task to remove
  63489. */
  63490. removeTask(task: AbstractAssetTask): void;
  63491. private _decreaseWaitingTasksCount;
  63492. private _runTask;
  63493. /**
  63494. * Reset the AssetsManager and remove all tasks
  63495. * @return the current instance of the AssetsManager
  63496. */
  63497. reset(): AssetsManager;
  63498. /**
  63499. * Start the loading process
  63500. * @return the current instance of the AssetsManager
  63501. */
  63502. load(): AssetsManager;
  63503. /**
  63504. * Start the loading process as an async operation
  63505. * @return a promise returning the list of failed tasks
  63506. */
  63507. loadAsync(): Promise<void>;
  63508. }
  63509. }
  63510. declare module BABYLON {
  63511. /**
  63512. * Wrapper class for promise with external resolve and reject.
  63513. */
  63514. export class Deferred<T> {
  63515. /**
  63516. * The promise associated with this deferred object.
  63517. */
  63518. readonly promise: Promise<T>;
  63519. private _resolve;
  63520. private _reject;
  63521. /**
  63522. * The resolve method of the promise associated with this deferred object.
  63523. */
  63524. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63525. /**
  63526. * The reject method of the promise associated with this deferred object.
  63527. */
  63528. readonly reject: (reason?: any) => void;
  63529. /**
  63530. * Constructor for this deferred object.
  63531. */
  63532. constructor();
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /**
  63537. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63538. */
  63539. export class MeshExploder {
  63540. private _centerMesh;
  63541. private _meshes;
  63542. private _meshesOrigins;
  63543. private _toCenterVectors;
  63544. private _scaledDirection;
  63545. private _newPosition;
  63546. private _centerPosition;
  63547. /**
  63548. * Explodes meshes from a center mesh.
  63549. * @param meshes The meshes to explode.
  63550. * @param centerMesh The mesh to be center of explosion.
  63551. */
  63552. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63553. private _setCenterMesh;
  63554. /**
  63555. * Get class name
  63556. * @returns "MeshExploder"
  63557. */
  63558. getClassName(): string;
  63559. /**
  63560. * "Exploded meshes"
  63561. * @returns Array of meshes with the centerMesh at index 0.
  63562. */
  63563. getMeshes(): Array<Mesh>;
  63564. /**
  63565. * Explodes meshes giving a specific direction
  63566. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63567. */
  63568. explode(direction?: number): void;
  63569. }
  63570. }
  63571. declare module BABYLON {
  63572. /**
  63573. * Class used to help managing file picking and drag'n'drop
  63574. */
  63575. export class FilesInput {
  63576. /**
  63577. * List of files ready to be loaded
  63578. */
  63579. static readonly FilesToLoad: {
  63580. [key: string]: File;
  63581. };
  63582. /**
  63583. * Callback called when a file is processed
  63584. */
  63585. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63586. private _engine;
  63587. private _currentScene;
  63588. private _sceneLoadedCallback;
  63589. private _progressCallback;
  63590. private _additionalRenderLoopLogicCallback;
  63591. private _textureLoadingCallback;
  63592. private _startingProcessingFilesCallback;
  63593. private _onReloadCallback;
  63594. private _errorCallback;
  63595. private _elementToMonitor;
  63596. private _sceneFileToLoad;
  63597. private _filesToLoad;
  63598. /**
  63599. * Creates a new FilesInput
  63600. * @param engine defines the rendering engine
  63601. * @param scene defines the hosting scene
  63602. * @param sceneLoadedCallback callback called when scene is loaded
  63603. * @param progressCallback callback called to track progress
  63604. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63605. * @param textureLoadingCallback callback called when a texture is loading
  63606. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63607. * @param onReloadCallback callback called when a reload is requested
  63608. * @param errorCallback callback call if an error occurs
  63609. */
  63610. 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);
  63611. private _dragEnterHandler;
  63612. private _dragOverHandler;
  63613. private _dropHandler;
  63614. /**
  63615. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63616. * @param elementToMonitor defines the DOM element to track
  63617. */
  63618. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63619. /**
  63620. * Release all associated resources
  63621. */
  63622. dispose(): void;
  63623. private renderFunction;
  63624. private drag;
  63625. private drop;
  63626. private _traverseFolder;
  63627. private _processFiles;
  63628. /**
  63629. * Load files from a drop event
  63630. * @param event defines the drop event to use as source
  63631. */
  63632. loadFiles(event: any): void;
  63633. private _processReload;
  63634. /**
  63635. * Reload the current scene from the loaded files
  63636. */
  63637. reload(): void;
  63638. }
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63644. */
  63645. export class SceneOptimization {
  63646. /**
  63647. * Defines the priority of this optimization (0 by default which means first in the list)
  63648. */
  63649. priority: number;
  63650. /**
  63651. * Gets a string describing the action executed by the current optimization
  63652. * @returns description string
  63653. */
  63654. getDescription(): string;
  63655. /**
  63656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63657. * @param scene defines the current scene where to apply this optimization
  63658. * @param optimizer defines the current optimizer
  63659. * @returns true if everything that can be done was applied
  63660. */
  63661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63662. /**
  63663. * Creates the SceneOptimization object
  63664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63665. * @param desc defines the description associated with the optimization
  63666. */
  63667. constructor(
  63668. /**
  63669. * Defines the priority of this optimization (0 by default which means first in the list)
  63670. */
  63671. priority?: number);
  63672. }
  63673. /**
  63674. * Defines an optimization used to reduce the size of render target textures
  63675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63676. */
  63677. export class TextureOptimization extends SceneOptimization {
  63678. /**
  63679. * Defines the priority of this optimization (0 by default which means first in the list)
  63680. */
  63681. priority: number;
  63682. /**
  63683. * 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
  63684. */
  63685. maximumSize: number;
  63686. /**
  63687. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63688. */
  63689. step: number;
  63690. /**
  63691. * Gets a string describing the action executed by the current optimization
  63692. * @returns description string
  63693. */
  63694. getDescription(): string;
  63695. /**
  63696. * Creates the TextureOptimization object
  63697. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63698. * @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
  63699. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63700. */
  63701. constructor(
  63702. /**
  63703. * Defines the priority of this optimization (0 by default which means first in the list)
  63704. */
  63705. priority?: number,
  63706. /**
  63707. * 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
  63708. */
  63709. maximumSize?: number,
  63710. /**
  63711. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63712. */
  63713. step?: number);
  63714. /**
  63715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63716. * @param scene defines the current scene where to apply this optimization
  63717. * @param optimizer defines the current optimizer
  63718. * @returns true if everything that can be done was applied
  63719. */
  63720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63721. }
  63722. /**
  63723. * Defines an optimization used to increase or decrease the rendering resolution
  63724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63725. */
  63726. export class HardwareScalingOptimization extends SceneOptimization {
  63727. /**
  63728. * Defines the priority of this optimization (0 by default which means first in the list)
  63729. */
  63730. priority: number;
  63731. /**
  63732. * Defines the maximum scale to use (2 by default)
  63733. */
  63734. maximumScale: number;
  63735. /**
  63736. * Defines the step to use between two passes (0.5 by default)
  63737. */
  63738. step: number;
  63739. private _currentScale;
  63740. private _directionOffset;
  63741. /**
  63742. * Gets a string describing the action executed by the current optimization
  63743. * @return description string
  63744. */
  63745. getDescription(): string;
  63746. /**
  63747. * Creates the HardwareScalingOptimization object
  63748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63749. * @param maximumScale defines the maximum scale to use (2 by default)
  63750. * @param step defines the step to use between two passes (0.5 by default)
  63751. */
  63752. constructor(
  63753. /**
  63754. * Defines the priority of this optimization (0 by default which means first in the list)
  63755. */
  63756. priority?: number,
  63757. /**
  63758. * Defines the maximum scale to use (2 by default)
  63759. */
  63760. maximumScale?: number,
  63761. /**
  63762. * Defines the step to use between two passes (0.5 by default)
  63763. */
  63764. step?: number);
  63765. /**
  63766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63767. * @param scene defines the current scene where to apply this optimization
  63768. * @param optimizer defines the current optimizer
  63769. * @returns true if everything that can be done was applied
  63770. */
  63771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63772. }
  63773. /**
  63774. * Defines an optimization used to remove shadows
  63775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63776. */
  63777. export class ShadowsOptimization extends SceneOptimization {
  63778. /**
  63779. * Gets a string describing the action executed by the current optimization
  63780. * @return description string
  63781. */
  63782. getDescription(): string;
  63783. /**
  63784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63785. * @param scene defines the current scene where to apply this optimization
  63786. * @param optimizer defines the current optimizer
  63787. * @returns true if everything that can be done was applied
  63788. */
  63789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63790. }
  63791. /**
  63792. * Defines an optimization used to turn post-processes off
  63793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63794. */
  63795. export class PostProcessesOptimization extends SceneOptimization {
  63796. /**
  63797. * Gets a string describing the action executed by the current optimization
  63798. * @return description string
  63799. */
  63800. getDescription(): string;
  63801. /**
  63802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63803. * @param scene defines the current scene where to apply this optimization
  63804. * @param optimizer defines the current optimizer
  63805. * @returns true if everything that can be done was applied
  63806. */
  63807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63808. }
  63809. /**
  63810. * Defines an optimization used to turn lens flares off
  63811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63812. */
  63813. export class LensFlaresOptimization extends SceneOptimization {
  63814. /**
  63815. * Gets a string describing the action executed by the current optimization
  63816. * @return description string
  63817. */
  63818. getDescription(): string;
  63819. /**
  63820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63821. * @param scene defines the current scene where to apply this optimization
  63822. * @param optimizer defines the current optimizer
  63823. * @returns true if everything that can be done was applied
  63824. */
  63825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63826. }
  63827. /**
  63828. * Defines an optimization based on user defined callback.
  63829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63830. */
  63831. export class CustomOptimization extends SceneOptimization {
  63832. /**
  63833. * Callback called to apply the custom optimization.
  63834. */
  63835. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63836. /**
  63837. * Callback called to get custom description
  63838. */
  63839. onGetDescription: () => string;
  63840. /**
  63841. * Gets a string describing the action executed by the current optimization
  63842. * @returns description string
  63843. */
  63844. getDescription(): string;
  63845. /**
  63846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63847. * @param scene defines the current scene where to apply this optimization
  63848. * @param optimizer defines the current optimizer
  63849. * @returns true if everything that can be done was applied
  63850. */
  63851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63852. }
  63853. /**
  63854. * Defines an optimization used to turn particles off
  63855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63856. */
  63857. export class ParticlesOptimization extends SceneOptimization {
  63858. /**
  63859. * Gets a string describing the action executed by the current optimization
  63860. * @return description string
  63861. */
  63862. getDescription(): string;
  63863. /**
  63864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63865. * @param scene defines the current scene where to apply this optimization
  63866. * @param optimizer defines the current optimizer
  63867. * @returns true if everything that can be done was applied
  63868. */
  63869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63870. }
  63871. /**
  63872. * Defines an optimization used to turn render targets off
  63873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63874. */
  63875. export class RenderTargetsOptimization extends SceneOptimization {
  63876. /**
  63877. * Gets a string describing the action executed by the current optimization
  63878. * @return description string
  63879. */
  63880. getDescription(): string;
  63881. /**
  63882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63883. * @param scene defines the current scene where to apply this optimization
  63884. * @param optimizer defines the current optimizer
  63885. * @returns true if everything that can be done was applied
  63886. */
  63887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63888. }
  63889. /**
  63890. * Defines an optimization used to merge meshes with compatible materials
  63891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63892. */
  63893. export class MergeMeshesOptimization extends SceneOptimization {
  63894. private static _UpdateSelectionTree;
  63895. /**
  63896. * Gets or sets a boolean which defines if optimization octree has to be updated
  63897. */
  63898. /**
  63899. * Gets or sets a boolean which defines if optimization octree has to be updated
  63900. */
  63901. static UpdateSelectionTree: boolean;
  63902. /**
  63903. * Gets a string describing the action executed by the current optimization
  63904. * @return description string
  63905. */
  63906. getDescription(): string;
  63907. private _canBeMerged;
  63908. /**
  63909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63910. * @param scene defines the current scene where to apply this optimization
  63911. * @param optimizer defines the current optimizer
  63912. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63913. * @returns true if everything that can be done was applied
  63914. */
  63915. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63916. }
  63917. /**
  63918. * Defines a list of options used by SceneOptimizer
  63919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63920. */
  63921. export class SceneOptimizerOptions {
  63922. /**
  63923. * Defines the target frame rate to reach (60 by default)
  63924. */
  63925. targetFrameRate: number;
  63926. /**
  63927. * Defines the interval between two checkes (2000ms by default)
  63928. */
  63929. trackerDuration: number;
  63930. /**
  63931. * Gets the list of optimizations to apply
  63932. */
  63933. optimizations: SceneOptimization[];
  63934. /**
  63935. * Creates a new list of options used by SceneOptimizer
  63936. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63937. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63938. */
  63939. constructor(
  63940. /**
  63941. * Defines the target frame rate to reach (60 by default)
  63942. */
  63943. targetFrameRate?: number,
  63944. /**
  63945. * Defines the interval between two checkes (2000ms by default)
  63946. */
  63947. trackerDuration?: number);
  63948. /**
  63949. * Add a new optimization
  63950. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63951. * @returns the current SceneOptimizerOptions
  63952. */
  63953. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63954. /**
  63955. * Add a new custom optimization
  63956. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63957. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63958. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63959. * @returns the current SceneOptimizerOptions
  63960. */
  63961. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63962. /**
  63963. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63964. * @param targetFrameRate defines the target frame rate (60 by default)
  63965. * @returns a SceneOptimizerOptions object
  63966. */
  63967. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63968. /**
  63969. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63970. * @param targetFrameRate defines the target frame rate (60 by default)
  63971. * @returns a SceneOptimizerOptions object
  63972. */
  63973. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63974. /**
  63975. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63976. * @param targetFrameRate defines the target frame rate (60 by default)
  63977. * @returns a SceneOptimizerOptions object
  63978. */
  63979. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63980. }
  63981. /**
  63982. * Class used to run optimizations in order to reach a target frame rate
  63983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63984. */
  63985. export class SceneOptimizer implements IDisposable {
  63986. private _isRunning;
  63987. private _options;
  63988. private _scene;
  63989. private _currentPriorityLevel;
  63990. private _targetFrameRate;
  63991. private _trackerDuration;
  63992. private _currentFrameRate;
  63993. private _sceneDisposeObserver;
  63994. private _improvementMode;
  63995. /**
  63996. * Defines an observable called when the optimizer reaches the target frame rate
  63997. */
  63998. onSuccessObservable: Observable<SceneOptimizer>;
  63999. /**
  64000. * Defines an observable called when the optimizer enables an optimization
  64001. */
  64002. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  64003. /**
  64004. * Defines an observable called when the optimizer is not able to reach the target frame rate
  64005. */
  64006. onFailureObservable: Observable<SceneOptimizer>;
  64007. /**
  64008. * Gets a boolean indicating if the optimizer is in improvement mode
  64009. */
  64010. readonly isInImprovementMode: boolean;
  64011. /**
  64012. * Gets the current priority level (0 at start)
  64013. */
  64014. readonly currentPriorityLevel: number;
  64015. /**
  64016. * Gets the current frame rate checked by the SceneOptimizer
  64017. */
  64018. readonly currentFrameRate: number;
  64019. /**
  64020. * Gets or sets the current target frame rate (60 by default)
  64021. */
  64022. /**
  64023. * Gets or sets the current target frame rate (60 by default)
  64024. */
  64025. targetFrameRate: number;
  64026. /**
  64027. * Gets or sets the current interval between two checks (every 2000ms by default)
  64028. */
  64029. /**
  64030. * Gets or sets the current interval between two checks (every 2000ms by default)
  64031. */
  64032. trackerDuration: number;
  64033. /**
  64034. * Gets the list of active optimizations
  64035. */
  64036. readonly optimizations: SceneOptimization[];
  64037. /**
  64038. * Creates a new SceneOptimizer
  64039. * @param scene defines the scene to work on
  64040. * @param options defines the options to use with the SceneOptimizer
  64041. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  64042. * @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)
  64043. */
  64044. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  64045. /**
  64046. * Stops the current optimizer
  64047. */
  64048. stop(): void;
  64049. /**
  64050. * Reset the optimizer to initial step (current priority level = 0)
  64051. */
  64052. reset(): void;
  64053. /**
  64054. * Start the optimizer. By default it will try to reach a specific framerate
  64055. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  64056. */
  64057. start(): void;
  64058. private _checkCurrentState;
  64059. /**
  64060. * Release all resources
  64061. */
  64062. dispose(): void;
  64063. /**
  64064. * Helper function to create a SceneOptimizer with one single line of code
  64065. * @param scene defines the scene to work on
  64066. * @param options defines the options to use with the SceneOptimizer
  64067. * @param onSuccess defines a callback to call on success
  64068. * @param onFailure defines a callback to call on failure
  64069. * @returns the new SceneOptimizer object
  64070. */
  64071. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  64072. }
  64073. }
  64074. declare module BABYLON {
  64075. /**
  64076. * Class used to serialize a scene into a string
  64077. */
  64078. export class SceneSerializer {
  64079. /**
  64080. * Clear cache used by a previous serialization
  64081. */
  64082. static ClearCache(): void;
  64083. /**
  64084. * Serialize a scene into a JSON compatible object
  64085. * @param scene defines the scene to serialize
  64086. * @returns a JSON compatible object
  64087. */
  64088. static Serialize(scene: Scene): any;
  64089. /**
  64090. * Serialize a mesh into a JSON compatible object
  64091. * @param toSerialize defines the mesh to serialize
  64092. * @param withParents defines if parents must be serialized as well
  64093. * @param withChildren defines if children must be serialized as well
  64094. * @returns a JSON compatible object
  64095. */
  64096. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  64097. }
  64098. }
  64099. declare module BABYLON {
  64100. /**
  64101. * Class used to host texture specific utilities
  64102. */
  64103. export class TextureTools {
  64104. /**
  64105. * Uses the GPU to create a copy texture rescaled at a given size
  64106. * @param texture Texture to copy from
  64107. * @param width defines the desired width
  64108. * @param height defines the desired height
  64109. * @param useBilinearMode defines if bilinear mode has to be used
  64110. * @return the generated texture
  64111. */
  64112. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  64113. }
  64114. }
  64115. declare module BABYLON {
  64116. /**
  64117. * This represents the different options available for the video capture.
  64118. */
  64119. export interface VideoRecorderOptions {
  64120. /** Defines the mime type of the video. */
  64121. mimeType: string;
  64122. /** Defines the FPS the video should be recorded at. */
  64123. fps: number;
  64124. /** Defines the chunk size for the recording data. */
  64125. recordChunckSize: number;
  64126. /** The audio tracks to attach to the recording. */
  64127. audioTracks?: MediaStreamTrack[];
  64128. }
  64129. /**
  64130. * This can help with recording videos from BabylonJS.
  64131. * This is based on the available WebRTC functionalities of the browser.
  64132. *
  64133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  64134. */
  64135. export class VideoRecorder {
  64136. private static readonly _defaultOptions;
  64137. /**
  64138. * Returns whether or not the VideoRecorder is available in your browser.
  64139. * @param engine Defines the Babylon Engine.
  64140. * @returns true if supported otherwise false.
  64141. */
  64142. static IsSupported(engine: Engine): boolean;
  64143. private readonly _options;
  64144. private _canvas;
  64145. private _mediaRecorder;
  64146. private _recordedChunks;
  64147. private _fileName;
  64148. private _resolve;
  64149. private _reject;
  64150. /**
  64151. * True when a recording is already in progress.
  64152. */
  64153. readonly isRecording: boolean;
  64154. /**
  64155. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  64156. * @param engine Defines the BabylonJS Engine you wish to record.
  64157. * @param options Defines options that can be used to customize the capture.
  64158. */
  64159. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  64160. /**
  64161. * Stops the current recording before the default capture timeout passed in the startRecording function.
  64162. */
  64163. stopRecording(): void;
  64164. /**
  64165. * Starts recording the canvas for a max duration specified in parameters.
  64166. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  64167. * If null no automatic download will start and you can rely on the promise to get the data back.
  64168. * @param maxDuration Defines the maximum recording time in seconds.
  64169. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  64170. * @return A promise callback at the end of the recording with the video data in Blob.
  64171. */
  64172. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  64173. /**
  64174. * Releases internal resources used during the recording.
  64175. */
  64176. dispose(): void;
  64177. private _handleDataAvailable;
  64178. private _handleError;
  64179. private _handleStop;
  64180. }
  64181. }
  64182. declare module BABYLON {
  64183. /**
  64184. * Class containing a set of static utilities functions for screenshots
  64185. */
  64186. export class ScreenshotTools {
  64187. /**
  64188. * Captures a screenshot of the current rendering
  64189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64190. * @param engine defines the rendering engine
  64191. * @param camera defines the source camera
  64192. * @param size This parameter can be set to a single number or to an object with the
  64193. * following (optional) properties: precision, width, height. If a single number is passed,
  64194. * it will be used for both width and height. If an object is passed, the screenshot size
  64195. * will be derived from the parameters. The precision property is a multiplier allowing
  64196. * rendering at a higher or lower resolution
  64197. * @param successCallback defines the callback receives a single parameter which contains the
  64198. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64199. * src parameter of an <img> to display it
  64200. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64201. * Check your browser for supported MIME types
  64202. */
  64203. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  64204. /**
  64205. * Captures a screenshot of the current rendering
  64206. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64207. * @param engine defines the rendering engine
  64208. * @param camera defines the source camera
  64209. * @param size This parameter can be set to a single number or to an object with the
  64210. * following (optional) properties: precision, width, height. If a single number is passed,
  64211. * it will be used for both width and height. If an object is passed, the screenshot size
  64212. * will be derived from the parameters. The precision property is a multiplier allowing
  64213. * rendering at a higher or lower resolution
  64214. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  64215. * Check your browser for supported MIME types
  64216. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64217. * to the src parameter of an <img> to display it
  64218. */
  64219. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  64220. /**
  64221. * Generates an image screenshot from the specified camera.
  64222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64223. * @param engine The engine to use for rendering
  64224. * @param camera The camera to use for rendering
  64225. * @param size This parameter can be set to a single number or to an object with the
  64226. * following (optional) properties: precision, width, height. If a single number is passed,
  64227. * it will be used for both width and height. If an object is passed, the screenshot size
  64228. * will be derived from the parameters. The precision property is a multiplier allowing
  64229. * rendering at a higher or lower resolution
  64230. * @param successCallback The callback receives a single parameter which contains the
  64231. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  64232. * src parameter of an <img> to display it
  64233. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64234. * Check your browser for supported MIME types
  64235. * @param samples Texture samples (default: 1)
  64236. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64237. * @param fileName A name for for the downloaded file.
  64238. */
  64239. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  64240. /**
  64241. * Generates an image screenshot from the specified camera.
  64242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64243. * @param engine The engine to use for rendering
  64244. * @param camera The camera to use for rendering
  64245. * @param size This parameter can be set to a single number or to an object with the
  64246. * following (optional) properties: precision, width, height. If a single number is passed,
  64247. * it will be used for both width and height. If an object is passed, the screenshot size
  64248. * will be derived from the parameters. The precision property is a multiplier allowing
  64249. * rendering at a higher or lower resolution
  64250. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64251. * Check your browser for supported MIME types
  64252. * @param samples Texture samples (default: 1)
  64253. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64254. * @param fileName A name for for the downloaded file.
  64255. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64256. * to the src parameter of an <img> to display it
  64257. */
  64258. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64259. /**
  64260. * Gets height and width for screenshot size
  64261. * @private
  64262. */
  64263. private static _getScreenshotSize;
  64264. }
  64265. }
  64266. declare module BABYLON {
  64267. /**
  64268. * Interface for a data buffer
  64269. */
  64270. export interface IDataBuffer {
  64271. /**
  64272. * Reads bytes from the data buffer.
  64273. * @param byteOffset The byte offset to read
  64274. * @param byteLength The byte length to read
  64275. * @returns A promise that resolves when the bytes are read
  64276. */
  64277. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  64278. /**
  64279. * The byte length of the buffer.
  64280. */
  64281. readonly byteLength: number;
  64282. }
  64283. /**
  64284. * Utility class for reading from a data buffer
  64285. */
  64286. export class DataReader {
  64287. /**
  64288. * The data buffer associated with this data reader.
  64289. */
  64290. readonly buffer: IDataBuffer;
  64291. /**
  64292. * The current byte offset from the beginning of the data buffer.
  64293. */
  64294. byteOffset: number;
  64295. private _dataView;
  64296. private _dataByteOffset;
  64297. /**
  64298. * Constructor
  64299. * @param buffer The buffer to read
  64300. */
  64301. constructor(buffer: IDataBuffer);
  64302. /**
  64303. * Loads the given byte length.
  64304. * @param byteLength The byte length to load
  64305. * @returns A promise that resolves when the load is complete
  64306. */
  64307. loadAsync(byteLength: number): Promise<void>;
  64308. /**
  64309. * Read a unsigned 32-bit integer from the currently loaded data range.
  64310. * @returns The 32-bit integer read
  64311. */
  64312. readUint32(): number;
  64313. /**
  64314. * Read a byte array from the currently loaded data range.
  64315. * @param byteLength The byte length to read
  64316. * @returns The byte array read
  64317. */
  64318. readUint8Array(byteLength: number): Uint8Array;
  64319. /**
  64320. * Read a string from the currently loaded data range.
  64321. * @param byteLength The byte length to read
  64322. * @returns The string read
  64323. */
  64324. readString(byteLength: number): string;
  64325. /**
  64326. * Skips the given byte length the currently loaded data range.
  64327. * @param byteLength The byte length to skip
  64328. */
  64329. skipBytes(byteLength: number): void;
  64330. }
  64331. }
  64332. declare module BABYLON {
  64333. /**
  64334. * A cursor which tracks a point on a path
  64335. */
  64336. export class PathCursor {
  64337. private path;
  64338. /**
  64339. * Stores path cursor callbacks for when an onchange event is triggered
  64340. */
  64341. private _onchange;
  64342. /**
  64343. * The value of the path cursor
  64344. */
  64345. value: number;
  64346. /**
  64347. * The animation array of the path cursor
  64348. */
  64349. animations: Animation[];
  64350. /**
  64351. * Initializes the path cursor
  64352. * @param path The path to track
  64353. */
  64354. constructor(path: Path2);
  64355. /**
  64356. * Gets the cursor point on the path
  64357. * @returns A point on the path cursor at the cursor location
  64358. */
  64359. getPoint(): Vector3;
  64360. /**
  64361. * Moves the cursor ahead by the step amount
  64362. * @param step The amount to move the cursor forward
  64363. * @returns This path cursor
  64364. */
  64365. moveAhead(step?: number): PathCursor;
  64366. /**
  64367. * Moves the cursor behind by the step amount
  64368. * @param step The amount to move the cursor back
  64369. * @returns This path cursor
  64370. */
  64371. moveBack(step?: number): PathCursor;
  64372. /**
  64373. * Moves the cursor by the step amount
  64374. * If the step amount is greater than one, an exception is thrown
  64375. * @param step The amount to move the cursor
  64376. * @returns This path cursor
  64377. */
  64378. move(step: number): PathCursor;
  64379. /**
  64380. * Ensures that the value is limited between zero and one
  64381. * @returns This path cursor
  64382. */
  64383. private ensureLimits;
  64384. /**
  64385. * Runs onchange callbacks on change (used by the animation engine)
  64386. * @returns This path cursor
  64387. */
  64388. private raiseOnChange;
  64389. /**
  64390. * Executes a function on change
  64391. * @param f A path cursor onchange callback
  64392. * @returns This path cursor
  64393. */
  64394. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64395. }
  64396. }
  64397. declare module BABYLON {
  64398. /** @hidden */
  64399. export var blurPixelShader: {
  64400. name: string;
  64401. shader: string;
  64402. };
  64403. }
  64404. declare module BABYLON {
  64405. /** @hidden */
  64406. export var pointCloudVertexDeclaration: {
  64407. name: string;
  64408. shader: string;
  64409. };
  64410. }
  64411. // Mixins
  64412. interface Window {
  64413. mozIndexedDB: IDBFactory;
  64414. webkitIndexedDB: IDBFactory;
  64415. msIndexedDB: IDBFactory;
  64416. webkitURL: typeof URL;
  64417. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  64418. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  64419. WebGLRenderingContext: WebGLRenderingContext;
  64420. MSGesture: MSGesture;
  64421. CANNON: any;
  64422. AudioContext: AudioContext;
  64423. webkitAudioContext: AudioContext;
  64424. PointerEvent: any;
  64425. Math: Math;
  64426. Uint8Array: Uint8ArrayConstructor;
  64427. Float32Array: Float32ArrayConstructor;
  64428. mozURL: typeof URL;
  64429. msURL: typeof URL;
  64430. VRFrameData: any; // WebVR, from specs 1.1
  64431. DracoDecoderModule: any;
  64432. setImmediate(handler: (...args: any[]) => void): number;
  64433. }
  64434. interface HTMLCanvasElement {
  64435. requestPointerLock(): void;
  64436. msRequestPointerLock?(): void;
  64437. mozRequestPointerLock?(): void;
  64438. webkitRequestPointerLock?(): void;
  64439. /** Track wether a record is in progress */
  64440. isRecording: boolean;
  64441. /** Capture Stream method defined by some browsers */
  64442. captureStream(fps?: number): MediaStream;
  64443. }
  64444. interface CanvasRenderingContext2D {
  64445. msImageSmoothingEnabled: boolean;
  64446. }
  64447. interface MouseEvent {
  64448. mozMovementX: number;
  64449. mozMovementY: number;
  64450. webkitMovementX: number;
  64451. webkitMovementY: number;
  64452. msMovementX: number;
  64453. msMovementY: number;
  64454. }
  64455. interface Navigator {
  64456. mozGetVRDevices: (any: any) => any;
  64457. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64458. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64459. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  64460. webkitGetGamepads(): Gamepad[];
  64461. msGetGamepads(): Gamepad[];
  64462. webkitGamepads(): Gamepad[];
  64463. }
  64464. interface HTMLVideoElement {
  64465. mozSrcObject: any;
  64466. }
  64467. interface Math {
  64468. fround(x: number): number;
  64469. imul(a: number, b: number): number;
  64470. }
  64471. interface WebGLRenderingContext {
  64472. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  64473. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  64474. vertexAttribDivisor(index: number, divisor: number): void;
  64475. createVertexArray(): any;
  64476. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  64477. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  64478. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  64479. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  64480. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  64481. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  64482. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  64483. // Queries
  64484. createQuery(): WebGLQuery;
  64485. deleteQuery(query: WebGLQuery): void;
  64486. beginQuery(target: number, query: WebGLQuery): void;
  64487. endQuery(target: number): void;
  64488. getQueryParameter(query: WebGLQuery, pname: number): any;
  64489. getQuery(target: number, pname: number): any;
  64490. MAX_SAMPLES: number;
  64491. RGBA8: number;
  64492. READ_FRAMEBUFFER: number;
  64493. DRAW_FRAMEBUFFER: number;
  64494. UNIFORM_BUFFER: number;
  64495. HALF_FLOAT_OES: number;
  64496. RGBA16F: number;
  64497. RGBA32F: number;
  64498. R32F: number;
  64499. RG32F: number;
  64500. RGB32F: number;
  64501. R16F: number;
  64502. RG16F: number;
  64503. RGB16F: number;
  64504. RED: number;
  64505. RG: number;
  64506. R8: number;
  64507. RG8: number;
  64508. UNSIGNED_INT_24_8: number;
  64509. DEPTH24_STENCIL8: number;
  64510. MIN: number;
  64511. MAX: number;
  64512. /* Multiple Render Targets */
  64513. drawBuffers(buffers: number[]): void;
  64514. readBuffer(src: number): void;
  64515. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  64516. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  64517. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  64518. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  64519. // Occlusion Query
  64520. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  64521. ANY_SAMPLES_PASSED: number;
  64522. QUERY_RESULT_AVAILABLE: number;
  64523. QUERY_RESULT: number;
  64524. }
  64525. interface WebGLProgram {
  64526. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  64527. }
  64528. interface EXT_disjoint_timer_query {
  64529. QUERY_COUNTER_BITS_EXT: number;
  64530. TIME_ELAPSED_EXT: number;
  64531. TIMESTAMP_EXT: number;
  64532. GPU_DISJOINT_EXT: number;
  64533. QUERY_RESULT_EXT: number;
  64534. QUERY_RESULT_AVAILABLE_EXT: number;
  64535. queryCounterEXT(query: WebGLQuery, target: number): void;
  64536. createQueryEXT(): WebGLQuery;
  64537. beginQueryEXT(target: number, query: WebGLQuery): void;
  64538. endQueryEXT(target: number): void;
  64539. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  64540. deleteQueryEXT(query: WebGLQuery): void;
  64541. }
  64542. interface WebGLUniformLocation {
  64543. _currentState: any;
  64544. }
  64545. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  64546. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  64547. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  64548. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64549. interface WebGLRenderingContext {
  64550. readonly RASTERIZER_DISCARD: number;
  64551. readonly DEPTH_COMPONENT24: number;
  64552. readonly TEXTURE_3D: number;
  64553. readonly TEXTURE_2D_ARRAY: number;
  64554. readonly TEXTURE_COMPARE_FUNC: number;
  64555. readonly TEXTURE_COMPARE_MODE: number;
  64556. readonly COMPARE_REF_TO_TEXTURE: number;
  64557. readonly TEXTURE_WRAP_R: number;
  64558. readonly HALF_FLOAT: number;
  64559. readonly RGB8: number;
  64560. readonly RED_INTEGER: number;
  64561. readonly RG_INTEGER: number;
  64562. readonly RGB_INTEGER: number;
  64563. readonly RGBA_INTEGER: number;
  64564. readonly R8_SNORM: number;
  64565. readonly RG8_SNORM: number;
  64566. readonly RGB8_SNORM: number;
  64567. readonly RGBA8_SNORM: number;
  64568. readonly R8I: number;
  64569. readonly RG8I: number;
  64570. readonly RGB8I: number;
  64571. readonly RGBA8I: number;
  64572. readonly R8UI: number;
  64573. readonly RG8UI: number;
  64574. readonly RGB8UI: number;
  64575. readonly RGBA8UI: number;
  64576. readonly R16I: number;
  64577. readonly RG16I: number;
  64578. readonly RGB16I: number;
  64579. readonly RGBA16I: number;
  64580. readonly R16UI: number;
  64581. readonly RG16UI: number;
  64582. readonly RGB16UI: number;
  64583. readonly RGBA16UI: number;
  64584. readonly R32I: number;
  64585. readonly RG32I: number;
  64586. readonly RGB32I: number;
  64587. readonly RGBA32I: number;
  64588. readonly R32UI: number;
  64589. readonly RG32UI: number;
  64590. readonly RGB32UI: number;
  64591. readonly RGBA32UI: number;
  64592. readonly RGB10_A2UI: number;
  64593. readonly R11F_G11F_B10F: number;
  64594. readonly RGB9_E5: number;
  64595. readonly RGB10_A2: number;
  64596. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64597. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64598. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64599. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64600. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64601. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64602. 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;
  64603. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64604. readonly TRANSFORM_FEEDBACK: number;
  64605. readonly INTERLEAVED_ATTRIBS: number;
  64606. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64607. createTransformFeedback(): WebGLTransformFeedback;
  64608. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64609. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64610. beginTransformFeedback(primitiveMode: number): void;
  64611. endTransformFeedback(): void;
  64612. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64613. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64614. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64615. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64616. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64617. }
  64618. interface ImageBitmap {
  64619. readonly width: number;
  64620. readonly height: number;
  64621. close(): void;
  64622. }
  64623. interface WebGLQuery extends WebGLObject {
  64624. }
  64625. declare var WebGLQuery: {
  64626. prototype: WebGLQuery;
  64627. new(): WebGLQuery;
  64628. };
  64629. interface WebGLSampler extends WebGLObject {
  64630. }
  64631. declare var WebGLSampler: {
  64632. prototype: WebGLSampler;
  64633. new(): WebGLSampler;
  64634. };
  64635. interface WebGLSync extends WebGLObject {
  64636. }
  64637. declare var WebGLSync: {
  64638. prototype: WebGLSync;
  64639. new(): WebGLSync;
  64640. };
  64641. interface WebGLTransformFeedback extends WebGLObject {
  64642. }
  64643. declare var WebGLTransformFeedback: {
  64644. prototype: WebGLTransformFeedback;
  64645. new(): WebGLTransformFeedback;
  64646. };
  64647. interface WebGLVertexArrayObject extends WebGLObject {
  64648. }
  64649. declare var WebGLVertexArrayObject: {
  64650. prototype: WebGLVertexArrayObject;
  64651. new(): WebGLVertexArrayObject;
  64652. };
  64653. // Type definitions for WebVR API
  64654. // Project: https://w3c.github.io/webvr/
  64655. // Definitions by: six a <https://github.com/lostfictions>
  64656. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64657. interface VRDisplay extends EventTarget {
  64658. /**
  64659. * Dictionary of capabilities describing the VRDisplay.
  64660. */
  64661. readonly capabilities: VRDisplayCapabilities;
  64662. /**
  64663. * z-depth defining the far plane of the eye view frustum
  64664. * enables mapping of values in the render target depth
  64665. * attachment to scene coordinates. Initially set to 10000.0.
  64666. */
  64667. depthFar: number;
  64668. /**
  64669. * z-depth defining the near plane of the eye view frustum
  64670. * enables mapping of values in the render target depth
  64671. * attachment to scene coordinates. Initially set to 0.01.
  64672. */
  64673. depthNear: number;
  64674. /**
  64675. * An identifier for this distinct VRDisplay. Used as an
  64676. * association point in the Gamepad API.
  64677. */
  64678. readonly displayId: number;
  64679. /**
  64680. * A display name, a user-readable name identifying it.
  64681. */
  64682. readonly displayName: string;
  64683. readonly isConnected: boolean;
  64684. readonly isPresenting: boolean;
  64685. /**
  64686. * If this VRDisplay supports room-scale experiences, the optional
  64687. * stage attribute contains details on the room-scale parameters.
  64688. */
  64689. readonly stageParameters: VRStageParameters | null;
  64690. /**
  64691. * Passing the value returned by `requestAnimationFrame` to
  64692. * `cancelAnimationFrame` will unregister the callback.
  64693. * @param handle Define the hanle of the request to cancel
  64694. */
  64695. cancelAnimationFrame(handle: number): void;
  64696. /**
  64697. * Stops presenting to the VRDisplay.
  64698. * @returns a promise to know when it stopped
  64699. */
  64700. exitPresent(): Promise<void>;
  64701. /**
  64702. * Return the current VREyeParameters for the given eye.
  64703. * @param whichEye Define the eye we want the parameter for
  64704. * @returns the eye parameters
  64705. */
  64706. getEyeParameters(whichEye: string): VREyeParameters;
  64707. /**
  64708. * Populates the passed VRFrameData with the information required to render
  64709. * the current frame.
  64710. * @param frameData Define the data structure to populate
  64711. * @returns true if ok otherwise false
  64712. */
  64713. getFrameData(frameData: VRFrameData): boolean;
  64714. /**
  64715. * Get the layers currently being presented.
  64716. * @returns the list of VR layers
  64717. */
  64718. getLayers(): VRLayer[];
  64719. /**
  64720. * Return a VRPose containing the future predicted pose of the VRDisplay
  64721. * when the current frame will be presented. The value returned will not
  64722. * change until JavaScript has returned control to the browser.
  64723. *
  64724. * The VRPose will contain the position, orientation, velocity,
  64725. * and acceleration of each of these properties.
  64726. * @returns the pose object
  64727. */
  64728. getPose(): VRPose;
  64729. /**
  64730. * Return the current instantaneous pose of the VRDisplay, with no
  64731. * prediction applied.
  64732. * @returns the current instantaneous pose
  64733. */
  64734. getImmediatePose(): VRPose;
  64735. /**
  64736. * The callback passed to `requestAnimationFrame` will be called
  64737. * any time a new frame should be rendered. When the VRDisplay is
  64738. * presenting the callback will be called at the native refresh
  64739. * rate of the HMD. When not presenting this function acts
  64740. * identically to how window.requestAnimationFrame acts. Content should
  64741. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64742. * asynchronously from other displays and at differing refresh rates.
  64743. * @param callback Define the eaction to run next frame
  64744. * @returns the request handle it
  64745. */
  64746. requestAnimationFrame(callback: FrameRequestCallback): number;
  64747. /**
  64748. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64749. * Repeat calls while already presenting will update the VRLayers being displayed.
  64750. * @param layers Define the list of layer to present
  64751. * @returns a promise to know when the request has been fulfilled
  64752. */
  64753. requestPresent(layers: VRLayer[]): Promise<void>;
  64754. /**
  64755. * Reset the pose for this display, treating its current position and
  64756. * orientation as the "origin/zero" values. VRPose.position,
  64757. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64758. * updated when calling resetPose(). This should be called in only
  64759. * sitting-space experiences.
  64760. */
  64761. resetPose(): void;
  64762. /**
  64763. * The VRLayer provided to the VRDisplay will be captured and presented
  64764. * in the HMD. Calling this function has the same effect on the source
  64765. * canvas as any other operation that uses its source image, and canvases
  64766. * created without preserveDrawingBuffer set to true will be cleared.
  64767. * @param pose Define the pose to submit
  64768. */
  64769. submitFrame(pose?: VRPose): void;
  64770. }
  64771. declare var VRDisplay: {
  64772. prototype: VRDisplay;
  64773. new(): VRDisplay;
  64774. };
  64775. interface VRLayer {
  64776. leftBounds?: number[] | Float32Array | null;
  64777. rightBounds?: number[] | Float32Array | null;
  64778. source?: HTMLCanvasElement | null;
  64779. }
  64780. interface VRDisplayCapabilities {
  64781. readonly canPresent: boolean;
  64782. readonly hasExternalDisplay: boolean;
  64783. readonly hasOrientation: boolean;
  64784. readonly hasPosition: boolean;
  64785. readonly maxLayers: number;
  64786. }
  64787. interface VREyeParameters {
  64788. /** @deprecated */
  64789. readonly fieldOfView: VRFieldOfView;
  64790. readonly offset: Float32Array;
  64791. readonly renderHeight: number;
  64792. readonly renderWidth: number;
  64793. }
  64794. interface VRFieldOfView {
  64795. readonly downDegrees: number;
  64796. readonly leftDegrees: number;
  64797. readonly rightDegrees: number;
  64798. readonly upDegrees: number;
  64799. }
  64800. interface VRFrameData {
  64801. readonly leftProjectionMatrix: Float32Array;
  64802. readonly leftViewMatrix: Float32Array;
  64803. readonly pose: VRPose;
  64804. readonly rightProjectionMatrix: Float32Array;
  64805. readonly rightViewMatrix: Float32Array;
  64806. readonly timestamp: number;
  64807. }
  64808. interface VRPose {
  64809. readonly angularAcceleration: Float32Array | null;
  64810. readonly angularVelocity: Float32Array | null;
  64811. readonly linearAcceleration: Float32Array | null;
  64812. readonly linearVelocity: Float32Array | null;
  64813. readonly orientation: Float32Array | null;
  64814. readonly position: Float32Array | null;
  64815. readonly timestamp: number;
  64816. }
  64817. interface VRStageParameters {
  64818. sittingToStandingTransform?: Float32Array;
  64819. sizeX?: number;
  64820. sizeY?: number;
  64821. }
  64822. interface Navigator {
  64823. getVRDisplays(): Promise<VRDisplay[]>;
  64824. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64825. }
  64826. interface Window {
  64827. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64828. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64829. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64830. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64831. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64832. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64833. }
  64834. interface Gamepad {
  64835. readonly displayId: number;
  64836. }
  64837. type XRSessionMode =
  64838. | "inline"
  64839. | "immersive-vr"
  64840. | "immersive-ar";
  64841. type XRReferenceSpaceType =
  64842. | "viewer"
  64843. | "local"
  64844. | "local-floor"
  64845. | "bounded-floor"
  64846. | "unbounded";
  64847. type XREnvironmentBlendMode =
  64848. | "opaque"
  64849. | "additive"
  64850. | "alpha-blend";
  64851. type XRVisibilityState =
  64852. | "visible"
  64853. | "visible-blurred"
  64854. | "hidden";
  64855. type XRHandedness =
  64856. | "none"
  64857. | "left"
  64858. | "right";
  64859. type XRTargetRayMode =
  64860. | "gaze"
  64861. | "tracked-pointer"
  64862. | "screen";
  64863. type XREye =
  64864. | "none"
  64865. | "left"
  64866. | "right";
  64867. interface XRSpace extends EventTarget {
  64868. }
  64869. interface XRRenderState {
  64870. depthNear?: number;
  64871. depthFar?: number;
  64872. inlineVerticalFieldOfView?: number;
  64873. baseLayer?: XRWebGLLayer;
  64874. }
  64875. interface XRInputSource {
  64876. handedness: XRHandedness;
  64877. targetRayMode: XRTargetRayMode;
  64878. targetRaySpace: XRSpace;
  64879. gripSpace: XRSpace | undefined;
  64880. gamepad: Gamepad | undefined;
  64881. profiles: Array<string>;
  64882. }
  64883. interface XRSession {
  64884. addEventListener: Function;
  64885. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64886. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64887. requestAnimationFrame: Function;
  64888. end(): Promise<void>;
  64889. renderState: XRRenderState;
  64890. inputSources: Array<XRInputSource>;
  64891. }
  64892. interface XRReferenceSpace extends XRSpace {
  64893. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64894. onreset: any;
  64895. }
  64896. interface XRFrame {
  64897. session: XRSession;
  64898. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64899. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64900. }
  64901. interface XRViewerPose extends XRPose {
  64902. views: Array<XRView>;
  64903. }
  64904. interface XRPose {
  64905. transform: XRRigidTransform;
  64906. emulatedPosition: boolean;
  64907. }
  64908. declare var XRWebGLLayer: {
  64909. prototype: XRWebGLLayer;
  64910. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64911. };
  64912. interface XRWebGLLayer {
  64913. framebuffer: WebGLFramebuffer;
  64914. framebufferWidth: number;
  64915. framebufferHeight: number;
  64916. getViewport: Function;
  64917. }
  64918. interface XRRigidTransform {
  64919. position: DOMPointReadOnly;
  64920. orientation: DOMPointReadOnly;
  64921. matrix: Float32Array;
  64922. inverse: XRRigidTransform;
  64923. }
  64924. interface XRView {
  64925. eye: XREye;
  64926. projectionMatrix: Float32Array;
  64927. transform: XRRigidTransform;
  64928. }
  64929. interface XRInputSourceChangeEvent {
  64930. session: XRSession;
  64931. removed: Array<XRInputSource>;
  64932. added: Array<XRInputSource>;
  64933. }
  64934. /**
  64935. * @ignore
  64936. */
  64937. declare module BABYLON.GLTF2.Exporter {
  64938. }
  64939. /**
  64940. * @ignore
  64941. */
  64942. declare module BABYLON.GLTF1 {
  64943. }
  64944. declare module BABYLON.GUI {
  64945. /**
  64946. * Class used to specific a value and its associated unit
  64947. */
  64948. export class ValueAndUnit {
  64949. /** defines the unit to store */
  64950. unit: number;
  64951. /** defines a boolean indicating if the value can be negative */
  64952. negativeValueAllowed: boolean;
  64953. private _value;
  64954. private _originalUnit;
  64955. /**
  64956. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64957. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64958. */
  64959. ignoreAdaptiveScaling: boolean;
  64960. /**
  64961. * Creates a new ValueAndUnit
  64962. * @param value defines the value to store
  64963. * @param unit defines the unit to store
  64964. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64965. */
  64966. constructor(value: number,
  64967. /** defines the unit to store */
  64968. unit?: number,
  64969. /** defines a boolean indicating if the value can be negative */
  64970. negativeValueAllowed?: boolean);
  64971. /** Gets a boolean indicating if the value is a percentage */
  64972. readonly isPercentage: boolean;
  64973. /** Gets a boolean indicating if the value is store as pixel */
  64974. readonly isPixel: boolean;
  64975. /** Gets direct internal value */
  64976. readonly internalValue: number;
  64977. /**
  64978. * Gets value as pixel
  64979. * @param host defines the root host
  64980. * @param refValue defines the reference value for percentages
  64981. * @returns the value as pixel
  64982. */
  64983. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64984. /**
  64985. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64986. * @param value defines the value to store
  64987. * @param unit defines the unit to store
  64988. * @returns the current ValueAndUnit
  64989. */
  64990. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64991. /**
  64992. * Gets the value accordingly to its unit
  64993. * @param host defines the root host
  64994. * @returns the value
  64995. */
  64996. getValue(host: AdvancedDynamicTexture): number;
  64997. /**
  64998. * Gets a string representation of the value
  64999. * @param host defines the root host
  65000. * @param decimals defines an optional number of decimals to display
  65001. * @returns a string
  65002. */
  65003. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  65004. /**
  65005. * Store a value parsed from a string
  65006. * @param source defines the source string
  65007. * @returns true if the value was successfully parsed
  65008. */
  65009. fromString(source: string | number): boolean;
  65010. private static _Regex;
  65011. private static _UNITMODE_PERCENTAGE;
  65012. private static _UNITMODE_PIXEL;
  65013. /** UNITMODE_PERCENTAGE */
  65014. static readonly UNITMODE_PERCENTAGE: number;
  65015. /** UNITMODE_PIXEL */
  65016. static readonly UNITMODE_PIXEL: number;
  65017. }
  65018. }
  65019. declare module BABYLON.GUI {
  65020. /**
  65021. * Define a style used by control to automatically setup properties based on a template.
  65022. * Only support font related properties so far
  65023. */
  65024. export class Style implements BABYLON.IDisposable {
  65025. private _fontFamily;
  65026. private _fontStyle;
  65027. private _fontWeight;
  65028. /** @hidden */
  65029. _host: AdvancedDynamicTexture;
  65030. /** @hidden */
  65031. _fontSize: ValueAndUnit;
  65032. /**
  65033. * BABYLON.Observable raised when the style values are changed
  65034. */
  65035. onChangedObservable: BABYLON.Observable<Style>;
  65036. /**
  65037. * Creates a new style object
  65038. * @param host defines the AdvancedDynamicTexture which hosts this style
  65039. */
  65040. constructor(host: AdvancedDynamicTexture);
  65041. /**
  65042. * Gets or sets the font size
  65043. */
  65044. fontSize: string | number;
  65045. /**
  65046. * Gets or sets the font family
  65047. */
  65048. fontFamily: string;
  65049. /**
  65050. * Gets or sets the font style
  65051. */
  65052. fontStyle: string;
  65053. /** Gets or sets font weight */
  65054. fontWeight: string;
  65055. /** Dispose all associated resources */
  65056. dispose(): void;
  65057. }
  65058. }
  65059. declare module BABYLON.GUI {
  65060. /**
  65061. * Class used to transport BABYLON.Vector2 information for pointer events
  65062. */
  65063. export class Vector2WithInfo extends BABYLON.Vector2 {
  65064. /** defines the current mouse button index */
  65065. buttonIndex: number;
  65066. /**
  65067. * Creates a new Vector2WithInfo
  65068. * @param source defines the vector2 data to transport
  65069. * @param buttonIndex defines the current mouse button index
  65070. */
  65071. constructor(source: BABYLON.Vector2,
  65072. /** defines the current mouse button index */
  65073. buttonIndex?: number);
  65074. }
  65075. /** Class used to provide 2D matrix features */
  65076. export class Matrix2D {
  65077. /** Gets the internal array of 6 floats used to store matrix data */
  65078. m: Float32Array;
  65079. /**
  65080. * Creates a new matrix
  65081. * @param m00 defines value for (0, 0)
  65082. * @param m01 defines value for (0, 1)
  65083. * @param m10 defines value for (1, 0)
  65084. * @param m11 defines value for (1, 1)
  65085. * @param m20 defines value for (2, 0)
  65086. * @param m21 defines value for (2, 1)
  65087. */
  65088. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  65089. /**
  65090. * Fills the matrix from direct values
  65091. * @param m00 defines value for (0, 0)
  65092. * @param m01 defines value for (0, 1)
  65093. * @param m10 defines value for (1, 0)
  65094. * @param m11 defines value for (1, 1)
  65095. * @param m20 defines value for (2, 0)
  65096. * @param m21 defines value for (2, 1)
  65097. * @returns the current modified matrix
  65098. */
  65099. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  65100. /**
  65101. * Gets matrix determinant
  65102. * @returns the determinant
  65103. */
  65104. determinant(): number;
  65105. /**
  65106. * Inverses the matrix and stores it in a target matrix
  65107. * @param result defines the target matrix
  65108. * @returns the current matrix
  65109. */
  65110. invertToRef(result: Matrix2D): Matrix2D;
  65111. /**
  65112. * Multiplies the current matrix with another one
  65113. * @param other defines the second operand
  65114. * @param result defines the target matrix
  65115. * @returns the current matrix
  65116. */
  65117. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  65118. /**
  65119. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  65120. * @param x defines the x coordinate to transform
  65121. * @param y defines the x coordinate to transform
  65122. * @param result defines the target vector2
  65123. * @returns the current matrix
  65124. */
  65125. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  65126. /**
  65127. * Creates an identity matrix
  65128. * @returns a new matrix
  65129. */
  65130. static Identity(): Matrix2D;
  65131. /**
  65132. * Creates a translation matrix and stores it in a target matrix
  65133. * @param x defines the x coordinate of the translation
  65134. * @param y defines the y coordinate of the translation
  65135. * @param result defines the target matrix
  65136. */
  65137. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  65138. /**
  65139. * Creates a scaling matrix and stores it in a target matrix
  65140. * @param x defines the x coordinate of the scaling
  65141. * @param y defines the y coordinate of the scaling
  65142. * @param result defines the target matrix
  65143. */
  65144. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  65145. /**
  65146. * Creates a rotation matrix and stores it in a target matrix
  65147. * @param angle defines the rotation angle
  65148. * @param result defines the target matrix
  65149. */
  65150. static RotationToRef(angle: number, result: Matrix2D): void;
  65151. private static _TempPreTranslationMatrix;
  65152. private static _TempPostTranslationMatrix;
  65153. private static _TempRotationMatrix;
  65154. private static _TempScalingMatrix;
  65155. private static _TempCompose0;
  65156. private static _TempCompose1;
  65157. private static _TempCompose2;
  65158. /**
  65159. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  65160. * @param tx defines the x coordinate of the translation
  65161. * @param ty defines the y coordinate of the translation
  65162. * @param angle defines the rotation angle
  65163. * @param scaleX defines the x coordinate of the scaling
  65164. * @param scaleY defines the y coordinate of the scaling
  65165. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  65166. * @param result defines the target matrix
  65167. */
  65168. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  65169. }
  65170. }
  65171. declare module BABYLON.GUI {
  65172. /**
  65173. * Class used to store 2D control sizes
  65174. */
  65175. export class Measure {
  65176. /** defines left coordinate */
  65177. left: number;
  65178. /** defines top coordinate */
  65179. top: number;
  65180. /** defines width dimension */
  65181. width: number;
  65182. /** defines height dimension */
  65183. height: number;
  65184. /**
  65185. * Creates a new measure
  65186. * @param left defines left coordinate
  65187. * @param top defines top coordinate
  65188. * @param width defines width dimension
  65189. * @param height defines height dimension
  65190. */
  65191. constructor(
  65192. /** defines left coordinate */
  65193. left: number,
  65194. /** defines top coordinate */
  65195. top: number,
  65196. /** defines width dimension */
  65197. width: number,
  65198. /** defines height dimension */
  65199. height: number);
  65200. /**
  65201. * Copy from another measure
  65202. * @param other defines the other measure to copy from
  65203. */
  65204. copyFrom(other: Measure): void;
  65205. /**
  65206. * Copy from a group of 4 floats
  65207. * @param left defines left coordinate
  65208. * @param top defines top coordinate
  65209. * @param width defines width dimension
  65210. * @param height defines height dimension
  65211. */
  65212. copyFromFloats(left: number, top: number, width: number, height: number): void;
  65213. /**
  65214. * Computes the axis aligned bounding box measure for two given measures
  65215. * @param a Input measure
  65216. * @param b Input measure
  65217. * @param result the resulting bounding measure
  65218. */
  65219. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  65220. /**
  65221. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  65222. * @param transform the matrix to transform the measure before computing the AABB
  65223. * @param result the resulting AABB
  65224. */
  65225. transformToRef(transform: Matrix2D, result: Measure): void;
  65226. /**
  65227. * Check equality between this measure and another one
  65228. * @param other defines the other measures
  65229. * @returns true if both measures are equals
  65230. */
  65231. isEqualsTo(other: Measure): boolean;
  65232. /**
  65233. * Creates an empty measure
  65234. * @returns a new measure
  65235. */
  65236. static Empty(): Measure;
  65237. }
  65238. }
  65239. declare module BABYLON.GUI {
  65240. /**
  65241. * Interface used to define a control that can receive focus
  65242. */
  65243. export interface IFocusableControl {
  65244. /**
  65245. * Function called when the control receives the focus
  65246. */
  65247. onFocus(): void;
  65248. /**
  65249. * Function called when the control loses the focus
  65250. */
  65251. onBlur(): void;
  65252. /**
  65253. * Function called to let the control handle keyboard events
  65254. * @param evt defines the current keyboard event
  65255. */
  65256. processKeyboard(evt: KeyboardEvent): void;
  65257. /**
  65258. * Function called to get the list of controls that should not steal the focus from this control
  65259. * @returns an array of controls
  65260. */
  65261. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65262. }
  65263. /**
  65264. * Class used to create texture to support 2D GUI elements
  65265. * @see http://doc.babylonjs.com/how_to/gui
  65266. */
  65267. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  65268. private _isDirty;
  65269. private _renderObserver;
  65270. private _resizeObserver;
  65271. private _preKeyboardObserver;
  65272. private _pointerMoveObserver;
  65273. private _pointerObserver;
  65274. private _canvasPointerOutObserver;
  65275. private _background;
  65276. /** @hidden */
  65277. _rootContainer: Container;
  65278. /** @hidden */
  65279. _lastPickedControl: Control;
  65280. /** @hidden */
  65281. _lastControlOver: {
  65282. [pointerId: number]: Control;
  65283. };
  65284. /** @hidden */
  65285. _lastControlDown: {
  65286. [pointerId: number]: Control;
  65287. };
  65288. /** @hidden */
  65289. _capturingControl: {
  65290. [pointerId: number]: Control;
  65291. };
  65292. /** @hidden */
  65293. _shouldBlockPointer: boolean;
  65294. /** @hidden */
  65295. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  65296. /** @hidden */
  65297. _linkedControls: Control[];
  65298. private _isFullscreen;
  65299. private _fullscreenViewport;
  65300. private _idealWidth;
  65301. private _idealHeight;
  65302. private _useSmallestIdeal;
  65303. private _renderAtIdealSize;
  65304. private _focusedControl;
  65305. private _blockNextFocusCheck;
  65306. private _renderScale;
  65307. private _rootElement;
  65308. private _cursorChanged;
  65309. /**
  65310. * Define type to string to ensure compatibility across browsers
  65311. * Safari doesn't support DataTransfer constructor
  65312. */
  65313. private _clipboardData;
  65314. /**
  65315. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  65316. */
  65317. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  65318. /**
  65319. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  65320. */
  65321. onControlPickedObservable: BABYLON.Observable<Control>;
  65322. /**
  65323. * BABYLON.Observable event triggered before layout is evaluated
  65324. */
  65325. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65326. /**
  65327. * BABYLON.Observable event triggered after the layout was evaluated
  65328. */
  65329. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65330. /**
  65331. * BABYLON.Observable event triggered before the texture is rendered
  65332. */
  65333. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65334. /**
  65335. * BABYLON.Observable event triggered after the texture was rendered
  65336. */
  65337. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  65338. /**
  65339. * Gets or sets a boolean defining if alpha is stored as premultiplied
  65340. */
  65341. premulAlpha: boolean;
  65342. /**
  65343. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  65344. * Useful when you want more antialiasing
  65345. */
  65346. renderScale: number;
  65347. /** Gets or sets the background color */
  65348. background: string;
  65349. /**
  65350. * Gets or sets the ideal width used to design controls.
  65351. * The GUI will then rescale everything accordingly
  65352. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65353. */
  65354. idealWidth: number;
  65355. /**
  65356. * Gets or sets the ideal height used to design controls.
  65357. * The GUI will then rescale everything accordingly
  65358. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65359. */
  65360. idealHeight: number;
  65361. /**
  65362. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  65363. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65364. */
  65365. useSmallestIdeal: boolean;
  65366. /**
  65367. * Gets or sets a boolean indicating if adaptive scaling must be used
  65368. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  65369. */
  65370. renderAtIdealSize: boolean;
  65371. /**
  65372. * Gets the underlying layer used to render the texture when in fullscreen mode
  65373. */
  65374. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  65375. /**
  65376. * Gets the root container control
  65377. */
  65378. readonly rootContainer: Container;
  65379. /**
  65380. * Returns an array containing the root container.
  65381. * This is mostly used to let the Inspector introspects the ADT
  65382. * @returns an array containing the rootContainer
  65383. */
  65384. getChildren(): Array<Container>;
  65385. /**
  65386. * Will return all controls that are inside this texture
  65387. * @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
  65388. * @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
  65389. * @return all child controls
  65390. */
  65391. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65392. /**
  65393. * Gets or sets the current focused control
  65394. */
  65395. focusedControl: BABYLON.Nullable<IFocusableControl>;
  65396. /**
  65397. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  65398. */
  65399. isForeground: boolean;
  65400. /**
  65401. * Gets or set information about clipboardData
  65402. */
  65403. clipboardData: string;
  65404. /**
  65405. * Creates a new AdvancedDynamicTexture
  65406. * @param name defines the name of the texture
  65407. * @param width defines the width of the texture
  65408. * @param height defines the height of the texture
  65409. * @param scene defines the hosting scene
  65410. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  65411. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  65412. */
  65413. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  65414. /**
  65415. * Get the current class name of the texture useful for serialization or dynamic coding.
  65416. * @returns "AdvancedDynamicTexture"
  65417. */
  65418. getClassName(): string;
  65419. /**
  65420. * Function used to execute a function on all controls
  65421. * @param func defines the function to execute
  65422. * @param container defines the container where controls belong. If null the root container will be used
  65423. */
  65424. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  65425. private _useInvalidateRectOptimization;
  65426. /**
  65427. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  65428. */
  65429. useInvalidateRectOptimization: boolean;
  65430. private _invalidatedRectangle;
  65431. /**
  65432. * Invalidates a rectangle area on the gui texture
  65433. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  65434. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  65435. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  65436. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  65437. */
  65438. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  65439. /**
  65440. * Marks the texture as dirty forcing a complete update
  65441. */
  65442. markAsDirty(): void;
  65443. /**
  65444. * Helper function used to create a new style
  65445. * @returns a new style
  65446. * @see http://doc.babylonjs.com/how_to/gui#styles
  65447. */
  65448. createStyle(): Style;
  65449. /**
  65450. * Adds a new control to the root container
  65451. * @param control defines the control to add
  65452. * @returns the current texture
  65453. */
  65454. addControl(control: Control): AdvancedDynamicTexture;
  65455. /**
  65456. * Removes a control from the root container
  65457. * @param control defines the control to remove
  65458. * @returns the current texture
  65459. */
  65460. removeControl(control: Control): AdvancedDynamicTexture;
  65461. /**
  65462. * Release all resources
  65463. */
  65464. dispose(): void;
  65465. private _onResize;
  65466. /** @hidden */
  65467. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  65468. /**
  65469. * Get screen coordinates for a vector3
  65470. * @param position defines the position to project
  65471. * @param worldMatrix defines the world matrix to use
  65472. * @returns the projected position
  65473. */
  65474. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  65475. private _checkUpdate;
  65476. private _clearMeasure;
  65477. private _render;
  65478. /** @hidden */
  65479. _changeCursor(cursor: string): void;
  65480. /** @hidden */
  65481. _registerLastControlDown(control: Control, pointerId: number): void;
  65482. private _doPicking;
  65483. /** @hidden */
  65484. _cleanControlAfterRemovalFromList(list: {
  65485. [pointerId: number]: Control;
  65486. }, control: Control): void;
  65487. /** @hidden */
  65488. _cleanControlAfterRemoval(control: Control): void;
  65489. /** Attach to all scene events required to support pointer events */
  65490. attach(): void;
  65491. /** @hidden */
  65492. private onClipboardCopy;
  65493. /** @hidden */
  65494. private onClipboardCut;
  65495. /** @hidden */
  65496. private onClipboardPaste;
  65497. /**
  65498. * Register the clipboard Events onto the canvas
  65499. */
  65500. registerClipboardEvents(): void;
  65501. /**
  65502. * Unregister the clipboard Events from the canvas
  65503. */
  65504. unRegisterClipboardEvents(): void;
  65505. /**
  65506. * Connect the texture to a hosting mesh to enable interactions
  65507. * @param mesh defines the mesh to attach to
  65508. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  65509. */
  65510. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  65511. /**
  65512. * Move the focus to a specific control
  65513. * @param control defines the control which will receive the focus
  65514. */
  65515. moveFocusToControl(control: IFocusableControl): void;
  65516. private _manageFocus;
  65517. private _attachToOnPointerOut;
  65518. /**
  65519. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  65520. * @param mesh defines the mesh which will receive the texture
  65521. * @param width defines the texture width (1024 by default)
  65522. * @param height defines the texture height (1024 by default)
  65523. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  65524. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  65525. * @returns a new AdvancedDynamicTexture
  65526. */
  65527. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  65528. /**
  65529. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  65530. * In this mode the texture will rely on a layer for its rendering.
  65531. * This allows it to be treated like any other layer.
  65532. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  65533. * LayerMask is set through advancedTexture.layer.layerMask
  65534. * @param name defines name for the texture
  65535. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  65536. * @param scene defines the hsoting scene
  65537. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  65538. * @returns a new AdvancedDynamicTexture
  65539. */
  65540. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  65541. }
  65542. }
  65543. declare module BABYLON.GUI {
  65544. /**
  65545. * Root class used for all 2D controls
  65546. * @see http://doc.babylonjs.com/how_to/gui#controls
  65547. */
  65548. export class Control {
  65549. /** defines the name of the control */
  65550. name?: string | undefined;
  65551. /**
  65552. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  65553. */
  65554. static AllowAlphaInheritance: boolean;
  65555. private _alpha;
  65556. private _alphaSet;
  65557. private _zIndex;
  65558. /** @hidden */
  65559. _host: AdvancedDynamicTexture;
  65560. /** Gets or sets the control parent */
  65561. parent: BABYLON.Nullable<Container>;
  65562. /** @hidden */
  65563. _currentMeasure: Measure;
  65564. private _fontFamily;
  65565. private _fontStyle;
  65566. private _fontWeight;
  65567. private _fontSize;
  65568. private _font;
  65569. /** @hidden */
  65570. _width: ValueAndUnit;
  65571. /** @hidden */
  65572. _height: ValueAndUnit;
  65573. /** @hidden */
  65574. protected _fontOffset: {
  65575. ascent: number;
  65576. height: number;
  65577. descent: number;
  65578. };
  65579. private _color;
  65580. private _style;
  65581. private _styleObserver;
  65582. /** @hidden */
  65583. protected _horizontalAlignment: number;
  65584. /** @hidden */
  65585. protected _verticalAlignment: number;
  65586. /** @hidden */
  65587. protected _isDirty: boolean;
  65588. /** @hidden */
  65589. protected _wasDirty: boolean;
  65590. /** @hidden */
  65591. _tempParentMeasure: Measure;
  65592. /** @hidden */
  65593. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65594. /** @hidden */
  65595. protected _cachedParentMeasure: Measure;
  65596. private _paddingLeft;
  65597. private _paddingRight;
  65598. private _paddingTop;
  65599. private _paddingBottom;
  65600. /** @hidden */
  65601. _left: ValueAndUnit;
  65602. /** @hidden */
  65603. _top: ValueAndUnit;
  65604. private _scaleX;
  65605. private _scaleY;
  65606. private _rotation;
  65607. private _transformCenterX;
  65608. private _transformCenterY;
  65609. /** @hidden */
  65610. _transformMatrix: Matrix2D;
  65611. /** @hidden */
  65612. protected _invertTransformMatrix: Matrix2D;
  65613. /** @hidden */
  65614. protected _transformedPosition: BABYLON.Vector2;
  65615. private _isMatrixDirty;
  65616. private _cachedOffsetX;
  65617. private _cachedOffsetY;
  65618. private _isVisible;
  65619. private _isHighlighted;
  65620. /** @hidden */
  65621. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65622. private _fontSet;
  65623. private _dummyVector2;
  65624. private _downCount;
  65625. private _enterCount;
  65626. private _doNotRender;
  65627. private _downPointerIds;
  65628. protected _isEnabled: boolean;
  65629. protected _disabledColor: string;
  65630. /** @hidden */
  65631. protected _rebuildLayout: boolean;
  65632. /** @hidden */
  65633. _isClipped: boolean;
  65634. /** @hidden */
  65635. _tag: any;
  65636. /**
  65637. * 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
  65638. */
  65639. uniqueId: number;
  65640. /**
  65641. * Gets or sets an object used to store user defined information for the node
  65642. */
  65643. metadata: any;
  65644. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65645. isHitTestVisible: boolean;
  65646. /** Gets or sets a boolean indicating if the control can block pointer events */
  65647. isPointerBlocker: boolean;
  65648. /** Gets or sets a boolean indicating if the control can be focusable */
  65649. isFocusInvisible: boolean;
  65650. /**
  65651. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65652. * 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
  65653. */
  65654. clipChildren: boolean;
  65655. /**
  65656. * Gets or sets a boolean indicating that control content must be clipped
  65657. * 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
  65658. */
  65659. clipContent: boolean;
  65660. /**
  65661. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65662. */
  65663. useBitmapCache: boolean;
  65664. private _cacheData;
  65665. private _shadowOffsetX;
  65666. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65667. shadowOffsetX: number;
  65668. private _shadowOffsetY;
  65669. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65670. shadowOffsetY: number;
  65671. private _shadowBlur;
  65672. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65673. shadowBlur: number;
  65674. private _shadowColor;
  65675. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65676. shadowColor: string;
  65677. /** Gets or sets the cursor to use when the control is hovered */
  65678. hoverCursor: string;
  65679. /** @hidden */
  65680. protected _linkOffsetX: ValueAndUnit;
  65681. /** @hidden */
  65682. protected _linkOffsetY: ValueAndUnit;
  65683. /** Gets the control type name */
  65684. readonly typeName: string;
  65685. /**
  65686. * Get the current class name of the control.
  65687. * @returns current class name
  65688. */
  65689. getClassName(): string;
  65690. /**
  65691. * An event triggered when the pointer move over the control.
  65692. */
  65693. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65694. /**
  65695. * An event triggered when the pointer move out of the control.
  65696. */
  65697. onPointerOutObservable: BABYLON.Observable<Control>;
  65698. /**
  65699. * An event triggered when the pointer taps the control
  65700. */
  65701. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65702. /**
  65703. * An event triggered when pointer up
  65704. */
  65705. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65706. /**
  65707. * An event triggered when a control is clicked on
  65708. */
  65709. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65710. /**
  65711. * An event triggered when pointer enters the control
  65712. */
  65713. onPointerEnterObservable: BABYLON.Observable<Control>;
  65714. /**
  65715. * An event triggered when the control is marked as dirty
  65716. */
  65717. onDirtyObservable: BABYLON.Observable<Control>;
  65718. /**
  65719. * An event triggered before drawing the control
  65720. */
  65721. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65722. /**
  65723. * An event triggered after the control was drawn
  65724. */
  65725. onAfterDrawObservable: BABYLON.Observable<Control>;
  65726. /**
  65727. * Get the hosting AdvancedDynamicTexture
  65728. */
  65729. readonly host: AdvancedDynamicTexture;
  65730. /** Gets or set information about font offsets (used to render and align text) */
  65731. fontOffset: {
  65732. ascent: number;
  65733. height: number;
  65734. descent: number;
  65735. };
  65736. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65737. alpha: number;
  65738. /**
  65739. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65740. */
  65741. isHighlighted: boolean;
  65742. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65743. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65744. */
  65745. scaleX: number;
  65746. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65747. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65748. */
  65749. scaleY: number;
  65750. /** Gets or sets the rotation angle (0 by default)
  65751. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65752. */
  65753. rotation: number;
  65754. /** Gets or sets the transformation center on Y axis (0 by default)
  65755. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65756. */
  65757. transformCenterY: number;
  65758. /** Gets or sets the transformation center on X axis (0 by default)
  65759. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65760. */
  65761. transformCenterX: number;
  65762. /**
  65763. * Gets or sets the horizontal alignment
  65764. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65765. */
  65766. horizontalAlignment: number;
  65767. /**
  65768. * Gets or sets the vertical alignment
  65769. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65770. */
  65771. verticalAlignment: number;
  65772. /**
  65773. * Gets or sets control width
  65774. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65775. */
  65776. width: string | number;
  65777. /**
  65778. * Gets or sets the control width in pixel
  65779. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65780. */
  65781. widthInPixels: number;
  65782. /**
  65783. * Gets or sets control height
  65784. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65785. */
  65786. height: string | number;
  65787. /**
  65788. * Gets or sets control height in pixel
  65789. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65790. */
  65791. heightInPixels: number;
  65792. /** Gets or set font family */
  65793. fontFamily: string;
  65794. /** Gets or sets font style */
  65795. fontStyle: string;
  65796. /** Gets or sets font weight */
  65797. fontWeight: string;
  65798. /**
  65799. * Gets or sets style
  65800. * @see http://doc.babylonjs.com/how_to/gui#styles
  65801. */
  65802. style: BABYLON.Nullable<Style>;
  65803. /** @hidden */
  65804. readonly _isFontSizeInPercentage: boolean;
  65805. /** Gets or sets font size in pixels */
  65806. fontSizeInPixels: number;
  65807. /** Gets or sets font size */
  65808. fontSize: string | number;
  65809. /** Gets or sets foreground color */
  65810. color: string;
  65811. /** Gets or sets z index which is used to reorder controls on the z axis */
  65812. zIndex: number;
  65813. /** Gets or sets a boolean indicating if the control can be rendered */
  65814. notRenderable: boolean;
  65815. /** Gets or sets a boolean indicating if the control is visible */
  65816. isVisible: boolean;
  65817. /** Gets a boolean indicating that the control needs to update its rendering */
  65818. readonly isDirty: boolean;
  65819. /**
  65820. * Gets the current linked mesh (or null if none)
  65821. */
  65822. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65823. /**
  65824. * Gets or sets a value indicating the padding to use on the left of the control
  65825. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65826. */
  65827. paddingLeft: string | number;
  65828. /**
  65829. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65830. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65831. */
  65832. paddingLeftInPixels: number;
  65833. /**
  65834. * Gets or sets a value indicating the padding to use on the right of the control
  65835. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65836. */
  65837. paddingRight: string | number;
  65838. /**
  65839. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65840. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65841. */
  65842. paddingRightInPixels: number;
  65843. /**
  65844. * Gets or sets a value indicating the padding to use on the top of the control
  65845. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65846. */
  65847. paddingTop: string | number;
  65848. /**
  65849. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65850. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65851. */
  65852. paddingTopInPixels: number;
  65853. /**
  65854. * Gets or sets a value indicating the padding to use on the bottom of the control
  65855. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65856. */
  65857. paddingBottom: string | number;
  65858. /**
  65859. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65860. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65861. */
  65862. paddingBottomInPixels: number;
  65863. /**
  65864. * Gets or sets a value indicating the left coordinate of the control
  65865. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65866. */
  65867. left: string | number;
  65868. /**
  65869. * Gets or sets a value indicating the left coordinate in pixels of the control
  65870. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65871. */
  65872. leftInPixels: number;
  65873. /**
  65874. * Gets or sets a value indicating the top coordinate of the control
  65875. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65876. */
  65877. top: string | number;
  65878. /**
  65879. * Gets or sets a value indicating the top coordinate in pixels of the control
  65880. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65881. */
  65882. topInPixels: number;
  65883. /**
  65884. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65885. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65886. */
  65887. linkOffsetX: string | number;
  65888. /**
  65889. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65890. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65891. */
  65892. linkOffsetXInPixels: number;
  65893. /**
  65894. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65895. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65896. */
  65897. linkOffsetY: string | number;
  65898. /**
  65899. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65900. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65901. */
  65902. linkOffsetYInPixels: number;
  65903. /** Gets the center coordinate on X axis */
  65904. readonly centerX: number;
  65905. /** Gets the center coordinate on Y axis */
  65906. readonly centerY: number;
  65907. /** Gets or sets if control is Enabled*/
  65908. isEnabled: boolean;
  65909. /** Gets or sets background color of control if it's disabled*/
  65910. disabledColor: string;
  65911. /**
  65912. * Creates a new control
  65913. * @param name defines the name of the control
  65914. */
  65915. constructor(
  65916. /** defines the name of the control */
  65917. name?: string | undefined);
  65918. /** @hidden */
  65919. protected _getTypeName(): string;
  65920. /**
  65921. * Gets the first ascendant in the hierarchy of the given type
  65922. * @param className defines the required type
  65923. * @returns the ascendant or null if not found
  65924. */
  65925. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65926. /** @hidden */
  65927. _resetFontCache(): void;
  65928. /**
  65929. * Determines if a container is an ascendant of the current control
  65930. * @param container defines the container to look for
  65931. * @returns true if the container is one of the ascendant of the control
  65932. */
  65933. isAscendant(container: Control): boolean;
  65934. /**
  65935. * Gets coordinates in local control space
  65936. * @param globalCoordinates defines the coordinates to transform
  65937. * @returns the new coordinates in local space
  65938. */
  65939. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65940. /**
  65941. * Gets coordinates in local control space
  65942. * @param globalCoordinates defines the coordinates to transform
  65943. * @param result defines the target vector2 where to store the result
  65944. * @returns the current control
  65945. */
  65946. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65947. /**
  65948. * Gets coordinates in parent local control space
  65949. * @param globalCoordinates defines the coordinates to transform
  65950. * @returns the new coordinates in parent local space
  65951. */
  65952. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65953. /**
  65954. * Move the current control to a vector3 position projected onto the screen.
  65955. * @param position defines the target position
  65956. * @param scene defines the hosting scene
  65957. */
  65958. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65959. /** @hidden */
  65960. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65961. /**
  65962. * Will return all controls that have this control as ascendant
  65963. * @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
  65964. * @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
  65965. * @return all child controls
  65966. */
  65967. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65968. /**
  65969. * Link current control with a target mesh
  65970. * @param mesh defines the mesh to link with
  65971. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65972. */
  65973. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65974. /** @hidden */
  65975. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65976. /** @hidden */
  65977. _offsetLeft(offset: number): void;
  65978. /** @hidden */
  65979. _offsetTop(offset: number): void;
  65980. /** @hidden */
  65981. _markMatrixAsDirty(): void;
  65982. /** @hidden */
  65983. _flagDescendantsAsMatrixDirty(): void;
  65984. /** @hidden */
  65985. _intersectsRect(rect: Measure): boolean;
  65986. /** @hidden */
  65987. protected invalidateRect(): void;
  65988. /** @hidden */
  65989. _markAsDirty(force?: boolean): void;
  65990. /** @hidden */
  65991. _markAllAsDirty(): void;
  65992. /** @hidden */
  65993. _link(host: AdvancedDynamicTexture): void;
  65994. /** @hidden */
  65995. protected _transform(context?: CanvasRenderingContext2D): void;
  65996. /** @hidden */
  65997. _renderHighlight(context: CanvasRenderingContext2D): void;
  65998. /** @hidden */
  65999. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66000. /** @hidden */
  66001. protected _applyStates(context: CanvasRenderingContext2D): void;
  66002. /** @hidden */
  66003. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66004. /** @hidden */
  66005. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66006. protected _evaluateClippingState(parentMeasure: Measure): void;
  66007. /** @hidden */
  66008. _measure(): void;
  66009. /** @hidden */
  66010. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66011. /** @hidden */
  66012. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66013. /** @hidden */
  66014. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66015. /** @hidden */
  66016. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66017. private static _ClipMeasure;
  66018. private _tmpMeasureA;
  66019. private _clip;
  66020. /** @hidden */
  66021. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  66022. /** @hidden */
  66023. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  66024. /**
  66025. * Tests if a given coordinates belong to the current control
  66026. * @param x defines x coordinate to test
  66027. * @param y defines y coordinate to test
  66028. * @returns true if the coordinates are inside the control
  66029. */
  66030. contains(x: number, y: number): boolean;
  66031. /** @hidden */
  66032. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66033. /** @hidden */
  66034. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66035. /** @hidden */
  66036. _onPointerEnter(target: Control): boolean;
  66037. /** @hidden */
  66038. _onPointerOut(target: Control, force?: boolean): void;
  66039. /** @hidden */
  66040. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66041. /** @hidden */
  66042. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66043. /** @hidden */
  66044. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66045. /** @hidden */
  66046. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  66047. private _prepareFont;
  66048. /** Releases associated resources */
  66049. dispose(): void;
  66050. private static _HORIZONTAL_ALIGNMENT_LEFT;
  66051. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  66052. private static _HORIZONTAL_ALIGNMENT_CENTER;
  66053. private static _VERTICAL_ALIGNMENT_TOP;
  66054. private static _VERTICAL_ALIGNMENT_BOTTOM;
  66055. private static _VERTICAL_ALIGNMENT_CENTER;
  66056. /** HORIZONTAL_ALIGNMENT_LEFT */
  66057. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  66058. /** HORIZONTAL_ALIGNMENT_RIGHT */
  66059. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  66060. /** HORIZONTAL_ALIGNMENT_CENTER */
  66061. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  66062. /** VERTICAL_ALIGNMENT_TOP */
  66063. static readonly VERTICAL_ALIGNMENT_TOP: number;
  66064. /** VERTICAL_ALIGNMENT_BOTTOM */
  66065. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  66066. /** VERTICAL_ALIGNMENT_CENTER */
  66067. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  66068. private static _FontHeightSizes;
  66069. /** @hidden */
  66070. static _GetFontOffset(font: string): {
  66071. ascent: number;
  66072. height: number;
  66073. descent: number;
  66074. };
  66075. /**
  66076. * Creates a stack panel that can be used to render headers
  66077. * @param control defines the control to associate with the header
  66078. * @param text defines the text of the header
  66079. * @param size defines the size of the header
  66080. * @param options defines options used to configure the header
  66081. * @returns a new StackPanel
  66082. * @ignore
  66083. * @hidden
  66084. */
  66085. static AddHeader: (control: Control, text: string, size: string | number, options: {
  66086. isHorizontal: boolean;
  66087. controlFirst: boolean;
  66088. }) => any;
  66089. /** @hidden */
  66090. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  66091. }
  66092. }
  66093. declare module BABYLON.GUI {
  66094. /**
  66095. * Root class for 2D containers
  66096. * @see http://doc.babylonjs.com/how_to/gui#containers
  66097. */
  66098. export class Container extends Control {
  66099. name?: string | undefined;
  66100. /** @hidden */
  66101. protected _children: Control[];
  66102. /** @hidden */
  66103. protected _measureForChildren: Measure;
  66104. /** @hidden */
  66105. protected _background: string;
  66106. /** @hidden */
  66107. protected _adaptWidthToChildren: boolean;
  66108. /** @hidden */
  66109. protected _adaptHeightToChildren: boolean;
  66110. /**
  66111. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  66112. */
  66113. logLayoutCycleErrors: boolean;
  66114. /**
  66115. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  66116. */
  66117. maxLayoutCycle: number;
  66118. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  66119. adaptHeightToChildren: boolean;
  66120. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  66121. adaptWidthToChildren: boolean;
  66122. /** Gets or sets background color */
  66123. background: string;
  66124. /** Gets the list of children */
  66125. readonly children: Control[];
  66126. /**
  66127. * Creates a new Container
  66128. * @param name defines the name of the container
  66129. */
  66130. constructor(name?: string | undefined);
  66131. protected _getTypeName(): string;
  66132. _flagDescendantsAsMatrixDirty(): void;
  66133. /**
  66134. * Gets a child using its name
  66135. * @param name defines the child name to look for
  66136. * @returns the child control if found
  66137. */
  66138. getChildByName(name: string): BABYLON.Nullable<Control>;
  66139. /**
  66140. * Gets a child using its type and its name
  66141. * @param name defines the child name to look for
  66142. * @param type defines the child type to look for
  66143. * @returns the child control if found
  66144. */
  66145. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  66146. /**
  66147. * Search for a specific control in children
  66148. * @param control defines the control to look for
  66149. * @returns true if the control is in child list
  66150. */
  66151. containsControl(control: Control): boolean;
  66152. /**
  66153. * Adds a new control to the current container
  66154. * @param control defines the control to add
  66155. * @returns the current container
  66156. */
  66157. addControl(control: BABYLON.Nullable<Control>): Container;
  66158. /**
  66159. * Removes all controls from the current container
  66160. * @returns the current container
  66161. */
  66162. clearControls(): Container;
  66163. /**
  66164. * Removes a control from the current container
  66165. * @param control defines the control to remove
  66166. * @returns the current container
  66167. */
  66168. removeControl(control: Control): Container;
  66169. /** @hidden */
  66170. _reOrderControl(control: Control): void;
  66171. /** @hidden */
  66172. _offsetLeft(offset: number): void;
  66173. /** @hidden */
  66174. _offsetTop(offset: number): void;
  66175. /** @hidden */
  66176. _markAllAsDirty(): void;
  66177. /** @hidden */
  66178. protected _localDraw(context: CanvasRenderingContext2D): void;
  66179. /** @hidden */
  66180. _link(host: AdvancedDynamicTexture): void;
  66181. /** @hidden */
  66182. protected _beforeLayout(): void;
  66183. /** @hidden */
  66184. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66185. /** @hidden */
  66186. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  66187. protected _postMeasure(): void;
  66188. /** @hidden */
  66189. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  66190. /** @hidden */
  66191. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  66192. /** @hidden */
  66193. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66194. /** @hidden */
  66195. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66196. /** Releases associated resources */
  66197. dispose(): void;
  66198. }
  66199. }
  66200. declare module BABYLON.GUI {
  66201. /** Class used to create rectangle container */
  66202. export class Rectangle extends Container {
  66203. name?: string | undefined;
  66204. private _thickness;
  66205. private _cornerRadius;
  66206. /** Gets or sets border thickness */
  66207. thickness: number;
  66208. /** Gets or sets the corner radius angle */
  66209. cornerRadius: number;
  66210. /**
  66211. * Creates a new Rectangle
  66212. * @param name defines the control name
  66213. */
  66214. constructor(name?: string | undefined);
  66215. protected _getTypeName(): string;
  66216. protected _localDraw(context: CanvasRenderingContext2D): void;
  66217. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66218. private _drawRoundedRect;
  66219. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66220. }
  66221. }
  66222. declare module BABYLON.GUI {
  66223. /**
  66224. * Enum that determines the text-wrapping mode to use.
  66225. */
  66226. export enum TextWrapping {
  66227. /**
  66228. * Clip the text when it's larger than Control.width; this is the default mode.
  66229. */
  66230. Clip = 0,
  66231. /**
  66232. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  66233. */
  66234. WordWrap = 1,
  66235. /**
  66236. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  66237. */
  66238. Ellipsis = 2
  66239. }
  66240. /**
  66241. * Class used to create text block control
  66242. */
  66243. export class TextBlock extends Control {
  66244. /**
  66245. * Defines the name of the control
  66246. */
  66247. name?: string | undefined;
  66248. private _text;
  66249. private _textWrapping;
  66250. private _textHorizontalAlignment;
  66251. private _textVerticalAlignment;
  66252. private _lines;
  66253. private _resizeToFit;
  66254. private _lineSpacing;
  66255. private _outlineWidth;
  66256. private _outlineColor;
  66257. /**
  66258. * An event triggered after the text is changed
  66259. */
  66260. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  66261. /**
  66262. * An event triggered after the text was broken up into lines
  66263. */
  66264. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  66265. /**
  66266. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  66267. */
  66268. readonly lines: any[];
  66269. /**
  66270. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66271. */
  66272. /**
  66273. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  66274. */
  66275. resizeToFit: boolean;
  66276. /**
  66277. * Gets or sets a boolean indicating if text must be wrapped
  66278. */
  66279. /**
  66280. * Gets or sets a boolean indicating if text must be wrapped
  66281. */
  66282. textWrapping: TextWrapping | boolean;
  66283. /**
  66284. * Gets or sets text to display
  66285. */
  66286. /**
  66287. * Gets or sets text to display
  66288. */
  66289. text: string;
  66290. /**
  66291. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66292. */
  66293. /**
  66294. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  66295. */
  66296. textHorizontalAlignment: number;
  66297. /**
  66298. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66299. */
  66300. /**
  66301. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  66302. */
  66303. textVerticalAlignment: number;
  66304. /**
  66305. * Gets or sets line spacing value
  66306. */
  66307. /**
  66308. * Gets or sets line spacing value
  66309. */
  66310. lineSpacing: string | number;
  66311. /**
  66312. * Gets or sets outlineWidth of the text to display
  66313. */
  66314. /**
  66315. * Gets or sets outlineWidth of the text to display
  66316. */
  66317. outlineWidth: number;
  66318. /**
  66319. * Gets or sets outlineColor of the text to display
  66320. */
  66321. /**
  66322. * Gets or sets outlineColor of the text to display
  66323. */
  66324. outlineColor: string;
  66325. /**
  66326. * Creates a new TextBlock object
  66327. * @param name defines the name of the control
  66328. * @param text defines the text to display (emptry string by default)
  66329. */
  66330. constructor(
  66331. /**
  66332. * Defines the name of the control
  66333. */
  66334. name?: string | undefined, text?: string);
  66335. protected _getTypeName(): string;
  66336. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66337. private _drawText;
  66338. /** @hidden */
  66339. _draw(context: CanvasRenderingContext2D): void;
  66340. protected _applyStates(context: CanvasRenderingContext2D): void;
  66341. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  66342. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  66343. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  66344. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  66345. protected _renderLines(context: CanvasRenderingContext2D): void;
  66346. /**
  66347. * Given a width constraint applied on the text block, find the expected height
  66348. * @returns expected height
  66349. */
  66350. computeExpectedHeight(): number;
  66351. dispose(): void;
  66352. }
  66353. }
  66354. declare module BABYLON.GUI {
  66355. /**
  66356. * Class used to create 2D images
  66357. */
  66358. export class Image extends Control {
  66359. name?: string | undefined;
  66360. private _workingCanvas;
  66361. private _domImage;
  66362. private _imageWidth;
  66363. private _imageHeight;
  66364. private _loaded;
  66365. private _stretch;
  66366. private _source;
  66367. private _autoScale;
  66368. private _sourceLeft;
  66369. private _sourceTop;
  66370. private _sourceWidth;
  66371. private _sourceHeight;
  66372. private _cellWidth;
  66373. private _cellHeight;
  66374. private _cellId;
  66375. private _populateNinePatchSlicesFromImage;
  66376. private _sliceLeft;
  66377. private _sliceRight;
  66378. private _sliceTop;
  66379. private _sliceBottom;
  66380. private _detectPointerOnOpaqueOnly;
  66381. /**
  66382. * BABYLON.Observable notified when the content is loaded
  66383. */
  66384. onImageLoadedObservable: BABYLON.Observable<Image>;
  66385. /**
  66386. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  66387. */
  66388. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  66389. /**
  66390. * Gets a boolean indicating that the content is loaded
  66391. */
  66392. readonly isLoaded: boolean;
  66393. /**
  66394. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  66395. */
  66396. populateNinePatchSlicesFromImage: boolean;
  66397. /**
  66398. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  66399. * Beware using this as this will comsume more memory as the image has to be stored twice
  66400. */
  66401. detectPointerOnOpaqueOnly: boolean;
  66402. /**
  66403. * Gets or sets the left value for slicing (9-patch)
  66404. */
  66405. sliceLeft: number;
  66406. /**
  66407. * Gets or sets the right value for slicing (9-patch)
  66408. */
  66409. sliceRight: number;
  66410. /**
  66411. * Gets or sets the top value for slicing (9-patch)
  66412. */
  66413. sliceTop: number;
  66414. /**
  66415. * Gets or sets the bottom value for slicing (9-patch)
  66416. */
  66417. sliceBottom: number;
  66418. /**
  66419. * Gets or sets the left coordinate in the source image
  66420. */
  66421. sourceLeft: number;
  66422. /**
  66423. * Gets or sets the top coordinate in the source image
  66424. */
  66425. sourceTop: number;
  66426. /**
  66427. * Gets or sets the width to capture in the source image
  66428. */
  66429. sourceWidth: number;
  66430. /**
  66431. * Gets or sets the height to capture in the source image
  66432. */
  66433. sourceHeight: number;
  66434. /**
  66435. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  66436. * @see http://doc.babylonjs.com/how_to/gui#image
  66437. */
  66438. autoScale: boolean;
  66439. /** Gets or sets the streching mode used by the image */
  66440. stretch: number;
  66441. /**
  66442. * Gets or sets the internal DOM image used to render the control
  66443. */
  66444. domImage: HTMLImageElement;
  66445. private _onImageLoaded;
  66446. private _extractNinePatchSliceDataFromImage;
  66447. /**
  66448. * Gets or sets image source url
  66449. */
  66450. source: BABYLON.Nullable<string>;
  66451. /**
  66452. * Checks for svg document with icon id present
  66453. */
  66454. private _svgCheck;
  66455. /**
  66456. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  66457. * given external svg file and icon id
  66458. */
  66459. private _getSVGAttribs;
  66460. /**
  66461. * Gets or sets the cell width to use when animation sheet is enabled
  66462. * @see http://doc.babylonjs.com/how_to/gui#image
  66463. */
  66464. cellWidth: number;
  66465. /**
  66466. * Gets or sets the cell height to use when animation sheet is enabled
  66467. * @see http://doc.babylonjs.com/how_to/gui#image
  66468. */
  66469. cellHeight: number;
  66470. /**
  66471. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  66472. * @see http://doc.babylonjs.com/how_to/gui#image
  66473. */
  66474. cellId: number;
  66475. /**
  66476. * Creates a new Image
  66477. * @param name defines the control name
  66478. * @param url defines the image url
  66479. */
  66480. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  66481. /**
  66482. * Tests if a given coordinates belong to the current control
  66483. * @param x defines x coordinate to test
  66484. * @param y defines y coordinate to test
  66485. * @returns true if the coordinates are inside the control
  66486. */
  66487. contains(x: number, y: number): boolean;
  66488. protected _getTypeName(): string;
  66489. /** Force the control to synchronize with its content */
  66490. synchronizeSizeWithContent(): void;
  66491. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66492. private _prepareWorkingCanvasForOpaqueDetection;
  66493. private _drawImage;
  66494. _draw(context: CanvasRenderingContext2D): void;
  66495. private _renderCornerPatch;
  66496. private _renderNinePatch;
  66497. dispose(): void;
  66498. /** STRETCH_NONE */
  66499. static readonly STRETCH_NONE: number;
  66500. /** STRETCH_FILL */
  66501. static readonly STRETCH_FILL: number;
  66502. /** STRETCH_UNIFORM */
  66503. static readonly STRETCH_UNIFORM: number;
  66504. /** STRETCH_EXTEND */
  66505. static readonly STRETCH_EXTEND: number;
  66506. /** NINE_PATCH */
  66507. static readonly STRETCH_NINE_PATCH: number;
  66508. }
  66509. }
  66510. declare module BABYLON.GUI {
  66511. /**
  66512. * Class used to create 2D buttons
  66513. */
  66514. export class Button extends Rectangle {
  66515. name?: string | undefined;
  66516. /**
  66517. * Function called to generate a pointer enter animation
  66518. */
  66519. pointerEnterAnimation: () => void;
  66520. /**
  66521. * Function called to generate a pointer out animation
  66522. */
  66523. pointerOutAnimation: () => void;
  66524. /**
  66525. * Function called to generate a pointer down animation
  66526. */
  66527. pointerDownAnimation: () => void;
  66528. /**
  66529. * Function called to generate a pointer up animation
  66530. */
  66531. pointerUpAnimation: () => void;
  66532. /**
  66533. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  66534. */
  66535. delegatePickingToChildren: boolean;
  66536. private _image;
  66537. /**
  66538. * Returns the image part of the button (if any)
  66539. */
  66540. readonly image: BABYLON.Nullable<Image>;
  66541. private _textBlock;
  66542. /**
  66543. * Returns the image part of the button (if any)
  66544. */
  66545. readonly textBlock: BABYLON.Nullable<TextBlock>;
  66546. /**
  66547. * Creates a new Button
  66548. * @param name defines the name of the button
  66549. */
  66550. constructor(name?: string | undefined);
  66551. protected _getTypeName(): string;
  66552. /** @hidden */
  66553. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  66554. /** @hidden */
  66555. _onPointerEnter(target: Control): boolean;
  66556. /** @hidden */
  66557. _onPointerOut(target: Control, force?: boolean): void;
  66558. /** @hidden */
  66559. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66560. /** @hidden */
  66561. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66562. /**
  66563. * Creates a new button made with an image and a text
  66564. * @param name defines the name of the button
  66565. * @param text defines the text of the button
  66566. * @param imageUrl defines the url of the image
  66567. * @returns a new Button
  66568. */
  66569. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  66570. /**
  66571. * Creates a new button made with an image
  66572. * @param name defines the name of the button
  66573. * @param imageUrl defines the url of the image
  66574. * @returns a new Button
  66575. */
  66576. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66577. /**
  66578. * Creates a new button made with a text
  66579. * @param name defines the name of the button
  66580. * @param text defines the text of the button
  66581. * @returns a new Button
  66582. */
  66583. static CreateSimpleButton(name: string, text: string): Button;
  66584. /**
  66585. * Creates a new button made with an image and a centered text
  66586. * @param name defines the name of the button
  66587. * @param text defines the text of the button
  66588. * @param imageUrl defines the url of the image
  66589. * @returns a new Button
  66590. */
  66591. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66592. }
  66593. }
  66594. declare module BABYLON.GUI {
  66595. /**
  66596. * Class used to create a 2D stack panel container
  66597. */
  66598. export class StackPanel extends Container {
  66599. name?: string | undefined;
  66600. private _isVertical;
  66601. private _manualWidth;
  66602. private _manualHeight;
  66603. private _doNotTrackManualChanges;
  66604. /**
  66605. * Gets or sets a boolean indicating that layou warnings should be ignored
  66606. */
  66607. ignoreLayoutWarnings: boolean;
  66608. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66609. isVertical: boolean;
  66610. /**
  66611. * Gets or sets panel width.
  66612. * This value should not be set when in horizontal mode as it will be computed automatically
  66613. */
  66614. width: string | number;
  66615. /**
  66616. * Gets or sets panel height.
  66617. * This value should not be set when in vertical mode as it will be computed automatically
  66618. */
  66619. height: string | number;
  66620. /**
  66621. * Creates a new StackPanel
  66622. * @param name defines control name
  66623. */
  66624. constructor(name?: string | undefined);
  66625. protected _getTypeName(): string;
  66626. /** @hidden */
  66627. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66628. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66629. protected _postMeasure(): void;
  66630. }
  66631. }
  66632. declare module BABYLON.GUI {
  66633. /**
  66634. * Class used to represent a 2D checkbox
  66635. */
  66636. export class Checkbox extends Control {
  66637. name?: string | undefined;
  66638. private _isChecked;
  66639. private _background;
  66640. private _checkSizeRatio;
  66641. private _thickness;
  66642. /** Gets or sets border thickness */
  66643. thickness: number;
  66644. /**
  66645. * BABYLON.Observable raised when isChecked property changes
  66646. */
  66647. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66648. /** Gets or sets a value indicating the ratio between overall size and check size */
  66649. checkSizeRatio: number;
  66650. /** Gets or sets background color */
  66651. background: string;
  66652. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66653. isChecked: boolean;
  66654. /**
  66655. * Creates a new CheckBox
  66656. * @param name defines the control name
  66657. */
  66658. constructor(name?: string | undefined);
  66659. protected _getTypeName(): string;
  66660. /** @hidden */
  66661. _draw(context: CanvasRenderingContext2D): void;
  66662. /** @hidden */
  66663. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66664. /**
  66665. * Utility function to easily create a checkbox with a header
  66666. * @param title defines the label to use for the header
  66667. * @param onValueChanged defines the callback to call when value changes
  66668. * @returns a StackPanel containing the checkbox and a textBlock
  66669. */
  66670. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66671. }
  66672. }
  66673. declare module BABYLON.GUI {
  66674. /**
  66675. * Class used to store key control properties
  66676. */
  66677. export class KeyPropertySet {
  66678. /** Width */
  66679. width?: string;
  66680. /** Height */
  66681. height?: string;
  66682. /** Left padding */
  66683. paddingLeft?: string;
  66684. /** Right padding */
  66685. paddingRight?: string;
  66686. /** Top padding */
  66687. paddingTop?: string;
  66688. /** Bottom padding */
  66689. paddingBottom?: string;
  66690. /** Foreground color */
  66691. color?: string;
  66692. /** Background color */
  66693. background?: string;
  66694. }
  66695. /**
  66696. * Class used to create virtual keyboard
  66697. */
  66698. export class VirtualKeyboard extends StackPanel {
  66699. /** BABYLON.Observable raised when a key is pressed */
  66700. onKeyPressObservable: BABYLON.Observable<string>;
  66701. /** Gets or sets default key button width */
  66702. defaultButtonWidth: string;
  66703. /** Gets or sets default key button height */
  66704. defaultButtonHeight: string;
  66705. /** Gets or sets default key button left padding */
  66706. defaultButtonPaddingLeft: string;
  66707. /** Gets or sets default key button right padding */
  66708. defaultButtonPaddingRight: string;
  66709. /** Gets or sets default key button top padding */
  66710. defaultButtonPaddingTop: string;
  66711. /** Gets or sets default key button bottom padding */
  66712. defaultButtonPaddingBottom: string;
  66713. /** Gets or sets default key button foreground color */
  66714. defaultButtonColor: string;
  66715. /** Gets or sets default key button background color */
  66716. defaultButtonBackground: string;
  66717. /** Gets or sets shift button foreground color */
  66718. shiftButtonColor: string;
  66719. /** Gets or sets shift button thickness*/
  66720. selectedShiftThickness: number;
  66721. /** Gets shift key state */
  66722. shiftState: number;
  66723. protected _getTypeName(): string;
  66724. private _createKey;
  66725. /**
  66726. * Adds a new row of keys
  66727. * @param keys defines the list of keys to add
  66728. * @param propertySets defines the associated property sets
  66729. */
  66730. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66731. /**
  66732. * Set the shift key to a specific state
  66733. * @param shiftState defines the new shift state
  66734. */
  66735. applyShiftState(shiftState: number): void;
  66736. private _currentlyConnectedInputText;
  66737. private _connectedInputTexts;
  66738. private _onKeyPressObserver;
  66739. /** Gets the input text control currently attached to the keyboard */
  66740. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66741. /**
  66742. * Connects the keyboard with an input text control
  66743. *
  66744. * @param input defines the target control
  66745. */
  66746. connect(input: InputText): void;
  66747. /**
  66748. * Disconnects the keyboard from connected InputText controls
  66749. *
  66750. * @param input optionally defines a target control, otherwise all are disconnected
  66751. */
  66752. disconnect(input?: InputText): void;
  66753. private _removeConnectedInputObservables;
  66754. /**
  66755. * Release all resources
  66756. */
  66757. dispose(): void;
  66758. /**
  66759. * Creates a new keyboard using a default layout
  66760. *
  66761. * @param name defines control name
  66762. * @returns a new VirtualKeyboard
  66763. */
  66764. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66765. }
  66766. }
  66767. declare module BABYLON.GUI {
  66768. /**
  66769. * Class used to create input text control
  66770. */
  66771. export class InputText extends Control implements IFocusableControl {
  66772. name?: string | undefined;
  66773. private _text;
  66774. private _placeholderText;
  66775. private _background;
  66776. private _focusedBackground;
  66777. private _focusedColor;
  66778. private _placeholderColor;
  66779. private _thickness;
  66780. private _margin;
  66781. private _autoStretchWidth;
  66782. private _maxWidth;
  66783. private _isFocused;
  66784. private _blinkTimeout;
  66785. private _blinkIsEven;
  66786. private _cursorOffset;
  66787. private _scrollLeft;
  66788. private _textWidth;
  66789. private _clickedCoordinate;
  66790. private _deadKey;
  66791. private _addKey;
  66792. private _currentKey;
  66793. private _isTextHighlightOn;
  66794. private _textHighlightColor;
  66795. private _highligherOpacity;
  66796. private _highlightedText;
  66797. private _startHighlightIndex;
  66798. private _endHighlightIndex;
  66799. private _cursorIndex;
  66800. private _onFocusSelectAll;
  66801. private _isPointerDown;
  66802. private _onClipboardObserver;
  66803. private _onPointerDblTapObserver;
  66804. /** @hidden */
  66805. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66806. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66807. promptMessage: string;
  66808. /** Force disable prompt on mobile device */
  66809. disableMobilePrompt: boolean;
  66810. /** BABYLON.Observable raised when the text changes */
  66811. onTextChangedObservable: BABYLON.Observable<InputText>;
  66812. /** BABYLON.Observable raised just before an entered character is to be added */
  66813. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66814. /** BABYLON.Observable raised when the control gets the focus */
  66815. onFocusObservable: BABYLON.Observable<InputText>;
  66816. /** BABYLON.Observable raised when the control loses the focus */
  66817. onBlurObservable: BABYLON.Observable<InputText>;
  66818. /**Observable raised when the text is highlighted */
  66819. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66820. /**Observable raised when copy event is triggered */
  66821. onTextCopyObservable: BABYLON.Observable<InputText>;
  66822. /** BABYLON.Observable raised when cut event is triggered */
  66823. onTextCutObservable: BABYLON.Observable<InputText>;
  66824. /** BABYLON.Observable raised when paste event is triggered */
  66825. onTextPasteObservable: BABYLON.Observable<InputText>;
  66826. /** BABYLON.Observable raised when a key event was processed */
  66827. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66828. /** Gets or sets the maximum width allowed by the control */
  66829. maxWidth: string | number;
  66830. /** Gets the maximum width allowed by the control in pixels */
  66831. readonly maxWidthInPixels: number;
  66832. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66833. highligherOpacity: number;
  66834. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66835. onFocusSelectAll: boolean;
  66836. /** Gets or sets the text hightlight color */
  66837. textHighlightColor: string;
  66838. /** Gets or sets control margin */
  66839. margin: string;
  66840. /** Gets control margin in pixels */
  66841. readonly marginInPixels: number;
  66842. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66843. autoStretchWidth: boolean;
  66844. /** Gets or sets border thickness */
  66845. thickness: number;
  66846. /** Gets or sets the background color when focused */
  66847. focusedBackground: string;
  66848. /** Gets or sets the background color when focused */
  66849. focusedColor: string;
  66850. /** Gets or sets the background color */
  66851. background: string;
  66852. /** Gets or sets the placeholder color */
  66853. placeholderColor: string;
  66854. /** Gets or sets the text displayed when the control is empty */
  66855. placeholderText: string;
  66856. /** Gets or sets the dead key flag */
  66857. deadKey: boolean;
  66858. /** Gets or sets the highlight text */
  66859. highlightedText: string;
  66860. /** Gets or sets if the current key should be added */
  66861. addKey: boolean;
  66862. /** Gets or sets the value of the current key being entered */
  66863. currentKey: string;
  66864. /** Gets or sets the text displayed in the control */
  66865. text: string;
  66866. /** Gets or sets control width */
  66867. width: string | number;
  66868. /**
  66869. * Creates a new InputText
  66870. * @param name defines the control name
  66871. * @param text defines the text of the control
  66872. */
  66873. constructor(name?: string | undefined, text?: string);
  66874. /** @hidden */
  66875. onBlur(): void;
  66876. /** @hidden */
  66877. onFocus(): void;
  66878. protected _getTypeName(): string;
  66879. /**
  66880. * Function called to get the list of controls that should not steal the focus from this control
  66881. * @returns an array of controls
  66882. */
  66883. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66884. /** @hidden */
  66885. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66886. /** @hidden */
  66887. private _updateValueFromCursorIndex;
  66888. /** @hidden */
  66889. private _processDblClick;
  66890. /** @hidden */
  66891. private _selectAllText;
  66892. /**
  66893. * Handles the keyboard event
  66894. * @param evt Defines the KeyboardEvent
  66895. */
  66896. processKeyboard(evt: KeyboardEvent): void;
  66897. /** @hidden */
  66898. private _onCopyText;
  66899. /** @hidden */
  66900. private _onCutText;
  66901. /** @hidden */
  66902. private _onPasteText;
  66903. _draw(context: CanvasRenderingContext2D): void;
  66904. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66905. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66906. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66907. protected _beforeRenderText(text: string): string;
  66908. dispose(): void;
  66909. }
  66910. }
  66911. declare module BABYLON.GUI {
  66912. /**
  66913. * Class used to create a 2D grid container
  66914. */
  66915. export class Grid extends Container {
  66916. name?: string | undefined;
  66917. private _rowDefinitions;
  66918. private _columnDefinitions;
  66919. private _cells;
  66920. private _childControls;
  66921. /**
  66922. * Gets the number of columns
  66923. */
  66924. readonly columnCount: number;
  66925. /**
  66926. * Gets the number of rows
  66927. */
  66928. readonly rowCount: number;
  66929. /** Gets the list of children */
  66930. readonly children: Control[];
  66931. /** Gets the list of cells (e.g. the containers) */
  66932. readonly cells: {
  66933. [key: string]: Container;
  66934. };
  66935. /**
  66936. * Gets the definition of a specific row
  66937. * @param index defines the index of the row
  66938. * @returns the row definition
  66939. */
  66940. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66941. /**
  66942. * Gets the definition of a specific column
  66943. * @param index defines the index of the column
  66944. * @returns the column definition
  66945. */
  66946. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66947. /**
  66948. * Adds a new row to the grid
  66949. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66950. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66951. * @returns the current grid
  66952. */
  66953. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66954. /**
  66955. * Adds a new column to the grid
  66956. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66957. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66958. * @returns the current grid
  66959. */
  66960. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66961. /**
  66962. * Update a row definition
  66963. * @param index defines the index of the row to update
  66964. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66965. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66966. * @returns the current grid
  66967. */
  66968. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66969. /**
  66970. * Update a column definition
  66971. * @param index defines the index of the column to update
  66972. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66973. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66974. * @returns the current grid
  66975. */
  66976. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66977. /**
  66978. * Gets the list of children stored in a specific cell
  66979. * @param row defines the row to check
  66980. * @param column defines the column to check
  66981. * @returns the list of controls
  66982. */
  66983. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66984. /**
  66985. * Gets a string representing the child cell info (row x column)
  66986. * @param child defines the control to get info from
  66987. * @returns a string containing the child cell info (row x column)
  66988. */
  66989. getChildCellInfo(child: Control): string;
  66990. private _removeCell;
  66991. private _offsetCell;
  66992. /**
  66993. * Remove a column definition at specified index
  66994. * @param index defines the index of the column to remove
  66995. * @returns the current grid
  66996. */
  66997. removeColumnDefinition(index: number): Grid;
  66998. /**
  66999. * Remove a row definition at specified index
  67000. * @param index defines the index of the row to remove
  67001. * @returns the current grid
  67002. */
  67003. removeRowDefinition(index: number): Grid;
  67004. /**
  67005. * Adds a new control to the current grid
  67006. * @param control defines the control to add
  67007. * @param row defines the row where to add the control (0 by default)
  67008. * @param column defines the column where to add the control (0 by default)
  67009. * @returns the current grid
  67010. */
  67011. addControl(control: Control, row?: number, column?: number): Grid;
  67012. /**
  67013. * Removes a control from the current container
  67014. * @param control defines the control to remove
  67015. * @returns the current container
  67016. */
  67017. removeControl(control: Control): Container;
  67018. /**
  67019. * Creates a new Grid
  67020. * @param name defines control name
  67021. */
  67022. constructor(name?: string | undefined);
  67023. protected _getTypeName(): string;
  67024. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  67025. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67026. _flagDescendantsAsMatrixDirty(): void;
  67027. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67028. /** Releases associated resources */
  67029. dispose(): void;
  67030. }
  67031. }
  67032. declare module BABYLON.GUI {
  67033. /** Class used to create color pickers */
  67034. export class ColorPicker extends Control {
  67035. name?: string | undefined;
  67036. private static _Epsilon;
  67037. private _colorWheelCanvas;
  67038. private _value;
  67039. private _tmpColor;
  67040. private _pointerStartedOnSquare;
  67041. private _pointerStartedOnWheel;
  67042. private _squareLeft;
  67043. private _squareTop;
  67044. private _squareSize;
  67045. private _h;
  67046. private _s;
  67047. private _v;
  67048. private _lastPointerDownID;
  67049. /**
  67050. * BABYLON.Observable raised when the value changes
  67051. */
  67052. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  67053. /** Gets or sets the color of the color picker */
  67054. value: BABYLON.Color3;
  67055. /**
  67056. * Gets or sets control width
  67057. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67058. */
  67059. width: string | number;
  67060. /**
  67061. * Gets or sets control height
  67062. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  67063. */
  67064. /** Gets or sets control height */
  67065. height: string | number;
  67066. /** Gets or sets control size */
  67067. size: string | number;
  67068. /**
  67069. * Creates a new ColorPicker
  67070. * @param name defines the control name
  67071. */
  67072. constructor(name?: string | undefined);
  67073. protected _getTypeName(): string;
  67074. /** @hidden */
  67075. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67076. private _updateSquareProps;
  67077. private _drawGradientSquare;
  67078. private _drawCircle;
  67079. private _createColorWheelCanvas;
  67080. /** @hidden */
  67081. _draw(context: CanvasRenderingContext2D): void;
  67082. private _pointerIsDown;
  67083. private _updateValueFromPointer;
  67084. private _isPointOnSquare;
  67085. private _isPointOnWheel;
  67086. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67087. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67088. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67089. /**
  67090. * This function expands the color picker by creating a color picker dialog with manual
  67091. * color value input and the ability to save colors into an array to be used later in
  67092. * subsequent launches of the dialogue.
  67093. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  67094. * @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.
  67095. * @returns picked color as a hex string and the saved colors array as hex strings.
  67096. */
  67097. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  67098. pickerWidth?: string;
  67099. pickerHeight?: string;
  67100. headerHeight?: string;
  67101. lastColor?: string;
  67102. swatchLimit?: number;
  67103. numSwatchesPerLine?: number;
  67104. savedColors?: Array<string>;
  67105. }): Promise<{
  67106. savedColors?: string[];
  67107. pickedColor: string;
  67108. }>;
  67109. }
  67110. }
  67111. declare module BABYLON.GUI {
  67112. /** Class used to create 2D ellipse containers */
  67113. export class Ellipse extends Container {
  67114. name?: string | undefined;
  67115. private _thickness;
  67116. /** Gets or sets border thickness */
  67117. thickness: number;
  67118. /**
  67119. * Creates a new Ellipse
  67120. * @param name defines the control name
  67121. */
  67122. constructor(name?: string | undefined);
  67123. protected _getTypeName(): string;
  67124. protected _localDraw(context: CanvasRenderingContext2D): void;
  67125. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67126. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  67127. }
  67128. }
  67129. declare module BABYLON.GUI {
  67130. /**
  67131. * Class used to create a password control
  67132. */
  67133. export class InputPassword extends InputText {
  67134. protected _beforeRenderText(text: string): string;
  67135. }
  67136. }
  67137. declare module BABYLON.GUI {
  67138. /** Class used to render 2D lines */
  67139. export class Line extends Control {
  67140. name?: string | undefined;
  67141. private _lineWidth;
  67142. private _x1;
  67143. private _y1;
  67144. private _x2;
  67145. private _y2;
  67146. private _dash;
  67147. private _connectedControl;
  67148. private _connectedControlDirtyObserver;
  67149. /** Gets or sets the dash pattern */
  67150. dash: Array<number>;
  67151. /** Gets or sets the control connected with the line end */
  67152. connectedControl: Control;
  67153. /** Gets or sets start coordinates on X axis */
  67154. x1: string | number;
  67155. /** Gets or sets start coordinates on Y axis */
  67156. y1: string | number;
  67157. /** Gets or sets end coordinates on X axis */
  67158. x2: string | number;
  67159. /** Gets or sets end coordinates on Y axis */
  67160. y2: string | number;
  67161. /** Gets or sets line width */
  67162. lineWidth: number;
  67163. /** Gets or sets horizontal alignment */
  67164. horizontalAlignment: number;
  67165. /** Gets or sets vertical alignment */
  67166. verticalAlignment: number;
  67167. private readonly _effectiveX2;
  67168. private readonly _effectiveY2;
  67169. /**
  67170. * Creates a new Line
  67171. * @param name defines the control name
  67172. */
  67173. constructor(name?: string | undefined);
  67174. protected _getTypeName(): string;
  67175. _draw(context: CanvasRenderingContext2D): void;
  67176. _measure(): void;
  67177. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67178. /**
  67179. * Move one end of the line given 3D cartesian coordinates.
  67180. * @param position Targeted world position
  67181. * @param scene BABYLON.Scene
  67182. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67183. */
  67184. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  67185. /**
  67186. * Move one end of the line to a position in screen absolute space.
  67187. * @param projectedPosition Position in screen absolute space (X, Y)
  67188. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  67189. */
  67190. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  67191. }
  67192. }
  67193. declare module BABYLON.GUI {
  67194. /**
  67195. * Class used to store a point for a MultiLine object.
  67196. * The point can be pure 2D coordinates, a mesh or a control
  67197. */
  67198. export class MultiLinePoint {
  67199. private _multiLine;
  67200. private _x;
  67201. private _y;
  67202. private _control;
  67203. private _mesh;
  67204. private _controlObserver;
  67205. private _meshObserver;
  67206. /** @hidden */
  67207. _point: BABYLON.Vector2;
  67208. /**
  67209. * Creates a new MultiLinePoint
  67210. * @param multiLine defines the source MultiLine object
  67211. */
  67212. constructor(multiLine: MultiLine);
  67213. /** Gets or sets x coordinate */
  67214. x: string | number;
  67215. /** Gets or sets y coordinate */
  67216. y: string | number;
  67217. /** Gets or sets the control associated with this point */
  67218. control: BABYLON.Nullable<Control>;
  67219. /** Gets or sets the mesh associated with this point */
  67220. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67221. /** Resets links */
  67222. resetLinks(): void;
  67223. /**
  67224. * Gets a translation vector
  67225. * @returns the translation vector
  67226. */
  67227. translate(): BABYLON.Vector2;
  67228. private _translatePoint;
  67229. /** Release associated resources */
  67230. dispose(): void;
  67231. }
  67232. }
  67233. declare module BABYLON.GUI {
  67234. /**
  67235. * Class used to create multi line control
  67236. */
  67237. export class MultiLine extends Control {
  67238. name?: string | undefined;
  67239. private _lineWidth;
  67240. private _dash;
  67241. private _points;
  67242. private _minX;
  67243. private _minY;
  67244. private _maxX;
  67245. private _maxY;
  67246. /**
  67247. * Creates a new MultiLine
  67248. * @param name defines the control name
  67249. */
  67250. constructor(name?: string | undefined);
  67251. /** Gets or sets dash pattern */
  67252. dash: Array<number>;
  67253. /**
  67254. * Gets point stored at specified index
  67255. * @param index defines the index to look for
  67256. * @returns the requested point if found
  67257. */
  67258. getAt(index: number): MultiLinePoint;
  67259. /** Function called when a point is updated */
  67260. onPointUpdate: () => void;
  67261. /**
  67262. * Adds new points to the point collection
  67263. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  67264. * @returns the list of created MultiLinePoint
  67265. */
  67266. add(...items: (AbstractMesh | Control | {
  67267. x: string | number;
  67268. y: string | number;
  67269. })[]): MultiLinePoint[];
  67270. /**
  67271. * Adds a new point to the point collection
  67272. * @param item defines the item (mesh, control or 2d coordiantes) to add
  67273. * @returns the created MultiLinePoint
  67274. */
  67275. push(item?: (AbstractMesh | Control | {
  67276. x: string | number;
  67277. y: string | number;
  67278. })): MultiLinePoint;
  67279. /**
  67280. * Remove a specific value or point from the active point collection
  67281. * @param value defines the value or point to remove
  67282. */
  67283. remove(value: number | MultiLinePoint): void;
  67284. /**
  67285. * Resets this object to initial state (no point)
  67286. */
  67287. reset(): void;
  67288. /**
  67289. * Resets all links
  67290. */
  67291. resetLinks(): void;
  67292. /** Gets or sets line width */
  67293. lineWidth: number;
  67294. horizontalAlignment: number;
  67295. verticalAlignment: number;
  67296. protected _getTypeName(): string;
  67297. _draw(context: CanvasRenderingContext2D): void;
  67298. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67299. _measure(): void;
  67300. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67301. dispose(): void;
  67302. }
  67303. }
  67304. declare module BABYLON.GUI {
  67305. /**
  67306. * Class used to create radio button controls
  67307. */
  67308. export class RadioButton extends Control {
  67309. name?: string | undefined;
  67310. private _isChecked;
  67311. private _background;
  67312. private _checkSizeRatio;
  67313. private _thickness;
  67314. /** Gets or sets border thickness */
  67315. thickness: number;
  67316. /** Gets or sets group name */
  67317. group: string;
  67318. /** BABYLON.Observable raised when isChecked is changed */
  67319. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  67320. /** Gets or sets a value indicating the ratio between overall size and check size */
  67321. checkSizeRatio: number;
  67322. /** Gets or sets background color */
  67323. background: string;
  67324. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  67325. isChecked: boolean;
  67326. /**
  67327. * Creates a new RadioButton
  67328. * @param name defines the control name
  67329. */
  67330. constructor(name?: string | undefined);
  67331. protected _getTypeName(): string;
  67332. _draw(context: CanvasRenderingContext2D): void;
  67333. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67334. /**
  67335. * Utility function to easily create a radio button with a header
  67336. * @param title defines the label to use for the header
  67337. * @param group defines the group to use for the radio button
  67338. * @param isChecked defines the initial state of the radio button
  67339. * @param onValueChanged defines the callback to call when value changes
  67340. * @returns a StackPanel containing the radio button and a textBlock
  67341. */
  67342. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  67343. }
  67344. }
  67345. declare module BABYLON.GUI {
  67346. /**
  67347. * Class used to create slider controls
  67348. */
  67349. export class BaseSlider extends Control {
  67350. name?: string | undefined;
  67351. protected _thumbWidth: ValueAndUnit;
  67352. private _minimum;
  67353. private _maximum;
  67354. private _value;
  67355. private _isVertical;
  67356. protected _barOffset: ValueAndUnit;
  67357. private _isThumbClamped;
  67358. protected _displayThumb: boolean;
  67359. private _step;
  67360. private _lastPointerDownID;
  67361. protected _effectiveBarOffset: number;
  67362. protected _renderLeft: number;
  67363. protected _renderTop: number;
  67364. protected _renderWidth: number;
  67365. protected _renderHeight: number;
  67366. protected _backgroundBoxLength: number;
  67367. protected _backgroundBoxThickness: number;
  67368. protected _effectiveThumbThickness: number;
  67369. /** BABYLON.Observable raised when the sldier value changes */
  67370. onValueChangedObservable: BABYLON.Observable<number>;
  67371. /** Gets or sets a boolean indicating if the thumb must be rendered */
  67372. displayThumb: boolean;
  67373. /** Gets or sets a step to apply to values (0 by default) */
  67374. step: number;
  67375. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  67376. barOffset: string | number;
  67377. /** Gets main bar offset in pixels*/
  67378. readonly barOffsetInPixels: number;
  67379. /** Gets or sets thumb width */
  67380. thumbWidth: string | number;
  67381. /** Gets thumb width in pixels */
  67382. readonly thumbWidthInPixels: number;
  67383. /** Gets or sets minimum value */
  67384. minimum: number;
  67385. /** Gets or sets maximum value */
  67386. maximum: number;
  67387. /** Gets or sets current value */
  67388. value: number;
  67389. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  67390. isVertical: boolean;
  67391. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  67392. isThumbClamped: boolean;
  67393. /**
  67394. * Creates a new BaseSlider
  67395. * @param name defines the control name
  67396. */
  67397. constructor(name?: string | undefined);
  67398. protected _getTypeName(): string;
  67399. protected _getThumbPosition(): number;
  67400. protected _getThumbThickness(type: string): number;
  67401. protected _prepareRenderingData(type: string): void;
  67402. private _pointerIsDown;
  67403. /** @hidden */
  67404. protected _updateValueFromPointer(x: number, y: number): void;
  67405. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67406. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  67407. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67408. }
  67409. }
  67410. declare module BABYLON.GUI {
  67411. /**
  67412. * Class used to create slider controls
  67413. */
  67414. export class Slider extends BaseSlider {
  67415. name?: string | undefined;
  67416. private _background;
  67417. private _borderColor;
  67418. private _isThumbCircle;
  67419. protected _displayValueBar: boolean;
  67420. /** Gets or sets a boolean indicating if the value bar must be rendered */
  67421. displayValueBar: boolean;
  67422. /** Gets or sets border color */
  67423. borderColor: string;
  67424. /** Gets or sets background color */
  67425. background: string;
  67426. /** Gets or sets a boolean indicating if the thumb should be round or square */
  67427. isThumbCircle: boolean;
  67428. /**
  67429. * Creates a new Slider
  67430. * @param name defines the control name
  67431. */
  67432. constructor(name?: string | undefined);
  67433. protected _getTypeName(): string;
  67434. _draw(context: CanvasRenderingContext2D): void;
  67435. }
  67436. }
  67437. declare module BABYLON.GUI {
  67438. /** Class used to create a RadioGroup
  67439. * which contains groups of radio buttons
  67440. */
  67441. export class SelectorGroup {
  67442. /** name of SelectorGroup */
  67443. name: string;
  67444. private _groupPanel;
  67445. private _selectors;
  67446. private _groupHeader;
  67447. /**
  67448. * Creates a new SelectorGroup
  67449. * @param name of group, used as a group heading
  67450. */
  67451. constructor(
  67452. /** name of SelectorGroup */
  67453. name: string);
  67454. /** Gets the groupPanel of the SelectorGroup */
  67455. readonly groupPanel: StackPanel;
  67456. /** Gets the selectors array */
  67457. readonly selectors: StackPanel[];
  67458. /** Gets and sets the group header */
  67459. header: string;
  67460. /** @hidden */
  67461. private _addGroupHeader;
  67462. /** @hidden*/
  67463. _getSelector(selectorNb: number): StackPanel | undefined;
  67464. /** Removes the selector at the given position
  67465. * @param selectorNb the position of the selector within the group
  67466. */
  67467. removeSelector(selectorNb: number): void;
  67468. }
  67469. /** Class used to create a CheckboxGroup
  67470. * which contains groups of checkbox buttons
  67471. */
  67472. export class CheckboxGroup extends SelectorGroup {
  67473. /** Adds a checkbox as a control
  67474. * @param text is the label for the selector
  67475. * @param func is the function called when the Selector is checked
  67476. * @param checked is true when Selector is checked
  67477. */
  67478. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  67479. /** @hidden */
  67480. _setSelectorLabel(selectorNb: number, label: string): void;
  67481. /** @hidden */
  67482. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67483. /** @hidden */
  67484. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67485. /** @hidden */
  67486. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67487. }
  67488. /** Class used to create a RadioGroup
  67489. * which contains groups of radio buttons
  67490. */
  67491. export class RadioGroup extends SelectorGroup {
  67492. private _selectNb;
  67493. /** Adds a radio button as a control
  67494. * @param label is the label for the selector
  67495. * @param func is the function called when the Selector is checked
  67496. * @param checked is true when Selector is checked
  67497. */
  67498. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  67499. /** @hidden */
  67500. _setSelectorLabel(selectorNb: number, label: string): void;
  67501. /** @hidden */
  67502. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67503. /** @hidden */
  67504. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67505. /** @hidden */
  67506. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67507. }
  67508. /** Class used to create a SliderGroup
  67509. * which contains groups of slider buttons
  67510. */
  67511. export class SliderGroup extends SelectorGroup {
  67512. /**
  67513. * Adds a slider to the SelectorGroup
  67514. * @param label is the label for the SliderBar
  67515. * @param func is the function called when the Slider moves
  67516. * @param unit is a string describing the units used, eg degrees or metres
  67517. * @param min is the minimum value for the Slider
  67518. * @param max is the maximum value for the Slider
  67519. * @param value is the start value for the Slider between min and max
  67520. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  67521. */
  67522. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  67523. /** @hidden */
  67524. _setSelectorLabel(selectorNb: number, label: string): void;
  67525. /** @hidden */
  67526. _setSelectorLabelColor(selectorNb: number, color: string): void;
  67527. /** @hidden */
  67528. _setSelectorButtonColor(selectorNb: number, color: string): void;
  67529. /** @hidden */
  67530. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  67531. }
  67532. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  67533. * @see http://doc.babylonjs.com/how_to/selector
  67534. */
  67535. export class SelectionPanel extends Rectangle {
  67536. /** name of SelectionPanel */
  67537. name: string;
  67538. /** an array of SelectionGroups */
  67539. groups: SelectorGroup[];
  67540. private _panel;
  67541. private _buttonColor;
  67542. private _buttonBackground;
  67543. private _headerColor;
  67544. private _barColor;
  67545. private _barHeight;
  67546. private _spacerHeight;
  67547. private _labelColor;
  67548. private _groups;
  67549. private _bars;
  67550. /**
  67551. * Creates a new SelectionPanel
  67552. * @param name of SelectionPanel
  67553. * @param groups is an array of SelectionGroups
  67554. */
  67555. constructor(
  67556. /** name of SelectionPanel */
  67557. name: string,
  67558. /** an array of SelectionGroups */
  67559. groups?: SelectorGroup[]);
  67560. protected _getTypeName(): string;
  67561. /** Gets or sets the headerColor */
  67562. headerColor: string;
  67563. private _setHeaderColor;
  67564. /** Gets or sets the button color */
  67565. buttonColor: string;
  67566. private _setbuttonColor;
  67567. /** Gets or sets the label color */
  67568. labelColor: string;
  67569. private _setLabelColor;
  67570. /** Gets or sets the button background */
  67571. buttonBackground: string;
  67572. private _setButtonBackground;
  67573. /** Gets or sets the color of separator bar */
  67574. barColor: string;
  67575. private _setBarColor;
  67576. /** Gets or sets the height of separator bar */
  67577. barHeight: string;
  67578. private _setBarHeight;
  67579. /** Gets or sets the height of spacers*/
  67580. spacerHeight: string;
  67581. private _setSpacerHeight;
  67582. /** Adds a bar between groups */
  67583. private _addSpacer;
  67584. /** Add a group to the selection panel
  67585. * @param group is the selector group to add
  67586. */
  67587. addGroup(group: SelectorGroup): void;
  67588. /** Remove the group from the given position
  67589. * @param groupNb is the position of the group in the list
  67590. */
  67591. removeGroup(groupNb: number): void;
  67592. /** Change a group header label
  67593. * @param label is the new group header label
  67594. * @param groupNb is the number of the group to relabel
  67595. * */
  67596. setHeaderName(label: string, groupNb: number): void;
  67597. /** Change selector label to the one given
  67598. * @param label is the new selector label
  67599. * @param groupNb is the number of the groupcontaining the selector
  67600. * @param selectorNb is the number of the selector within a group to relabel
  67601. * */
  67602. relabel(label: string, groupNb: number, selectorNb: number): void;
  67603. /** For a given group position remove the selector at the given position
  67604. * @param groupNb is the number of the group to remove the selector from
  67605. * @param selectorNb is the number of the selector within the group
  67606. */
  67607. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67608. /** For a given group position of correct type add a checkbox button
  67609. * @param groupNb is the number of the group to remove the selector from
  67610. * @param label is the label for the selector
  67611. * @param func is the function called when the Selector is checked
  67612. * @param checked is true when Selector is checked
  67613. */
  67614. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67615. /** For a given group position of correct type add a radio button
  67616. * @param groupNb is the number of the group to remove the selector from
  67617. * @param label is the label for the selector
  67618. * @param func is the function called when the Selector is checked
  67619. * @param checked is true when Selector is checked
  67620. */
  67621. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67622. /**
  67623. * For a given slider group add a slider
  67624. * @param groupNb is the number of the group to add the slider to
  67625. * @param label is the label for the Slider
  67626. * @param func is the function called when the Slider moves
  67627. * @param unit is a string describing the units used, eg degrees or metres
  67628. * @param min is the minimum value for the Slider
  67629. * @param max is the maximum value for the Slider
  67630. * @param value is the start value for the Slider between min and max
  67631. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67632. */
  67633. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67634. }
  67635. }
  67636. declare module BABYLON.GUI {
  67637. /**
  67638. * Class used to hold a the container for ScrollViewer
  67639. * @hidden
  67640. */
  67641. export class _ScrollViewerWindow extends Container {
  67642. parentClientWidth: number;
  67643. parentClientHeight: number;
  67644. /**
  67645. * Creates a new ScrollViewerWindow
  67646. * @param name of ScrollViewerWindow
  67647. */
  67648. constructor(name?: string);
  67649. protected _getTypeName(): string;
  67650. /** @hidden */
  67651. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67652. protected _postMeasure(): void;
  67653. }
  67654. }
  67655. declare module BABYLON.GUI {
  67656. /**
  67657. * Class used to create slider controls
  67658. */
  67659. export class ScrollBar extends BaseSlider {
  67660. name?: string | undefined;
  67661. private _background;
  67662. private _borderColor;
  67663. private _thumbMeasure;
  67664. /** Gets or sets border color */
  67665. borderColor: string;
  67666. /** Gets or sets background color */
  67667. background: string;
  67668. /**
  67669. * Creates a new Slider
  67670. * @param name defines the control name
  67671. */
  67672. constructor(name?: string | undefined);
  67673. protected _getTypeName(): string;
  67674. protected _getThumbThickness(): number;
  67675. _draw(context: CanvasRenderingContext2D): void;
  67676. private _first;
  67677. private _originX;
  67678. private _originY;
  67679. /** @hidden */
  67680. protected _updateValueFromPointer(x: number, y: number): void;
  67681. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67682. }
  67683. }
  67684. declare module BABYLON.GUI {
  67685. /**
  67686. * Class used to hold a viewer window and sliders in a grid
  67687. */
  67688. export class ScrollViewer extends Rectangle {
  67689. private _grid;
  67690. private _horizontalBarSpace;
  67691. private _verticalBarSpace;
  67692. private _dragSpace;
  67693. private _horizontalBar;
  67694. private _verticalBar;
  67695. private _barColor;
  67696. private _barBackground;
  67697. private _barSize;
  67698. private _endLeft;
  67699. private _endTop;
  67700. private _window;
  67701. private _pointerIsOver;
  67702. private _wheelPrecision;
  67703. private _onPointerObserver;
  67704. private _clientWidth;
  67705. private _clientHeight;
  67706. /**
  67707. * Gets the horizontal scrollbar
  67708. */
  67709. readonly horizontalBar: ScrollBar;
  67710. /**
  67711. * Gets the vertical scrollbar
  67712. */
  67713. readonly verticalBar: ScrollBar;
  67714. /**
  67715. * Adds a new control to the current container
  67716. * @param control defines the control to add
  67717. * @returns the current container
  67718. */
  67719. addControl(control: BABYLON.Nullable<Control>): Container;
  67720. /**
  67721. * Removes a control from the current container
  67722. * @param control defines the control to remove
  67723. * @returns the current container
  67724. */
  67725. removeControl(control: Control): Container;
  67726. /** Gets the list of children */
  67727. readonly children: Control[];
  67728. _flagDescendantsAsMatrixDirty(): void;
  67729. /**
  67730. * Creates a new ScrollViewer
  67731. * @param name of ScrollViewer
  67732. */
  67733. constructor(name?: string);
  67734. /** Reset the scroll viewer window to initial size */
  67735. resetWindow(): void;
  67736. protected _getTypeName(): string;
  67737. private _buildClientSizes;
  67738. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67739. protected _postMeasure(): void;
  67740. /**
  67741. * Gets or sets the mouse wheel precision
  67742. * from 0 to 1 with a default value of 0.05
  67743. * */
  67744. wheelPrecision: number;
  67745. /** Gets or sets the bar color */
  67746. barColor: string;
  67747. /** Gets or sets the size of the bar */
  67748. barSize: number;
  67749. /** Gets or sets the bar background */
  67750. barBackground: string;
  67751. /** @hidden */
  67752. private _updateScroller;
  67753. _link(host: AdvancedDynamicTexture): void;
  67754. /** @hidden */
  67755. private _attachWheel;
  67756. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67757. /** Releases associated resources */
  67758. dispose(): void;
  67759. }
  67760. }
  67761. declare module BABYLON.GUI {
  67762. /** Class used to render a grid */
  67763. export class DisplayGrid extends Control {
  67764. name?: string | undefined;
  67765. private _cellWidth;
  67766. private _cellHeight;
  67767. private _minorLineTickness;
  67768. private _minorLineColor;
  67769. private _majorLineTickness;
  67770. private _majorLineColor;
  67771. private _majorLineFrequency;
  67772. private _background;
  67773. private _displayMajorLines;
  67774. private _displayMinorLines;
  67775. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67776. displayMinorLines: boolean;
  67777. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67778. displayMajorLines: boolean;
  67779. /** Gets or sets background color (Black by default) */
  67780. background: string;
  67781. /** Gets or sets the width of each cell (20 by default) */
  67782. cellWidth: number;
  67783. /** Gets or sets the height of each cell (20 by default) */
  67784. cellHeight: number;
  67785. /** Gets or sets the tickness of minor lines (1 by default) */
  67786. minorLineTickness: number;
  67787. /** Gets or sets the color of minor lines (DarkGray by default) */
  67788. minorLineColor: string;
  67789. /** Gets or sets the tickness of major lines (2 by default) */
  67790. majorLineTickness: number;
  67791. /** Gets or sets the color of major lines (White by default) */
  67792. majorLineColor: string;
  67793. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67794. majorLineFrequency: number;
  67795. /**
  67796. * Creates a new GridDisplayRectangle
  67797. * @param name defines the control name
  67798. */
  67799. constructor(name?: string | undefined);
  67800. _draw(context: CanvasRenderingContext2D): void;
  67801. protected _getTypeName(): string;
  67802. }
  67803. }
  67804. declare module BABYLON.GUI {
  67805. /**
  67806. * Class used to create slider controls based on images
  67807. */
  67808. export class ImageBasedSlider extends BaseSlider {
  67809. name?: string | undefined;
  67810. private _backgroundImage;
  67811. private _thumbImage;
  67812. private _valueBarImage;
  67813. private _tempMeasure;
  67814. displayThumb: boolean;
  67815. /**
  67816. * Gets or sets the image used to render the background
  67817. */
  67818. backgroundImage: Image;
  67819. /**
  67820. * Gets or sets the image used to render the value bar
  67821. */
  67822. valueBarImage: Image;
  67823. /**
  67824. * Gets or sets the image used to render the thumb
  67825. */
  67826. thumbImage: Image;
  67827. /**
  67828. * Creates a new ImageBasedSlider
  67829. * @param name defines the control name
  67830. */
  67831. constructor(name?: string | undefined);
  67832. protected _getTypeName(): string;
  67833. _draw(context: CanvasRenderingContext2D): void;
  67834. }
  67835. }
  67836. declare module BABYLON.GUI {
  67837. /**
  67838. * Forcing an export so that this code will execute
  67839. * @hidden
  67840. */
  67841. const name = "Statics";
  67842. }
  67843. declare module BABYLON.GUI {
  67844. /**
  67845. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67846. */
  67847. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67848. /**
  67849. * Define the instrumented AdvancedDynamicTexture.
  67850. */
  67851. texture: AdvancedDynamicTexture;
  67852. private _captureRenderTime;
  67853. private _renderTime;
  67854. private _captureLayoutTime;
  67855. private _layoutTime;
  67856. private _onBeginRenderObserver;
  67857. private _onEndRenderObserver;
  67858. private _onBeginLayoutObserver;
  67859. private _onEndLayoutObserver;
  67860. /**
  67861. * Gets the perf counter used to capture render time
  67862. */
  67863. readonly renderTimeCounter: BABYLON.PerfCounter;
  67864. /**
  67865. * Gets the perf counter used to capture layout time
  67866. */
  67867. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67868. /**
  67869. * Enable or disable the render time capture
  67870. */
  67871. captureRenderTime: boolean;
  67872. /**
  67873. * Enable or disable the layout time capture
  67874. */
  67875. captureLayoutTime: boolean;
  67876. /**
  67877. * Instantiates a new advanced dynamic texture instrumentation.
  67878. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67879. * @param texture Defines the AdvancedDynamicTexture to instrument
  67880. */
  67881. constructor(
  67882. /**
  67883. * Define the instrumented AdvancedDynamicTexture.
  67884. */
  67885. texture: AdvancedDynamicTexture);
  67886. /**
  67887. * Dispose and release associated resources.
  67888. */
  67889. dispose(): void;
  67890. }
  67891. }
  67892. declare module BABYLON.GUI {
  67893. /**
  67894. * Class used to load GUI via XML.
  67895. */
  67896. export class XmlLoader {
  67897. private _nodes;
  67898. private _nodeTypes;
  67899. private _isLoaded;
  67900. private _objectAttributes;
  67901. private _parentClass;
  67902. /**
  67903. * Create a new xml loader
  67904. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67905. */
  67906. constructor(parentClass?: null);
  67907. private _getChainElement;
  67908. private _getClassAttribute;
  67909. private _createGuiElement;
  67910. private _parseGrid;
  67911. private _parseElement;
  67912. private _prepareSourceElement;
  67913. private _parseElementsFromSource;
  67914. private _parseXml;
  67915. /**
  67916. * Gets if the loading has finished.
  67917. * @returns whether the loading has finished or not
  67918. */
  67919. isLoaded(): boolean;
  67920. /**
  67921. * Gets a loaded node / control by id.
  67922. * @param id the Controls id set in the xml
  67923. * @returns element of type Control
  67924. */
  67925. getNodeById(id: string): any;
  67926. /**
  67927. * Gets all loaded nodes / controls
  67928. * @returns Array of controls
  67929. */
  67930. getNodes(): any;
  67931. /**
  67932. * Initiates the xml layout loading
  67933. * @param xmlFile defines the xml layout to load
  67934. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67935. * @param callback defines the callback called on layout load.
  67936. */
  67937. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67938. }
  67939. }
  67940. declare module BABYLON.GUI {
  67941. /**
  67942. * Class used to create containers for controls
  67943. */
  67944. export class Container3D extends Control3D {
  67945. private _blockLayout;
  67946. /**
  67947. * Gets the list of child controls
  67948. */
  67949. protected _children: Control3D[];
  67950. /**
  67951. * Gets the list of child controls
  67952. */
  67953. readonly children: Array<Control3D>;
  67954. /**
  67955. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67956. * This is helpful to optimize layout operation when adding multiple children in a row
  67957. */
  67958. blockLayout: boolean;
  67959. /**
  67960. * Creates a new container
  67961. * @param name defines the container name
  67962. */
  67963. constructor(name?: string);
  67964. /**
  67965. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67966. * @returns the current container
  67967. */
  67968. updateLayout(): Container3D;
  67969. /**
  67970. * Gets a boolean indicating if the given control is in the children of this control
  67971. * @param control defines the control to check
  67972. * @returns true if the control is in the child list
  67973. */
  67974. containsControl(control: Control3D): boolean;
  67975. /**
  67976. * Adds a control to the children of this control
  67977. * @param control defines the control to add
  67978. * @returns the current container
  67979. */
  67980. addControl(control: Control3D): Container3D;
  67981. /**
  67982. * This function will be called everytime a new control is added
  67983. */
  67984. protected _arrangeChildren(): void;
  67985. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67986. /**
  67987. * Removes a control from the children of this control
  67988. * @param control defines the control to remove
  67989. * @returns the current container
  67990. */
  67991. removeControl(control: Control3D): Container3D;
  67992. protected _getTypeName(): string;
  67993. /**
  67994. * Releases all associated resources
  67995. */
  67996. dispose(): void;
  67997. /** Control rotation will remain unchanged */
  67998. static readonly UNSET_ORIENTATION: number;
  67999. /** Control will rotate to make it look at sphere central axis */
  68000. static readonly FACEORIGIN_ORIENTATION: number;
  68001. /** Control will rotate to make it look back at sphere central axis */
  68002. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  68003. /** Control will rotate to look at z axis (0, 0, 1) */
  68004. static readonly FACEFORWARD_ORIENTATION: number;
  68005. /** Control will rotate to look at negative z axis (0, 0, -1) */
  68006. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  68007. }
  68008. }
  68009. declare module BABYLON.GUI {
  68010. /**
  68011. * Class used to manage 3D user interface
  68012. * @see http://doc.babylonjs.com/how_to/gui3d
  68013. */
  68014. export class GUI3DManager implements BABYLON.IDisposable {
  68015. private _scene;
  68016. private _sceneDisposeObserver;
  68017. private _utilityLayer;
  68018. private _rootContainer;
  68019. private _pointerObserver;
  68020. private _pointerOutObserver;
  68021. /** @hidden */
  68022. _lastPickedControl: Control3D;
  68023. /** @hidden */
  68024. _lastControlOver: {
  68025. [pointerId: number]: Control3D;
  68026. };
  68027. /** @hidden */
  68028. _lastControlDown: {
  68029. [pointerId: number]: Control3D;
  68030. };
  68031. /**
  68032. * BABYLON.Observable raised when the point picked by the pointer events changed
  68033. */
  68034. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  68035. /** @hidden */
  68036. _sharedMaterials: {
  68037. [key: string]: BABYLON.Material;
  68038. };
  68039. /** Gets the hosting scene */
  68040. readonly scene: BABYLON.Scene;
  68041. /** Gets associated utility layer */
  68042. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  68043. /**
  68044. * Creates a new GUI3DManager
  68045. * @param scene
  68046. */
  68047. constructor(scene?: BABYLON.Scene);
  68048. private _handlePointerOut;
  68049. private _doPicking;
  68050. /**
  68051. * Gets the root container
  68052. */
  68053. readonly rootContainer: Container3D;
  68054. /**
  68055. * Gets a boolean indicating if the given control is in the root child list
  68056. * @param control defines the control to check
  68057. * @returns true if the control is in the root child list
  68058. */
  68059. containsControl(control: Control3D): boolean;
  68060. /**
  68061. * Adds a control to the root child list
  68062. * @param control defines the control to add
  68063. * @returns the current manager
  68064. */
  68065. addControl(control: Control3D): GUI3DManager;
  68066. /**
  68067. * Removes a control from the root child list
  68068. * @param control defines the control to remove
  68069. * @returns the current container
  68070. */
  68071. removeControl(control: Control3D): GUI3DManager;
  68072. /**
  68073. * Releases all associated resources
  68074. */
  68075. dispose(): void;
  68076. }
  68077. }
  68078. declare module BABYLON.GUI {
  68079. /**
  68080. * Class used to transport BABYLON.Vector3 information for pointer events
  68081. */
  68082. export class Vector3WithInfo extends BABYLON.Vector3 {
  68083. /** defines the current mouse button index */
  68084. buttonIndex: number;
  68085. /**
  68086. * Creates a new Vector3WithInfo
  68087. * @param source defines the vector3 data to transport
  68088. * @param buttonIndex defines the current mouse button index
  68089. */
  68090. constructor(source: BABYLON.Vector3,
  68091. /** defines the current mouse button index */
  68092. buttonIndex?: number);
  68093. }
  68094. }
  68095. declare module BABYLON.GUI {
  68096. /**
  68097. * Class used as base class for controls
  68098. */
  68099. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  68100. /** Defines the control name */
  68101. name?: string | undefined;
  68102. /** @hidden */
  68103. _host: GUI3DManager;
  68104. private _node;
  68105. private _downCount;
  68106. private _enterCount;
  68107. private _downPointerIds;
  68108. private _isVisible;
  68109. /** Gets or sets the control position in world space */
  68110. position: BABYLON.Vector3;
  68111. /** Gets or sets the control scaling in world space */
  68112. scaling: BABYLON.Vector3;
  68113. /** Callback used to start pointer enter animation */
  68114. pointerEnterAnimation: () => void;
  68115. /** Callback used to start pointer out animation */
  68116. pointerOutAnimation: () => void;
  68117. /** Callback used to start pointer down animation */
  68118. pointerDownAnimation: () => void;
  68119. /** Callback used to start pointer up animation */
  68120. pointerUpAnimation: () => void;
  68121. /**
  68122. * An event triggered when the pointer move over the control
  68123. */
  68124. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  68125. /**
  68126. * An event triggered when the pointer move out of the control
  68127. */
  68128. onPointerOutObservable: BABYLON.Observable<Control3D>;
  68129. /**
  68130. * An event triggered when the pointer taps the control
  68131. */
  68132. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  68133. /**
  68134. * An event triggered when pointer is up
  68135. */
  68136. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  68137. /**
  68138. * An event triggered when a control is clicked on (with a mouse)
  68139. */
  68140. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  68141. /**
  68142. * An event triggered when pointer enters the control
  68143. */
  68144. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  68145. /**
  68146. * Gets or sets the parent container
  68147. */
  68148. parent: BABYLON.Nullable<Container3D>;
  68149. private _behaviors;
  68150. /**
  68151. * Gets the list of attached behaviors
  68152. * @see http://doc.babylonjs.com/features/behaviour
  68153. */
  68154. readonly behaviors: BABYLON.Behavior<Control3D>[];
  68155. /**
  68156. * Attach a behavior to the control
  68157. * @see http://doc.babylonjs.com/features/behaviour
  68158. * @param behavior defines the behavior to attach
  68159. * @returns the current control
  68160. */
  68161. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68162. /**
  68163. * Remove an attached behavior
  68164. * @see http://doc.babylonjs.com/features/behaviour
  68165. * @param behavior defines the behavior to attach
  68166. * @returns the current control
  68167. */
  68168. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  68169. /**
  68170. * Gets an attached behavior by name
  68171. * @param name defines the name of the behavior to look for
  68172. * @see http://doc.babylonjs.com/features/behaviour
  68173. * @returns null if behavior was not found else the requested behavior
  68174. */
  68175. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  68176. /** Gets or sets a boolean indicating if the control is visible */
  68177. isVisible: boolean;
  68178. /**
  68179. * Creates a new control
  68180. * @param name defines the control name
  68181. */
  68182. constructor(
  68183. /** Defines the control name */
  68184. name?: string | undefined);
  68185. /**
  68186. * Gets a string representing the class name
  68187. */
  68188. readonly typeName: string;
  68189. /**
  68190. * Get the current class name of the control.
  68191. * @returns current class name
  68192. */
  68193. getClassName(): string;
  68194. protected _getTypeName(): string;
  68195. /**
  68196. * Gets the transform node used by this control
  68197. */
  68198. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  68199. /**
  68200. * Gets the mesh used to render this control
  68201. */
  68202. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  68203. /**
  68204. * Link the control as child of the given node
  68205. * @param node defines the node to link to. Use null to unlink the control
  68206. * @returns the current control
  68207. */
  68208. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  68209. /** @hidden **/
  68210. _prepareNode(scene: BABYLON.Scene): void;
  68211. /**
  68212. * Node creation.
  68213. * Can be overriden by children
  68214. * @param scene defines the scene where the node must be attached
  68215. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  68216. */
  68217. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  68218. /**
  68219. * Affect a material to the given mesh
  68220. * @param mesh defines the mesh which will represent the control
  68221. */
  68222. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68223. /** @hidden */
  68224. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  68225. /** @hidden */
  68226. _onPointerEnter(target: Control3D): boolean;
  68227. /** @hidden */
  68228. _onPointerOut(target: Control3D): void;
  68229. /** @hidden */
  68230. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68231. /** @hidden */
  68232. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  68233. /** @hidden */
  68234. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  68235. /** @hidden */
  68236. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  68237. /** @hidden */
  68238. _disposeNode(): void;
  68239. /**
  68240. * Releases all associated resources
  68241. */
  68242. dispose(): void;
  68243. }
  68244. }
  68245. declare module BABYLON.GUI {
  68246. /**
  68247. * Class used as a root to all buttons
  68248. */
  68249. export class AbstractButton3D extends Control3D {
  68250. /**
  68251. * Creates a new button
  68252. * @param name defines the control name
  68253. */
  68254. constructor(name?: string);
  68255. protected _getTypeName(): string;
  68256. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68257. }
  68258. }
  68259. declare module BABYLON.GUI {
  68260. /**
  68261. * Class used to create a button in 3D
  68262. */
  68263. export class Button3D extends AbstractButton3D {
  68264. /** @hidden */
  68265. protected _currentMaterial: BABYLON.Material;
  68266. private _facadeTexture;
  68267. private _content;
  68268. private _contentResolution;
  68269. private _contentScaleRatio;
  68270. /**
  68271. * Gets or sets the texture resolution used to render content (512 by default)
  68272. */
  68273. contentResolution: BABYLON.int;
  68274. /**
  68275. * Gets or sets the texture scale ratio used to render content (2 by default)
  68276. */
  68277. contentScaleRatio: number;
  68278. protected _disposeFacadeTexture(): void;
  68279. protected _resetContent(): void;
  68280. /**
  68281. * Creates a new button
  68282. * @param name defines the control name
  68283. */
  68284. constructor(name?: string);
  68285. /**
  68286. * Gets or sets the GUI 2D content used to display the button's facade
  68287. */
  68288. content: Control;
  68289. /**
  68290. * Apply the facade texture (created from the content property).
  68291. * This function can be overloaded by child classes
  68292. * @param facadeTexture defines the AdvancedDynamicTexture to use
  68293. */
  68294. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68295. protected _getTypeName(): string;
  68296. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68297. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68298. /**
  68299. * Releases all associated resources
  68300. */
  68301. dispose(): void;
  68302. }
  68303. }
  68304. declare module BABYLON.GUI {
  68305. /**
  68306. * Abstract class used to create a container panel deployed on the surface of a volume
  68307. */
  68308. export abstract class VolumeBasedPanel extends Container3D {
  68309. private _columns;
  68310. private _rows;
  68311. private _rowThenColum;
  68312. private _orientation;
  68313. protected _cellWidth: number;
  68314. protected _cellHeight: number;
  68315. /**
  68316. * Gets or sets the distance between elements
  68317. */
  68318. margin: number;
  68319. /**
  68320. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  68321. * | Value | Type | Description |
  68322. * | ----- | ----------------------------------- | ----------- |
  68323. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  68324. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  68325. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  68326. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  68327. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  68328. */
  68329. orientation: number;
  68330. /**
  68331. * Gets or sets the number of columns requested (10 by default).
  68332. * The panel will automatically compute the number of rows based on number of child controls.
  68333. */
  68334. columns: BABYLON.int;
  68335. /**
  68336. * Gets or sets a the number of rows requested.
  68337. * The panel will automatically compute the number of columns based on number of child controls.
  68338. */
  68339. rows: BABYLON.int;
  68340. /**
  68341. * Creates new VolumeBasedPanel
  68342. */
  68343. constructor();
  68344. protected _arrangeChildren(): void;
  68345. /** Child classes must implement this function to provide correct control positioning */
  68346. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68347. /** Child classes can implement this function to provide additional processing */
  68348. protected _finalProcessing(): void;
  68349. }
  68350. }
  68351. declare module BABYLON.GUI {
  68352. /**
  68353. * Class used to create a container panel deployed on the surface of a cylinder
  68354. */
  68355. export class CylinderPanel extends VolumeBasedPanel {
  68356. private _radius;
  68357. /**
  68358. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  68359. */
  68360. radius: BABYLON.float;
  68361. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68362. private _cylindricalMapping;
  68363. }
  68364. }
  68365. declare module BABYLON.GUI {
  68366. /** @hidden */
  68367. export var fluentVertexShader: {
  68368. name: string;
  68369. shader: string;
  68370. };
  68371. }
  68372. declare module BABYLON.GUI {
  68373. /** @hidden */
  68374. export var fluentPixelShader: {
  68375. name: string;
  68376. shader: string;
  68377. };
  68378. }
  68379. declare module BABYLON.GUI {
  68380. /** @hidden */
  68381. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  68382. INNERGLOW: boolean;
  68383. BORDER: boolean;
  68384. HOVERLIGHT: boolean;
  68385. TEXTURE: boolean;
  68386. constructor();
  68387. }
  68388. /**
  68389. * Class used to render controls with fluent desgin
  68390. */
  68391. export class FluentMaterial extends BABYLON.PushMaterial {
  68392. /**
  68393. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  68394. */
  68395. innerGlowColorIntensity: number;
  68396. /**
  68397. * Gets or sets the inner glow color (white by default)
  68398. */
  68399. innerGlowColor: BABYLON.Color3;
  68400. /**
  68401. * Gets or sets alpha value (default is 1.0)
  68402. */
  68403. alpha: number;
  68404. /**
  68405. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  68406. */
  68407. albedoColor: BABYLON.Color3;
  68408. /**
  68409. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  68410. */
  68411. renderBorders: boolean;
  68412. /**
  68413. * Gets or sets border width (default is 0.5)
  68414. */
  68415. borderWidth: number;
  68416. /**
  68417. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  68418. */
  68419. edgeSmoothingValue: number;
  68420. /**
  68421. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  68422. */
  68423. borderMinValue: number;
  68424. /**
  68425. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  68426. */
  68427. renderHoverLight: boolean;
  68428. /**
  68429. * Gets or sets the radius used to render the hover light (default is 1.0)
  68430. */
  68431. hoverRadius: number;
  68432. /**
  68433. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  68434. */
  68435. hoverColor: BABYLON.Color4;
  68436. /**
  68437. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  68438. */
  68439. hoverPosition: BABYLON.Vector3;
  68440. private _albedoTexture;
  68441. /** Gets or sets the texture to use for albedo color */
  68442. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68443. /**
  68444. * Creates a new Fluent material
  68445. * @param name defines the name of the material
  68446. * @param scene defines the hosting scene
  68447. */
  68448. constructor(name: string, scene: BABYLON.Scene);
  68449. needAlphaBlending(): boolean;
  68450. needAlphaTesting(): boolean;
  68451. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68452. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68453. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68454. getActiveTextures(): BABYLON.BaseTexture[];
  68455. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68456. dispose(forceDisposeEffect?: boolean): void;
  68457. clone(name: string): FluentMaterial;
  68458. serialize(): any;
  68459. getClassName(): string;
  68460. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  68461. }
  68462. }
  68463. declare module BABYLON.GUI {
  68464. /**
  68465. * Class used to create a holographic button in 3D
  68466. */
  68467. export class HolographicButton extends Button3D {
  68468. private _backPlate;
  68469. private _textPlate;
  68470. private _frontPlate;
  68471. private _text;
  68472. private _imageUrl;
  68473. private _shareMaterials;
  68474. private _frontMaterial;
  68475. private _backMaterial;
  68476. private _plateMaterial;
  68477. private _pickedPointObserver;
  68478. private _tooltipFade;
  68479. private _tooltipTextBlock;
  68480. private _tooltipTexture;
  68481. private _tooltipMesh;
  68482. private _tooltipHoverObserver;
  68483. private _tooltipOutObserver;
  68484. private _disposeTooltip;
  68485. /**
  68486. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  68487. */
  68488. tooltipText: BABYLON.Nullable<string>;
  68489. /**
  68490. * Gets or sets text for the button
  68491. */
  68492. text: string;
  68493. /**
  68494. * Gets or sets the image url for the button
  68495. */
  68496. imageUrl: string;
  68497. /**
  68498. * Gets the back material used by this button
  68499. */
  68500. readonly backMaterial: FluentMaterial;
  68501. /**
  68502. * Gets the front material used by this button
  68503. */
  68504. readonly frontMaterial: FluentMaterial;
  68505. /**
  68506. * Gets the plate material used by this button
  68507. */
  68508. readonly plateMaterial: BABYLON.StandardMaterial;
  68509. /**
  68510. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  68511. */
  68512. readonly shareMaterials: boolean;
  68513. /**
  68514. * Creates a new button
  68515. * @param name defines the control name
  68516. */
  68517. constructor(name?: string, shareMaterials?: boolean);
  68518. protected _getTypeName(): string;
  68519. private _rebuildContent;
  68520. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68521. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  68522. private _createBackMaterial;
  68523. private _createFrontMaterial;
  68524. private _createPlateMaterial;
  68525. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  68526. /**
  68527. * Releases all associated resources
  68528. */
  68529. dispose(): void;
  68530. }
  68531. }
  68532. declare module BABYLON.GUI {
  68533. /**
  68534. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  68535. */
  68536. export class MeshButton3D extends Button3D {
  68537. /** @hidden */
  68538. protected _currentMesh: BABYLON.Mesh;
  68539. /**
  68540. * Creates a new 3D button based on a mesh
  68541. * @param mesh mesh to become a 3D button
  68542. * @param name defines the control name
  68543. */
  68544. constructor(mesh: BABYLON.Mesh, name?: string);
  68545. protected _getTypeName(): string;
  68546. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  68547. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  68548. }
  68549. }
  68550. declare module BABYLON.GUI {
  68551. /**
  68552. * Class used to create a container panel deployed on the surface of a plane
  68553. */
  68554. export class PlanePanel extends VolumeBasedPanel {
  68555. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68556. }
  68557. }
  68558. declare module BABYLON.GUI {
  68559. /**
  68560. * Class used to create a container panel where items get randomized planar mapping
  68561. */
  68562. export class ScatterPanel extends VolumeBasedPanel {
  68563. private _iteration;
  68564. /**
  68565. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  68566. */
  68567. iteration: BABYLON.float;
  68568. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68569. private _scatterMapping;
  68570. protected _finalProcessing(): void;
  68571. }
  68572. }
  68573. declare module BABYLON.GUI {
  68574. /**
  68575. * Class used to create a container panel deployed on the surface of a sphere
  68576. */
  68577. export class SpherePanel extends VolumeBasedPanel {
  68578. private _radius;
  68579. /**
  68580. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68581. */
  68582. radius: BABYLON.float;
  68583. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68584. private _sphericalMapping;
  68585. }
  68586. }
  68587. declare module BABYLON.GUI {
  68588. /**
  68589. * Class used to create a stack panel in 3D on XY plane
  68590. */
  68591. export class StackPanel3D extends Container3D {
  68592. private _isVertical;
  68593. /**
  68594. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68595. */
  68596. isVertical: boolean;
  68597. /**
  68598. * Gets or sets the distance between elements
  68599. */
  68600. margin: number;
  68601. /**
  68602. * Creates new StackPanel
  68603. * @param isVertical
  68604. */
  68605. constructor(isVertical?: boolean);
  68606. protected _arrangeChildren(): void;
  68607. }
  68608. }
  68609. declare module BABYLON {
  68610. /**
  68611. * Mode that determines the coordinate system to use.
  68612. */
  68613. export enum GLTFLoaderCoordinateSystemMode {
  68614. /**
  68615. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68616. */
  68617. AUTO = 0,
  68618. /**
  68619. * Sets the useRightHandedSystem flag on the scene.
  68620. */
  68621. FORCE_RIGHT_HANDED = 1
  68622. }
  68623. /**
  68624. * Mode that determines what animations will start.
  68625. */
  68626. export enum GLTFLoaderAnimationStartMode {
  68627. /**
  68628. * No animation will start.
  68629. */
  68630. NONE = 0,
  68631. /**
  68632. * The first animation will start.
  68633. */
  68634. FIRST = 1,
  68635. /**
  68636. * All animations will start.
  68637. */
  68638. ALL = 2
  68639. }
  68640. /**
  68641. * Interface that contains the data for the glTF asset.
  68642. */
  68643. export interface IGLTFLoaderData {
  68644. /**
  68645. * The object that represents the glTF JSON.
  68646. */
  68647. json: Object;
  68648. /**
  68649. * The BIN chunk of a binary glTF.
  68650. */
  68651. bin: Nullable<IDataBuffer>;
  68652. }
  68653. /**
  68654. * Interface for extending the loader.
  68655. */
  68656. export interface IGLTFLoaderExtension {
  68657. /**
  68658. * The name of this extension.
  68659. */
  68660. readonly name: string;
  68661. /**
  68662. * Defines whether this extension is enabled.
  68663. */
  68664. enabled: boolean;
  68665. /**
  68666. * Defines the order of this extension.
  68667. * The loader sorts the extensions using these values when loading.
  68668. */
  68669. order?: number;
  68670. }
  68671. /**
  68672. * Loader state.
  68673. */
  68674. export enum GLTFLoaderState {
  68675. /**
  68676. * The asset is loading.
  68677. */
  68678. LOADING = 0,
  68679. /**
  68680. * The asset is ready for rendering.
  68681. */
  68682. READY = 1,
  68683. /**
  68684. * The asset is completely loaded.
  68685. */
  68686. COMPLETE = 2
  68687. }
  68688. /** @hidden */
  68689. export interface IGLTFLoader extends IDisposable {
  68690. readonly state: Nullable<GLTFLoaderState>;
  68691. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68692. meshes: AbstractMesh[];
  68693. particleSystems: IParticleSystem[];
  68694. skeletons: Skeleton[];
  68695. animationGroups: AnimationGroup[];
  68696. }>;
  68697. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68698. }
  68699. /**
  68700. * File loader for loading glTF files into a scene.
  68701. */
  68702. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68703. /** @hidden */
  68704. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68705. /** @hidden */
  68706. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68707. /**
  68708. * Raised when the asset has been parsed
  68709. */
  68710. onParsedObservable: Observable<IGLTFLoaderData>;
  68711. private _onParsedObserver;
  68712. /**
  68713. * Raised when the asset has been parsed
  68714. */
  68715. onParsed: (loaderData: IGLTFLoaderData) => void;
  68716. /**
  68717. * 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.
  68718. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68719. * Defaults to true.
  68720. * @hidden
  68721. */
  68722. static IncrementalLoading: boolean;
  68723. /**
  68724. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68725. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68726. * @hidden
  68727. */
  68728. static HomogeneousCoordinates: boolean;
  68729. /**
  68730. * The coordinate system mode. Defaults to AUTO.
  68731. */
  68732. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68733. /**
  68734. * The animation start mode. Defaults to FIRST.
  68735. */
  68736. animationStartMode: GLTFLoaderAnimationStartMode;
  68737. /**
  68738. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68739. */
  68740. compileMaterials: boolean;
  68741. /**
  68742. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68743. */
  68744. useClipPlane: boolean;
  68745. /**
  68746. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68747. */
  68748. compileShadowGenerators: boolean;
  68749. /**
  68750. * Defines if the Alpha blended materials are only applied as coverage.
  68751. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68752. * If true, no extra effects are applied to transparent pixels.
  68753. */
  68754. transparencyAsCoverage: boolean;
  68755. /**
  68756. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68757. * Enabling will disable offline support and glTF validator.
  68758. * Defaults to false.
  68759. */
  68760. useRangeRequests: boolean;
  68761. /**
  68762. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  68763. */
  68764. createInstances: boolean;
  68765. /**
  68766. * Function called before loading a url referenced by the asset.
  68767. */
  68768. preprocessUrlAsync: (url: string) => Promise<string>;
  68769. /**
  68770. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68771. */
  68772. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68773. private _onMeshLoadedObserver;
  68774. /**
  68775. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68776. */
  68777. onMeshLoaded: (mesh: AbstractMesh) => void;
  68778. /**
  68779. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68780. */
  68781. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68782. private _onTextureLoadedObserver;
  68783. /**
  68784. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68785. */
  68786. onTextureLoaded: (texture: BaseTexture) => void;
  68787. /**
  68788. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68789. */
  68790. readonly onMaterialLoadedObservable: Observable<Material>;
  68791. private _onMaterialLoadedObserver;
  68792. /**
  68793. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68794. */
  68795. onMaterialLoaded: (material: Material) => void;
  68796. /**
  68797. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68798. */
  68799. readonly onCameraLoadedObservable: Observable<Camera>;
  68800. private _onCameraLoadedObserver;
  68801. /**
  68802. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68803. */
  68804. onCameraLoaded: (camera: Camera) => void;
  68805. /**
  68806. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68807. * For assets with LODs, raised when all of the LODs are complete.
  68808. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68809. */
  68810. readonly onCompleteObservable: Observable<void>;
  68811. private _onCompleteObserver;
  68812. /**
  68813. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68814. * For assets with LODs, raised when all of the LODs are complete.
  68815. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68816. */
  68817. onComplete: () => void;
  68818. /**
  68819. * Observable raised when an error occurs.
  68820. */
  68821. readonly onErrorObservable: Observable<any>;
  68822. private _onErrorObserver;
  68823. /**
  68824. * Callback raised when an error occurs.
  68825. */
  68826. onError: (reason: any) => void;
  68827. /**
  68828. * Observable raised after the loader is disposed.
  68829. */
  68830. readonly onDisposeObservable: Observable<void>;
  68831. private _onDisposeObserver;
  68832. /**
  68833. * Callback raised after the loader is disposed.
  68834. */
  68835. onDispose: () => void;
  68836. /**
  68837. * Observable raised after a loader extension is created.
  68838. * Set additional options for a loader extension in this event.
  68839. */
  68840. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68841. private _onExtensionLoadedObserver;
  68842. /**
  68843. * Callback raised after a loader extension is created.
  68844. */
  68845. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68846. /**
  68847. * Defines if the loader logging is enabled.
  68848. */
  68849. loggingEnabled: boolean;
  68850. /**
  68851. * Defines if the loader should capture performance counters.
  68852. */
  68853. capturePerformanceCounters: boolean;
  68854. /**
  68855. * Defines if the loader should validate the asset.
  68856. */
  68857. validate: boolean;
  68858. /**
  68859. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68860. */
  68861. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68862. private _onValidatedObserver;
  68863. /**
  68864. * Callback raised after a loader extension is created.
  68865. */
  68866. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68867. private _loader;
  68868. /**
  68869. * Name of the loader ("gltf")
  68870. */
  68871. name: string;
  68872. /** @hidden */
  68873. extensions: ISceneLoaderPluginExtensions;
  68874. /**
  68875. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68876. */
  68877. dispose(): void;
  68878. /** @hidden */
  68879. _clear(): void;
  68880. /** @hidden */
  68881. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68882. /** @hidden */
  68883. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68884. /** @hidden */
  68885. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68886. meshes: AbstractMesh[];
  68887. particleSystems: IParticleSystem[];
  68888. skeletons: Skeleton[];
  68889. animationGroups: AnimationGroup[];
  68890. }>;
  68891. /** @hidden */
  68892. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68893. /** @hidden */
  68894. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68895. /** @hidden */
  68896. canDirectLoad(data: string): boolean;
  68897. /** @hidden */
  68898. directLoad(scene: Scene, data: string): any;
  68899. /**
  68900. * The callback that allows custom handling of the root url based on the response url.
  68901. * @param rootUrl the original root url
  68902. * @param responseURL the response url if available
  68903. * @returns the new root url
  68904. */
  68905. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68906. /** @hidden */
  68907. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68908. /**
  68909. * The loader state or null if the loader is not active.
  68910. */
  68911. readonly loaderState: Nullable<GLTFLoaderState>;
  68912. /**
  68913. * Returns a promise that resolves when the asset is completely loaded.
  68914. * @returns a promise that resolves when the asset is completely loaded.
  68915. */
  68916. whenCompleteAsync(): Promise<void>;
  68917. private _validateAsync;
  68918. private _getLoader;
  68919. private _parseJson;
  68920. private _unpackBinaryAsync;
  68921. private _unpackBinaryV1Async;
  68922. private _unpackBinaryV2Async;
  68923. private static _parseVersion;
  68924. private static _compareVersion;
  68925. private static readonly _logSpaces;
  68926. private _logIndentLevel;
  68927. private _loggingEnabled;
  68928. /** @hidden */
  68929. _log: (message: string) => void;
  68930. /** @hidden */
  68931. _logOpen(message: string): void;
  68932. /** @hidden */
  68933. _logClose(): void;
  68934. private _logEnabled;
  68935. private _logDisabled;
  68936. private _capturePerformanceCounters;
  68937. /** @hidden */
  68938. _startPerformanceCounter: (counterName: string) => void;
  68939. /** @hidden */
  68940. _endPerformanceCounter: (counterName: string) => void;
  68941. private _startPerformanceCounterEnabled;
  68942. private _startPerformanceCounterDisabled;
  68943. private _endPerformanceCounterEnabled;
  68944. private _endPerformanceCounterDisabled;
  68945. }
  68946. }
  68947. declare module BABYLON.GLTF1 {
  68948. /**
  68949. * Enums
  68950. * @hidden
  68951. */
  68952. export enum EComponentType {
  68953. BYTE = 5120,
  68954. UNSIGNED_BYTE = 5121,
  68955. SHORT = 5122,
  68956. UNSIGNED_SHORT = 5123,
  68957. FLOAT = 5126
  68958. }
  68959. /** @hidden */
  68960. export enum EShaderType {
  68961. FRAGMENT = 35632,
  68962. VERTEX = 35633
  68963. }
  68964. /** @hidden */
  68965. export enum EParameterType {
  68966. BYTE = 5120,
  68967. UNSIGNED_BYTE = 5121,
  68968. SHORT = 5122,
  68969. UNSIGNED_SHORT = 5123,
  68970. INT = 5124,
  68971. UNSIGNED_INT = 5125,
  68972. FLOAT = 5126,
  68973. FLOAT_VEC2 = 35664,
  68974. FLOAT_VEC3 = 35665,
  68975. FLOAT_VEC4 = 35666,
  68976. INT_VEC2 = 35667,
  68977. INT_VEC3 = 35668,
  68978. INT_VEC4 = 35669,
  68979. BOOL = 35670,
  68980. BOOL_VEC2 = 35671,
  68981. BOOL_VEC3 = 35672,
  68982. BOOL_VEC4 = 35673,
  68983. FLOAT_MAT2 = 35674,
  68984. FLOAT_MAT3 = 35675,
  68985. FLOAT_MAT4 = 35676,
  68986. SAMPLER_2D = 35678
  68987. }
  68988. /** @hidden */
  68989. export enum ETextureWrapMode {
  68990. CLAMP_TO_EDGE = 33071,
  68991. MIRRORED_REPEAT = 33648,
  68992. REPEAT = 10497
  68993. }
  68994. /** @hidden */
  68995. export enum ETextureFilterType {
  68996. NEAREST = 9728,
  68997. LINEAR = 9728,
  68998. NEAREST_MIPMAP_NEAREST = 9984,
  68999. LINEAR_MIPMAP_NEAREST = 9985,
  69000. NEAREST_MIPMAP_LINEAR = 9986,
  69001. LINEAR_MIPMAP_LINEAR = 9987
  69002. }
  69003. /** @hidden */
  69004. export enum ETextureFormat {
  69005. ALPHA = 6406,
  69006. RGB = 6407,
  69007. RGBA = 6408,
  69008. LUMINANCE = 6409,
  69009. LUMINANCE_ALPHA = 6410
  69010. }
  69011. /** @hidden */
  69012. export enum ECullingType {
  69013. FRONT = 1028,
  69014. BACK = 1029,
  69015. FRONT_AND_BACK = 1032
  69016. }
  69017. /** @hidden */
  69018. export enum EBlendingFunction {
  69019. ZERO = 0,
  69020. ONE = 1,
  69021. SRC_COLOR = 768,
  69022. ONE_MINUS_SRC_COLOR = 769,
  69023. DST_COLOR = 774,
  69024. ONE_MINUS_DST_COLOR = 775,
  69025. SRC_ALPHA = 770,
  69026. ONE_MINUS_SRC_ALPHA = 771,
  69027. DST_ALPHA = 772,
  69028. ONE_MINUS_DST_ALPHA = 773,
  69029. CONSTANT_COLOR = 32769,
  69030. ONE_MINUS_CONSTANT_COLOR = 32770,
  69031. CONSTANT_ALPHA = 32771,
  69032. ONE_MINUS_CONSTANT_ALPHA = 32772,
  69033. SRC_ALPHA_SATURATE = 776
  69034. }
  69035. /** @hidden */
  69036. export interface IGLTFProperty {
  69037. extensions?: {
  69038. [key: string]: any;
  69039. };
  69040. extras?: Object;
  69041. }
  69042. /** @hidden */
  69043. export interface IGLTFChildRootProperty extends IGLTFProperty {
  69044. name?: string;
  69045. }
  69046. /** @hidden */
  69047. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  69048. bufferView: string;
  69049. byteOffset: number;
  69050. byteStride: number;
  69051. count: number;
  69052. type: string;
  69053. componentType: EComponentType;
  69054. max?: number[];
  69055. min?: number[];
  69056. name?: string;
  69057. }
  69058. /** @hidden */
  69059. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  69060. buffer: string;
  69061. byteOffset: number;
  69062. byteLength: number;
  69063. byteStride: number;
  69064. target?: number;
  69065. }
  69066. /** @hidden */
  69067. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  69068. uri: string;
  69069. byteLength?: number;
  69070. type?: string;
  69071. }
  69072. /** @hidden */
  69073. export interface IGLTFShader extends IGLTFChildRootProperty {
  69074. uri: string;
  69075. type: EShaderType;
  69076. }
  69077. /** @hidden */
  69078. export interface IGLTFProgram extends IGLTFChildRootProperty {
  69079. attributes: string[];
  69080. fragmentShader: string;
  69081. vertexShader: string;
  69082. }
  69083. /** @hidden */
  69084. export interface IGLTFTechniqueParameter {
  69085. type: number;
  69086. count?: number;
  69087. semantic?: string;
  69088. node?: string;
  69089. value?: number | boolean | string | Array<any>;
  69090. source?: string;
  69091. babylonValue?: any;
  69092. }
  69093. /** @hidden */
  69094. export interface IGLTFTechniqueCommonProfile {
  69095. lightingModel: string;
  69096. texcoordBindings: Object;
  69097. parameters?: Array<any>;
  69098. }
  69099. /** @hidden */
  69100. export interface IGLTFTechniqueStatesFunctions {
  69101. blendColor?: number[];
  69102. blendEquationSeparate?: number[];
  69103. blendFuncSeparate?: number[];
  69104. colorMask: boolean[];
  69105. cullFace: number[];
  69106. }
  69107. /** @hidden */
  69108. export interface IGLTFTechniqueStates {
  69109. enable: number[];
  69110. functions: IGLTFTechniqueStatesFunctions;
  69111. }
  69112. /** @hidden */
  69113. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  69114. parameters: {
  69115. [key: string]: IGLTFTechniqueParameter;
  69116. };
  69117. program: string;
  69118. attributes: {
  69119. [key: string]: string;
  69120. };
  69121. uniforms: {
  69122. [key: string]: string;
  69123. };
  69124. states: IGLTFTechniqueStates;
  69125. }
  69126. /** @hidden */
  69127. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  69128. technique?: string;
  69129. values: string[];
  69130. }
  69131. /** @hidden */
  69132. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  69133. attributes: {
  69134. [key: string]: string;
  69135. };
  69136. indices: string;
  69137. material: string;
  69138. mode?: number;
  69139. }
  69140. /** @hidden */
  69141. export interface IGLTFMesh extends IGLTFChildRootProperty {
  69142. primitives: IGLTFMeshPrimitive[];
  69143. }
  69144. /** @hidden */
  69145. export interface IGLTFImage extends IGLTFChildRootProperty {
  69146. uri: string;
  69147. }
  69148. /** @hidden */
  69149. export interface IGLTFSampler extends IGLTFChildRootProperty {
  69150. magFilter?: number;
  69151. minFilter?: number;
  69152. wrapS?: number;
  69153. wrapT?: number;
  69154. }
  69155. /** @hidden */
  69156. export interface IGLTFTexture extends IGLTFChildRootProperty {
  69157. sampler: string;
  69158. source: string;
  69159. format?: ETextureFormat;
  69160. internalFormat?: ETextureFormat;
  69161. target?: number;
  69162. type?: number;
  69163. babylonTexture?: Texture;
  69164. }
  69165. /** @hidden */
  69166. export interface IGLTFAmbienLight {
  69167. color?: number[];
  69168. }
  69169. /** @hidden */
  69170. export interface IGLTFDirectionalLight {
  69171. color?: number[];
  69172. }
  69173. /** @hidden */
  69174. export interface IGLTFPointLight {
  69175. color?: number[];
  69176. constantAttenuation?: number;
  69177. linearAttenuation?: number;
  69178. quadraticAttenuation?: number;
  69179. }
  69180. /** @hidden */
  69181. export interface IGLTFSpotLight {
  69182. color?: number[];
  69183. constantAttenuation?: number;
  69184. fallOfAngle?: number;
  69185. fallOffExponent?: number;
  69186. linearAttenuation?: number;
  69187. quadraticAttenuation?: number;
  69188. }
  69189. /** @hidden */
  69190. export interface IGLTFLight extends IGLTFChildRootProperty {
  69191. type: string;
  69192. }
  69193. /** @hidden */
  69194. export interface IGLTFCameraOrthographic {
  69195. xmag: number;
  69196. ymag: number;
  69197. zfar: number;
  69198. znear: number;
  69199. }
  69200. /** @hidden */
  69201. export interface IGLTFCameraPerspective {
  69202. aspectRatio: number;
  69203. yfov: number;
  69204. zfar: number;
  69205. znear: number;
  69206. }
  69207. /** @hidden */
  69208. export interface IGLTFCamera extends IGLTFChildRootProperty {
  69209. type: string;
  69210. }
  69211. /** @hidden */
  69212. export interface IGLTFAnimationChannelTarget {
  69213. id: string;
  69214. path: string;
  69215. }
  69216. /** @hidden */
  69217. export interface IGLTFAnimationChannel {
  69218. sampler: string;
  69219. target: IGLTFAnimationChannelTarget;
  69220. }
  69221. /** @hidden */
  69222. export interface IGLTFAnimationSampler {
  69223. input: string;
  69224. output: string;
  69225. interpolation?: string;
  69226. }
  69227. /** @hidden */
  69228. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  69229. channels?: IGLTFAnimationChannel[];
  69230. parameters?: {
  69231. [key: string]: string;
  69232. };
  69233. samplers?: {
  69234. [key: string]: IGLTFAnimationSampler;
  69235. };
  69236. }
  69237. /** @hidden */
  69238. export interface IGLTFNodeInstanceSkin {
  69239. skeletons: string[];
  69240. skin: string;
  69241. meshes: string[];
  69242. }
  69243. /** @hidden */
  69244. export interface IGLTFSkins extends IGLTFChildRootProperty {
  69245. bindShapeMatrix: number[];
  69246. inverseBindMatrices: string;
  69247. jointNames: string[];
  69248. babylonSkeleton?: Skeleton;
  69249. }
  69250. /** @hidden */
  69251. export interface IGLTFNode extends IGLTFChildRootProperty {
  69252. camera?: string;
  69253. children: string[];
  69254. skin?: string;
  69255. jointName?: string;
  69256. light?: string;
  69257. matrix: number[];
  69258. mesh?: string;
  69259. meshes?: string[];
  69260. rotation?: number[];
  69261. scale?: number[];
  69262. translation?: number[];
  69263. babylonNode?: Node;
  69264. }
  69265. /** @hidden */
  69266. export interface IGLTFScene extends IGLTFChildRootProperty {
  69267. nodes: string[];
  69268. }
  69269. /** @hidden */
  69270. export interface IGLTFRuntime {
  69271. extensions: {
  69272. [key: string]: any;
  69273. };
  69274. accessors: {
  69275. [key: string]: IGLTFAccessor;
  69276. };
  69277. buffers: {
  69278. [key: string]: IGLTFBuffer;
  69279. };
  69280. bufferViews: {
  69281. [key: string]: IGLTFBufferView;
  69282. };
  69283. meshes: {
  69284. [key: string]: IGLTFMesh;
  69285. };
  69286. lights: {
  69287. [key: string]: IGLTFLight;
  69288. };
  69289. cameras: {
  69290. [key: string]: IGLTFCamera;
  69291. };
  69292. nodes: {
  69293. [key: string]: IGLTFNode;
  69294. };
  69295. images: {
  69296. [key: string]: IGLTFImage;
  69297. };
  69298. textures: {
  69299. [key: string]: IGLTFTexture;
  69300. };
  69301. shaders: {
  69302. [key: string]: IGLTFShader;
  69303. };
  69304. programs: {
  69305. [key: string]: IGLTFProgram;
  69306. };
  69307. samplers: {
  69308. [key: string]: IGLTFSampler;
  69309. };
  69310. techniques: {
  69311. [key: string]: IGLTFTechnique;
  69312. };
  69313. materials: {
  69314. [key: string]: IGLTFMaterial;
  69315. };
  69316. animations: {
  69317. [key: string]: IGLTFAnimation;
  69318. };
  69319. skins: {
  69320. [key: string]: IGLTFSkins;
  69321. };
  69322. currentScene?: Object;
  69323. scenes: {
  69324. [key: string]: IGLTFScene;
  69325. };
  69326. extensionsUsed: string[];
  69327. extensionsRequired?: string[];
  69328. buffersCount: number;
  69329. shaderscount: number;
  69330. scene: Scene;
  69331. rootUrl: string;
  69332. loadedBufferCount: number;
  69333. loadedBufferViews: {
  69334. [name: string]: ArrayBufferView;
  69335. };
  69336. loadedShaderCount: number;
  69337. importOnlyMeshes: boolean;
  69338. importMeshesNames?: string[];
  69339. dummyNodes: Node[];
  69340. }
  69341. /** @hidden */
  69342. export interface INodeToRoot {
  69343. bone: Bone;
  69344. node: IGLTFNode;
  69345. id: string;
  69346. }
  69347. /** @hidden */
  69348. export interface IJointNode {
  69349. node: IGLTFNode;
  69350. id: string;
  69351. }
  69352. }
  69353. declare module BABYLON.GLTF1 {
  69354. /**
  69355. * Utils functions for GLTF
  69356. * @hidden
  69357. */
  69358. export class GLTFUtils {
  69359. /**
  69360. * Sets the given "parameter" matrix
  69361. * @param scene: the Scene object
  69362. * @param source: the source node where to pick the matrix
  69363. * @param parameter: the GLTF technique parameter
  69364. * @param uniformName: the name of the shader's uniform
  69365. * @param shaderMaterial: the shader material
  69366. */
  69367. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  69368. /**
  69369. * Sets the given "parameter" matrix
  69370. * @param shaderMaterial: the shader material
  69371. * @param uniform: the name of the shader's uniform
  69372. * @param value: the value of the uniform
  69373. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  69374. */
  69375. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  69376. /**
  69377. * Returns the wrap mode of the texture
  69378. * @param mode: the mode value
  69379. */
  69380. static GetWrapMode(mode: number): number;
  69381. /**
  69382. * Returns the byte stride giving an accessor
  69383. * @param accessor: the GLTF accessor objet
  69384. */
  69385. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  69386. /**
  69387. * Returns the texture filter mode giving a mode value
  69388. * @param mode: the filter mode value
  69389. */
  69390. static GetTextureFilterMode(mode: number): ETextureFilterType;
  69391. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  69392. /**
  69393. * Returns a buffer from its accessor
  69394. * @param gltfRuntime: the GLTF runtime
  69395. * @param accessor: the GLTF accessor
  69396. */
  69397. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  69398. /**
  69399. * Decodes a buffer view into a string
  69400. * @param view: the buffer view
  69401. */
  69402. static DecodeBufferToText(view: ArrayBufferView): string;
  69403. /**
  69404. * Returns the default material of gltf. Related to
  69405. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  69406. * @param scene: the Babylon.js scene
  69407. */
  69408. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  69409. private static _DefaultMaterial;
  69410. }
  69411. }
  69412. declare module BABYLON.GLTF1 {
  69413. /**
  69414. * Implementation of the base glTF spec
  69415. * @hidden
  69416. */
  69417. export class GLTFLoaderBase {
  69418. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  69419. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69420. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  69421. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69422. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  69423. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69424. }
  69425. /**
  69426. * glTF V1 Loader
  69427. * @hidden
  69428. */
  69429. export class GLTFLoader implements IGLTFLoader {
  69430. static Extensions: {
  69431. [name: string]: GLTFLoaderExtension;
  69432. };
  69433. static RegisterExtension(extension: GLTFLoaderExtension): void;
  69434. state: Nullable<GLTFLoaderState>;
  69435. dispose(): void;
  69436. private _importMeshAsync;
  69437. /**
  69438. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  69439. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69440. * @param scene the scene the meshes should be added to
  69441. * @param data gltf data containing information of the meshes in a loaded file
  69442. * @param rootUrl root url to load from
  69443. * @param onProgress event that fires when loading progress has occured
  69444. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69445. */
  69446. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  69447. meshes: AbstractMesh[];
  69448. particleSystems: IParticleSystem[];
  69449. skeletons: Skeleton[];
  69450. animationGroups: AnimationGroup[];
  69451. }>;
  69452. private _loadAsync;
  69453. /**
  69454. * Imports all objects from a loaded gltf file and adds them to the scene
  69455. * @param scene the scene the objects should be added to
  69456. * @param data gltf data containing information of the meshes in a loaded file
  69457. * @param rootUrl root url to load from
  69458. * @param onProgress event that fires when loading progress has occured
  69459. * @returns a promise which completes when objects have been loaded to the scene
  69460. */
  69461. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69462. private _loadShadersAsync;
  69463. private _loadBuffersAsync;
  69464. private _createNodes;
  69465. }
  69466. /** @hidden */
  69467. export abstract class GLTFLoaderExtension {
  69468. private _name;
  69469. constructor(name: string);
  69470. readonly name: string;
  69471. /**
  69472. * Defines an override for loading the runtime
  69473. * Return true to stop further extensions from loading the runtime
  69474. */
  69475. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69476. /**
  69477. * Defines an onverride for creating gltf runtime
  69478. * Return true to stop further extensions from creating the runtime
  69479. */
  69480. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69481. /**
  69482. * Defines an override for loading buffers
  69483. * Return true to stop further extensions from loading this buffer
  69484. */
  69485. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69486. /**
  69487. * Defines an override for loading texture buffers
  69488. * Return true to stop further extensions from loading this texture data
  69489. */
  69490. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69491. /**
  69492. * Defines an override for creating textures
  69493. * Return true to stop further extensions from loading this texture
  69494. */
  69495. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69496. /**
  69497. * Defines an override for loading shader strings
  69498. * Return true to stop further extensions from loading this shader data
  69499. */
  69500. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69501. /**
  69502. * Defines an override for loading materials
  69503. * Return true to stop further extensions from loading this material
  69504. */
  69505. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69506. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69507. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69508. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69509. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69510. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69511. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69512. private static LoadTextureBufferAsync;
  69513. private static CreateTextureAsync;
  69514. private static ApplyExtensions;
  69515. }
  69516. }
  69517. declare module BABYLON.GLTF1 {
  69518. /** @hidden */
  69519. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69520. private _bin;
  69521. constructor();
  69522. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69523. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69524. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69525. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69526. }
  69527. }
  69528. declare module BABYLON.GLTF1 {
  69529. /** @hidden */
  69530. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69531. constructor();
  69532. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69533. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69534. private _loadTexture;
  69535. }
  69536. }
  69537. declare module BABYLON.GLTF2.Loader {
  69538. /**
  69539. * Loader interface with an index field.
  69540. */
  69541. export interface IArrayItem {
  69542. /**
  69543. * The index of this item in the array.
  69544. */
  69545. index: number;
  69546. }
  69547. /**
  69548. * Loader interface with additional members.
  69549. */
  69550. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69551. /** @hidden */
  69552. _data?: Promise<ArrayBufferView>;
  69553. /** @hidden */
  69554. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69555. }
  69556. /**
  69557. * Loader interface with additional members.
  69558. */
  69559. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69560. }
  69561. /** @hidden */
  69562. export interface _IAnimationSamplerData {
  69563. input: Float32Array;
  69564. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69565. output: Float32Array;
  69566. }
  69567. /**
  69568. * Loader interface with additional members.
  69569. */
  69570. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69571. /** @hidden */
  69572. _data?: Promise<_IAnimationSamplerData>;
  69573. }
  69574. /**
  69575. * Loader interface with additional members.
  69576. */
  69577. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69578. channels: IAnimationChannel[];
  69579. samplers: IAnimationSampler[];
  69580. /** @hidden */
  69581. _babylonAnimationGroup?: AnimationGroup;
  69582. }
  69583. /**
  69584. * Loader interface with additional members.
  69585. */
  69586. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69587. /** @hidden */
  69588. _data?: Promise<ArrayBufferView>;
  69589. }
  69590. /**
  69591. * Loader interface with additional members.
  69592. */
  69593. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69594. /** @hidden */
  69595. _data?: Promise<ArrayBufferView>;
  69596. /** @hidden */
  69597. _babylonBuffer?: Promise<Buffer>;
  69598. }
  69599. /**
  69600. * Loader interface with additional members.
  69601. */
  69602. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69603. }
  69604. /**
  69605. * Loader interface with additional members.
  69606. */
  69607. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69608. /** @hidden */
  69609. _data?: Promise<ArrayBufferView>;
  69610. }
  69611. /**
  69612. * Loader interface with additional members.
  69613. */
  69614. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69615. }
  69616. /**
  69617. * Loader interface with additional members.
  69618. */
  69619. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69620. }
  69621. /**
  69622. * Loader interface with additional members.
  69623. */
  69624. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69625. baseColorTexture?: ITextureInfo;
  69626. metallicRoughnessTexture?: ITextureInfo;
  69627. }
  69628. /**
  69629. * Loader interface with additional members.
  69630. */
  69631. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69632. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69633. normalTexture?: IMaterialNormalTextureInfo;
  69634. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69635. emissiveTexture?: ITextureInfo;
  69636. /** @hidden */
  69637. _data?: {
  69638. [babylonDrawMode: number]: {
  69639. babylonMaterial: Material;
  69640. babylonMeshes: AbstractMesh[];
  69641. promise: Promise<void>;
  69642. };
  69643. };
  69644. }
  69645. /**
  69646. * Loader interface with additional members.
  69647. */
  69648. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69649. primitives: IMeshPrimitive[];
  69650. }
  69651. /**
  69652. * Loader interface with additional members.
  69653. */
  69654. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69655. /** @hidden */
  69656. _instanceData?: {
  69657. babylonSourceMesh: Mesh;
  69658. promise: Promise<any>;
  69659. };
  69660. }
  69661. /**
  69662. * Loader interface with additional members.
  69663. */
  69664. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69665. /**
  69666. * The parent glTF node.
  69667. */
  69668. parent?: INode;
  69669. /** @hidden */
  69670. _babylonTransformNode?: TransformNode;
  69671. /** @hidden */
  69672. _primitiveBabylonMeshes?: AbstractMesh[];
  69673. /** @hidden */
  69674. _babylonBones?: Bone[];
  69675. /** @hidden */
  69676. _numMorphTargets?: number;
  69677. }
  69678. /** @hidden */
  69679. export interface _ISamplerData {
  69680. noMipMaps: boolean;
  69681. samplingMode: number;
  69682. wrapU: number;
  69683. wrapV: number;
  69684. }
  69685. /**
  69686. * Loader interface with additional members.
  69687. */
  69688. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69689. /** @hidden */
  69690. _data?: _ISamplerData;
  69691. }
  69692. /**
  69693. * Loader interface with additional members.
  69694. */
  69695. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69696. }
  69697. /**
  69698. * Loader interface with additional members.
  69699. */
  69700. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69701. /** @hidden */
  69702. _data?: {
  69703. babylonSkeleton: Skeleton;
  69704. promise: Promise<void>;
  69705. };
  69706. }
  69707. /**
  69708. * Loader interface with additional members.
  69709. */
  69710. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69711. }
  69712. /**
  69713. * Loader interface with additional members.
  69714. */
  69715. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69716. }
  69717. /**
  69718. * Loader interface with additional members.
  69719. */
  69720. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69721. accessors?: IAccessor[];
  69722. animations?: IAnimation[];
  69723. buffers?: IBuffer[];
  69724. bufferViews?: IBufferView[];
  69725. cameras?: ICamera[];
  69726. images?: IImage[];
  69727. materials?: IMaterial[];
  69728. meshes?: IMesh[];
  69729. nodes?: INode[];
  69730. samplers?: ISampler[];
  69731. scenes?: IScene[];
  69732. skins?: ISkin[];
  69733. textures?: ITexture[];
  69734. }
  69735. }
  69736. declare module BABYLON.GLTF2 {
  69737. /**
  69738. * Interface for a glTF loader extension.
  69739. */
  69740. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69741. /**
  69742. * Called after the loader state changes to LOADING.
  69743. */
  69744. onLoading?(): void;
  69745. /**
  69746. * Called after the loader state changes to READY.
  69747. */
  69748. onReady?(): void;
  69749. /**
  69750. * Define this method to modify the default behavior when loading scenes.
  69751. * @param context The context when loading the asset
  69752. * @param scene The glTF scene property
  69753. * @returns A promise that resolves when the load is complete or null if not handled
  69754. */
  69755. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69756. /**
  69757. * Define this method to modify the default behavior when loading nodes.
  69758. * @param context The context when loading the asset
  69759. * @param node The glTF node property
  69760. * @param assign A function called synchronously after parsing the glTF properties
  69761. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69762. */
  69763. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69764. /**
  69765. * Define this method to modify the default behavior when loading cameras.
  69766. * @param context The context when loading the asset
  69767. * @param camera The glTF camera property
  69768. * @param assign A function called synchronously after parsing the glTF properties
  69769. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69770. */
  69771. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69772. /**
  69773. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69774. * @param context The context when loading the asset
  69775. * @param primitive The glTF mesh primitive property
  69776. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69777. */
  69778. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69779. /**
  69780. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69781. * @param context The context when loading the asset
  69782. * @param name The mesh name when loading the asset
  69783. * @param node The glTF node when loading the asset
  69784. * @param mesh The glTF mesh when loading the asset
  69785. * @param primitive The glTF mesh primitive property
  69786. * @param assign A function called synchronously after parsing the glTF properties
  69787. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69788. */
  69789. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69790. /**
  69791. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69792. * @param context The context when loading the asset
  69793. * @param material The glTF material property
  69794. * @param assign A function called synchronously after parsing the glTF properties
  69795. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69796. */
  69797. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69798. /**
  69799. * Define this method to modify the default behavior when creating materials.
  69800. * @param context The context when loading the asset
  69801. * @param material The glTF material property
  69802. * @param babylonDrawMode The draw mode for the Babylon material
  69803. * @returns The Babylon material or null if not handled
  69804. */
  69805. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69806. /**
  69807. * Define this method to modify the default behavior when loading material properties.
  69808. * @param context The context when loading the asset
  69809. * @param material The glTF material property
  69810. * @param babylonMaterial The Babylon material
  69811. * @returns A promise that resolves when the load is complete or null if not handled
  69812. */
  69813. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69814. /**
  69815. * Define this method to modify the default behavior when loading texture infos.
  69816. * @param context The context when loading the asset
  69817. * @param textureInfo The glTF texture info property
  69818. * @param assign A function called synchronously after parsing the glTF properties
  69819. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69820. */
  69821. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69822. /**
  69823. * Define this method to modify the default behavior when loading animations.
  69824. * @param context The context when loading the asset
  69825. * @param animation The glTF animation property
  69826. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69827. */
  69828. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69829. /**
  69830. * @hidden Define this method to modify the default behavior when loading skins.
  69831. * @param context The context when loading the asset
  69832. * @param node The glTF node property
  69833. * @param skin The glTF skin property
  69834. * @returns A promise that resolves when the load is complete or null if not handled
  69835. */
  69836. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69837. /**
  69838. * @hidden Define this method to modify the default behavior when loading uris.
  69839. * @param context The context when loading the asset
  69840. * @param property The glTF property associated with the uri
  69841. * @param uri The uri to load
  69842. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69843. */
  69844. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69845. /**
  69846. * Define this method to modify the default behavior when loading buffer views.
  69847. * @param context The context when loading the asset
  69848. * @param bufferView The glTF buffer view property
  69849. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69850. */
  69851. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69852. /**
  69853. * Define this method to modify the default behavior when loading buffers.
  69854. * @param context The context when loading the asset
  69855. * @param buffer The glTF buffer property
  69856. * @param byteOffset The byte offset to load
  69857. * @param byteLength The byte length to load
  69858. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69859. */
  69860. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69861. }
  69862. }
  69863. declare module BABYLON.GLTF2 {
  69864. /**
  69865. * Helper class for working with arrays when loading the glTF asset
  69866. */
  69867. export class ArrayItem {
  69868. /**
  69869. * Gets an item from the given array.
  69870. * @param context The context when loading the asset
  69871. * @param array The array to get the item from
  69872. * @param index The index to the array
  69873. * @returns The array item
  69874. */
  69875. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69876. /**
  69877. * Assign an `index` field to each item of the given array.
  69878. * @param array The array of items
  69879. */
  69880. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69881. }
  69882. /**
  69883. * The glTF 2.0 loader
  69884. */
  69885. export class GLTFLoader implements IGLTFLoader {
  69886. /** @hidden */
  69887. _completePromises: Promise<any>[];
  69888. private _disposed;
  69889. private _parent;
  69890. private _state;
  69891. private _extensions;
  69892. private _rootUrl;
  69893. private _fileName;
  69894. private _uniqueRootUrl;
  69895. private _gltf;
  69896. private _bin;
  69897. private _babylonScene;
  69898. private _rootBabylonMesh;
  69899. private _defaultBabylonMaterialData;
  69900. private _progressCallback?;
  69901. private _requests;
  69902. private static readonly _DefaultSampler;
  69903. private static _RegisteredExtensions;
  69904. /**
  69905. * Registers a loader extension.
  69906. * @param name The name of the loader extension.
  69907. * @param factory The factory function that creates the loader extension.
  69908. */
  69909. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69910. /**
  69911. * Unregisters a loader extension.
  69912. * @param name The name of the loader extension.
  69913. * @returns A boolean indicating whether the extension has been unregistered
  69914. */
  69915. static UnregisterExtension(name: string): boolean;
  69916. /**
  69917. * Gets the loader state.
  69918. */
  69919. readonly state: Nullable<GLTFLoaderState>;
  69920. /**
  69921. * The object that represents the glTF JSON.
  69922. */
  69923. readonly gltf: IGLTF;
  69924. /**
  69925. * The BIN chunk of a binary glTF.
  69926. */
  69927. readonly bin: Nullable<IDataBuffer>;
  69928. /**
  69929. * The parent file loader.
  69930. */
  69931. readonly parent: GLTFFileLoader;
  69932. /**
  69933. * The Babylon scene when loading the asset.
  69934. */
  69935. readonly babylonScene: Scene;
  69936. /**
  69937. * The root Babylon mesh when loading the asset.
  69938. */
  69939. readonly rootBabylonMesh: Mesh;
  69940. /** @hidden */
  69941. constructor(parent: GLTFFileLoader);
  69942. /** @hidden */
  69943. dispose(): void;
  69944. /** @hidden */
  69945. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69946. meshes: AbstractMesh[];
  69947. particleSystems: IParticleSystem[];
  69948. skeletons: Skeleton[];
  69949. animationGroups: AnimationGroup[];
  69950. }>;
  69951. /** @hidden */
  69952. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69953. private _loadAsync;
  69954. private _loadData;
  69955. private _setupData;
  69956. private _loadExtensions;
  69957. private _checkExtensions;
  69958. private _setState;
  69959. private _createRootNode;
  69960. /**
  69961. * Loads a glTF scene.
  69962. * @param context The context when loading the asset
  69963. * @param scene The glTF scene property
  69964. * @returns A promise that resolves when the load is complete
  69965. */
  69966. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69967. private _forEachPrimitive;
  69968. private _getMeshes;
  69969. private _getSkeletons;
  69970. private _getAnimationGroups;
  69971. private _startAnimations;
  69972. /**
  69973. * Loads a glTF node.
  69974. * @param context The context when loading the asset
  69975. * @param node The glTF node property
  69976. * @param assign A function called synchronously after parsing the glTF properties
  69977. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69978. */
  69979. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69980. private _loadMeshAsync;
  69981. /**
  69982. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69983. * @param context The context when loading the asset
  69984. * @param name The mesh name when loading the asset
  69985. * @param node The glTF node when loading the asset
  69986. * @param mesh The glTF mesh when loading the asset
  69987. * @param primitive The glTF mesh primitive property
  69988. * @param assign A function called synchronously after parsing the glTF properties
  69989. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69990. */
  69991. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69992. private _loadVertexDataAsync;
  69993. private _createMorphTargets;
  69994. private _loadMorphTargetsAsync;
  69995. private _loadMorphTargetVertexDataAsync;
  69996. private static _LoadTransform;
  69997. private _loadSkinAsync;
  69998. private _loadBones;
  69999. private _loadBone;
  70000. private _loadSkinInverseBindMatricesDataAsync;
  70001. private _updateBoneMatrices;
  70002. private _getNodeMatrix;
  70003. /**
  70004. * Loads a glTF camera.
  70005. * @param context The context when loading the asset
  70006. * @param camera The glTF camera property
  70007. * @param assign A function called synchronously after parsing the glTF properties
  70008. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  70009. */
  70010. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  70011. private _loadAnimationsAsync;
  70012. /**
  70013. * Loads a glTF animation.
  70014. * @param context The context when loading the asset
  70015. * @param animation The glTF animation property
  70016. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  70017. */
  70018. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  70019. /**
  70020. * @hidden Loads a glTF animation channel.
  70021. * @param context The context when loading the asset
  70022. * @param animationContext The context of the animation when loading the asset
  70023. * @param animation The glTF animation property
  70024. * @param channel The glTF animation channel property
  70025. * @param babylonAnimationGroup The babylon animation group property
  70026. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  70027. * @returns A void promise when the channel load is complete
  70028. */
  70029. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  70030. private _loadAnimationSamplerAsync;
  70031. private _loadBufferAsync;
  70032. /**
  70033. * Loads a glTF buffer view.
  70034. * @param context The context when loading the asset
  70035. * @param bufferView The glTF buffer view property
  70036. * @returns A promise that resolves with the loaded data when the load is complete
  70037. */
  70038. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  70039. private _loadAccessorAsync;
  70040. private _loadFloatAccessorAsync;
  70041. private _loadIndicesAccessorAsync;
  70042. private _loadVertexBufferViewAsync;
  70043. private _loadVertexAccessorAsync;
  70044. private _loadMaterialMetallicRoughnessPropertiesAsync;
  70045. /** @hidden */
  70046. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  70047. private _createDefaultMaterial;
  70048. /**
  70049. * Creates a Babylon material from a glTF material.
  70050. * @param context The context when loading the asset
  70051. * @param material The glTF material property
  70052. * @param babylonDrawMode The draw mode for the Babylon material
  70053. * @returns The Babylon material
  70054. */
  70055. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  70056. /**
  70057. * Loads properties from a glTF material into a Babylon material.
  70058. * @param context The context when loading the asset
  70059. * @param material The glTF material property
  70060. * @param babylonMaterial The Babylon material
  70061. * @returns A promise that resolves when the load is complete
  70062. */
  70063. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70064. /**
  70065. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  70066. * @param context The context when loading the asset
  70067. * @param material The glTF material property
  70068. * @param babylonMaterial The Babylon material
  70069. * @returns A promise that resolves when the load is complete
  70070. */
  70071. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  70072. /**
  70073. * Loads the alpha properties from a glTF material into a Babylon material.
  70074. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  70075. * @param context The context when loading the asset
  70076. * @param material The glTF material property
  70077. * @param babylonMaterial The Babylon material
  70078. */
  70079. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  70080. /**
  70081. * Loads a glTF texture info.
  70082. * @param context The context when loading the asset
  70083. * @param textureInfo The glTF texture info property
  70084. * @param assign A function called synchronously after parsing the glTF properties
  70085. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  70086. */
  70087. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  70088. private _loadTextureAsync;
  70089. private _loadSampler;
  70090. /**
  70091. * Loads a glTF image.
  70092. * @param context The context when loading the asset
  70093. * @param image The glTF image property
  70094. * @returns A promise that resolves with the loaded data when the load is complete
  70095. */
  70096. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  70097. /**
  70098. * Loads a glTF uri.
  70099. * @param context The context when loading the asset
  70100. * @param property The glTF property associated with the uri
  70101. * @param uri The base64 or relative uri
  70102. * @returns A promise that resolves with the loaded data when the load is complete
  70103. */
  70104. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  70105. private _onProgress;
  70106. /**
  70107. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  70108. * @param babylonObject the Babylon object with metadata
  70109. * @param pointer the JSON pointer
  70110. */
  70111. static AddPointerMetadata(babylonObject: {
  70112. metadata: any;
  70113. }, pointer: string): void;
  70114. private static _GetTextureWrapMode;
  70115. private static _GetTextureSamplingMode;
  70116. private static _GetTypedArrayConstructor;
  70117. private static _GetTypedArray;
  70118. private static _GetNumComponents;
  70119. private static _ValidateUri;
  70120. private static _GetDrawMode;
  70121. private _compileMaterialsAsync;
  70122. private _compileShadowGeneratorsAsync;
  70123. private _forEachExtensions;
  70124. private _applyExtensions;
  70125. private _extensionsOnLoading;
  70126. private _extensionsOnReady;
  70127. private _extensionsLoadSceneAsync;
  70128. private _extensionsLoadNodeAsync;
  70129. private _extensionsLoadCameraAsync;
  70130. private _extensionsLoadVertexDataAsync;
  70131. private _extensionsLoadMeshPrimitiveAsync;
  70132. private _extensionsLoadMaterialAsync;
  70133. private _extensionsCreateMaterial;
  70134. private _extensionsLoadMaterialPropertiesAsync;
  70135. private _extensionsLoadTextureInfoAsync;
  70136. private _extensionsLoadAnimationAsync;
  70137. private _extensionsLoadSkinAsync;
  70138. private _extensionsLoadUriAsync;
  70139. private _extensionsLoadBufferViewAsync;
  70140. private _extensionsLoadBufferAsync;
  70141. /**
  70142. * Helper method called by a loader extension to load an glTF extension.
  70143. * @param context The context when loading the asset
  70144. * @param property The glTF property to load the extension from
  70145. * @param extensionName The name of the extension to load
  70146. * @param actionAsync The action to run
  70147. * @returns The promise returned by actionAsync or null if the extension does not exist
  70148. */
  70149. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70150. /**
  70151. * Helper method called by a loader extension to load a glTF extra.
  70152. * @param context The context when loading the asset
  70153. * @param property The glTF property to load the extra from
  70154. * @param extensionName The name of the extension to load
  70155. * @param actionAsync The action to run
  70156. * @returns The promise returned by actionAsync or null if the extra does not exist
  70157. */
  70158. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  70159. /**
  70160. * Checks for presence of an extension.
  70161. * @param name The name of the extension to check
  70162. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  70163. */
  70164. isExtensionUsed(name: string): boolean;
  70165. /**
  70166. * Increments the indentation level and logs a message.
  70167. * @param message The message to log
  70168. */
  70169. logOpen(message: string): void;
  70170. /**
  70171. * Decrements the indentation level.
  70172. */
  70173. logClose(): void;
  70174. /**
  70175. * Logs a message
  70176. * @param message The message to log
  70177. */
  70178. log(message: string): void;
  70179. /**
  70180. * Starts a performance counter.
  70181. * @param counterName The name of the performance counter
  70182. */
  70183. startPerformanceCounter(counterName: string): void;
  70184. /**
  70185. * Ends a performance counter.
  70186. * @param counterName The name of the performance counter
  70187. */
  70188. endPerformanceCounter(counterName: string): void;
  70189. }
  70190. }
  70191. declare module BABYLON.GLTF2.Loader.Extensions {
  70192. /**
  70193. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  70194. */
  70195. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  70196. /**
  70197. * The name of this extension.
  70198. */
  70199. readonly name: string;
  70200. /**
  70201. * Defines whether this extension is enabled.
  70202. */
  70203. enabled: boolean;
  70204. private _loader;
  70205. private _lights?;
  70206. /** @hidden */
  70207. constructor(loader: GLTFLoader);
  70208. /** @hidden */
  70209. dispose(): void;
  70210. /** @hidden */
  70211. onLoading(): void;
  70212. /** @hidden */
  70213. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70214. private _loadLightAsync;
  70215. }
  70216. }
  70217. declare module BABYLON.GLTF2.Loader.Extensions {
  70218. /**
  70219. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  70220. */
  70221. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  70222. /**
  70223. * The name of this extension.
  70224. */
  70225. readonly name: string;
  70226. /**
  70227. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  70228. */
  70229. dracoCompression?: DracoCompression;
  70230. /**
  70231. * Defines whether this extension is enabled.
  70232. */
  70233. enabled: boolean;
  70234. private _loader;
  70235. /** @hidden */
  70236. constructor(loader: GLTFLoader);
  70237. /** @hidden */
  70238. dispose(): void;
  70239. /** @hidden */
  70240. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  70241. }
  70242. }
  70243. declare module BABYLON.GLTF2.Loader.Extensions {
  70244. /**
  70245. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70246. */
  70247. export class KHR_lights implements IGLTFLoaderExtension {
  70248. /**
  70249. * The name of this extension.
  70250. */
  70251. readonly name: string;
  70252. /**
  70253. * Defines whether this extension is enabled.
  70254. */
  70255. enabled: boolean;
  70256. private _loader;
  70257. private _lights?;
  70258. /** @hidden */
  70259. constructor(loader: GLTFLoader);
  70260. /** @hidden */
  70261. dispose(): void;
  70262. /** @hidden */
  70263. onLoading(): void;
  70264. /** @hidden */
  70265. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70266. }
  70267. }
  70268. declare module BABYLON.GLTF2.Loader.Extensions {
  70269. /**
  70270. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  70271. */
  70272. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  70273. /**
  70274. * The name of this extension.
  70275. */
  70276. readonly name: string;
  70277. /**
  70278. * Defines whether this extension is enabled.
  70279. */
  70280. enabled: boolean;
  70281. /**
  70282. * Defines a number that determines the order the extensions are applied.
  70283. */
  70284. order: number;
  70285. private _loader;
  70286. /** @hidden */
  70287. constructor(loader: GLTFLoader);
  70288. /** @hidden */
  70289. dispose(): void;
  70290. /** @hidden */
  70291. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70292. private _loadSpecularGlossinessPropertiesAsync;
  70293. }
  70294. }
  70295. declare module BABYLON.GLTF2.Loader.Extensions {
  70296. /**
  70297. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  70298. */
  70299. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  70300. /**
  70301. * The name of this extension.
  70302. */
  70303. readonly name: string;
  70304. /**
  70305. * Defines whether this extension is enabled.
  70306. */
  70307. enabled: boolean;
  70308. /**
  70309. * Defines a number that determines the order the extensions are applied.
  70310. */
  70311. order: number;
  70312. private _loader;
  70313. /** @hidden */
  70314. constructor(loader: GLTFLoader);
  70315. /** @hidden */
  70316. dispose(): void;
  70317. /** @hidden */
  70318. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70319. private _loadUnlitPropertiesAsync;
  70320. }
  70321. }
  70322. declare module BABYLON.GLTF2.Loader.Extensions {
  70323. /**
  70324. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70325. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  70326. * !!! Experimental Extension Subject to Changes !!!
  70327. */
  70328. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  70329. /**
  70330. * The name of this extension.
  70331. */
  70332. readonly name: string;
  70333. /**
  70334. * Defines whether this extension is enabled.
  70335. */
  70336. enabled: boolean;
  70337. /**
  70338. * Defines a number that determines the order the extensions are applied.
  70339. */
  70340. order: number;
  70341. private _loader;
  70342. /** @hidden */
  70343. constructor(loader: GLTFLoader);
  70344. /** @hidden */
  70345. dispose(): void;
  70346. /** @hidden */
  70347. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70348. private _loadClearCoatPropertiesAsync;
  70349. }
  70350. }
  70351. declare module BABYLON.GLTF2.Loader.Extensions {
  70352. /**
  70353. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  70354. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70355. * !!! Experimental Extension Subject to Changes !!!
  70356. */
  70357. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  70358. /**
  70359. * The name of this extension.
  70360. */
  70361. readonly name: string;
  70362. /**
  70363. * Defines whether this extension is enabled.
  70364. */
  70365. enabled: boolean;
  70366. /**
  70367. * Defines a number that determines the order the extensions are applied.
  70368. */
  70369. order: number;
  70370. private _loader;
  70371. /** @hidden */
  70372. constructor(loader: GLTFLoader);
  70373. /** @hidden */
  70374. dispose(): void;
  70375. /** @hidden */
  70376. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70377. private _loadSheenPropertiesAsync;
  70378. }
  70379. }
  70380. declare module BABYLON.GLTF2.Loader.Extensions {
  70381. /**
  70382. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  70383. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  70384. * !!! Experimental Extension Subject to Changes !!!
  70385. */
  70386. export class KHR_materials_specular implements IGLTFLoaderExtension {
  70387. /**
  70388. * The name of this extension.
  70389. */
  70390. readonly name: string;
  70391. /**
  70392. * Defines whether this extension is enabled.
  70393. */
  70394. enabled: boolean;
  70395. /**
  70396. * Defines a number that determines the order the extensions are applied.
  70397. */
  70398. order: number;
  70399. private _loader;
  70400. /** @hidden */
  70401. constructor(loader: GLTFLoader);
  70402. /** @hidden */
  70403. dispose(): void;
  70404. /** @hidden */
  70405. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70406. private _loadSpecularPropertiesAsync;
  70407. }
  70408. }
  70409. declare module BABYLON.GLTF2.Loader.Extensions {
  70410. /**
  70411. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  70412. */
  70413. export class KHR_texture_transform implements IGLTFLoaderExtension {
  70414. /**
  70415. * The name of this extension.
  70416. */
  70417. readonly name: string;
  70418. /**
  70419. * Defines whether this extension is enabled.
  70420. */
  70421. enabled: boolean;
  70422. private _loader;
  70423. /** @hidden */
  70424. constructor(loader: GLTFLoader);
  70425. /** @hidden */
  70426. dispose(): void;
  70427. /** @hidden */
  70428. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  70429. }
  70430. }
  70431. declare module BABYLON.GLTF2.Loader.Extensions {
  70432. /**
  70433. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  70434. */
  70435. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  70436. /**
  70437. * The name of this extension.
  70438. */
  70439. readonly name: string;
  70440. /**
  70441. * Defines whether this extension is enabled.
  70442. */
  70443. enabled: boolean;
  70444. private _loader;
  70445. private _clips;
  70446. private _emitters;
  70447. /** @hidden */
  70448. constructor(loader: GLTFLoader);
  70449. /** @hidden */
  70450. dispose(): void;
  70451. /** @hidden */
  70452. onLoading(): void;
  70453. /** @hidden */
  70454. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  70455. /** @hidden */
  70456. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70457. /** @hidden */
  70458. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  70459. private _loadClipAsync;
  70460. private _loadEmitterAsync;
  70461. private _getEventAction;
  70462. private _loadAnimationEventAsync;
  70463. }
  70464. }
  70465. declare module BABYLON.GLTF2.Loader.Extensions {
  70466. /**
  70467. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  70468. */
  70469. export class MSFT_lod implements IGLTFLoaderExtension {
  70470. /**
  70471. * The name of this extension.
  70472. */
  70473. readonly name: string;
  70474. /**
  70475. * Defines whether this extension is enabled.
  70476. */
  70477. enabled: boolean;
  70478. /**
  70479. * Defines a number that determines the order the extensions are applied.
  70480. */
  70481. order: number;
  70482. /**
  70483. * Maximum number of LODs to load, starting from the lowest LOD.
  70484. */
  70485. maxLODsToLoad: number;
  70486. /**
  70487. * Observable raised when all node LODs of one level are loaded.
  70488. * The event data is the index of the loaded LOD starting from zero.
  70489. * Dispose the loader to cancel the loading of the next level of LODs.
  70490. */
  70491. onNodeLODsLoadedObservable: Observable<number>;
  70492. /**
  70493. * Observable raised when all material LODs of one level are loaded.
  70494. * The event data is the index of the loaded LOD starting from zero.
  70495. * Dispose the loader to cancel the loading of the next level of LODs.
  70496. */
  70497. onMaterialLODsLoadedObservable: Observable<number>;
  70498. private _loader;
  70499. private _nodeIndexLOD;
  70500. private _nodeSignalLODs;
  70501. private _nodePromiseLODs;
  70502. private _materialIndexLOD;
  70503. private _materialSignalLODs;
  70504. private _materialPromiseLODs;
  70505. private _indexLOD;
  70506. private _bufferLODs;
  70507. /** @hidden */
  70508. constructor(loader: GLTFLoader);
  70509. /** @hidden */
  70510. dispose(): void;
  70511. /** @hidden */
  70512. onReady(): void;
  70513. /** @hidden */
  70514. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70515. /** @hidden */
  70516. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  70517. /** @hidden */
  70518. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  70519. /** @hidden */
  70520. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  70521. private _loadBufferLOD;
  70522. /**
  70523. * Gets an array of LOD properties from lowest to highest.
  70524. */
  70525. private _getLODs;
  70526. private _disposeUnusedMaterials;
  70527. }
  70528. }
  70529. declare module BABYLON.GLTF2.Loader.Extensions {
  70530. /** @hidden */
  70531. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  70532. readonly name: string;
  70533. enabled: boolean;
  70534. private _loader;
  70535. constructor(loader: GLTFLoader);
  70536. dispose(): void;
  70537. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70538. }
  70539. }
  70540. declare module BABYLON.GLTF2.Loader.Extensions {
  70541. /** @hidden */
  70542. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  70543. readonly name: string;
  70544. enabled: boolean;
  70545. private _loader;
  70546. constructor(loader: GLTFLoader);
  70547. dispose(): void;
  70548. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  70549. }
  70550. }
  70551. declare module BABYLON.GLTF2.Loader.Extensions {
  70552. /**
  70553. * Store glTF extras (if present) in BJS objects' metadata
  70554. */
  70555. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  70556. /**
  70557. * The name of this extension.
  70558. */
  70559. readonly name: string;
  70560. /**
  70561. * Defines whether this extension is enabled.
  70562. */
  70563. enabled: boolean;
  70564. private _loader;
  70565. private _assignExtras;
  70566. /** @hidden */
  70567. constructor(loader: GLTFLoader);
  70568. /** @hidden */
  70569. dispose(): void;
  70570. /** @hidden */
  70571. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  70572. /** @hidden */
  70573. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  70574. /** @hidden */
  70575. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  70576. }
  70577. }
  70578. declare module BABYLON {
  70579. /**
  70580. * Class reading and parsing the MTL file bundled with the obj file.
  70581. */
  70582. export class MTLFileLoader {
  70583. /**
  70584. * All material loaded from the mtl will be set here
  70585. */
  70586. materials: StandardMaterial[];
  70587. /**
  70588. * This function will read the mtl file and create each material described inside
  70589. * This function could be improve by adding :
  70590. * -some component missing (Ni, Tf...)
  70591. * -including the specific options available
  70592. *
  70593. * @param scene defines the scene the material will be created in
  70594. * @param data defines the mtl data to parse
  70595. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70596. */
  70597. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70598. /**
  70599. * Gets the texture for the material.
  70600. *
  70601. * If the material is imported from input file,
  70602. * We sanitize the url to ensure it takes the textre from aside the material.
  70603. *
  70604. * @param rootUrl The root url to load from
  70605. * @param value The value stored in the mtl
  70606. * @return The Texture
  70607. */
  70608. private static _getTexture;
  70609. }
  70610. /**
  70611. * Options for loading OBJ/MTL files
  70612. */
  70613. type MeshLoadOptions = {
  70614. /**
  70615. * Defines if UVs are optimized by default during load.
  70616. */
  70617. OptimizeWithUV: boolean;
  70618. /**
  70619. * Defines custom scaling of UV coordinates of loaded meshes.
  70620. */
  70621. UVScaling: Vector2;
  70622. /**
  70623. * Invert model on y-axis (does a model scaling inversion)
  70624. */
  70625. InvertY: boolean;
  70626. /**
  70627. * Invert Y-Axis of referenced textures on load
  70628. */
  70629. InvertTextureY: boolean;
  70630. /**
  70631. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70632. */
  70633. ImportVertexColors: boolean;
  70634. /**
  70635. * Compute the normals for the model, even if normals are present in the file.
  70636. */
  70637. ComputeNormals: boolean;
  70638. /**
  70639. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70640. */
  70641. SkipMaterials: boolean;
  70642. /**
  70643. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70644. */
  70645. MaterialLoadingFailsSilently: boolean;
  70646. };
  70647. /**
  70648. * OBJ file type loader.
  70649. * This is a babylon scene loader plugin.
  70650. */
  70651. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70652. /**
  70653. * Defines if UVs are optimized by default during load.
  70654. */
  70655. static OPTIMIZE_WITH_UV: boolean;
  70656. /**
  70657. * Invert model on y-axis (does a model scaling inversion)
  70658. */
  70659. static INVERT_Y: boolean;
  70660. /**
  70661. * Invert Y-Axis of referenced textures on load
  70662. */
  70663. static INVERT_TEXTURE_Y: boolean;
  70664. /**
  70665. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70666. */
  70667. static IMPORT_VERTEX_COLORS: boolean;
  70668. /**
  70669. * Compute the normals for the model, even if normals are present in the file.
  70670. */
  70671. static COMPUTE_NORMALS: boolean;
  70672. /**
  70673. * Defines custom scaling of UV coordinates of loaded meshes.
  70674. */
  70675. static UV_SCALING: Vector2;
  70676. /**
  70677. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70678. */
  70679. static SKIP_MATERIALS: boolean;
  70680. /**
  70681. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70682. *
  70683. * Defaults to true for backwards compatibility.
  70684. */
  70685. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70686. /**
  70687. * Defines the name of the plugin.
  70688. */
  70689. name: string;
  70690. /**
  70691. * Defines the extension the plugin is able to load.
  70692. */
  70693. extensions: string;
  70694. /** @hidden */
  70695. obj: RegExp;
  70696. /** @hidden */
  70697. group: RegExp;
  70698. /** @hidden */
  70699. mtllib: RegExp;
  70700. /** @hidden */
  70701. usemtl: RegExp;
  70702. /** @hidden */
  70703. smooth: RegExp;
  70704. /** @hidden */
  70705. vertexPattern: RegExp;
  70706. /** @hidden */
  70707. normalPattern: RegExp;
  70708. /** @hidden */
  70709. uvPattern: RegExp;
  70710. /** @hidden */
  70711. facePattern1: RegExp;
  70712. /** @hidden */
  70713. facePattern2: RegExp;
  70714. /** @hidden */
  70715. facePattern3: RegExp;
  70716. /** @hidden */
  70717. facePattern4: RegExp;
  70718. /** @hidden */
  70719. facePattern5: RegExp;
  70720. private _meshLoadOptions;
  70721. /**
  70722. * Creates loader for .OBJ files
  70723. *
  70724. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70725. */
  70726. constructor(meshLoadOptions?: MeshLoadOptions);
  70727. private static readonly currentMeshLoadOptions;
  70728. /**
  70729. * Calls synchronously the MTL file attached to this obj.
  70730. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70731. * Without this function materials are not displayed in the first frame (but displayed after).
  70732. * In consequence it is impossible to get material information in your HTML file
  70733. *
  70734. * @param url The URL of the MTL file
  70735. * @param rootUrl
  70736. * @param onSuccess Callback function to be called when the MTL file is loaded
  70737. * @private
  70738. */
  70739. private _loadMTL;
  70740. /**
  70741. * Instantiates a OBJ file loader plugin.
  70742. * @returns the created plugin
  70743. */
  70744. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70745. /**
  70746. * If the data string can be loaded directly.
  70747. *
  70748. * @param data string containing the file data
  70749. * @returns if the data can be loaded directly
  70750. */
  70751. canDirectLoad(data: string): boolean;
  70752. /**
  70753. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70754. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70755. * @param scene the scene the meshes should be added to
  70756. * @param data the OBJ data to load
  70757. * @param rootUrl root url to load from
  70758. * @param onProgress event that fires when loading progress has occured
  70759. * @param fileName Defines the name of the file to load
  70760. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70761. */
  70762. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70763. meshes: AbstractMesh[];
  70764. particleSystems: IParticleSystem[];
  70765. skeletons: Skeleton[];
  70766. animationGroups: AnimationGroup[];
  70767. }>;
  70768. /**
  70769. * Imports all objects from the loaded OBJ data and adds them to the scene
  70770. * @param scene the scene the objects should be added to
  70771. * @param data the OBJ data to load
  70772. * @param rootUrl root url to load from
  70773. * @param onProgress event that fires when loading progress has occured
  70774. * @param fileName Defines the name of the file to load
  70775. * @returns a promise which completes when objects have been loaded to the scene
  70776. */
  70777. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70778. /**
  70779. * Load into an asset container.
  70780. * @param scene The scene to load into
  70781. * @param data The data to import
  70782. * @param rootUrl The root url for scene and resources
  70783. * @param onProgress The callback when the load progresses
  70784. * @param fileName Defines the name of the file to load
  70785. * @returns The loaded asset container
  70786. */
  70787. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70788. /**
  70789. * Read the OBJ file and create an Array of meshes.
  70790. * Each mesh contains all information given by the OBJ and the MTL file.
  70791. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70792. *
  70793. * @param meshesNames
  70794. * @param scene Scene The scene where are displayed the data
  70795. * @param data String The content of the obj file
  70796. * @param rootUrl String The path to the folder
  70797. * @returns Array<AbstractMesh>
  70798. * @private
  70799. */
  70800. private _parseSolid;
  70801. }
  70802. }
  70803. declare module BABYLON {
  70804. /**
  70805. * STL file type loader.
  70806. * This is a babylon scene loader plugin.
  70807. */
  70808. export class STLFileLoader implements ISceneLoaderPlugin {
  70809. /** @hidden */
  70810. solidPattern: RegExp;
  70811. /** @hidden */
  70812. facetsPattern: RegExp;
  70813. /** @hidden */
  70814. normalPattern: RegExp;
  70815. /** @hidden */
  70816. vertexPattern: RegExp;
  70817. /**
  70818. * Defines the name of the plugin.
  70819. */
  70820. name: string;
  70821. /**
  70822. * Defines the extensions the stl loader is able to load.
  70823. * force data to come in as an ArrayBuffer
  70824. * we'll convert to string if it looks like it's an ASCII .stl
  70825. */
  70826. extensions: ISceneLoaderPluginExtensions;
  70827. /**
  70828. * Import meshes into a scene.
  70829. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70830. * @param scene The scene to import into
  70831. * @param data The data to import
  70832. * @param rootUrl The root url for scene and resources
  70833. * @param meshes The meshes array to import into
  70834. * @param particleSystems The particle systems array to import into
  70835. * @param skeletons The skeletons array to import into
  70836. * @param onError The callback when import fails
  70837. * @returns True if successful or false otherwise
  70838. */
  70839. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70840. /**
  70841. * Load into a scene.
  70842. * @param scene The scene to load into
  70843. * @param data The data to import
  70844. * @param rootUrl The root url for scene and resources
  70845. * @param onError The callback when import fails
  70846. * @returns true if successful or false otherwise
  70847. */
  70848. load(scene: Scene, data: any, rootUrl: string): boolean;
  70849. /**
  70850. * Load into an asset container.
  70851. * @param scene The scene to load into
  70852. * @param data The data to import
  70853. * @param rootUrl The root url for scene and resources
  70854. * @param onError The callback when import fails
  70855. * @returns The loaded asset container
  70856. */
  70857. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70858. private _isBinary;
  70859. private _parseBinary;
  70860. private _parseASCII;
  70861. }
  70862. }
  70863. declare module BABYLON {
  70864. /**
  70865. * Class for generating OBJ data from a Babylon scene.
  70866. */
  70867. export class OBJExport {
  70868. /**
  70869. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70870. * @param mesh defines the list of meshes to serialize
  70871. * @param materials defines if materials should be exported
  70872. * @param matlibname defines the name of the associated mtl file
  70873. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70874. * @returns the OBJ content
  70875. */
  70876. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70877. /**
  70878. * Exports the material(s) of a mesh in .MTL file format (text)
  70879. * @param mesh defines the mesh to extract the material from
  70880. * @returns the mtl content
  70881. */
  70882. static MTL(mesh: Mesh): string;
  70883. }
  70884. }
  70885. declare module BABYLON {
  70886. /** @hidden */
  70887. export var __IGLTFExporterExtension: number;
  70888. /**
  70889. * Interface for extending the exporter
  70890. * @hidden
  70891. */
  70892. export interface IGLTFExporterExtension {
  70893. /**
  70894. * The name of this extension
  70895. */
  70896. readonly name: string;
  70897. /**
  70898. * Defines whether this extension is enabled
  70899. */
  70900. enabled: boolean;
  70901. /**
  70902. * Defines whether this extension is required
  70903. */
  70904. required: boolean;
  70905. }
  70906. }
  70907. declare module BABYLON.GLTF2.Exporter {
  70908. /** @hidden */
  70909. export var __IGLTFExporterExtensionV2: number;
  70910. /**
  70911. * Interface for a glTF exporter extension
  70912. * @hidden
  70913. */
  70914. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70915. /**
  70916. * Define this method to modify the default behavior before exporting a texture
  70917. * @param context The context when loading the asset
  70918. * @param babylonTexture The glTF texture info property
  70919. * @param mimeType The mime-type of the generated image
  70920. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70921. */
  70922. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70923. /**
  70924. * Define this method to modify the default behavior when exporting texture info
  70925. * @param context The context when loading the asset
  70926. * @param meshPrimitive glTF mesh primitive
  70927. * @param babylonSubMesh Babylon submesh
  70928. * @param binaryWriter glTF serializer binary writer instance
  70929. * @returns nullable IMeshPrimitive promise
  70930. */
  70931. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70932. /**
  70933. * Define this method to modify the default behavior when exporting a node
  70934. * @param context The context when exporting the node
  70935. * @param node glTF node
  70936. * @param babylonNode BabylonJS node
  70937. * @returns nullable INode promise
  70938. */
  70939. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70940. /**
  70941. * Called after the exporter state changes to EXPORTING
  70942. */
  70943. onExporting?(): void;
  70944. }
  70945. }
  70946. declare module BABYLON.GLTF2.Exporter {
  70947. /**
  70948. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70949. * @hidden
  70950. */
  70951. export class _GLTFMaterialExporter {
  70952. /**
  70953. * Represents the dielectric specular values for R, G and B
  70954. */
  70955. private static readonly _DielectricSpecular;
  70956. /**
  70957. * Allows the maximum specular power to be defined for material calculations
  70958. */
  70959. private static readonly _MaxSpecularPower;
  70960. /**
  70961. * Mapping to store textures
  70962. */
  70963. private _textureMap;
  70964. /**
  70965. * Numeric tolerance value
  70966. */
  70967. private static readonly _Epsilon;
  70968. /**
  70969. * Reference to the glTF Exporter
  70970. */
  70971. private _exporter;
  70972. constructor(exporter: _Exporter);
  70973. /**
  70974. * Specifies if two colors are approximately equal in value
  70975. * @param color1 first color to compare to
  70976. * @param color2 second color to compare to
  70977. * @param epsilon threshold value
  70978. */
  70979. private static FuzzyEquals;
  70980. /**
  70981. * Gets the materials from a Babylon scene and converts them to glTF materials
  70982. * @param scene babylonjs scene
  70983. * @param mimeType texture mime type
  70984. * @param images array of images
  70985. * @param textures array of textures
  70986. * @param materials array of materials
  70987. * @param imageData mapping of texture names to base64 textures
  70988. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70989. */
  70990. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70991. /**
  70992. * Makes a copy of the glTF material without the texture parameters
  70993. * @param originalMaterial original glTF material
  70994. * @returns glTF material without texture parameters
  70995. */
  70996. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70997. /**
  70998. * Specifies if the material has any texture parameters present
  70999. * @param material glTF Material
  71000. * @returns boolean specifying if texture parameters are present
  71001. */
  71002. _hasTexturesPresent(material: IMaterial): boolean;
  71003. /**
  71004. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  71005. * @param babylonStandardMaterial
  71006. * @returns glTF Metallic Roughness Material representation
  71007. */
  71008. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  71009. /**
  71010. * Computes the metallic factor
  71011. * @param diffuse diffused value
  71012. * @param specular specular value
  71013. * @param oneMinusSpecularStrength one minus the specular strength
  71014. * @returns metallic value
  71015. */
  71016. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  71017. /**
  71018. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  71019. * @param glTFMaterial glTF material
  71020. * @param babylonMaterial Babylon material
  71021. */
  71022. private static _SetAlphaMode;
  71023. /**
  71024. * Converts a Babylon Standard Material to a glTF Material
  71025. * @param babylonStandardMaterial BJS Standard Material
  71026. * @param mimeType mime type to use for the textures
  71027. * @param images array of glTF image interfaces
  71028. * @param textures array of glTF texture interfaces
  71029. * @param materials array of glTF material interfaces
  71030. * @param imageData map of image file name to data
  71031. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71032. */
  71033. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71034. /**
  71035. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71036. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  71037. * @param mimeType mime type to use for the textures
  71038. * @param images array of glTF image interfaces
  71039. * @param textures array of glTF texture interfaces
  71040. * @param materials array of glTF material interfaces
  71041. * @param imageData map of image file name to data
  71042. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71043. */
  71044. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71045. /**
  71046. * Converts an image typed array buffer to a base64 image
  71047. * @param buffer typed array buffer
  71048. * @param width width of the image
  71049. * @param height height of the image
  71050. * @param mimeType mimetype of the image
  71051. * @returns base64 image string
  71052. */
  71053. private _createBase64FromCanvasAsync;
  71054. /**
  71055. * Generates a white texture based on the specified width and height
  71056. * @param width width of the texture in pixels
  71057. * @param height height of the texture in pixels
  71058. * @param scene babylonjs scene
  71059. * @returns white texture
  71060. */
  71061. private _createWhiteTexture;
  71062. /**
  71063. * 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
  71064. * @param texture1 first texture to resize
  71065. * @param texture2 second texture to resize
  71066. * @param scene babylonjs scene
  71067. * @returns resized textures or null
  71068. */
  71069. private _resizeTexturesToSameDimensions;
  71070. /**
  71071. * Converts an array of pixels to a Float32Array
  71072. * Throws an error if the pixel format is not supported
  71073. * @param pixels - array buffer containing pixel values
  71074. * @returns Float32 of pixels
  71075. */
  71076. private _convertPixelArrayToFloat32;
  71077. /**
  71078. * Convert Specular Glossiness Textures to Metallic Roughness
  71079. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  71080. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  71081. * @param diffuseTexture texture used to store diffuse information
  71082. * @param specularGlossinessTexture texture used to store specular and glossiness information
  71083. * @param factors specular glossiness material factors
  71084. * @param mimeType the mime type to use for the texture
  71085. * @returns pbr metallic roughness interface or null
  71086. */
  71087. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  71088. /**
  71089. * Converts specular glossiness material properties to metallic roughness
  71090. * @param specularGlossiness interface with specular glossiness material properties
  71091. * @returns interface with metallic roughness material properties
  71092. */
  71093. private _convertSpecularGlossinessToMetallicRoughness;
  71094. /**
  71095. * Calculates the surface reflectance, independent of lighting conditions
  71096. * @param color Color source to calculate brightness from
  71097. * @returns number representing the perceived brightness, or zero if color is undefined
  71098. */
  71099. private _getPerceivedBrightness;
  71100. /**
  71101. * Returns the maximum color component value
  71102. * @param color
  71103. * @returns maximum color component value, or zero if color is null or undefined
  71104. */
  71105. private _getMaxComponent;
  71106. /**
  71107. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  71108. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71109. * @param mimeType mime type to use for the textures
  71110. * @param images array of glTF image interfaces
  71111. * @param textures array of glTF texture interfaces
  71112. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71113. * @param imageData map of image file name to data
  71114. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71115. * @returns glTF PBR Metallic Roughness factors
  71116. */
  71117. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  71118. private _getGLTFTextureSampler;
  71119. private _getGLTFTextureWrapMode;
  71120. private _getGLTFTextureWrapModesSampler;
  71121. /**
  71122. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  71123. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71124. * @param mimeType mime type to use for the textures
  71125. * @param images array of glTF image interfaces
  71126. * @param textures array of glTF texture interfaces
  71127. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  71128. * @param imageData map of image file name to data
  71129. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71130. * @returns glTF PBR Metallic Roughness factors
  71131. */
  71132. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  71133. /**
  71134. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  71135. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  71136. * @param mimeType mime type to use for the textures
  71137. * @param images array of glTF image interfaces
  71138. * @param textures array of glTF texture interfaces
  71139. * @param materials array of glTF material interfaces
  71140. * @param imageData map of image file name to data
  71141. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  71142. */
  71143. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  71144. private setMetallicRoughnessPbrMaterial;
  71145. private getPixelsFromTexture;
  71146. /**
  71147. * Extracts a texture from a Babylon texture into file data and glTF data
  71148. * @param babylonTexture Babylon texture to extract
  71149. * @param mimeType Mime Type of the babylonTexture
  71150. * @return glTF texture info, or null if the texture format is not supported
  71151. */
  71152. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71153. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  71154. /**
  71155. * Builds a texture from base64 string
  71156. * @param base64Texture base64 texture string
  71157. * @param baseTextureName Name to use for the texture
  71158. * @param mimeType image mime type for the texture
  71159. * @param images array of images
  71160. * @param textures array of textures
  71161. * @param imageData map of image data
  71162. * @returns glTF texture info, or null if the texture format is not supported
  71163. */
  71164. private _getTextureInfoFromBase64;
  71165. }
  71166. }
  71167. declare module BABYLON {
  71168. /**
  71169. * Class for holding and downloading glTF file data
  71170. */
  71171. export class GLTFData {
  71172. /**
  71173. * Object which contains the file name as the key and its data as the value
  71174. */
  71175. glTFFiles: {
  71176. [fileName: string]: string | Blob;
  71177. };
  71178. /**
  71179. * Initializes the glTF file object
  71180. */
  71181. constructor();
  71182. /**
  71183. * Downloads the glTF data as files based on their names and data
  71184. */
  71185. downloadFiles(): void;
  71186. }
  71187. }
  71188. declare module BABYLON {
  71189. /**
  71190. * Holds a collection of exporter options and parameters
  71191. */
  71192. export interface IExportOptions {
  71193. /**
  71194. * Function which indicates whether a babylon node should be exported or not
  71195. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  71196. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  71197. */
  71198. shouldExportNode?(node: Node): boolean;
  71199. /**
  71200. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  71201. * @param metadata source metadata to read from
  71202. * @returns the data to store to glTF node extras
  71203. */
  71204. metadataSelector?(metadata: any): any;
  71205. /**
  71206. * The sample rate to bake animation curves
  71207. */
  71208. animationSampleRate?: number;
  71209. /**
  71210. * Begin serialization without waiting for the scene to be ready
  71211. */
  71212. exportWithoutWaitingForScene?: boolean;
  71213. }
  71214. /**
  71215. * Class for generating glTF data from a Babylon scene.
  71216. */
  71217. export class GLTF2Export {
  71218. /**
  71219. * Exports the geometry of the scene to .gltf file format asynchronously
  71220. * @param scene Babylon scene with scene hierarchy information
  71221. * @param filePrefix File prefix to use when generating the glTF file
  71222. * @param options Exporter options
  71223. * @returns Returns an object with a .gltf file and associates texture names
  71224. * as keys and their data and paths as values
  71225. */
  71226. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71227. private static _PreExportAsync;
  71228. private static _PostExportAsync;
  71229. /**
  71230. * Exports the geometry of the scene to .glb file format asychronously
  71231. * @param scene Babylon scene with scene hierarchy information
  71232. * @param filePrefix File prefix to use when generating glb file
  71233. * @param options Exporter options
  71234. * @returns Returns an object with a .glb filename as key and data as value
  71235. */
  71236. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  71237. }
  71238. }
  71239. declare module BABYLON.GLTF2.Exporter {
  71240. /**
  71241. * @hidden
  71242. */
  71243. export class _GLTFUtilities {
  71244. /**
  71245. * Creates a buffer view based on the supplied arguments
  71246. * @param bufferIndex index value of the specified buffer
  71247. * @param byteOffset byte offset value
  71248. * @param byteLength byte length of the bufferView
  71249. * @param byteStride byte distance between conequential elements
  71250. * @param name name of the buffer view
  71251. * @returns bufferView for glTF
  71252. */
  71253. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  71254. /**
  71255. * Creates an accessor based on the supplied arguments
  71256. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  71257. * @param name The name of the accessor
  71258. * @param type The type of the accessor
  71259. * @param componentType The datatype of components in the attribute
  71260. * @param count The number of attributes referenced by this accessor
  71261. * @param byteOffset The offset relative to the start of the bufferView in bytes
  71262. * @param min Minimum value of each component in this attribute
  71263. * @param max Maximum value of each component in this attribute
  71264. * @returns accessor for glTF
  71265. */
  71266. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  71267. /**
  71268. * Calculates the minimum and maximum values of an array of position floats
  71269. * @param positions Positions array of a mesh
  71270. * @param vertexStart Starting vertex offset to calculate min and max values
  71271. * @param vertexCount Number of vertices to check for min and max values
  71272. * @returns min number array and max number array
  71273. */
  71274. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  71275. min: number[];
  71276. max: number[];
  71277. };
  71278. /**
  71279. * Converts a new right-handed Vector3
  71280. * @param vector vector3 array
  71281. * @returns right-handed Vector3
  71282. */
  71283. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  71284. /**
  71285. * Converts a Vector3 to right-handed
  71286. * @param vector Vector3 to convert to right-handed
  71287. */
  71288. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  71289. /**
  71290. * Converts a three element number array to right-handed
  71291. * @param vector number array to convert to right-handed
  71292. */
  71293. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  71294. /**
  71295. * Converts a new right-handed Vector3
  71296. * @param vector vector3 array
  71297. * @returns right-handed Vector3
  71298. */
  71299. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  71300. /**
  71301. * Converts a Vector3 to right-handed
  71302. * @param vector Vector3 to convert to right-handed
  71303. */
  71304. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  71305. /**
  71306. * Converts a three element number array to right-handed
  71307. * @param vector number array to convert to right-handed
  71308. */
  71309. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  71310. /**
  71311. * Converts a Vector4 to right-handed
  71312. * @param vector Vector4 to convert to right-handed
  71313. */
  71314. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  71315. /**
  71316. * Converts a Vector4 to right-handed
  71317. * @param vector Vector4 to convert to right-handed
  71318. */
  71319. static _GetRightHandedArray4FromRef(vector: number[]): void;
  71320. /**
  71321. * Converts a Quaternion to right-handed
  71322. * @param quaternion Source quaternion to convert to right-handed
  71323. */
  71324. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  71325. /**
  71326. * Converts a Quaternion to right-handed
  71327. * @param quaternion Source quaternion to convert to right-handed
  71328. */
  71329. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  71330. static _NormalizeTangentFromRef(tangent: Vector4): void;
  71331. }
  71332. }
  71333. declare module BABYLON.GLTF2.Exporter {
  71334. /**
  71335. * Converts Babylon Scene into glTF 2.0.
  71336. * @hidden
  71337. */
  71338. export class _Exporter {
  71339. /**
  71340. * Stores the glTF to export
  71341. */
  71342. _glTF: IGLTF;
  71343. /**
  71344. * Stores all generated buffer views, which represents views into the main glTF buffer data
  71345. */
  71346. _bufferViews: IBufferView[];
  71347. /**
  71348. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  71349. */
  71350. _accessors: IAccessor[];
  71351. /**
  71352. * Stores all the generated nodes, which contains transform and/or mesh information per node
  71353. */
  71354. private _nodes;
  71355. /**
  71356. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  71357. */
  71358. private _scenes;
  71359. /**
  71360. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  71361. */
  71362. private _meshes;
  71363. /**
  71364. * Stores all the generated material information, which represents the appearance of each primitive
  71365. */
  71366. _materials: IMaterial[];
  71367. _materialMap: {
  71368. [materialID: number]: number;
  71369. };
  71370. /**
  71371. * Stores all the generated texture information, which is referenced by glTF materials
  71372. */
  71373. _textures: ITexture[];
  71374. /**
  71375. * Stores all the generated image information, which is referenced by glTF textures
  71376. */
  71377. _images: IImage[];
  71378. /**
  71379. * Stores all the texture samplers
  71380. */
  71381. _samplers: ISampler[];
  71382. /**
  71383. * Stores all the generated animation samplers, which is referenced by glTF animations
  71384. */
  71385. /**
  71386. * Stores the animations for glTF models
  71387. */
  71388. private _animations;
  71389. /**
  71390. * Stores the total amount of bytes stored in the glTF buffer
  71391. */
  71392. private _totalByteLength;
  71393. /**
  71394. * Stores a reference to the Babylon scene containing the source geometry and material information
  71395. */
  71396. _babylonScene: Scene;
  71397. /**
  71398. * Stores a map of the image data, where the key is the file name and the value
  71399. * is the image data
  71400. */
  71401. _imageData: {
  71402. [fileName: string]: {
  71403. data: Uint8Array;
  71404. mimeType: ImageMimeType;
  71405. };
  71406. };
  71407. /**
  71408. * Stores a map of the unique id of a node to its index in the node array
  71409. */
  71410. private _nodeMap;
  71411. /**
  71412. * Specifies if the Babylon scene should be converted to right-handed on export
  71413. */
  71414. _convertToRightHandedSystem: boolean;
  71415. /**
  71416. * Baked animation sample rate
  71417. */
  71418. private _animationSampleRate;
  71419. private _options;
  71420. private _localEngine;
  71421. _glTFMaterialExporter: _GLTFMaterialExporter;
  71422. private _extensions;
  71423. private static _ExtensionNames;
  71424. private static _ExtensionFactories;
  71425. private _applyExtensions;
  71426. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  71427. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  71428. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71429. private _forEachExtensions;
  71430. private _extensionsOnExporting;
  71431. /**
  71432. * Load glTF serializer extensions
  71433. */
  71434. private _loadExtensions;
  71435. /**
  71436. * Creates a glTF Exporter instance, which can accept optional exporter options
  71437. * @param babylonScene Babylon scene object
  71438. * @param options Options to modify the behavior of the exporter
  71439. */
  71440. constructor(babylonScene: Scene, options?: IExportOptions);
  71441. /**
  71442. * Registers a glTF exporter extension
  71443. * @param name Name of the extension to export
  71444. * @param factory The factory function that creates the exporter extension
  71445. */
  71446. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  71447. /**
  71448. * Un-registers an exporter extension
  71449. * @param name The name fo the exporter extension
  71450. * @returns A boolean indicating whether the extension has been un-registered
  71451. */
  71452. static UnregisterExtension(name: string): boolean;
  71453. /**
  71454. * Lazy load a local engine with premultiplied alpha set to false
  71455. */
  71456. _getLocalEngine(): Engine;
  71457. private reorderIndicesBasedOnPrimitiveMode;
  71458. /**
  71459. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  71460. * clock-wise during export to glTF
  71461. * @param submesh BabylonJS submesh
  71462. * @param primitiveMode Primitive mode of the mesh
  71463. * @param sideOrientation the winding order of the submesh
  71464. * @param vertexBufferKind The type of vertex attribute
  71465. * @param meshAttributeArray The vertex attribute data
  71466. * @param byteOffset The offset to the binary data
  71467. * @param binaryWriter The binary data for the glTF file
  71468. */
  71469. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  71470. /**
  71471. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  71472. * clock-wise during export to glTF
  71473. * @param submesh BabylonJS submesh
  71474. * @param primitiveMode Primitive mode of the mesh
  71475. * @param sideOrientation the winding order of the submesh
  71476. * @param vertexBufferKind The type of vertex attribute
  71477. * @param meshAttributeArray The vertex attribute data
  71478. * @param byteOffset The offset to the binary data
  71479. * @param binaryWriter The binary data for the glTF file
  71480. */
  71481. private reorderTriangleFillMode;
  71482. /**
  71483. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  71484. * clock-wise during export to glTF
  71485. * @param submesh BabylonJS submesh
  71486. * @param primitiveMode Primitive mode of the mesh
  71487. * @param sideOrientation the winding order of the submesh
  71488. * @param vertexBufferKind The type of vertex attribute
  71489. * @param meshAttributeArray The vertex attribute data
  71490. * @param byteOffset The offset to the binary data
  71491. * @param binaryWriter The binary data for the glTF file
  71492. */
  71493. private reorderTriangleStripDrawMode;
  71494. /**
  71495. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  71496. * clock-wise during export to glTF
  71497. * @param submesh BabylonJS submesh
  71498. * @param primitiveMode Primitive mode of the mesh
  71499. * @param sideOrientation the winding order of the submesh
  71500. * @param vertexBufferKind The type of vertex attribute
  71501. * @param meshAttributeArray The vertex attribute data
  71502. * @param byteOffset The offset to the binary data
  71503. * @param binaryWriter The binary data for the glTF file
  71504. */
  71505. private reorderTriangleFanMode;
  71506. /**
  71507. * Writes the vertex attribute data to binary
  71508. * @param vertices The vertices to write to the binary writer
  71509. * @param byteOffset The offset into the binary writer to overwrite binary data
  71510. * @param vertexAttributeKind The vertex attribute type
  71511. * @param meshAttributeArray The vertex attribute data
  71512. * @param binaryWriter The writer containing the binary data
  71513. */
  71514. private writeVertexAttributeData;
  71515. /**
  71516. * Writes mesh attribute data to a data buffer
  71517. * Returns the bytelength of the data
  71518. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  71519. * @param meshAttributeArray Array containing the attribute data
  71520. * @param binaryWriter The buffer to write the binary data to
  71521. * @param indices Used to specify the order of the vertex data
  71522. */
  71523. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  71524. /**
  71525. * Generates glTF json data
  71526. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  71527. * @param glTFPrefix Text to use when prefixing a glTF file
  71528. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  71529. * @returns json data as string
  71530. */
  71531. private generateJSON;
  71532. /**
  71533. * Generates data for .gltf and .bin files based on the glTF prefix string
  71534. * @param glTFPrefix Text to use when prefixing a glTF file
  71535. * @returns GLTFData with glTF file data
  71536. */
  71537. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  71538. /**
  71539. * Creates a binary buffer for glTF
  71540. * @returns array buffer for binary data
  71541. */
  71542. private _generateBinaryAsync;
  71543. /**
  71544. * Pads the number to a multiple of 4
  71545. * @param num number to pad
  71546. * @returns padded number
  71547. */
  71548. private _getPadding;
  71549. /**
  71550. * Generates a glb file from the json and binary data
  71551. * Returns an object with the glb file name as the key and data as the value
  71552. * @param glTFPrefix
  71553. * @returns object with glb filename as key and data as value
  71554. */
  71555. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  71556. /**
  71557. * Sets the TRS for each node
  71558. * @param node glTF Node for storing the transformation data
  71559. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  71560. */
  71561. private setNodeTransformation;
  71562. private getVertexBufferFromMesh;
  71563. /**
  71564. * Creates a bufferview based on the vertices type for the Babylon mesh
  71565. * @param kind Indicates the type of vertices data
  71566. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  71567. * @param binaryWriter The buffer to write the bufferview data to
  71568. */
  71569. private createBufferViewKind;
  71570. /**
  71571. * The primitive mode of the Babylon mesh
  71572. * @param babylonMesh The BabylonJS mesh
  71573. */
  71574. private getMeshPrimitiveMode;
  71575. /**
  71576. * Sets the primitive mode of the glTF mesh primitive
  71577. * @param meshPrimitive glTF mesh primitive
  71578. * @param primitiveMode The primitive mode
  71579. */
  71580. private setPrimitiveMode;
  71581. /**
  71582. * Sets the vertex attribute accessor based of the glTF mesh primitive
  71583. * @param meshPrimitive glTF mesh primitive
  71584. * @param attributeKind vertex attribute
  71585. * @returns boolean specifying if uv coordinates are present
  71586. */
  71587. private setAttributeKind;
  71588. /**
  71589. * Sets data for the primitive attributes of each submesh
  71590. * @param mesh glTF Mesh object to store the primitive attribute information
  71591. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  71592. * @param binaryWriter Buffer to write the attribute data to
  71593. */
  71594. private setPrimitiveAttributesAsync;
  71595. /**
  71596. * Creates a glTF scene based on the array of meshes
  71597. * Returns the the total byte offset
  71598. * @param babylonScene Babylon scene to get the mesh data from
  71599. * @param binaryWriter Buffer to write binary data to
  71600. */
  71601. private createSceneAsync;
  71602. /**
  71603. * Creates a mapping of Node unique id to node index and handles animations
  71604. * @param babylonScene Babylon Scene
  71605. * @param nodes Babylon transform nodes
  71606. * @param binaryWriter Buffer to write binary data to
  71607. * @returns Node mapping of unique id to index
  71608. */
  71609. private createNodeMapAndAnimationsAsync;
  71610. /**
  71611. * Creates a glTF node from a Babylon mesh
  71612. * @param babylonMesh Source Babylon mesh
  71613. * @param binaryWriter Buffer for storing geometry data
  71614. * @returns glTF node
  71615. */
  71616. private createNodeAsync;
  71617. }
  71618. /**
  71619. * @hidden
  71620. *
  71621. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71622. */
  71623. export class _BinaryWriter {
  71624. /**
  71625. * Array buffer which stores all binary data
  71626. */
  71627. private _arrayBuffer;
  71628. /**
  71629. * View of the array buffer
  71630. */
  71631. private _dataView;
  71632. /**
  71633. * byte offset of data in array buffer
  71634. */
  71635. private _byteOffset;
  71636. /**
  71637. * Initialize binary writer with an initial byte length
  71638. * @param byteLength Initial byte length of the array buffer
  71639. */
  71640. constructor(byteLength: number);
  71641. /**
  71642. * Resize the array buffer to the specified byte length
  71643. * @param byteLength
  71644. */
  71645. private resizeBuffer;
  71646. /**
  71647. * Get an array buffer with the length of the byte offset
  71648. * @returns ArrayBuffer resized to the byte offset
  71649. */
  71650. getArrayBuffer(): ArrayBuffer;
  71651. /**
  71652. * Get the byte offset of the array buffer
  71653. * @returns byte offset
  71654. */
  71655. getByteOffset(): number;
  71656. /**
  71657. * Stores an UInt8 in the array buffer
  71658. * @param entry
  71659. * @param byteOffset If defined, specifies where to set the value as an offset.
  71660. */
  71661. setUInt8(entry: number, byteOffset?: number): void;
  71662. /**
  71663. * Gets an UInt32 in the array buffer
  71664. * @param entry
  71665. * @param byteOffset If defined, specifies where to set the value as an offset.
  71666. */
  71667. getUInt32(byteOffset: number): number;
  71668. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71669. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71670. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71671. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71672. /**
  71673. * Stores a Float32 in the array buffer
  71674. * @param entry
  71675. */
  71676. setFloat32(entry: number, byteOffset?: number): void;
  71677. /**
  71678. * Stores an UInt32 in the array buffer
  71679. * @param entry
  71680. * @param byteOffset If defined, specifies where to set the value as an offset.
  71681. */
  71682. setUInt32(entry: number, byteOffset?: number): void;
  71683. }
  71684. }
  71685. declare module BABYLON.GLTF2.Exporter {
  71686. /**
  71687. * @hidden
  71688. * Interface to store animation data.
  71689. */
  71690. export interface _IAnimationData {
  71691. /**
  71692. * Keyframe data.
  71693. */
  71694. inputs: number[];
  71695. /**
  71696. * Value data.
  71697. */
  71698. outputs: number[][];
  71699. /**
  71700. * Animation interpolation data.
  71701. */
  71702. samplerInterpolation: AnimationSamplerInterpolation;
  71703. /**
  71704. * Minimum keyframe value.
  71705. */
  71706. inputsMin: number;
  71707. /**
  71708. * Maximum keyframe value.
  71709. */
  71710. inputsMax: number;
  71711. }
  71712. /**
  71713. * @hidden
  71714. */
  71715. export interface _IAnimationInfo {
  71716. /**
  71717. * The target channel for the animation
  71718. */
  71719. animationChannelTargetPath: AnimationChannelTargetPath;
  71720. /**
  71721. * The glTF accessor type for the data.
  71722. */
  71723. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71724. /**
  71725. * Specifies if quaternions should be used.
  71726. */
  71727. useQuaternion: boolean;
  71728. }
  71729. /**
  71730. * @hidden
  71731. * Utility class for generating glTF animation data from BabylonJS.
  71732. */
  71733. export class _GLTFAnimation {
  71734. /**
  71735. * @ignore
  71736. *
  71737. * Creates glTF channel animation from BabylonJS animation.
  71738. * @param babylonTransformNode - BabylonJS mesh.
  71739. * @param animation - animation.
  71740. * @param animationChannelTargetPath - The target animation channel.
  71741. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71742. * @param useQuaternion - Specifies if quaternions are used.
  71743. * @returns nullable IAnimationData
  71744. */
  71745. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71746. private static _DeduceAnimationInfo;
  71747. /**
  71748. * @ignore
  71749. * Create node animations from the transform node animations
  71750. * @param babylonNode
  71751. * @param runtimeGLTFAnimation
  71752. * @param idleGLTFAnimations
  71753. * @param nodeMap
  71754. * @param nodes
  71755. * @param binaryWriter
  71756. * @param bufferViews
  71757. * @param accessors
  71758. * @param convertToRightHandedSystem
  71759. */
  71760. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71761. [key: number]: number;
  71762. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71763. /**
  71764. * @ignore
  71765. * Create node animations from the animation groups
  71766. * @param babylonScene
  71767. * @param glTFAnimations
  71768. * @param nodeMap
  71769. * @param nodes
  71770. * @param binaryWriter
  71771. * @param bufferViews
  71772. * @param accessors
  71773. * @param convertToRightHandedSystem
  71774. */
  71775. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71776. [key: number]: number;
  71777. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71778. private static AddAnimation;
  71779. /**
  71780. * Create a baked animation
  71781. * @param babylonTransformNode BabylonJS mesh
  71782. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71783. * @param animationChannelTargetPath animation target channel
  71784. * @param minFrame minimum animation frame
  71785. * @param maxFrame maximum animation frame
  71786. * @param fps frames per second of the animation
  71787. * @param inputs input key frames of the animation
  71788. * @param outputs output key frame data of the animation
  71789. * @param convertToRightHandedSystem converts the values to right-handed
  71790. * @param useQuaternion specifies if quaternions should be used
  71791. */
  71792. private static _CreateBakedAnimation;
  71793. private static _ConvertFactorToVector3OrQuaternion;
  71794. private static _SetInterpolatedValue;
  71795. /**
  71796. * Creates linear animation from the animation key frames
  71797. * @param babylonTransformNode BabylonJS mesh
  71798. * @param animation BabylonJS animation
  71799. * @param animationChannelTargetPath The target animation channel
  71800. * @param frameDelta The difference between the last and first frame of the animation
  71801. * @param inputs Array to store the key frame times
  71802. * @param outputs Array to store the key frame data
  71803. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71804. * @param useQuaternion Specifies if quaternions are used in the animation
  71805. */
  71806. private static _CreateLinearOrStepAnimation;
  71807. /**
  71808. * Creates cubic spline animation from the animation key frames
  71809. * @param babylonTransformNode BabylonJS mesh
  71810. * @param animation BabylonJS animation
  71811. * @param animationChannelTargetPath The target animation channel
  71812. * @param frameDelta The difference between the last and first frame of the animation
  71813. * @param inputs Array to store the key frame times
  71814. * @param outputs Array to store the key frame data
  71815. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71816. * @param useQuaternion Specifies if quaternions are used in the animation
  71817. */
  71818. private static _CreateCubicSplineAnimation;
  71819. private static _GetBasePositionRotationOrScale;
  71820. /**
  71821. * Adds a key frame value
  71822. * @param keyFrame
  71823. * @param animation
  71824. * @param outputs
  71825. * @param animationChannelTargetPath
  71826. * @param basePositionRotationOrScale
  71827. * @param convertToRightHandedSystem
  71828. * @param useQuaternion
  71829. */
  71830. private static _AddKeyframeValue;
  71831. /**
  71832. * Determine the interpolation based on the key frames
  71833. * @param keyFrames
  71834. * @param animationChannelTargetPath
  71835. * @param useQuaternion
  71836. */
  71837. private static _DeduceInterpolation;
  71838. /**
  71839. * Adds an input tangent or output tangent to the output data
  71840. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71841. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71842. * @param outputs The animation data by keyframe
  71843. * @param animationChannelTargetPath The target animation channel
  71844. * @param interpolation The interpolation type
  71845. * @param keyFrame The key frame with the animation data
  71846. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71847. * @param useQuaternion Specifies if quaternions are used
  71848. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71849. */
  71850. private static AddSplineTangent;
  71851. /**
  71852. * Get the minimum and maximum key frames' frame values
  71853. * @param keyFrames animation key frames
  71854. * @returns the minimum and maximum key frame value
  71855. */
  71856. private static calculateMinMaxKeyFrames;
  71857. }
  71858. }
  71859. declare module BABYLON.GLTF2.Exporter {
  71860. /** @hidden */
  71861. export var textureTransformPixelShader: {
  71862. name: string;
  71863. shader: string;
  71864. };
  71865. }
  71866. declare module BABYLON.GLTF2.Exporter.Extensions {
  71867. /**
  71868. * @hidden
  71869. */
  71870. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71871. /** Name of this extension */
  71872. readonly name: string;
  71873. /** Defines whether this extension is enabled */
  71874. enabled: boolean;
  71875. /** Defines whether this extension is required */
  71876. required: boolean;
  71877. /** Reference to the glTF exporter */
  71878. private _exporter;
  71879. constructor(exporter: _Exporter);
  71880. dispose(): void;
  71881. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71882. /**
  71883. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71884. * @param babylonTexture
  71885. * @param offset
  71886. * @param rotation
  71887. * @param scale
  71888. * @param scene
  71889. */
  71890. private _textureTransformTextureAsync;
  71891. }
  71892. }
  71893. declare module BABYLON.GLTF2.Exporter.Extensions {
  71894. /**
  71895. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71896. */
  71897. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71898. /** The name of this extension. */
  71899. readonly name: string;
  71900. /** Defines whether this extension is enabled. */
  71901. enabled: boolean;
  71902. /** Defines whether this extension is required */
  71903. required: boolean;
  71904. /** Reference to the glTF exporter */
  71905. private _exporter;
  71906. private _lights;
  71907. /** @hidden */
  71908. constructor(exporter: _Exporter);
  71909. /** @hidden */
  71910. dispose(): void;
  71911. /** @hidden */
  71912. onExporting(): void;
  71913. /**
  71914. * Define this method to modify the default behavior when exporting a node
  71915. * @param context The context when exporting the node
  71916. * @param node glTF node
  71917. * @param babylonNode BabylonJS node
  71918. * @returns nullable INode promise
  71919. */
  71920. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71921. }
  71922. }
  71923. declare module BABYLON {
  71924. /**
  71925. * Class for generating STL data from a Babylon scene.
  71926. */
  71927. export class STLExport {
  71928. /**
  71929. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71930. * @param meshes list defines the mesh to serialize
  71931. * @param download triggers the automatic download of the file.
  71932. * @param fileName changes the downloads fileName.
  71933. * @param binary changes the STL to a binary type.
  71934. * @param isLittleEndian toggle for binary type exporter.
  71935. * @returns the STL as UTF8 string
  71936. */
  71937. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71938. }
  71939. }
  71940. declare module "babylonjs-gltf2interface" {
  71941. export = BABYLON.GLTF2;
  71942. }
  71943. /**
  71944. * Module for glTF 2.0 Interface
  71945. */
  71946. declare module BABYLON.GLTF2 {
  71947. /**
  71948. * The datatype of the components in the attribute
  71949. */
  71950. const enum AccessorComponentType {
  71951. /**
  71952. * Byte
  71953. */
  71954. BYTE = 5120,
  71955. /**
  71956. * Unsigned Byte
  71957. */
  71958. UNSIGNED_BYTE = 5121,
  71959. /**
  71960. * Short
  71961. */
  71962. SHORT = 5122,
  71963. /**
  71964. * Unsigned Short
  71965. */
  71966. UNSIGNED_SHORT = 5123,
  71967. /**
  71968. * Unsigned Int
  71969. */
  71970. UNSIGNED_INT = 5125,
  71971. /**
  71972. * Float
  71973. */
  71974. FLOAT = 5126,
  71975. }
  71976. /**
  71977. * Specifies if the attirbute is a scalar, vector, or matrix
  71978. */
  71979. const enum AccessorType {
  71980. /**
  71981. * Scalar
  71982. */
  71983. SCALAR = "SCALAR",
  71984. /**
  71985. * Vector2
  71986. */
  71987. VEC2 = "VEC2",
  71988. /**
  71989. * Vector3
  71990. */
  71991. VEC3 = "VEC3",
  71992. /**
  71993. * Vector4
  71994. */
  71995. VEC4 = "VEC4",
  71996. /**
  71997. * Matrix2x2
  71998. */
  71999. MAT2 = "MAT2",
  72000. /**
  72001. * Matrix3x3
  72002. */
  72003. MAT3 = "MAT3",
  72004. /**
  72005. * Matrix4x4
  72006. */
  72007. MAT4 = "MAT4",
  72008. }
  72009. /**
  72010. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72011. */
  72012. const enum AnimationChannelTargetPath {
  72013. /**
  72014. * Translation
  72015. */
  72016. TRANSLATION = "translation",
  72017. /**
  72018. * Rotation
  72019. */
  72020. ROTATION = "rotation",
  72021. /**
  72022. * Scale
  72023. */
  72024. SCALE = "scale",
  72025. /**
  72026. * Weights
  72027. */
  72028. WEIGHTS = "weights",
  72029. }
  72030. /**
  72031. * Interpolation algorithm
  72032. */
  72033. const enum AnimationSamplerInterpolation {
  72034. /**
  72035. * The animated values are linearly interpolated between keyframes
  72036. */
  72037. LINEAR = "LINEAR",
  72038. /**
  72039. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  72040. */
  72041. STEP = "STEP",
  72042. /**
  72043. * The animation's interpolation is computed using a cubic spline with specified tangents
  72044. */
  72045. CUBICSPLINE = "CUBICSPLINE",
  72046. }
  72047. /**
  72048. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72049. */
  72050. const enum CameraType {
  72051. /**
  72052. * A perspective camera containing properties to create a perspective projection matrix
  72053. */
  72054. PERSPECTIVE = "perspective",
  72055. /**
  72056. * An orthographic camera containing properties to create an orthographic projection matrix
  72057. */
  72058. ORTHOGRAPHIC = "orthographic",
  72059. }
  72060. /**
  72061. * The mime-type of the image
  72062. */
  72063. const enum ImageMimeType {
  72064. /**
  72065. * JPEG Mime-type
  72066. */
  72067. JPEG = "image/jpeg",
  72068. /**
  72069. * PNG Mime-type
  72070. */
  72071. PNG = "image/png",
  72072. }
  72073. /**
  72074. * The alpha rendering mode of the material
  72075. */
  72076. const enum MaterialAlphaMode {
  72077. /**
  72078. * The alpha value is ignored and the rendered output is fully opaque
  72079. */
  72080. OPAQUE = "OPAQUE",
  72081. /**
  72082. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  72083. */
  72084. MASK = "MASK",
  72085. /**
  72086. * 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)
  72087. */
  72088. BLEND = "BLEND",
  72089. }
  72090. /**
  72091. * The type of the primitives to render
  72092. */
  72093. const enum MeshPrimitiveMode {
  72094. /**
  72095. * Points
  72096. */
  72097. POINTS = 0,
  72098. /**
  72099. * Lines
  72100. */
  72101. LINES = 1,
  72102. /**
  72103. * Line Loop
  72104. */
  72105. LINE_LOOP = 2,
  72106. /**
  72107. * Line Strip
  72108. */
  72109. LINE_STRIP = 3,
  72110. /**
  72111. * Triangles
  72112. */
  72113. TRIANGLES = 4,
  72114. /**
  72115. * Triangle Strip
  72116. */
  72117. TRIANGLE_STRIP = 5,
  72118. /**
  72119. * Triangle Fan
  72120. */
  72121. TRIANGLE_FAN = 6,
  72122. }
  72123. /**
  72124. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72125. */
  72126. const enum TextureMagFilter {
  72127. /**
  72128. * Nearest
  72129. */
  72130. NEAREST = 9728,
  72131. /**
  72132. * Linear
  72133. */
  72134. LINEAR = 9729,
  72135. }
  72136. /**
  72137. * Minification filter. All valid values correspond to WebGL enums
  72138. */
  72139. const enum TextureMinFilter {
  72140. /**
  72141. * Nearest
  72142. */
  72143. NEAREST = 9728,
  72144. /**
  72145. * Linear
  72146. */
  72147. LINEAR = 9729,
  72148. /**
  72149. * Nearest Mip-Map Nearest
  72150. */
  72151. NEAREST_MIPMAP_NEAREST = 9984,
  72152. /**
  72153. * Linear Mipmap Nearest
  72154. */
  72155. LINEAR_MIPMAP_NEAREST = 9985,
  72156. /**
  72157. * Nearest Mipmap Linear
  72158. */
  72159. NEAREST_MIPMAP_LINEAR = 9986,
  72160. /**
  72161. * Linear Mipmap Linear
  72162. */
  72163. LINEAR_MIPMAP_LINEAR = 9987,
  72164. }
  72165. /**
  72166. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72167. */
  72168. const enum TextureWrapMode {
  72169. /**
  72170. * Clamp to Edge
  72171. */
  72172. CLAMP_TO_EDGE = 33071,
  72173. /**
  72174. * Mirrored Repeat
  72175. */
  72176. MIRRORED_REPEAT = 33648,
  72177. /**
  72178. * Repeat
  72179. */
  72180. REPEAT = 10497,
  72181. }
  72182. /**
  72183. * glTF Property
  72184. */
  72185. interface IProperty {
  72186. /**
  72187. * Dictionary object with extension-specific objects
  72188. */
  72189. extensions?: {
  72190. [key: string]: any;
  72191. };
  72192. /**
  72193. * Application-Specific data
  72194. */
  72195. extras?: any;
  72196. }
  72197. /**
  72198. * glTF Child of Root Property
  72199. */
  72200. interface IChildRootProperty extends IProperty {
  72201. /**
  72202. * The user-defined name of this object
  72203. */
  72204. name?: string;
  72205. }
  72206. /**
  72207. * Indices of those attributes that deviate from their initialization value
  72208. */
  72209. interface IAccessorSparseIndices extends IProperty {
  72210. /**
  72211. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72212. */
  72213. bufferView: number;
  72214. /**
  72215. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72216. */
  72217. byteOffset?: number;
  72218. /**
  72219. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  72220. */
  72221. componentType: AccessorComponentType;
  72222. }
  72223. /**
  72224. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  72225. */
  72226. interface IAccessorSparseValues extends IProperty {
  72227. /**
  72228. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  72229. */
  72230. bufferView: number;
  72231. /**
  72232. * The offset relative to the start of the bufferView in bytes. Must be aligned
  72233. */
  72234. byteOffset?: number;
  72235. }
  72236. /**
  72237. * Sparse storage of attributes that deviate from their initialization value
  72238. */
  72239. interface IAccessorSparse extends IProperty {
  72240. /**
  72241. * The number of attributes encoded in this sparse accessor
  72242. */
  72243. count: number;
  72244. /**
  72245. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  72246. */
  72247. indices: IAccessorSparseIndices;
  72248. /**
  72249. * 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
  72250. */
  72251. values: IAccessorSparseValues;
  72252. }
  72253. /**
  72254. * 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
  72255. */
  72256. interface IAccessor extends IChildRootProperty {
  72257. /**
  72258. * The index of the bufferview
  72259. */
  72260. bufferView?: number;
  72261. /**
  72262. * The offset relative to the start of the bufferView in bytes
  72263. */
  72264. byteOffset?: number;
  72265. /**
  72266. * The datatype of components in the attribute
  72267. */
  72268. componentType: AccessorComponentType;
  72269. /**
  72270. * Specifies whether integer data values should be normalized
  72271. */
  72272. normalized?: boolean;
  72273. /**
  72274. * The number of attributes referenced by this accessor
  72275. */
  72276. count: number;
  72277. /**
  72278. * Specifies if the attribute is a scalar, vector, or matrix
  72279. */
  72280. type: AccessorType;
  72281. /**
  72282. * Maximum value of each component in this attribute
  72283. */
  72284. max?: number[];
  72285. /**
  72286. * Minimum value of each component in this attribute
  72287. */
  72288. min?: number[];
  72289. /**
  72290. * Sparse storage of attributes that deviate from their initialization value
  72291. */
  72292. sparse?: IAccessorSparse;
  72293. }
  72294. /**
  72295. * Targets an animation's sampler at a node's property
  72296. */
  72297. interface IAnimationChannel extends IProperty {
  72298. /**
  72299. * The index of a sampler in this animation used to compute the value for the target
  72300. */
  72301. sampler: number;
  72302. /**
  72303. * The index of the node and TRS property to target
  72304. */
  72305. target: IAnimationChannelTarget;
  72306. }
  72307. /**
  72308. * The index of the node and TRS property that an animation channel targets
  72309. */
  72310. interface IAnimationChannelTarget extends IProperty {
  72311. /**
  72312. * The index of the node to target
  72313. */
  72314. node: number;
  72315. /**
  72316. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  72317. */
  72318. path: AnimationChannelTargetPath;
  72319. }
  72320. /**
  72321. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72322. */
  72323. interface IAnimationSampler extends IProperty {
  72324. /**
  72325. * The index of an accessor containing keyframe input values, e.g., time
  72326. */
  72327. input: number;
  72328. /**
  72329. * Interpolation algorithm
  72330. */
  72331. interpolation?: AnimationSamplerInterpolation;
  72332. /**
  72333. * The index of an accessor, containing keyframe output values
  72334. */
  72335. output: number;
  72336. }
  72337. /**
  72338. * A keyframe animation
  72339. */
  72340. interface IAnimation extends IChildRootProperty {
  72341. /**
  72342. * An array of channels, each of which targets an animation's sampler at a node's property
  72343. */
  72344. channels: IAnimationChannel[];
  72345. /**
  72346. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  72347. */
  72348. samplers: IAnimationSampler[];
  72349. }
  72350. /**
  72351. * Metadata about the glTF asset
  72352. */
  72353. interface IAsset extends IChildRootProperty {
  72354. /**
  72355. * A copyright message suitable for display to credit the content creator
  72356. */
  72357. copyright?: string;
  72358. /**
  72359. * Tool that generated this glTF model. Useful for debugging
  72360. */
  72361. generator?: string;
  72362. /**
  72363. * The glTF version that this asset targets
  72364. */
  72365. version: string;
  72366. /**
  72367. * The minimum glTF version that this asset targets
  72368. */
  72369. minVersion?: string;
  72370. }
  72371. /**
  72372. * A buffer points to binary geometry, animation, or skins
  72373. */
  72374. interface IBuffer extends IChildRootProperty {
  72375. /**
  72376. * 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
  72377. */
  72378. uri?: string;
  72379. /**
  72380. * The length of the buffer in bytes
  72381. */
  72382. byteLength: number;
  72383. }
  72384. /**
  72385. * A view into a buffer generally representing a subset of the buffer
  72386. */
  72387. interface IBufferView extends IChildRootProperty {
  72388. /**
  72389. * The index of the buffer
  72390. */
  72391. buffer: number;
  72392. /**
  72393. * The offset into the buffer in bytes
  72394. */
  72395. byteOffset?: number;
  72396. /**
  72397. * The lenth of the bufferView in bytes
  72398. */
  72399. byteLength: number;
  72400. /**
  72401. * The stride, in bytes
  72402. */
  72403. byteStride?: number;
  72404. }
  72405. /**
  72406. * An orthographic camera containing properties to create an orthographic projection matrix
  72407. */
  72408. interface ICameraOrthographic extends IProperty {
  72409. /**
  72410. * The floating-point horizontal magnification of the view. Must not be zero
  72411. */
  72412. xmag: number;
  72413. /**
  72414. * The floating-point vertical magnification of the view. Must not be zero
  72415. */
  72416. ymag: number;
  72417. /**
  72418. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  72419. */
  72420. zfar: number;
  72421. /**
  72422. * The floating-point distance to the near clipping plane
  72423. */
  72424. znear: number;
  72425. }
  72426. /**
  72427. * A perspective camera containing properties to create a perspective projection matrix
  72428. */
  72429. interface ICameraPerspective extends IProperty {
  72430. /**
  72431. * The floating-point aspect ratio of the field of view
  72432. */
  72433. aspectRatio?: number;
  72434. /**
  72435. * The floating-point vertical field of view in radians
  72436. */
  72437. yfov: number;
  72438. /**
  72439. * The floating-point distance to the far clipping plane
  72440. */
  72441. zfar?: number;
  72442. /**
  72443. * The floating-point distance to the near clipping plane
  72444. */
  72445. znear: number;
  72446. }
  72447. /**
  72448. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  72449. */
  72450. interface ICamera extends IChildRootProperty {
  72451. /**
  72452. * An orthographic camera containing properties to create an orthographic projection matrix
  72453. */
  72454. orthographic?: ICameraOrthographic;
  72455. /**
  72456. * A perspective camera containing properties to create a perspective projection matrix
  72457. */
  72458. perspective?: ICameraPerspective;
  72459. /**
  72460. * Specifies if the camera uses a perspective or orthographic projection
  72461. */
  72462. type: CameraType;
  72463. }
  72464. /**
  72465. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  72466. */
  72467. interface IImage extends IChildRootProperty {
  72468. /**
  72469. * 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
  72470. */
  72471. uri?: string;
  72472. /**
  72473. * The image's MIME type
  72474. */
  72475. mimeType?: ImageMimeType;
  72476. /**
  72477. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  72478. */
  72479. bufferView?: number;
  72480. }
  72481. /**
  72482. * Material Normal Texture Info
  72483. */
  72484. interface IMaterialNormalTextureInfo extends ITextureInfo {
  72485. /**
  72486. * The scalar multiplier applied to each normal vector of the normal texture
  72487. */
  72488. scale?: number;
  72489. }
  72490. /**
  72491. * Material Occlusion Texture Info
  72492. */
  72493. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  72494. /**
  72495. * A scalar multiplier controlling the amount of occlusion applied
  72496. */
  72497. strength?: number;
  72498. }
  72499. /**
  72500. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  72501. */
  72502. interface IMaterialPbrMetallicRoughness {
  72503. /**
  72504. * The material's base color factor
  72505. */
  72506. baseColorFactor?: number[];
  72507. /**
  72508. * The base color texture
  72509. */
  72510. baseColorTexture?: ITextureInfo;
  72511. /**
  72512. * The metalness of the material
  72513. */
  72514. metallicFactor?: number;
  72515. /**
  72516. * The roughness of the material
  72517. */
  72518. roughnessFactor?: number;
  72519. /**
  72520. * The metallic-roughness texture
  72521. */
  72522. metallicRoughnessTexture?: ITextureInfo;
  72523. }
  72524. /**
  72525. * The material appearance of a primitive
  72526. */
  72527. interface IMaterial extends IChildRootProperty {
  72528. /**
  72529. * 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
  72530. */
  72531. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  72532. /**
  72533. * The normal map texture
  72534. */
  72535. normalTexture?: IMaterialNormalTextureInfo;
  72536. /**
  72537. * The occlusion map texture
  72538. */
  72539. occlusionTexture?: IMaterialOcclusionTextureInfo;
  72540. /**
  72541. * The emissive map texture
  72542. */
  72543. emissiveTexture?: ITextureInfo;
  72544. /**
  72545. * 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
  72546. */
  72547. emissiveFactor?: number[];
  72548. /**
  72549. * The alpha rendering mode of the material
  72550. */
  72551. alphaMode?: MaterialAlphaMode;
  72552. /**
  72553. * The alpha cutoff value of the material
  72554. */
  72555. alphaCutoff?: number;
  72556. /**
  72557. * Specifies whether the material is double sided
  72558. */
  72559. doubleSided?: boolean;
  72560. }
  72561. /**
  72562. * Geometry to be rendered with the given material
  72563. */
  72564. interface IMeshPrimitive extends IProperty {
  72565. /**
  72566. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  72567. */
  72568. attributes: {
  72569. [name: string]: number;
  72570. };
  72571. /**
  72572. * The index of the accessor that contains the indices
  72573. */
  72574. indices?: number;
  72575. /**
  72576. * The index of the material to apply to this primitive when rendering
  72577. */
  72578. material?: number;
  72579. /**
  72580. * The type of primitives to render. All valid values correspond to WebGL enums
  72581. */
  72582. mode?: MeshPrimitiveMode;
  72583. /**
  72584. * 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
  72585. */
  72586. targets?: {
  72587. [name: string]: number;
  72588. }[];
  72589. }
  72590. /**
  72591. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  72592. */
  72593. interface IMesh extends IChildRootProperty {
  72594. /**
  72595. * An array of primitives, each defining geometry to be rendered with a material
  72596. */
  72597. primitives: IMeshPrimitive[];
  72598. /**
  72599. * Array of weights to be applied to the Morph Targets
  72600. */
  72601. weights?: number[];
  72602. }
  72603. /**
  72604. * A node in the node hierarchy
  72605. */
  72606. interface INode extends IChildRootProperty {
  72607. /**
  72608. * The index of the camera referenced by this node
  72609. */
  72610. camera?: number;
  72611. /**
  72612. * The indices of this node's children
  72613. */
  72614. children?: number[];
  72615. /**
  72616. * The index of the skin referenced by this node
  72617. */
  72618. skin?: number;
  72619. /**
  72620. * A floating-point 4x4 transformation matrix stored in column-major order
  72621. */
  72622. matrix?: number[];
  72623. /**
  72624. * The index of the mesh in this node
  72625. */
  72626. mesh?: number;
  72627. /**
  72628. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72629. */
  72630. rotation?: number[];
  72631. /**
  72632. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72633. */
  72634. scale?: number[];
  72635. /**
  72636. * The node's translation along the x, y, and z axes
  72637. */
  72638. translation?: number[];
  72639. /**
  72640. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72641. */
  72642. weights?: number[];
  72643. }
  72644. /**
  72645. * Texture sampler properties for filtering and wrapping modes
  72646. */
  72647. interface ISampler extends IChildRootProperty {
  72648. /**
  72649. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72650. */
  72651. magFilter?: TextureMagFilter;
  72652. /**
  72653. * Minification filter. All valid values correspond to WebGL enums
  72654. */
  72655. minFilter?: TextureMinFilter;
  72656. /**
  72657. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72658. */
  72659. wrapS?: TextureWrapMode;
  72660. /**
  72661. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72662. */
  72663. wrapT?: TextureWrapMode;
  72664. }
  72665. /**
  72666. * The root nodes of a scene
  72667. */
  72668. interface IScene extends IChildRootProperty {
  72669. /**
  72670. * The indices of each root node
  72671. */
  72672. nodes: number[];
  72673. }
  72674. /**
  72675. * Joints and matrices defining a skin
  72676. */
  72677. interface ISkin extends IChildRootProperty {
  72678. /**
  72679. * 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
  72680. */
  72681. inverseBindMatrices?: number;
  72682. /**
  72683. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72684. */
  72685. skeleton?: number;
  72686. /**
  72687. * 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)
  72688. */
  72689. joints: number[];
  72690. }
  72691. /**
  72692. * A texture and its sampler
  72693. */
  72694. interface ITexture extends IChildRootProperty {
  72695. /**
  72696. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72697. */
  72698. sampler?: number;
  72699. /**
  72700. * The index of the image used by this texture
  72701. */
  72702. source: number;
  72703. }
  72704. /**
  72705. * Reference to a texture
  72706. */
  72707. interface ITextureInfo extends IProperty {
  72708. /**
  72709. * The index of the texture
  72710. */
  72711. index: number;
  72712. /**
  72713. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72714. */
  72715. texCoord?: number;
  72716. }
  72717. /**
  72718. * The root object for a glTF asset
  72719. */
  72720. interface IGLTF extends IProperty {
  72721. /**
  72722. * An array of accessors. An accessor is a typed view into a bufferView
  72723. */
  72724. accessors?: IAccessor[];
  72725. /**
  72726. * An array of keyframe animations
  72727. */
  72728. animations?: IAnimation[];
  72729. /**
  72730. * Metadata about the glTF asset
  72731. */
  72732. asset: IAsset;
  72733. /**
  72734. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72735. */
  72736. buffers?: IBuffer[];
  72737. /**
  72738. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72739. */
  72740. bufferViews?: IBufferView[];
  72741. /**
  72742. * An array of cameras
  72743. */
  72744. cameras?: ICamera[];
  72745. /**
  72746. * Names of glTF extensions used somewhere in this asset
  72747. */
  72748. extensionsUsed?: string[];
  72749. /**
  72750. * Names of glTF extensions required to properly load this asset
  72751. */
  72752. extensionsRequired?: string[];
  72753. /**
  72754. * An array of images. An image defines data used to create a texture
  72755. */
  72756. images?: IImage[];
  72757. /**
  72758. * An array of materials. A material defines the appearance of a primitive
  72759. */
  72760. materials?: IMaterial[];
  72761. /**
  72762. * An array of meshes. A mesh is a set of primitives to be rendered
  72763. */
  72764. meshes?: IMesh[];
  72765. /**
  72766. * An array of nodes
  72767. */
  72768. nodes?: INode[];
  72769. /**
  72770. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72771. */
  72772. samplers?: ISampler[];
  72773. /**
  72774. * The index of the default scene
  72775. */
  72776. scene?: number;
  72777. /**
  72778. * An array of scenes
  72779. */
  72780. scenes?: IScene[];
  72781. /**
  72782. * An array of skins. A skin is defined by joints and matrices
  72783. */
  72784. skins?: ISkin[];
  72785. /**
  72786. * An array of textures
  72787. */
  72788. textures?: ITexture[];
  72789. }
  72790. /**
  72791. * The glTF validation results
  72792. * @ignore
  72793. */
  72794. interface IGLTFValidationResults {
  72795. info: {
  72796. generator: string;
  72797. hasAnimations: boolean;
  72798. hasDefaultScene: boolean;
  72799. hasMaterials: boolean;
  72800. hasMorphTargets: boolean;
  72801. hasSkins: boolean;
  72802. hasTextures: boolean;
  72803. maxAttributesUsed: number;
  72804. primitivesCount: number
  72805. };
  72806. issues: {
  72807. messages: Array<string>;
  72808. numErrors: number;
  72809. numHints: number;
  72810. numInfos: number;
  72811. numWarnings: number;
  72812. truncated: boolean
  72813. };
  72814. mimeType: string;
  72815. uri: string;
  72816. validatedAt: string;
  72817. validatorVersion: string;
  72818. }
  72819. /**
  72820. * The glTF validation options
  72821. */
  72822. interface IGLTFValidationOptions {
  72823. /** Uri to use */
  72824. uri?: string;
  72825. /** Function used to load external resources */
  72826. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72827. /** Boolean indicating that we need to validate accessor data */
  72828. validateAccessorData?: boolean;
  72829. /** max number of issues allowed */
  72830. maxIssues?: number;
  72831. /** Ignored issues */
  72832. ignoredIssues?: Array<string>;
  72833. /** Value to override severy settings */
  72834. severityOverrides?: Object;
  72835. }
  72836. /**
  72837. * The glTF validator object
  72838. * @ignore
  72839. */
  72840. interface IGLTFValidator {
  72841. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72842. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72843. }
  72844. }
  72845. declare module BABYLON {
  72846. /** @hidden */
  72847. export var cellPixelShader: {
  72848. name: string;
  72849. shader: string;
  72850. };
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export var cellVertexShader: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module BABYLON {
  72860. export class CellMaterial extends BABYLON.PushMaterial {
  72861. private _diffuseTexture;
  72862. diffuseTexture: BABYLON.BaseTexture;
  72863. diffuseColor: BABYLON.Color3;
  72864. _computeHighLevel: boolean;
  72865. computeHighLevel: boolean;
  72866. private _disableLighting;
  72867. disableLighting: boolean;
  72868. private _maxSimultaneousLights;
  72869. maxSimultaneousLights: number;
  72870. private _renderId;
  72871. constructor(name: string, scene: BABYLON.Scene);
  72872. needAlphaBlending(): boolean;
  72873. needAlphaTesting(): boolean;
  72874. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72875. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72876. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72877. getAnimatables(): BABYLON.IAnimatable[];
  72878. getActiveTextures(): BABYLON.BaseTexture[];
  72879. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72880. dispose(forceDisposeEffect?: boolean): void;
  72881. getClassName(): string;
  72882. clone(name: string): CellMaterial;
  72883. serialize(): any;
  72884. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72885. }
  72886. }
  72887. declare module BABYLON {
  72888. export class CustomShaderStructure {
  72889. FragmentStore: string;
  72890. VertexStore: string;
  72891. constructor();
  72892. }
  72893. export class ShaderSpecialParts {
  72894. constructor();
  72895. Fragment_Begin: string;
  72896. Fragment_Definitions: string;
  72897. Fragment_MainBegin: string;
  72898. Fragment_Custom_Diffuse: string;
  72899. Fragment_Before_Lights: string;
  72900. Fragment_Before_Fog: string;
  72901. Fragment_Custom_Alpha: string;
  72902. Fragment_Before_FragColor: string;
  72903. Vertex_Begin: string;
  72904. Vertex_Definitions: string;
  72905. Vertex_MainBegin: string;
  72906. Vertex_Before_PositionUpdated: string;
  72907. Vertex_Before_NormalUpdated: string;
  72908. Vertex_MainEnd: string;
  72909. }
  72910. export class CustomMaterial extends BABYLON.StandardMaterial {
  72911. static ShaderIndexer: number;
  72912. CustomParts: ShaderSpecialParts;
  72913. _isCreatedShader: boolean;
  72914. _createdShaderName: string;
  72915. _customUniform: string[];
  72916. _newUniforms: string[];
  72917. _newUniformInstances: any[];
  72918. _newSamplerInstances: BABYLON.Texture[];
  72919. FragmentShader: string;
  72920. VertexShader: string;
  72921. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72922. ReviewUniform(name: string, arr: string[]): string[];
  72923. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72924. constructor(name: string, scene: BABYLON.Scene);
  72925. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72926. Fragment_Begin(shaderPart: string): CustomMaterial;
  72927. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72928. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72929. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72930. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72931. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72932. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72933. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72934. Vertex_Begin(shaderPart: string): CustomMaterial;
  72935. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72936. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72937. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72938. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72939. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72940. }
  72941. }
  72942. declare module BABYLON {
  72943. export class ShaderAlebdoParts {
  72944. constructor();
  72945. Fragment_Begin: string;
  72946. Fragment_Definitions: string;
  72947. Fragment_MainBegin: string;
  72948. Fragment_Custom_Albedo: string;
  72949. Fragment_Before_Lights: string;
  72950. Fragment_Custom_MetallicRoughness: string;
  72951. Fragment_Custom_MicroSurface: string;
  72952. Fragment_Before_Fog: string;
  72953. Fragment_Custom_Alpha: string;
  72954. Fragment_Before_FragColor: string;
  72955. Vertex_Begin: string;
  72956. Vertex_Definitions: string;
  72957. Vertex_MainBegin: string;
  72958. Vertex_Before_PositionUpdated: string;
  72959. Vertex_Before_NormalUpdated: string;
  72960. Vertex_MainEnd: string;
  72961. }
  72962. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72963. static ShaderIndexer: number;
  72964. CustomParts: ShaderAlebdoParts;
  72965. _isCreatedShader: boolean;
  72966. _createdShaderName: string;
  72967. _customUniform: string[];
  72968. _newUniforms: string[];
  72969. _newUniformInstances: any[];
  72970. _newSamplerInstances: BABYLON.Texture[];
  72971. FragmentShader: string;
  72972. VertexShader: string;
  72973. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72974. ReviewUniform(name: string, arr: string[]): string[];
  72975. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72976. constructor(name: string, scene: BABYLON.Scene);
  72977. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72978. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72979. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72980. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72981. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72982. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72983. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72984. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72985. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72986. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72987. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72988. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72989. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72990. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72991. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72992. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72993. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72994. }
  72995. }
  72996. declare module BABYLON {
  72997. /** @hidden */
  72998. export var firePixelShader: {
  72999. name: string;
  73000. shader: string;
  73001. };
  73002. }
  73003. declare module BABYLON {
  73004. /** @hidden */
  73005. export var fireVertexShader: {
  73006. name: string;
  73007. shader: string;
  73008. };
  73009. }
  73010. declare module BABYLON {
  73011. export class FireMaterial extends BABYLON.PushMaterial {
  73012. private _diffuseTexture;
  73013. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73014. private _distortionTexture;
  73015. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73016. private _opacityTexture;
  73017. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73018. diffuseColor: BABYLON.Color3;
  73019. speed: number;
  73020. private _scaledDiffuse;
  73021. private _renderId;
  73022. private _lastTime;
  73023. constructor(name: string, scene: BABYLON.Scene);
  73024. needAlphaBlending(): boolean;
  73025. needAlphaTesting(): boolean;
  73026. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73027. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73028. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73029. getAnimatables(): BABYLON.IAnimatable[];
  73030. getActiveTextures(): BABYLON.BaseTexture[];
  73031. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73032. getClassName(): string;
  73033. dispose(forceDisposeEffect?: boolean): void;
  73034. clone(name: string): FireMaterial;
  73035. serialize(): any;
  73036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /** @hidden */
  73041. export var furPixelShader: {
  73042. name: string;
  73043. shader: string;
  73044. };
  73045. }
  73046. declare module BABYLON {
  73047. /** @hidden */
  73048. export var furVertexShader: {
  73049. name: string;
  73050. shader: string;
  73051. };
  73052. }
  73053. declare module BABYLON {
  73054. export class FurMaterial extends BABYLON.PushMaterial {
  73055. private _diffuseTexture;
  73056. diffuseTexture: BABYLON.BaseTexture;
  73057. private _heightTexture;
  73058. heightTexture: BABYLON.BaseTexture;
  73059. diffuseColor: BABYLON.Color3;
  73060. furLength: number;
  73061. furAngle: number;
  73062. furColor: BABYLON.Color3;
  73063. furOffset: number;
  73064. furSpacing: number;
  73065. furGravity: BABYLON.Vector3;
  73066. furSpeed: number;
  73067. furDensity: number;
  73068. furOcclusion: number;
  73069. furTexture: BABYLON.DynamicTexture;
  73070. private _disableLighting;
  73071. disableLighting: boolean;
  73072. private _maxSimultaneousLights;
  73073. maxSimultaneousLights: number;
  73074. highLevelFur: boolean;
  73075. _meshes: BABYLON.AbstractMesh[];
  73076. private _renderId;
  73077. private _furTime;
  73078. constructor(name: string, scene: BABYLON.Scene);
  73079. furTime: number;
  73080. needAlphaBlending(): boolean;
  73081. needAlphaTesting(): boolean;
  73082. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73083. updateFur(): void;
  73084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73086. getAnimatables(): BABYLON.IAnimatable[];
  73087. getActiveTextures(): BABYLON.BaseTexture[];
  73088. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73089. dispose(forceDisposeEffect?: boolean): void;
  73090. clone(name: string): FurMaterial;
  73091. serialize(): any;
  73092. getClassName(): string;
  73093. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  73094. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  73095. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  73096. }
  73097. }
  73098. declare module BABYLON {
  73099. /** @hidden */
  73100. export var gradientPixelShader: {
  73101. name: string;
  73102. shader: string;
  73103. };
  73104. }
  73105. declare module BABYLON {
  73106. /** @hidden */
  73107. export var gradientVertexShader: {
  73108. name: string;
  73109. shader: string;
  73110. };
  73111. }
  73112. declare module BABYLON {
  73113. export class GradientMaterial extends BABYLON.PushMaterial {
  73114. private _maxSimultaneousLights;
  73115. maxSimultaneousLights: number;
  73116. topColor: BABYLON.Color3;
  73117. topColorAlpha: number;
  73118. bottomColor: BABYLON.Color3;
  73119. bottomColorAlpha: number;
  73120. offset: number;
  73121. scale: number;
  73122. smoothness: number;
  73123. private _disableLighting;
  73124. disableLighting: boolean;
  73125. private _renderId;
  73126. constructor(name: string, scene: BABYLON.Scene);
  73127. needAlphaBlending(): boolean;
  73128. needAlphaTesting(): boolean;
  73129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73132. getAnimatables(): BABYLON.IAnimatable[];
  73133. dispose(forceDisposeEffect?: boolean): void;
  73134. clone(name: string): GradientMaterial;
  73135. serialize(): any;
  73136. getClassName(): string;
  73137. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  73138. }
  73139. }
  73140. declare module BABYLON {
  73141. /** @hidden */
  73142. export var gridPixelShader: {
  73143. name: string;
  73144. shader: string;
  73145. };
  73146. }
  73147. declare module BABYLON {
  73148. /** @hidden */
  73149. export var gridVertexShader: {
  73150. name: string;
  73151. shader: string;
  73152. };
  73153. }
  73154. declare module BABYLON {
  73155. /**
  73156. * The grid materials allows you to wrap any shape with a grid.
  73157. * Colors are customizable.
  73158. */
  73159. export class GridMaterial extends BABYLON.PushMaterial {
  73160. /**
  73161. * Main color of the grid (e.g. between lines)
  73162. */
  73163. mainColor: BABYLON.Color3;
  73164. /**
  73165. * Color of the grid lines.
  73166. */
  73167. lineColor: BABYLON.Color3;
  73168. /**
  73169. * The scale of the grid compared to unit.
  73170. */
  73171. gridRatio: number;
  73172. /**
  73173. * Allows setting an offset for the grid lines.
  73174. */
  73175. gridOffset: BABYLON.Vector3;
  73176. /**
  73177. * The frequency of thicker lines.
  73178. */
  73179. majorUnitFrequency: number;
  73180. /**
  73181. * The visibility of minor units in the grid.
  73182. */
  73183. minorUnitVisibility: number;
  73184. /**
  73185. * The grid opacity outside of the lines.
  73186. */
  73187. opacity: number;
  73188. /**
  73189. * Determine RBG output is premultiplied by alpha value.
  73190. */
  73191. preMultiplyAlpha: boolean;
  73192. private _opacityTexture;
  73193. opacityTexture: BABYLON.BaseTexture;
  73194. private _gridControl;
  73195. private _renderId;
  73196. /**
  73197. * constructor
  73198. * @param name The name given to the material in order to identify it afterwards.
  73199. * @param scene The scene the material is used in.
  73200. */
  73201. constructor(name: string, scene: BABYLON.Scene);
  73202. /**
  73203. * Returns wehter or not the grid requires alpha blending.
  73204. */
  73205. needAlphaBlending(): boolean;
  73206. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73207. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73208. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73209. /**
  73210. * Dispose the material and its associated resources.
  73211. * @param forceDisposeEffect will also dispose the used effect when true
  73212. */
  73213. dispose(forceDisposeEffect?: boolean): void;
  73214. clone(name: string): GridMaterial;
  73215. serialize(): any;
  73216. getClassName(): string;
  73217. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  73218. }
  73219. }
  73220. declare module BABYLON {
  73221. /** @hidden */
  73222. export var lavaPixelShader: {
  73223. name: string;
  73224. shader: string;
  73225. };
  73226. }
  73227. declare module BABYLON {
  73228. /** @hidden */
  73229. export var lavaVertexShader: {
  73230. name: string;
  73231. shader: string;
  73232. };
  73233. }
  73234. declare module BABYLON {
  73235. export class LavaMaterial extends BABYLON.PushMaterial {
  73236. private _diffuseTexture;
  73237. diffuseTexture: BABYLON.BaseTexture;
  73238. noiseTexture: BABYLON.BaseTexture;
  73239. fogColor: BABYLON.Color3;
  73240. speed: number;
  73241. movingSpeed: number;
  73242. lowFrequencySpeed: number;
  73243. fogDensity: number;
  73244. private _lastTime;
  73245. diffuseColor: BABYLON.Color3;
  73246. private _disableLighting;
  73247. disableLighting: boolean;
  73248. private _unlit;
  73249. unlit: boolean;
  73250. private _maxSimultaneousLights;
  73251. maxSimultaneousLights: number;
  73252. private _scaledDiffuse;
  73253. private _renderId;
  73254. constructor(name: string, scene: BABYLON.Scene);
  73255. needAlphaBlending(): boolean;
  73256. needAlphaTesting(): boolean;
  73257. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73258. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73259. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73260. getAnimatables(): BABYLON.IAnimatable[];
  73261. getActiveTextures(): BABYLON.BaseTexture[];
  73262. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73263. dispose(forceDisposeEffect?: boolean): void;
  73264. clone(name: string): LavaMaterial;
  73265. serialize(): any;
  73266. getClassName(): string;
  73267. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /** @hidden */
  73272. export var mixPixelShader: {
  73273. name: string;
  73274. shader: string;
  73275. };
  73276. }
  73277. declare module BABYLON {
  73278. /** @hidden */
  73279. export var mixVertexShader: {
  73280. name: string;
  73281. shader: string;
  73282. };
  73283. }
  73284. declare module BABYLON {
  73285. export class MixMaterial extends BABYLON.PushMaterial {
  73286. /**
  73287. * Mix textures
  73288. */
  73289. private _mixTexture1;
  73290. mixTexture1: BABYLON.BaseTexture;
  73291. private _mixTexture2;
  73292. mixTexture2: BABYLON.BaseTexture;
  73293. /**
  73294. * Diffuse textures
  73295. */
  73296. private _diffuseTexture1;
  73297. diffuseTexture1: BABYLON.Texture;
  73298. private _diffuseTexture2;
  73299. diffuseTexture2: BABYLON.Texture;
  73300. private _diffuseTexture3;
  73301. diffuseTexture3: BABYLON.Texture;
  73302. private _diffuseTexture4;
  73303. diffuseTexture4: BABYLON.Texture;
  73304. private _diffuseTexture5;
  73305. diffuseTexture5: BABYLON.Texture;
  73306. private _diffuseTexture6;
  73307. diffuseTexture6: BABYLON.Texture;
  73308. private _diffuseTexture7;
  73309. diffuseTexture7: BABYLON.Texture;
  73310. private _diffuseTexture8;
  73311. diffuseTexture8: BABYLON.Texture;
  73312. /**
  73313. * Uniforms
  73314. */
  73315. diffuseColor: BABYLON.Color3;
  73316. specularColor: BABYLON.Color3;
  73317. specularPower: number;
  73318. private _disableLighting;
  73319. disableLighting: boolean;
  73320. private _maxSimultaneousLights;
  73321. maxSimultaneousLights: number;
  73322. private _renderId;
  73323. constructor(name: string, scene: BABYLON.Scene);
  73324. needAlphaBlending(): boolean;
  73325. needAlphaTesting(): boolean;
  73326. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73327. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73328. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73329. getAnimatables(): BABYLON.IAnimatable[];
  73330. getActiveTextures(): BABYLON.BaseTexture[];
  73331. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73332. dispose(forceDisposeEffect?: boolean): void;
  73333. clone(name: string): MixMaterial;
  73334. serialize(): any;
  73335. getClassName(): string;
  73336. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  73337. }
  73338. }
  73339. declare module BABYLON {
  73340. /** @hidden */
  73341. export var normalPixelShader: {
  73342. name: string;
  73343. shader: string;
  73344. };
  73345. }
  73346. declare module BABYLON {
  73347. /** @hidden */
  73348. export var normalVertexShader: {
  73349. name: string;
  73350. shader: string;
  73351. };
  73352. }
  73353. declare module BABYLON {
  73354. export class NormalMaterial extends BABYLON.PushMaterial {
  73355. private _diffuseTexture;
  73356. diffuseTexture: BABYLON.BaseTexture;
  73357. diffuseColor: BABYLON.Color3;
  73358. private _disableLighting;
  73359. disableLighting: boolean;
  73360. private _maxSimultaneousLights;
  73361. maxSimultaneousLights: number;
  73362. private _renderId;
  73363. constructor(name: string, scene: BABYLON.Scene);
  73364. needAlphaBlending(): boolean;
  73365. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  73366. needAlphaTesting(): boolean;
  73367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73370. getAnimatables(): BABYLON.IAnimatable[];
  73371. getActiveTextures(): BABYLON.BaseTexture[];
  73372. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73373. dispose(forceDisposeEffect?: boolean): void;
  73374. clone(name: string): NormalMaterial;
  73375. serialize(): any;
  73376. getClassName(): string;
  73377. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  73378. }
  73379. }
  73380. declare module BABYLON {
  73381. /** @hidden */
  73382. export var shadowOnlyPixelShader: {
  73383. name: string;
  73384. shader: string;
  73385. };
  73386. }
  73387. declare module BABYLON {
  73388. /** @hidden */
  73389. export var shadowOnlyVertexShader: {
  73390. name: string;
  73391. shader: string;
  73392. };
  73393. }
  73394. declare module BABYLON {
  73395. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  73396. private _renderId;
  73397. private _activeLight;
  73398. constructor(name: string, scene: BABYLON.Scene);
  73399. shadowColor: BABYLON.Color3;
  73400. needAlphaBlending(): boolean;
  73401. needAlphaTesting(): boolean;
  73402. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73403. activeLight: BABYLON.IShadowLight;
  73404. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73405. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73406. clone(name: string): ShadowOnlyMaterial;
  73407. serialize(): any;
  73408. getClassName(): string;
  73409. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  73410. }
  73411. }
  73412. declare module BABYLON {
  73413. /** @hidden */
  73414. export var simplePixelShader: {
  73415. name: string;
  73416. shader: string;
  73417. };
  73418. }
  73419. declare module BABYLON {
  73420. /** @hidden */
  73421. export var simpleVertexShader: {
  73422. name: string;
  73423. shader: string;
  73424. };
  73425. }
  73426. declare module BABYLON {
  73427. export class SimpleMaterial extends BABYLON.PushMaterial {
  73428. private _diffuseTexture;
  73429. diffuseTexture: BABYLON.BaseTexture;
  73430. diffuseColor: BABYLON.Color3;
  73431. private _disableLighting;
  73432. disableLighting: boolean;
  73433. private _maxSimultaneousLights;
  73434. maxSimultaneousLights: number;
  73435. private _renderId;
  73436. constructor(name: string, scene: BABYLON.Scene);
  73437. needAlphaBlending(): boolean;
  73438. needAlphaTesting(): boolean;
  73439. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73440. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73442. getAnimatables(): BABYLON.IAnimatable[];
  73443. getActiveTextures(): BABYLON.BaseTexture[];
  73444. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73445. dispose(forceDisposeEffect?: boolean): void;
  73446. clone(name: string): SimpleMaterial;
  73447. serialize(): any;
  73448. getClassName(): string;
  73449. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  73450. }
  73451. }
  73452. declare module BABYLON {
  73453. /** @hidden */
  73454. export var skyPixelShader: {
  73455. name: string;
  73456. shader: string;
  73457. };
  73458. }
  73459. declare module BABYLON {
  73460. /** @hidden */
  73461. export var skyVertexShader: {
  73462. name: string;
  73463. shader: string;
  73464. };
  73465. }
  73466. declare module BABYLON {
  73467. /**
  73468. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  73469. * @see https://doc.babylonjs.com/extensions/sky
  73470. */
  73471. export class SkyMaterial extends BABYLON.PushMaterial {
  73472. /**
  73473. * Defines the overall luminance of sky in interval ]0, 1[.
  73474. */
  73475. luminance: number;
  73476. /**
  73477. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  73478. */
  73479. turbidity: number;
  73480. /**
  73481. * Defines the sky appearance (light intensity).
  73482. */
  73483. rayleigh: number;
  73484. /**
  73485. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  73486. */
  73487. mieCoefficient: number;
  73488. /**
  73489. * Defines the amount of haze particles following the Mie scattering theory.
  73490. */
  73491. mieDirectionalG: number;
  73492. /**
  73493. * Defines the distance of the sun according to the active scene camera.
  73494. */
  73495. distance: number;
  73496. /**
  73497. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  73498. * "inclined".
  73499. */
  73500. inclination: number;
  73501. /**
  73502. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  73503. * an object direction and a reference direction.
  73504. */
  73505. azimuth: number;
  73506. /**
  73507. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  73508. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  73509. */
  73510. sunPosition: BABYLON.Vector3;
  73511. /**
  73512. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  73513. * .sunPosition property.
  73514. */
  73515. useSunPosition: boolean;
  73516. /**
  73517. * Defines an offset vector used to get a horizon offset.
  73518. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  73519. */
  73520. cameraOffset: BABYLON.Vector3;
  73521. private _cameraPosition;
  73522. private _renderId;
  73523. /**
  73524. * Instantiates a new sky material.
  73525. * This material allows to create dynamic and texture free
  73526. * effects for skyboxes by taking care of the atmosphere state.
  73527. * @see https://doc.babylonjs.com/extensions/sky
  73528. * @param name Define the name of the material in the scene
  73529. * @param scene Define the scene the material belong to
  73530. */
  73531. constructor(name: string, scene: BABYLON.Scene);
  73532. /**
  73533. * Specifies if the material will require alpha blending
  73534. * @returns a boolean specifying if alpha blending is needed
  73535. */
  73536. needAlphaBlending(): boolean;
  73537. /**
  73538. * Specifies if this material should be rendered in alpha test mode
  73539. * @returns false as the sky material doesn't need alpha testing.
  73540. */
  73541. needAlphaTesting(): boolean;
  73542. /**
  73543. * Get the texture used for alpha test purpose.
  73544. * @returns null as the sky material has no texture.
  73545. */
  73546. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73547. /**
  73548. * Get if the submesh is ready to be used and all its information available.
  73549. * Child classes can use it to update shaders
  73550. * @param mesh defines the mesh to check
  73551. * @param subMesh defines which submesh to check
  73552. * @param useInstances specifies that instances should be used
  73553. * @returns a boolean indicating that the submesh is ready or not
  73554. */
  73555. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73556. /**
  73557. * Binds the submesh to this material by preparing the effect and shader to draw
  73558. * @param world defines the world transformation matrix
  73559. * @param mesh defines the mesh containing the submesh
  73560. * @param subMesh defines the submesh to bind the material to
  73561. */
  73562. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73563. /**
  73564. * Get the list of animatables in the material.
  73565. * @returns the list of animatables object used in the material
  73566. */
  73567. getAnimatables(): BABYLON.IAnimatable[];
  73568. /**
  73569. * Disposes the material
  73570. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73571. */
  73572. dispose(forceDisposeEffect?: boolean): void;
  73573. /**
  73574. * Makes a duplicate of the material, and gives it a new name
  73575. * @param name defines the new name for the duplicated material
  73576. * @returns the cloned material
  73577. */
  73578. clone(name: string): SkyMaterial;
  73579. /**
  73580. * Serializes this material in a JSON representation
  73581. * @returns the serialized material object
  73582. */
  73583. serialize(): any;
  73584. /**
  73585. * Gets the current class name of the material e.g. "SkyMaterial"
  73586. * Mainly use in serialization.
  73587. * @returns the class name
  73588. */
  73589. getClassName(): string;
  73590. /**
  73591. * Creates a sky material from parsed material data
  73592. * @param source defines the JSON representation of the material
  73593. * @param scene defines the hosting scene
  73594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73595. * @returns a new sky material
  73596. */
  73597. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73598. }
  73599. }
  73600. declare module BABYLON {
  73601. /** @hidden */
  73602. export var terrainPixelShader: {
  73603. name: string;
  73604. shader: string;
  73605. };
  73606. }
  73607. declare module BABYLON {
  73608. /** @hidden */
  73609. export var terrainVertexShader: {
  73610. name: string;
  73611. shader: string;
  73612. };
  73613. }
  73614. declare module BABYLON {
  73615. export class TerrainMaterial extends BABYLON.PushMaterial {
  73616. private _mixTexture;
  73617. mixTexture: BABYLON.BaseTexture;
  73618. private _diffuseTexture1;
  73619. diffuseTexture1: BABYLON.Texture;
  73620. private _diffuseTexture2;
  73621. diffuseTexture2: BABYLON.Texture;
  73622. private _diffuseTexture3;
  73623. diffuseTexture3: BABYLON.Texture;
  73624. private _bumpTexture1;
  73625. bumpTexture1: BABYLON.Texture;
  73626. private _bumpTexture2;
  73627. bumpTexture2: BABYLON.Texture;
  73628. private _bumpTexture3;
  73629. bumpTexture3: BABYLON.Texture;
  73630. diffuseColor: BABYLON.Color3;
  73631. specularColor: BABYLON.Color3;
  73632. specularPower: number;
  73633. private _disableLighting;
  73634. disableLighting: boolean;
  73635. private _maxSimultaneousLights;
  73636. maxSimultaneousLights: number;
  73637. private _renderId;
  73638. constructor(name: string, scene: BABYLON.Scene);
  73639. needAlphaBlending(): boolean;
  73640. needAlphaTesting(): boolean;
  73641. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73642. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73643. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73644. getAnimatables(): BABYLON.IAnimatable[];
  73645. getActiveTextures(): BABYLON.BaseTexture[];
  73646. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73647. dispose(forceDisposeEffect?: boolean): void;
  73648. clone(name: string): TerrainMaterial;
  73649. serialize(): any;
  73650. getClassName(): string;
  73651. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73652. }
  73653. }
  73654. declare module BABYLON {
  73655. /** @hidden */
  73656. export var triplanarPixelShader: {
  73657. name: string;
  73658. shader: string;
  73659. };
  73660. }
  73661. declare module BABYLON {
  73662. /** @hidden */
  73663. export var triplanarVertexShader: {
  73664. name: string;
  73665. shader: string;
  73666. };
  73667. }
  73668. declare module BABYLON {
  73669. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73670. mixTexture: BABYLON.BaseTexture;
  73671. private _diffuseTextureX;
  73672. diffuseTextureX: BABYLON.BaseTexture;
  73673. private _diffuseTextureY;
  73674. diffuseTextureY: BABYLON.BaseTexture;
  73675. private _diffuseTextureZ;
  73676. diffuseTextureZ: BABYLON.BaseTexture;
  73677. private _normalTextureX;
  73678. normalTextureX: BABYLON.BaseTexture;
  73679. private _normalTextureY;
  73680. normalTextureY: BABYLON.BaseTexture;
  73681. private _normalTextureZ;
  73682. normalTextureZ: BABYLON.BaseTexture;
  73683. tileSize: number;
  73684. diffuseColor: BABYLON.Color3;
  73685. specularColor: BABYLON.Color3;
  73686. specularPower: number;
  73687. private _disableLighting;
  73688. disableLighting: boolean;
  73689. private _maxSimultaneousLights;
  73690. maxSimultaneousLights: number;
  73691. private _renderId;
  73692. constructor(name: string, scene: BABYLON.Scene);
  73693. needAlphaBlending(): boolean;
  73694. needAlphaTesting(): boolean;
  73695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73698. getAnimatables(): BABYLON.IAnimatable[];
  73699. getActiveTextures(): BABYLON.BaseTexture[];
  73700. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73701. dispose(forceDisposeEffect?: boolean): void;
  73702. clone(name: string): TriPlanarMaterial;
  73703. serialize(): any;
  73704. getClassName(): string;
  73705. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73706. }
  73707. }
  73708. declare module BABYLON {
  73709. /** @hidden */
  73710. export var waterPixelShader: {
  73711. name: string;
  73712. shader: string;
  73713. };
  73714. }
  73715. declare module BABYLON {
  73716. /** @hidden */
  73717. export var waterVertexShader: {
  73718. name: string;
  73719. shader: string;
  73720. };
  73721. }
  73722. declare module BABYLON {
  73723. export class WaterMaterial extends BABYLON.PushMaterial {
  73724. renderTargetSize: BABYLON.Vector2;
  73725. private _bumpTexture;
  73726. bumpTexture: BABYLON.BaseTexture;
  73727. diffuseColor: BABYLON.Color3;
  73728. specularColor: BABYLON.Color3;
  73729. specularPower: number;
  73730. private _disableLighting;
  73731. disableLighting: boolean;
  73732. private _maxSimultaneousLights;
  73733. maxSimultaneousLights: number;
  73734. /**
  73735. * @param {number}: Represents the wind force
  73736. */
  73737. windForce: number;
  73738. /**
  73739. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73740. */
  73741. windDirection: BABYLON.Vector2;
  73742. /**
  73743. * @param {number}: Wave height, represents the height of the waves
  73744. */
  73745. waveHeight: number;
  73746. /**
  73747. * @param {number}: Bump height, represents the bump height related to the bump map
  73748. */
  73749. bumpHeight: number;
  73750. /**
  73751. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73752. */
  73753. private _bumpSuperimpose;
  73754. bumpSuperimpose: boolean;
  73755. /**
  73756. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73757. */
  73758. private _fresnelSeparate;
  73759. fresnelSeparate: boolean;
  73760. /**
  73761. * @param {boolean}: bump Waves modify the reflection.
  73762. */
  73763. private _bumpAffectsReflection;
  73764. bumpAffectsReflection: boolean;
  73765. /**
  73766. * @param {number}: The water color blended with the refraction (near)
  73767. */
  73768. waterColor: BABYLON.Color3;
  73769. /**
  73770. * @param {number}: The blend factor related to the water color
  73771. */
  73772. colorBlendFactor: number;
  73773. /**
  73774. * @param {number}: The water color blended with the reflection (far)
  73775. */
  73776. waterColor2: BABYLON.Color3;
  73777. /**
  73778. * @param {number}: The blend factor related to the water color (reflection, far)
  73779. */
  73780. colorBlendFactor2: number;
  73781. /**
  73782. * @param {number}: Represents the maximum length of a wave
  73783. */
  73784. waveLength: number;
  73785. /**
  73786. * @param {number}: Defines the waves speed
  73787. */
  73788. waveSpeed: number;
  73789. /**
  73790. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73791. * will avoid calculating useless pixels in the pixel shader of the water material.
  73792. */
  73793. disableClipPlane: boolean;
  73794. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73795. private _mesh;
  73796. private _refractionRTT;
  73797. private _reflectionRTT;
  73798. private _reflectionTransform;
  73799. private _lastTime;
  73800. private _lastDeltaTime;
  73801. private _renderId;
  73802. private _useLogarithmicDepth;
  73803. private _waitingRenderList;
  73804. private _imageProcessingConfiguration;
  73805. private _imageProcessingObserver;
  73806. /**
  73807. * Gets a boolean indicating that current material needs to register RTT
  73808. */
  73809. readonly hasRenderTargetTextures: boolean;
  73810. /**
  73811. * Constructor
  73812. */
  73813. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73814. useLogarithmicDepth: boolean;
  73815. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73816. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73817. addToRenderList(node: any): void;
  73818. enableRenderTargets(enable: boolean): void;
  73819. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73820. readonly renderTargetsEnabled: boolean;
  73821. needAlphaBlending(): boolean;
  73822. needAlphaTesting(): boolean;
  73823. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73824. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73825. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73826. private _createRenderTargets;
  73827. getAnimatables(): BABYLON.IAnimatable[];
  73828. getActiveTextures(): BABYLON.BaseTexture[];
  73829. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73830. dispose(forceDisposeEffect?: boolean): void;
  73831. clone(name: string): WaterMaterial;
  73832. serialize(): any;
  73833. getClassName(): string;
  73834. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73835. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73836. }
  73837. }
  73838. declare module BABYLON {
  73839. /** @hidden */
  73840. export var asciiartPixelShader: {
  73841. name: string;
  73842. shader: string;
  73843. };
  73844. }
  73845. declare module BABYLON {
  73846. /**
  73847. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73848. *
  73849. * It basically takes care rendering the font front the given font size to a texture.
  73850. * This is used later on in the postprocess.
  73851. */
  73852. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73853. private _font;
  73854. private _text;
  73855. private _charSize;
  73856. /**
  73857. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73858. */
  73859. readonly charSize: number;
  73860. /**
  73861. * Create a new instance of the Ascii Art FontTexture class
  73862. * @param name the name of the texture
  73863. * @param font the font to use, use the W3C CSS notation
  73864. * @param text the caracter set to use in the rendering.
  73865. * @param scene the scene that owns the texture
  73866. */
  73867. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73868. /**
  73869. * Gets the max char width of a font.
  73870. * @param font the font to use, use the W3C CSS notation
  73871. * @return the max char width
  73872. */
  73873. private getFontWidth;
  73874. /**
  73875. * Gets the max char height of a font.
  73876. * @param font the font to use, use the W3C CSS notation
  73877. * @return the max char height
  73878. */
  73879. private getFontHeight;
  73880. /**
  73881. * Clones the current AsciiArtTexture.
  73882. * @return the clone of the texture.
  73883. */
  73884. clone(): AsciiArtFontTexture;
  73885. /**
  73886. * Parses a json object representing the texture and returns an instance of it.
  73887. * @param source the source JSON representation
  73888. * @param scene the scene to create the texture for
  73889. * @return the parsed texture
  73890. */
  73891. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73892. }
  73893. /**
  73894. * Option available in the Ascii Art Post Process.
  73895. */
  73896. export interface IAsciiArtPostProcessOptions {
  73897. /**
  73898. * The font to use following the w3c font definition.
  73899. */
  73900. font?: string;
  73901. /**
  73902. * The character set to use in the postprocess.
  73903. */
  73904. characterSet?: string;
  73905. /**
  73906. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73907. * This number is defined between 0 and 1;
  73908. */
  73909. mixToTile?: number;
  73910. /**
  73911. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73912. * This number is defined between 0 and 1;
  73913. */
  73914. mixToNormal?: number;
  73915. }
  73916. /**
  73917. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73918. *
  73919. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73920. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73921. */
  73922. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73923. /**
  73924. * The font texture used to render the char in the post process.
  73925. */
  73926. private _asciiArtFontTexture;
  73927. /**
  73928. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73929. * This number is defined between 0 and 1;
  73930. */
  73931. mixToTile: number;
  73932. /**
  73933. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73934. * This number is defined between 0 and 1;
  73935. */
  73936. mixToNormal: number;
  73937. /**
  73938. * Instantiates a new Ascii Art Post Process.
  73939. * @param name the name to give to the postprocess
  73940. * @camera the camera to apply the post process to.
  73941. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73942. */
  73943. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /** @hidden */
  73948. export var digitalrainPixelShader: {
  73949. name: string;
  73950. shader: string;
  73951. };
  73952. }
  73953. declare module BABYLON {
  73954. /**
  73955. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73956. *
  73957. * It basically takes care rendering the font front the given font size to a texture.
  73958. * This is used later on in the postprocess.
  73959. */
  73960. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73961. private _font;
  73962. private _text;
  73963. private _charSize;
  73964. /**
  73965. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73966. */
  73967. readonly charSize: number;
  73968. /**
  73969. * Create a new instance of the Digital Rain FontTexture class
  73970. * @param name the name of the texture
  73971. * @param font the font to use, use the W3C CSS notation
  73972. * @param text the caracter set to use in the rendering.
  73973. * @param scene the scene that owns the texture
  73974. */
  73975. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73976. /**
  73977. * Gets the max char width of a font.
  73978. * @param font the font to use, use the W3C CSS notation
  73979. * @return the max char width
  73980. */
  73981. private getFontWidth;
  73982. /**
  73983. * Gets the max char height of a font.
  73984. * @param font the font to use, use the W3C CSS notation
  73985. * @return the max char height
  73986. */
  73987. private getFontHeight;
  73988. /**
  73989. * Clones the current DigitalRainFontTexture.
  73990. * @return the clone of the texture.
  73991. */
  73992. clone(): DigitalRainFontTexture;
  73993. /**
  73994. * Parses a json object representing the texture and returns an instance of it.
  73995. * @param source the source JSON representation
  73996. * @param scene the scene to create the texture for
  73997. * @return the parsed texture
  73998. */
  73999. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  74000. }
  74001. /**
  74002. * Option available in the Digital Rain Post Process.
  74003. */
  74004. export interface IDigitalRainPostProcessOptions {
  74005. /**
  74006. * The font to use following the w3c font definition.
  74007. */
  74008. font?: string;
  74009. /**
  74010. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74011. * This number is defined between 0 and 1;
  74012. */
  74013. mixToTile?: number;
  74014. /**
  74015. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74016. * This number is defined between 0 and 1;
  74017. */
  74018. mixToNormal?: number;
  74019. }
  74020. /**
  74021. * DigitalRainPostProcess helps rendering everithing in digital rain.
  74022. *
  74023. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74024. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  74025. */
  74026. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  74027. /**
  74028. * The font texture used to render the char in the post process.
  74029. */
  74030. private _digitalRainFontTexture;
  74031. /**
  74032. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  74033. * This number is defined between 0 and 1;
  74034. */
  74035. mixToTile: number;
  74036. /**
  74037. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  74038. * This number is defined between 0 and 1;
  74039. */
  74040. mixToNormal: number;
  74041. /**
  74042. * Instantiates a new Digital Rain Post Process.
  74043. * @param name the name to give to the postprocess
  74044. * @camera the camera to apply the post process to.
  74045. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  74046. */
  74047. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  74048. }
  74049. }
  74050. declare module BABYLON {
  74051. /** @hidden */
  74052. export var oceanPostProcessPixelShader: {
  74053. name: string;
  74054. shader: string;
  74055. };
  74056. }
  74057. declare module BABYLON {
  74058. /**
  74059. * Option available in the Ocean Post Process.
  74060. */
  74061. export interface IOceanPostProcessOptions {
  74062. /**
  74063. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74064. */
  74065. reflectionSize?: number | {
  74066. width: number;
  74067. height: number;
  74068. } | {
  74069. ratio: number;
  74070. };
  74071. /**
  74072. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  74073. */
  74074. refractionSize?: number | {
  74075. width: number;
  74076. height: number;
  74077. } | {
  74078. ratio: number;
  74079. };
  74080. }
  74081. /**
  74082. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  74083. *
  74084. * Simmply add it to your scene and let the nerd that lives in you have fun.
  74085. * Example usage:
  74086. * var pp = new OceanPostProcess("myOcean", camera);
  74087. * pp.reflectionEnabled = true;
  74088. * pp.refractionEnabled = true;
  74089. */
  74090. export class OceanPostProcess extends BABYLON.PostProcess {
  74091. /**
  74092. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  74093. */
  74094. /**
  74095. * Sets weither or not the real-time reflection is enabled on the ocean.
  74096. * Is set to true, the reflection mirror texture will be used as reflection texture.
  74097. */
  74098. reflectionEnabled: boolean;
  74099. /**
  74100. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  74101. */
  74102. /**
  74103. * Sets weither or not the real-time refraction is enabled on the ocean.
  74104. * Is set to true, the refraction render target texture will be used as refraction texture.
  74105. */
  74106. refractionEnabled: boolean;
  74107. /**
  74108. * Gets wether or not the post-processes is supported by the running hardware.
  74109. * This requires draw buffer supports.
  74110. */
  74111. readonly isSupported: boolean;
  74112. /**
  74113. * This is the reflection mirror texture used to display reflections on the ocean.
  74114. * By default, render list is empty.
  74115. */
  74116. reflectionTexture: BABYLON.MirrorTexture;
  74117. /**
  74118. * This is the refraction render target texture used to display refraction on the ocean.
  74119. * By default, render list is empty.
  74120. */
  74121. refractionTexture: BABYLON.RenderTargetTexture;
  74122. private _time;
  74123. private _cameraRotation;
  74124. private _cameraViewMatrix;
  74125. private _reflectionEnabled;
  74126. private _refractionEnabled;
  74127. private _geometryRenderer;
  74128. /**
  74129. * Instantiates a new Ocean Post Process.
  74130. * @param name the name to give to the postprocess.
  74131. * @camera the camera to apply the post process to.
  74132. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  74133. */
  74134. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  74135. /**
  74136. * Returns the appropriate defines according to the current configuration.
  74137. */
  74138. private _getDefines;
  74139. /**
  74140. * Computes the current camera rotation as the shader requires a camera rotation.
  74141. */
  74142. private _computeCameraRotation;
  74143. }
  74144. }
  74145. declare module BABYLON {
  74146. /** @hidden */
  74147. export var brickProceduralTexturePixelShader: {
  74148. name: string;
  74149. shader: string;
  74150. };
  74151. }
  74152. declare module BABYLON {
  74153. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  74154. private _numberOfBricksHeight;
  74155. private _numberOfBricksWidth;
  74156. private _jointColor;
  74157. private _brickColor;
  74158. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74159. updateShaderUniforms(): void;
  74160. numberOfBricksHeight: number;
  74161. numberOfBricksWidth: number;
  74162. jointColor: BABYLON.Color3;
  74163. brickColor: BABYLON.Color3;
  74164. /**
  74165. * Serializes this brick procedural texture
  74166. * @returns a serialized brick procedural texture object
  74167. */
  74168. serialize(): any;
  74169. /**
  74170. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  74171. * @param parsedTexture defines parsed texture data
  74172. * @param scene defines the current scene
  74173. * @param rootUrl defines the root URL containing brick procedural texture information
  74174. * @returns a parsed Brick Procedural BABYLON.Texture
  74175. */
  74176. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  74177. }
  74178. }
  74179. declare module BABYLON {
  74180. /** @hidden */
  74181. export var cloudProceduralTexturePixelShader: {
  74182. name: string;
  74183. shader: string;
  74184. };
  74185. }
  74186. declare module BABYLON {
  74187. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  74188. private _skyColor;
  74189. private _cloudColor;
  74190. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74191. updateShaderUniforms(): void;
  74192. skyColor: BABYLON.Color4;
  74193. cloudColor: BABYLON.Color4;
  74194. /**
  74195. * Serializes this cloud procedural texture
  74196. * @returns a serialized cloud procedural texture object
  74197. */
  74198. serialize(): any;
  74199. /**
  74200. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  74201. * @param parsedTexture defines parsed texture data
  74202. * @param scene defines the current scene
  74203. * @param rootUrl defines the root URL containing cloud procedural texture information
  74204. * @returns a parsed Cloud Procedural BABYLON.Texture
  74205. */
  74206. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  74207. }
  74208. }
  74209. declare module BABYLON {
  74210. /** @hidden */
  74211. export var fireProceduralTexturePixelShader: {
  74212. name: string;
  74213. shader: string;
  74214. };
  74215. }
  74216. declare module BABYLON {
  74217. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  74218. private _time;
  74219. private _speed;
  74220. private _autoGenerateTime;
  74221. private _fireColors;
  74222. private _alphaThreshold;
  74223. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74224. updateShaderUniforms(): void;
  74225. render(useCameraPostProcess?: boolean): void;
  74226. static readonly PurpleFireColors: BABYLON.Color3[];
  74227. static readonly GreenFireColors: BABYLON.Color3[];
  74228. static readonly RedFireColors: BABYLON.Color3[];
  74229. static readonly BlueFireColors: BABYLON.Color3[];
  74230. autoGenerateTime: boolean;
  74231. fireColors: BABYLON.Color3[];
  74232. time: number;
  74233. speed: BABYLON.Vector2;
  74234. alphaThreshold: number;
  74235. /**
  74236. * Serializes this fire procedural texture
  74237. * @returns a serialized fire procedural texture object
  74238. */
  74239. serialize(): any;
  74240. /**
  74241. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  74242. * @param parsedTexture defines parsed texture data
  74243. * @param scene defines the current scene
  74244. * @param rootUrl defines the root URL containing fire procedural texture information
  74245. * @returns a parsed Fire Procedural BABYLON.Texture
  74246. */
  74247. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  74248. }
  74249. }
  74250. declare module BABYLON {
  74251. /** @hidden */
  74252. export var grassProceduralTexturePixelShader: {
  74253. name: string;
  74254. shader: string;
  74255. };
  74256. }
  74257. declare module BABYLON {
  74258. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  74259. private _grassColors;
  74260. private _groundColor;
  74261. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74262. updateShaderUniforms(): void;
  74263. grassColors: BABYLON.Color3[];
  74264. groundColor: BABYLON.Color3;
  74265. /**
  74266. * Serializes this grass procedural texture
  74267. * @returns a serialized grass procedural texture object
  74268. */
  74269. serialize(): any;
  74270. /**
  74271. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  74272. * @param parsedTexture defines parsed texture data
  74273. * @param scene defines the current scene
  74274. * @param rootUrl defines the root URL containing grass procedural texture information
  74275. * @returns a parsed Grass Procedural BABYLON.Texture
  74276. */
  74277. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  74278. }
  74279. }
  74280. declare module BABYLON {
  74281. /** @hidden */
  74282. export var marbleProceduralTexturePixelShader: {
  74283. name: string;
  74284. shader: string;
  74285. };
  74286. }
  74287. declare module BABYLON {
  74288. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  74289. private _numberOfTilesHeight;
  74290. private _numberOfTilesWidth;
  74291. private _amplitude;
  74292. private _jointColor;
  74293. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74294. updateShaderUniforms(): void;
  74295. numberOfTilesHeight: number;
  74296. amplitude: number;
  74297. numberOfTilesWidth: number;
  74298. jointColor: BABYLON.Color3;
  74299. /**
  74300. * Serializes this marble procedural texture
  74301. * @returns a serialized marble procedural texture object
  74302. */
  74303. serialize(): any;
  74304. /**
  74305. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  74306. * @param parsedTexture defines parsed texture data
  74307. * @param scene defines the current scene
  74308. * @param rootUrl defines the root URL containing marble procedural texture information
  74309. * @returns a parsed Marble Procedural BABYLON.Texture
  74310. */
  74311. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  74312. }
  74313. }
  74314. declare module BABYLON {
  74315. /** @hidden */
  74316. export var normalMapProceduralTexturePixelShader: {
  74317. name: string;
  74318. shader: string;
  74319. };
  74320. }
  74321. declare module BABYLON {
  74322. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  74323. private _baseTexture;
  74324. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74325. updateShaderUniforms(): void;
  74326. render(useCameraPostProcess?: boolean): void;
  74327. resize(size: any, generateMipMaps: any): void;
  74328. baseTexture: BABYLON.Texture;
  74329. /**
  74330. * Serializes this normal map procedural texture
  74331. * @returns a serialized normal map procedural texture object
  74332. */
  74333. serialize(): any;
  74334. /**
  74335. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  74336. * @param parsedTexture defines parsed texture data
  74337. * @param scene defines the current scene
  74338. * @param rootUrl defines the root URL containing normal map procedural texture information
  74339. * @returns a parsed Normal Map Procedural BABYLON.Texture
  74340. */
  74341. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  74342. }
  74343. }
  74344. declare module BABYLON {
  74345. /** @hidden */
  74346. export var perlinNoiseProceduralTexturePixelShader: {
  74347. name: string;
  74348. shader: string;
  74349. };
  74350. }
  74351. declare module BABYLON {
  74352. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  74353. time: number;
  74354. timeScale: number;
  74355. translationSpeed: number;
  74356. private _currentTranslation;
  74357. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74358. updateShaderUniforms(): void;
  74359. render(useCameraPostProcess?: boolean): void;
  74360. resize(size: any, generateMipMaps: any): void;
  74361. /**
  74362. * Serializes this perlin noise procedural texture
  74363. * @returns a serialized perlin noise procedural texture object
  74364. */
  74365. serialize(): any;
  74366. /**
  74367. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  74368. * @param parsedTexture defines parsed texture data
  74369. * @param scene defines the current scene
  74370. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  74371. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  74372. */
  74373. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  74374. }
  74375. }
  74376. declare module BABYLON {
  74377. /** @hidden */
  74378. export var roadProceduralTexturePixelShader: {
  74379. name: string;
  74380. shader: string;
  74381. };
  74382. }
  74383. declare module BABYLON {
  74384. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  74385. private _roadColor;
  74386. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74387. updateShaderUniforms(): void;
  74388. roadColor: BABYLON.Color3;
  74389. /**
  74390. * Serializes this road procedural texture
  74391. * @returns a serialized road procedural texture object
  74392. */
  74393. serialize(): any;
  74394. /**
  74395. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  74396. * @param parsedTexture defines parsed texture data
  74397. * @param scene defines the current scene
  74398. * @param rootUrl defines the root URL containing road procedural texture information
  74399. * @returns a parsed Road Procedural BABYLON.Texture
  74400. */
  74401. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  74402. }
  74403. }
  74404. declare module BABYLON {
  74405. /** @hidden */
  74406. export var starfieldProceduralTexturePixelShader: {
  74407. name: string;
  74408. shader: string;
  74409. };
  74410. }
  74411. declare module BABYLON {
  74412. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  74413. private _time;
  74414. private _alpha;
  74415. private _beta;
  74416. private _zoom;
  74417. private _formuparam;
  74418. private _stepsize;
  74419. private _tile;
  74420. private _brightness;
  74421. private _darkmatter;
  74422. private _distfading;
  74423. private _saturation;
  74424. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74425. updateShaderUniforms(): void;
  74426. time: number;
  74427. alpha: number;
  74428. beta: number;
  74429. formuparam: number;
  74430. stepsize: number;
  74431. zoom: number;
  74432. tile: number;
  74433. brightness: number;
  74434. darkmatter: number;
  74435. distfading: number;
  74436. saturation: number;
  74437. /**
  74438. * Serializes this starfield procedural texture
  74439. * @returns a serialized starfield procedural texture object
  74440. */
  74441. serialize(): any;
  74442. /**
  74443. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  74444. * @param parsedTexture defines parsed texture data
  74445. * @param scene defines the current scene
  74446. * @param rootUrl defines the root URL containing startfield procedural texture information
  74447. * @returns a parsed Starfield Procedural BABYLON.Texture
  74448. */
  74449. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  74450. }
  74451. }
  74452. declare module BABYLON {
  74453. /** @hidden */
  74454. export var woodProceduralTexturePixelShader: {
  74455. name: string;
  74456. shader: string;
  74457. };
  74458. }
  74459. declare module BABYLON {
  74460. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  74461. private _ampScale;
  74462. private _woodColor;
  74463. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  74464. updateShaderUniforms(): void;
  74465. ampScale: number;
  74466. woodColor: BABYLON.Color3;
  74467. /**
  74468. * Serializes this wood procedural texture
  74469. * @returns a serialized wood procedural texture object
  74470. */
  74471. serialize(): any;
  74472. /**
  74473. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  74474. * @param parsedTexture defines parsed texture data
  74475. * @param scene defines the current scene
  74476. * @param rootUrl defines the root URL containing wood procedural texture information
  74477. * @returns a parsed Wood Procedural BABYLON.Texture
  74478. */
  74479. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  74480. }
  74481. }